* add close alert threshold to prevent Ok - Warning back and forth

* remove part about repo being deleted, no longer behavior

* resource sync share general common

* remove this changelog. use releases

* remove changelog from readme

* write commit file clean up path

* docs: supports any git provider repo

* fix docs: authorization

* multiline command supports escaped newlines

* move webhook to build config advanced

* parser comments with escaped newline

* improve parser

* save use Enter. escape monaco using escape

* improve logic when deployment / stack action buttons shown

* used_mem = total - available

* Fix unrecognized path have 404

* webhooks will 404 if misconfigured

* move update logger / alerter

* delete migrator

* update examples

* publish typescript client komodo_client
This commit is contained in:
Maxwell Becker
2024-10-15 02:04:49 -04:00
committed by GitHub
parent dfafadf57b
commit 41d1ff9760
151 changed files with 801 additions and 1394 deletions

View File

@@ -1,6 +1,9 @@
use std::path::Path;
use komodo_client::entities::{komodo_timestamp, update::Log};
use komodo_client::{
entities::{komodo_timestamp, update::Log},
parser::parse_multiline_command,
};
use run_command::{async_run_command, CommandOutput};
/// Parses commands out of multiline string
@@ -23,35 +26,6 @@ pub async fn run_komodo_command(
output_into_log(stage, command, start_ts, output)
}
/// Parses commands out of multiline string
/// and chains them together with '&&'
///
/// Supports full line and end of line comments.
///
/// ## Example:
/// ```sh
/// # comments supported
/// sh ./shell1.sh # end of line supported
/// sh ./shell2.sh
/// # print done
/// echo done
/// ```
/// becomes
/// ```sh
/// sh ./shell1.sh && sh ./shell2.sh && echo done
/// ```
pub fn parse_multiline_command(command: impl AsRef<str>) -> String {
command
.as_ref()
.split('\n')
.map(str::trim)
.filter(|line| !line.is_empty() && !line.starts_with('#'))
.filter_map(|line| line.split(" #").next())
.map(str::trim)
.collect::<Vec<_>>()
.join(" && ")
}
pub fn output_into_log(
stage: &str,
command: String,

View File

@@ -1,4 +1,4 @@
use std::path::Path;
use std::path::{Path, PathBuf};
use anyhow::Context;
use command::run_komodo_command;
@@ -18,7 +18,8 @@ pub async fn write_commit_file(
file: &Path,
contents: &str,
) -> anyhow::Result<GitRes> {
let path = repo_dir.join(file);
// Clean up the path by stripping any redundant `/./`
let path = repo_dir.join(file).components().collect::<PathBuf>();
if let Some(parent) = path.parent() {
let _ = fs::create_dir_all(&parent).await;