mirror of
https://github.com/moghtech/komodo.git
synced 2026-09-11 00:01:21 +00:00
* inc version * Komodo interp in ui compose file * fix auto update when image doesn't specify tag by defaulting to latest * Pull image buttons don't need safety dialog * WIP crosscompile * rename * entrypoint * fix copy * remove example/* from workspace * add targets * multiarch pkg config * use specific COPY * update deps * multiarch build command * pre compile deps * cross compile * enable-linger * remove spammed log when server doesn't have docker * add multiarch.Dockerfile * fix casing * fix tag * try not let COPY fail * try * ARG TARGETPLATFORM * use /app for consistency * try * delete cross-compile approach * add multiarch core build * multiarch Deno * single arch multi arch * typeshare cli note * new typeshare * remove note about aarch64 image * test configs * fix config file headers * binaries dockerfile * update cargo build * docs * simple * just simple * use -p * add configurable binaries tag * add multi-arch * allow copy to fail * fix binary paths * frontend Dockerfiel * use dedicated static frontend build * auto retry getting instance state from aws * retry 5 times * cleanup * simplify binary build * try alpine and musl * install alpine deps * back to debian, try rustls * move fully to rustls * single arch builds using single binary image * default IMAGE_TAG * cleanup * try caching deps * single arch add frontend build * rustls::crypto::ring::default_provider() * back to simple * comment dockerfile * add select options prop, render checkboxes if present * add allowSelectedIf to enable / disable rows where necessary * rename allowSelectIf to isSelectable, allow false as global disable, disable checkboxes when not allowed * rename isSelectable to disableRow (it works the oppsite way lol) * selected resources hook, start deployment batch execute component * add deployment group actions * add deployment group actions * add default (empty) group actions for other resources * fix checkbox header styles * explicitly check if disableRow is passed (this prop is cursed) * don't disable row selection for deployments table * don't need id for groupactions * add group actions to resources page * fix row checkbox (prop not cursed, i dumb) * re-implement group action list using dropdown menu * only make group actions clickable when at least one row selected * add loading indicator * gap betwen new resource and group actions * refactor group actions * remove "Batch" from action labels * add group actions for relevant resources * fix hardcode * add selectOptions to relevant tables * select by name not id * expect selected to be names * add note re selection state init for future reference * multi select working nicely for all resources * configure server health check timeout * config message * refresh processes remove dead processes * simplify the build args * default timeout seconds 3 --------- Co-authored-by: kv <karamvir.singh98@gmail.com>
93 lines
2.3 KiB
Rust
93 lines
2.3 KiB
Rust
use std::{
|
|
collections::HashMap,
|
|
path::{Path, PathBuf},
|
|
};
|
|
|
|
use anyhow::Context;
|
|
use formatting::format_serror;
|
|
use komodo_client::entities::{update::Log, EnvironmentVar};
|
|
|
|
/// If the environment was written and needs to be passed to the compose command,
|
|
/// will return the env file PathBuf
|
|
pub async fn write_file(
|
|
environment: &[EnvironmentVar],
|
|
env_file_path: &str,
|
|
secrets: Option<&HashMap<String, String>>,
|
|
folder: &Path,
|
|
logs: &mut Vec<Log>,
|
|
) -> Result<Option<PathBuf>, ()> {
|
|
let env_file_path = folder.join(env_file_path);
|
|
|
|
if environment.is_empty() {
|
|
// Still want to return Some(env_file_path) if the path
|
|
// already exists on the host and is a file.
|
|
// This is for "Files on Server" mode when user writes the env file themself.
|
|
if env_file_path.is_file() {
|
|
return Ok(Some(env_file_path));
|
|
}
|
|
return Ok(None);
|
|
}
|
|
|
|
let contents = environment
|
|
.iter()
|
|
.map(|env| format!("{}={}", env.variable, env.value))
|
|
.collect::<Vec<_>>()
|
|
.join("\n");
|
|
|
|
let contents = if let Some(secrets) = secrets {
|
|
let res = svi::interpolate_variables(
|
|
&contents,
|
|
secrets,
|
|
svi::Interpolator::DoubleBrackets,
|
|
true,
|
|
)
|
|
.context("failed to interpolate secrets into environment");
|
|
|
|
let (contents, replacers) = match res {
|
|
Ok(res) => res,
|
|
Err(e) => {
|
|
logs.push(Log::error(
|
|
"interpolate periphery secrets",
|
|
format_serror(&e.into()),
|
|
));
|
|
return Err(());
|
|
}
|
|
};
|
|
|
|
if !replacers.is_empty() {
|
|
logs.push(Log::simple(
|
|
"Interpolate - Environment",
|
|
replacers
|
|
.iter()
|
|
.map(|(_, variable)| format!("<span class=\"text-muted-foreground\">replaced:</span> {variable}"))
|
|
.collect::<Vec<_>>()
|
|
.join("\n"),
|
|
))
|
|
}
|
|
|
|
contents
|
|
} else {
|
|
contents
|
|
};
|
|
|
|
if let Err(e) = tokio::fs::write(&env_file_path, contents)
|
|
.await
|
|
.with_context(|| {
|
|
format!("failed to write environment file to {env_file_path:?}")
|
|
})
|
|
{
|
|
logs.push(Log::error(
|
|
"write environment file",
|
|
format_serror(&e.into()),
|
|
));
|
|
return Err(());
|
|
}
|
|
|
|
logs.push(Log::simple(
|
|
"write environment file",
|
|
format!("environment written to {env_file_path:?}"),
|
|
));
|
|
|
|
Ok(Some(env_file_path))
|
|
}
|