forked from github-starred/komodo
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1bfb17cb5d | ||
|
|
b90acb66c7 | ||
|
|
7648b0dd10 | ||
|
|
2d69f1791a | ||
|
|
5ba887095a | ||
|
|
19b7405562 | ||
|
|
f5c5f734e1 | ||
|
|
8d1639bcaf | ||
|
|
e2446af00e |
32
Cargo.lock
generated
32
Cargo.lock
generated
@@ -734,7 +734,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "core"
|
||||
version = "0.2.4"
|
||||
version = "0.2.5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async_timing_util",
|
||||
@@ -753,7 +753,7 @@ dependencies = [
|
||||
"hmac",
|
||||
"jwt",
|
||||
"monitor_helpers",
|
||||
"monitor_types 0.2.4",
|
||||
"monitor_types 0.2.5",
|
||||
"mungos",
|
||||
"periphery_client",
|
||||
"serde",
|
||||
@@ -987,10 +987,10 @@ checksum = "23d8666cb01533c39dde32bcbab8e227b4ed6679b2c925eba05feabea39508fb"
|
||||
|
||||
[[package]]
|
||||
name = "db_client"
|
||||
version = "0.2.4"
|
||||
version = "0.2.5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"monitor_types 0.2.4",
|
||||
"monitor_types 0.2.5",
|
||||
"mungos",
|
||||
]
|
||||
|
||||
@@ -1837,7 +1837,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "monitor_cli"
|
||||
version = "0.2.4"
|
||||
version = "0.2.5"
|
||||
dependencies = [
|
||||
"async_timing_util",
|
||||
"clap",
|
||||
@@ -1853,12 +1853,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "monitor_client"
|
||||
version = "0.2.4"
|
||||
version = "0.2.5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"envy",
|
||||
"futures-util",
|
||||
"monitor_types 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"monitor_types 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
@@ -1870,11 +1870,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "monitor_helpers"
|
||||
version = "0.2.4"
|
||||
version = "0.2.5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"axum",
|
||||
"monitor_types 0.2.4",
|
||||
"monitor_types 0.2.5",
|
||||
"rand",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -1883,7 +1883,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "monitor_periphery"
|
||||
version = "0.2.4"
|
||||
version = "0.2.5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async_timing_util",
|
||||
@@ -1895,7 +1895,7 @@ dependencies = [
|
||||
"envy",
|
||||
"futures",
|
||||
"monitor_helpers",
|
||||
"monitor_types 0.2.4",
|
||||
"monitor_types 0.2.5",
|
||||
"run_command",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
@@ -1908,7 +1908,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "monitor_types"
|
||||
version = "0.2.4"
|
||||
version = "0.2.5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bollard",
|
||||
@@ -1925,9 +1925,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "monitor_types"
|
||||
version = "0.2.4"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "891189d5f49168915fd4c81f4e59d8fdd937008a59431831f28de3d5f8cf2af2"
|
||||
checksum = "de46e03ba424cb9f70a57a5dd38b81399cca131cdb2edf8bf7d03f829e02c140"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bollard",
|
||||
@@ -2183,11 +2183,11 @@ checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e"
|
||||
|
||||
[[package]]
|
||||
name = "periphery_client"
|
||||
version = "0.2.4"
|
||||
version = "0.2.5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"futures-util",
|
||||
"monitor_types 0.2.4",
|
||||
"monitor_types 0.2.5",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "monitor_cli"
|
||||
version = "0.2.4"
|
||||
version = "0.2.5"
|
||||
edition = "2021"
|
||||
authors = ["MoghTech"]
|
||||
description = "monitor cli | tools to setup monitor system"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "core"
|
||||
version = "0.2.4"
|
||||
version = "0.2.5"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
@@ -7,7 +7,7 @@ use mungos::{doc, to_bson};
|
||||
use types::{
|
||||
monitor_timestamp,
|
||||
traits::{Busy, Permissioned},
|
||||
Build, Log, Operation, PermissionLevel, Update, UpdateStatus, UpdateTarget, Version,
|
||||
Build, Log, Operation, PermissionLevel, Update, UpdateStatus, UpdateTarget, Version, AwsBuilderBuildConfig,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
@@ -15,6 +15,7 @@ use crate::{
|
||||
cloud::aws::{
|
||||
self, create_ec2_client, create_instance_with_ami, terminate_ec2_instance, Ec2Instance,
|
||||
},
|
||||
helpers::empty_or_only_spaces,
|
||||
state::State,
|
||||
};
|
||||
|
||||
@@ -58,6 +59,7 @@ impl State {
|
||||
.docker_organizations
|
||||
.get(0)
|
||||
.map(|d| d.to_string()),
|
||||
aws_config: Some(AwsBuilderBuildConfig::default()),
|
||||
permissions: [(user.id.clone(), PermissionLevel::Update)]
|
||||
.into_iter()
|
||||
.collect(),
|
||||
@@ -187,6 +189,17 @@ impl State {
|
||||
new_build.created_at = current_build.created_at.clone();
|
||||
new_build.updated_at = start_ts.clone();
|
||||
|
||||
// filter out any build args that contain empty strings
|
||||
// these could only happen by accident
|
||||
new_build.docker_build_args = new_build.docker_build_args.map(|mut args| {
|
||||
args.build_args = args
|
||||
.build_args
|
||||
.into_iter()
|
||||
.filter(|a| !empty_or_only_spaces(&a.variable) && !empty_or_only_spaces(&a.value))
|
||||
.collect();
|
||||
args
|
||||
});
|
||||
|
||||
self.db
|
||||
.builds
|
||||
.update_one(&new_build.id, mungos::Update::Regular(new_build.clone()))
|
||||
@@ -255,7 +268,7 @@ impl State {
|
||||
|
||||
async fn build_inner(&self, build_id: &str, user: &RequestUser) -> anyhow::Result<Update> {
|
||||
let mut build = self
|
||||
.get_build_check_permissions(build_id, user, PermissionLevel::Update)
|
||||
.get_build_check_permissions(build_id, user, PermissionLevel::Execute)
|
||||
.await?;
|
||||
build.version.increment();
|
||||
let mut update = Update {
|
||||
@@ -326,7 +339,7 @@ impl State {
|
||||
let clone_success = match self.periphery.clone_repo(&server.server, &build).await {
|
||||
Ok(clone_logs) => {
|
||||
update.logs.extend(clone_logs);
|
||||
true
|
||||
all_logs_success(&update.logs)
|
||||
}
|
||||
Err(e) => {
|
||||
update
|
||||
|
||||
@@ -9,7 +9,7 @@ use types::{
|
||||
|
||||
use crate::{
|
||||
auth::RequestUser,
|
||||
helpers::{any_option_diff_is_some, get_image_name, option_diff_is_some},
|
||||
helpers::{any_option_diff_is_some, empty_or_only_spaces, get_image_name, option_diff_is_some},
|
||||
state::State,
|
||||
};
|
||||
|
||||
@@ -197,6 +197,33 @@ impl State {
|
||||
new_deployment.created_at = current_deployment.created_at.clone();
|
||||
new_deployment.updated_at = start_ts.clone();
|
||||
|
||||
// filter out any volumes, ports, env vars, extra args which are or contain empty strings
|
||||
// these could only happen by accident
|
||||
new_deployment.docker_run_args.volumes = new_deployment
|
||||
.docker_run_args
|
||||
.volumes
|
||||
.into_iter()
|
||||
.filter(|v| !empty_or_only_spaces(&v.local) && !empty_or_only_spaces(&v.container))
|
||||
.collect();
|
||||
new_deployment.docker_run_args.ports = new_deployment
|
||||
.docker_run_args
|
||||
.ports
|
||||
.into_iter()
|
||||
.filter(|p| !empty_or_only_spaces(&p.local) && !empty_or_only_spaces(&p.container))
|
||||
.collect();
|
||||
new_deployment.docker_run_args.environment = new_deployment
|
||||
.docker_run_args
|
||||
.environment
|
||||
.into_iter()
|
||||
.filter(|e| !empty_or_only_spaces(&e.variable) && !empty_or_only_spaces(&e.value))
|
||||
.collect();
|
||||
new_deployment.docker_run_args.extra_args = new_deployment
|
||||
.docker_run_args
|
||||
.extra_args
|
||||
.into_iter()
|
||||
.filter(|a| a.len() != 0)
|
||||
.collect();
|
||||
|
||||
self.db
|
||||
.deployments
|
||||
.update_one(
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
use std::str::FromStr;
|
||||
|
||||
use anyhow::{anyhow, Context};
|
||||
use axum::{extract::Query, routing::get, Extension, Json, Router};
|
||||
use helpers::handle_anyhow_error;
|
||||
use mungos::{doc, to_bson, ObjectId};
|
||||
use mungos::{doc, to_bson};
|
||||
use serde_json::Value;
|
||||
use types::{PermissionLevel, Update, UpdateTarget};
|
||||
|
||||
@@ -159,7 +157,7 @@ impl State {
|
||||
.await
|
||||
.context("failed at query to get users builds")?
|
||||
.into_iter()
|
||||
.map(|e| ObjectId::from_str(&e.id).unwrap())
|
||||
.map(|e| e.id)
|
||||
.collect::<Vec<_>>();
|
||||
let deployment_ids = self
|
||||
.db
|
||||
@@ -168,7 +166,7 @@ impl State {
|
||||
.await
|
||||
.context("failed at query to get users deployments")?
|
||||
.into_iter()
|
||||
.map(|e| ObjectId::from_str(&e.id).unwrap())
|
||||
.map(|e| e.id)
|
||||
.collect::<Vec<_>>();
|
||||
let server_ids = self
|
||||
.db
|
||||
@@ -177,7 +175,7 @@ impl State {
|
||||
.await
|
||||
.context("failed at query to get users servers")?
|
||||
.into_iter()
|
||||
.map(|e| ObjectId::from_str(&e.id).unwrap())
|
||||
.map(|e| e.id)
|
||||
.collect::<Vec<_>>();
|
||||
let procedure_ids = self
|
||||
.db
|
||||
@@ -186,7 +184,7 @@ impl State {
|
||||
.await
|
||||
.context("failed at query to get users procedures")?
|
||||
.into_iter()
|
||||
.map(|e| ObjectId::from_str(&e.id).unwrap())
|
||||
.map(|e| e.id)
|
||||
.collect::<Vec<_>>();
|
||||
let filter = doc! {
|
||||
"$or": [
|
||||
|
||||
@@ -54,3 +54,15 @@ pub fn get_image_name(build: &Build) -> String {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn empty_or_only_spaces(word: &str) -> bool {
|
||||
if word.len() == 0 {
|
||||
return true;
|
||||
}
|
||||
for char in word.chars() {
|
||||
if char != ' ' {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@ const DescriptionMenu: Component<{
|
||||
const [desc, setDesc] = createSignal(p.description);
|
||||
const [loading, setLoading] = createSignal(false);
|
||||
const update_description = () => {
|
||||
if (!p.userCanUpdate) return;
|
||||
setLoading(true);
|
||||
client
|
||||
.update_description({ target: p.target, description: desc() || "" })
|
||||
@@ -113,10 +114,12 @@ const DescriptionMenu: Component<{
|
||||
style={{ width: "700px", "max-width": "90vw", padding: "1rem" }}
|
||||
disabled={!p.userCanUpdate}
|
||||
/>
|
||||
<Show when={!loading()} fallback={<Loading />}>
|
||||
<button class="green" onClick={update_description}>
|
||||
update
|
||||
</button>
|
||||
<Show when={p.userCanUpdate}>
|
||||
<Show when={!loading()} fallback={<Loading />}>
|
||||
<button class="green" onClick={update_description}>
|
||||
update
|
||||
</button>
|
||||
</Show>
|
||||
</Show>
|
||||
</Grid>
|
||||
);
|
||||
|
||||
@@ -22,11 +22,12 @@ const AwsBuilderConfig: Component<{}> = (p) => {
|
||||
const Ami: Component = () => {
|
||||
const { aws_builder_config } = useAppState();
|
||||
const { build, setBuild, userCanUpdate } = useConfig();
|
||||
const default_ami_id = () => aws_builder_config()?.default_ami_id;
|
||||
const get_ami_id = () => {
|
||||
if (build.aws_config?.ami_id) {
|
||||
return build.aws_config.ami_id;
|
||||
} else {
|
||||
return aws_builder_config()?.default_ami_id || "unknown";
|
||||
return default_ami_id() || "unknown";
|
||||
}
|
||||
};
|
||||
const get_ami_name = (ami_id: string) => {
|
||||
@@ -51,7 +52,13 @@ const Ami: Component = () => {
|
||||
targetClass="blue"
|
||||
selected={get_ami_id()}
|
||||
items={ami_ids()}
|
||||
onSelect={(ami_id) => setBuild("aws_config", "ami_id", ami_id)}
|
||||
onSelect={(ami_id) => {
|
||||
if (ami_id === default_ami_id()) {
|
||||
setBuild("aws_config", "ami_id", undefined);
|
||||
} else {
|
||||
setBuild("aws_config", "ami_id", ami_id);
|
||||
}
|
||||
}}
|
||||
itemMap={get_ami_name}
|
||||
position="bottom right"
|
||||
disabled={!userCanUpdate()}
|
||||
|
||||
@@ -87,7 +87,7 @@ const Docker: Component<{}> = (p) => {
|
||||
disabled={!userCanUpdate()}
|
||||
/>
|
||||
</Flex>
|
||||
<Show when={(dockerOrgs() || []).length > 0}>
|
||||
<Show when={build.docker_organization || (dockerOrgs() || []).length > 0}>
|
||||
<Flex
|
||||
justifyContent={userCanUpdate() ? "space-between" : undefined}
|
||||
alignItems="center"
|
||||
@@ -97,7 +97,7 @@ const Docker: Component<{}> = (p) => {
|
||||
<Selector
|
||||
targetClass="blue"
|
||||
selected={build.docker_organization || "none"}
|
||||
items={dockerOrgs() || []}
|
||||
items={["none", ...(dockerOrgs() || [])]}
|
||||
onSelect={(account) => {
|
||||
setBuild(
|
||||
"docker_organization",
|
||||
|
||||
@@ -17,8 +17,6 @@ import { Tab } from "../../../shared/tabs/Tabs";
|
||||
import RepoMount from "./mount-repo/RepoMount";
|
||||
import { OnClone, OnPull } from "./mount-repo/OnGit";
|
||||
import Loading from "../../../shared/loading/Loading";
|
||||
import { pushNotification, MONITOR_BASE_URL } from "../../../..";
|
||||
import { combineClasses, copyToClipboard, getId } from "../../../../util/helpers";
|
||||
import { useAppDimensions } from "../../../../state/DimensionProvider";
|
||||
import SimpleTabs from "../../../shared/tabs/SimpleTabs";
|
||||
import ExtraArgs from "./container/ExtraArgs";
|
||||
@@ -27,7 +25,6 @@ import WebhookUrl from "./container/WebhookUrl";
|
||||
const Config: Component<{}> = () => {
|
||||
const { deployment, reset, save, userCanUpdate } = useConfig();
|
||||
const { isMobile } = useAppDimensions();
|
||||
const listenerUrl = () => `${MONITOR_BASE_URL}/api/listener/deployment/${getId(deployment)}`;
|
||||
return (
|
||||
<Show when={deployment.loaded}>
|
||||
<Grid class="config">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "db_client"
|
||||
version = "0.2.4"
|
||||
version = "0.2.5"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "monitor_helpers"
|
||||
version = "0.2.4"
|
||||
version = "0.2.5"
|
||||
edition = "2021"
|
||||
authors = ["MoghTech"]
|
||||
description = "helpers used as dependency for mogh tech monitor"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "monitor_client"
|
||||
version = "0.2.4"
|
||||
version = "0.2.5"
|
||||
edition = "2021"
|
||||
authors = ["MoghTech"]
|
||||
description = "a client to interact with the monitor system"
|
||||
@@ -9,7 +9,7 @@ license = "GPL-3.0-or-later"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
monitor_types = "0.2.4"
|
||||
monitor_types = "0.2.5"
|
||||
# monitor_types = { path = "../types" }
|
||||
reqwest = { version = "0.11", features = ["json"] }
|
||||
tokio-tungstenite = { version = "0.18", features=["native-tls"] }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "periphery_client"
|
||||
version = "0.2.4"
|
||||
version = "0.2.5"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "monitor_types"
|
||||
version = "0.2.4"
|
||||
version = "0.2.5"
|
||||
edition = "2021"
|
||||
authors = ["MoghTech"]
|
||||
description = "types for the mogh tech monitor"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "monitor_periphery"
|
||||
version = "0.2.4"
|
||||
version = "0.2.5"
|
||||
edition = "2021"
|
||||
authors = ["MoghTech"]
|
||||
description = "monitor periphery binary | run monitor periphery as system daemon"
|
||||
|
||||
@@ -96,17 +96,19 @@ async fn clone(
|
||||
let command = format!("git clone {repo_url} {destination}{branch}");
|
||||
let start_ts = monitor_timestamp();
|
||||
let output = async_run_command(&command).await;
|
||||
let command = if access_token_at.len() > 0 {
|
||||
command.replace(&access_token.unwrap(), "<TOKEN>")
|
||||
let success = output.success();
|
||||
let (command, stderr) = if access_token_at.len() > 0 {
|
||||
let access_token = access_token.unwrap();
|
||||
(command.replace(&access_token, "<TOKEN>"), output.stderr.replace(&access_token, "<TOKEN>"))
|
||||
} else {
|
||||
command
|
||||
(command, output.stderr)
|
||||
};
|
||||
Log {
|
||||
stage: "clone repo".to_string(),
|
||||
command,
|
||||
success: output.success(),
|
||||
success,
|
||||
stdout: output.stdout,
|
||||
stderr: output.stderr,
|
||||
stderr,
|
||||
start_ts,
|
||||
end_ts: monitor_timestamp(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user