mirror of
https://github.com/moghtech/komodo.git
synced 2026-03-11 17:44:19 -05:00
partial derive working
This commit is contained in:
21
Cargo.lock
generated
21
Cargo.lock
generated
@@ -1069,6 +1069,12 @@ version = "0.4.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de"
|
||||
|
||||
[[package]]
|
||||
name = "make_option"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "99f3d3fcb53f2f961c24cc6042513be5c782d2c969b04f02ae14d7edbdca34e5"
|
||||
|
||||
[[package]]
|
||||
name = "matchit"
|
||||
version = "0.7.0"
|
||||
@@ -1191,6 +1197,8 @@ dependencies = [
|
||||
"bson",
|
||||
"derive_builder",
|
||||
"diff-struct",
|
||||
"make_option",
|
||||
"partial_derive2",
|
||||
"resolver_api",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -1400,6 +1408,17 @@ version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ffa94c2e5674923c67d7f3dfce1279507b191e10eb064881b46ed3e1256e5ca6"
|
||||
|
||||
[[package]]
|
||||
name = "partial_derive2"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75fabf7c9ed3ad64f33d05d4c8a7f180217c667892044a8088fe93f984bdeb17"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.18",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "percent-encoding"
|
||||
version = "2.3.0"
|
||||
@@ -1977,6 +1996,8 @@ dependencies = [
|
||||
"monitor_client",
|
||||
"monitor_types",
|
||||
"periphery_client",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@ strum = "0.24"
|
||||
strum_macros = "0.24"
|
||||
sysinfo = "0.29"
|
||||
async-trait = "0.1"
|
||||
partial_derive2 = "0.1.2"
|
||||
make_option = "0.1.2"
|
||||
# mogh
|
||||
run_command = { version = "0.0.6", features = ["async_tokio"] }
|
||||
slack = { package = "slack_client_rs", version = "0.0.8" }
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use termination_signal::tokio::immediate_term_handle;
|
||||
|
||||
mod config;
|
||||
mod state;
|
||||
mod resolvers;
|
||||
mod state;
|
||||
|
||||
async fn app() -> anyhow::Result<()> {
|
||||
Ok(())
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use resolver_api::derive::Resolver;
|
||||
use serde::{Serialize, Deserialize};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::state::State;
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
pub fn to_monitor_name(name: &str) -> String {
|
||||
name.to_lowercase().replace(' ', "_")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,4 +20,6 @@ bson.workspace = true
|
||||
async_timing_util.workspace = true
|
||||
resolver_api.workspace = true
|
||||
derive_builder.workspace = true
|
||||
bollard.workspace = true
|
||||
bollard.workspace = true
|
||||
partial_derive2.workspace = true
|
||||
make_option.workspace = true
|
||||
@@ -1 +1 @@
|
||||
pub mod requests;
|
||||
pub mod requests;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
|
||||
50
lib/types/src/entities/build.rs
Normal file
50
lib/types/src/entities/build.rs
Normal file
@@ -0,0 +1,50 @@
|
||||
use bson::serde_helpers::hex_string_as_object_id;
|
||||
use derive_builder::Builder;
|
||||
use diff::Diff;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use typeshare::typeshare;
|
||||
|
||||
use super::PermissionsMap;
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Default, Diff, Builder)]
|
||||
#[diff(attr(#[derive(Debug, Serialize)]))]
|
||||
pub struct Deployment {
|
||||
#[serde(
|
||||
default,
|
||||
rename = "_id",
|
||||
skip_serializing_if = "String::is_empty",
|
||||
with = "hex_string_as_object_id"
|
||||
)]
|
||||
#[diff(attr(#[serde(skip_serializing_if = "Option::is_none")]))]
|
||||
#[builder(setter(skip))]
|
||||
pub id: String,
|
||||
|
||||
#[diff(attr(#[serde(skip_serializing_if = "Option::is_none")]))]
|
||||
pub name: String,
|
||||
|
||||
#[serde(default)]
|
||||
#[builder(default)]
|
||||
#[diff(attr(#[serde(skip_serializing_if = "Option::is_none")]))]
|
||||
pub description: String,
|
||||
|
||||
#[serde(default)]
|
||||
#[diff(attr(#[serde(skip_serializing)]))]
|
||||
#[builder(setter(skip))]
|
||||
pub permissions: PermissionsMap,
|
||||
|
||||
#[serde(default, skip_serializing_if = "String::is_empty")]
|
||||
#[diff(attr(#[serde(skip)]))]
|
||||
#[builder(setter(skip))]
|
||||
pub created_at: String,
|
||||
|
||||
#[serde(default)]
|
||||
#[diff(attr(#[serde(skip)]))]
|
||||
#[builder(setter(skip))]
|
||||
pub updated_at: String,
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Default, Diff, Builder)]
|
||||
#[diff(attr(#[derive(Debug, Serialize)]))]
|
||||
pub struct DeploymentConfig {}
|
||||
@@ -1,8 +1,57 @@
|
||||
use bson::serde_helpers::hex_string_as_object_id;
|
||||
use derive_builder::Builder;
|
||||
use diff::Diff;
|
||||
use partial_derive2::Partial;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use strum_macros::{Display, EnumString};
|
||||
use typeshare::typeshare;
|
||||
|
||||
use super::PermissionsMap;
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Default, Diff, Builder)]
|
||||
#[diff(attr(#[derive(Debug, Serialize)]))]
|
||||
pub struct Deployment {
|
||||
#[serde(
|
||||
default,
|
||||
rename = "_id",
|
||||
skip_serializing_if = "String::is_empty",
|
||||
with = "hex_string_as_object_id"
|
||||
)]
|
||||
#[diff(attr(#[serde(skip_serializing_if = "Option::is_none")]))]
|
||||
#[builder(setter(skip))]
|
||||
pub id: String,
|
||||
|
||||
#[diff(attr(#[serde(skip_serializing_if = "Option::is_none")]))]
|
||||
pub name: String,
|
||||
|
||||
#[serde(default)]
|
||||
#[builder(default)]
|
||||
#[diff(attr(#[serde(skip_serializing_if = "Option::is_none")]))]
|
||||
pub description: String,
|
||||
|
||||
#[serde(default)]
|
||||
#[diff(attr(#[serde(skip_serializing)]))]
|
||||
#[builder(setter(skip))]
|
||||
pub permissions: PermissionsMap,
|
||||
|
||||
#[serde(default, skip_serializing_if = "String::is_empty")]
|
||||
#[diff(attr(#[serde(skip)]))]
|
||||
#[builder(setter(skip))]
|
||||
pub created_at: String,
|
||||
|
||||
#[serde(default)]
|
||||
#[diff(attr(#[serde(skip)]))]
|
||||
#[builder(setter(skip))]
|
||||
pub updated_at: String,
|
||||
}
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Default, Diff, Builder, Partial)]
|
||||
#[partial_derive(Serialize, Deserialize, Debug, Clone, Default)]
|
||||
#[diff(attr(#[derive(Debug, Serialize)]))]
|
||||
pub struct DeploymentConfig {}
|
||||
|
||||
#[typeshare]
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Default, PartialEq, Diff)]
|
||||
#[diff(attr(#[derive(Debug, PartialEq, Serialize)]))]
|
||||
|
||||
@@ -6,6 +6,7 @@ use serde::{Deserialize, Serialize};
|
||||
use strum_macros::{Display, EnumString};
|
||||
use typeshare::typeshare;
|
||||
|
||||
pub mod build;
|
||||
pub mod deployment;
|
||||
pub mod server;
|
||||
pub mod update;
|
||||
|
||||
@@ -6,8 +6,8 @@ use typeshare::typeshare;
|
||||
|
||||
use super::PermissionsMap;
|
||||
|
||||
pub mod docker_network;
|
||||
pub mod docker_image;
|
||||
pub mod docker_network;
|
||||
pub mod stats;
|
||||
|
||||
#[typeshare]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use serde::{Serialize, Deserialize};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use typeshare::typeshare;
|
||||
|
||||
use crate::{entities::Timelength, I64};
|
||||
@@ -119,4 +119,4 @@ pub struct SystemComponent {
|
||||
pub max: f32,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub critical: Option<f32>,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::{collections::HashMap, path::PathBuf};
|
||||
|
||||
use anyhow::{anyhow, Context};
|
||||
use monitor_helpers::to_monitor_name;
|
||||
use monitor_types::entities::{update::Log, Version, EnvironmentVar};
|
||||
use monitor_types::entities::{update::Log, EnvironmentVar, Version};
|
||||
|
||||
use crate::helpers::run_monitor_command;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use anyhow::{Context, anyhow};
|
||||
use anyhow::{anyhow, Context};
|
||||
use monitor_helpers::to_monitor_name;
|
||||
use monitor_types::entities::{
|
||||
deployment::{Conversion, RestartMode, TerminationSignal, DockerContainerStats},
|
||||
deployment::{Conversion, DockerContainerStats, RestartMode, TerminationSignal},
|
||||
update::Log,
|
||||
EnvironmentVar,
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::path::PathBuf;
|
||||
use anyhow::anyhow;
|
||||
use async_timing_util::unix_timestamp_ms;
|
||||
use monitor_helpers::to_monitor_name;
|
||||
use monitor_types::entities::{update::Log, SystemCommand, CloneArgs};
|
||||
use monitor_types::entities::{update::Log, CloneArgs, SystemCommand};
|
||||
use run_command::async_run_command;
|
||||
|
||||
use super::run_monitor_command;
|
||||
|
||||
@@ -6,7 +6,7 @@ use resolver_api::{
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{state::State, helpers::run_monitor_command};
|
||||
use crate::{helpers::run_monitor_command, state::State};
|
||||
|
||||
mod stats;
|
||||
pub use stats::*;
|
||||
|
||||
@@ -10,4 +10,6 @@ monitor_types.workspace = true
|
||||
monitor_client.workspace = true
|
||||
periphery_client.workspace = true
|
||||
tokio.workspace = true
|
||||
anyhow.workspace = true
|
||||
anyhow.workspace = true
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
@@ -4,38 +4,38 @@ use periphery_client::{requests, PeripheryClient};
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
let periphery = PeripheryClient::new("http://localhost:9001", "monitor_passkey");
|
||||
|
||||
// let version = periphery.request(requests::GetVersion {}).await?;
|
||||
// println!("{version:?}");
|
||||
let version = periphery.request(requests::GetVersion {}).await?;
|
||||
println!("{version:?}");
|
||||
|
||||
// let system_info = periphery.request(requests::GetSystemInformation {}).await?;
|
||||
// println!("{system_info:#?}");
|
||||
let system_info = periphery.request(requests::GetSystemInformation {}).await?;
|
||||
println!("{system_info:#?}");
|
||||
|
||||
// let processes = periphery.request(requests::GetSystemProcesses {}).await?;
|
||||
// // println!("{system_stats:#?}");
|
||||
let processes = periphery.request(requests::GetSystemProcesses {}).await?;
|
||||
// println!("{system_stats:#?}");
|
||||
|
||||
// let periphery_process = processes.into_iter().find(|p| p.name.contains("periphery"));
|
||||
// println!("{periphery_process:#?}");
|
||||
let periphery_process = processes.into_iter().find(|p| p.name.contains("periphery"));
|
||||
println!("{periphery_process:#?}");
|
||||
|
||||
// let accounts = periphery.request(requests::GetAccounts {}).await?;
|
||||
// println!("{accounts:#?}");
|
||||
let accounts = periphery.request(requests::GetAccounts {}).await?;
|
||||
println!("{accounts:#?}");
|
||||
|
||||
// let secrets = periphery.request(requests::GetSecrets {}).await?;
|
||||
// println!("{secrets:#?}");
|
||||
let secrets = periphery.request(requests::GetSecrets {}).await?;
|
||||
println!("{secrets:#?}");
|
||||
|
||||
// let container_stats = periphery
|
||||
// .request(requests::GetContainerStatsList {})
|
||||
// .await?;
|
||||
// println!("{container_stats:#?}");
|
||||
let container_stats = periphery
|
||||
.request(requests::GetContainerStatsList {})
|
||||
.await?;
|
||||
println!("{container_stats:#?}");
|
||||
|
||||
// let res = periphery.request(requests::GetNetworkList {}).await?;
|
||||
// println!("{res:#?}");
|
||||
let res = periphery.request(requests::GetNetworkList {}).await?;
|
||||
println!("{res:#?}");
|
||||
|
||||
// let res = periphery
|
||||
// .request(requests::GetContainerStats {
|
||||
// name: "monitor-mongo".into(),
|
||||
// })
|
||||
// .await?;
|
||||
// println!("{res:#?}");
|
||||
let res = periphery
|
||||
.request(requests::GetContainerStats {
|
||||
name: "monitor-mongo".into(),
|
||||
})
|
||||
.await?;
|
||||
println!("{res:#?}");
|
||||
|
||||
let res = periphery
|
||||
.request(requests::GetContainerLog {
|
||||
|
||||
Reference in New Issue
Block a user