diff --git a/examples/okd_cluster_alerts/Cargo.toml b/examples/okd_cluster_alerts/Cargo.toml new file mode 100644 index 0000000..5590675 --- /dev/null +++ b/examples/okd_cluster_alerts/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "example-okd-cluster-alerts" +edition = "2024" +version.workspace = true +readme.workspace = true +license.workspace = true +publish = false + +[dependencies] +harmony = { path = "../../harmony" } +harmony_cli = { path = "../../harmony_cli" } +harmony_types = { path = "../../harmony_types" } +harmony_secret = { path = "../../harmony_secret" } +harmony_secret_derive = { path = "../../harmony_secret_derive" } +cidr = { workspace = true } +tokio = { workspace = true } +harmony_macros = { path = "../../harmony_macros" } +log = { workspace = true } +env_logger = { workspace = true } +url = { workspace = true } +serde.workspace = true +brocade = { path = "../../brocade" } diff --git a/examples/okd_cluster_alerts/src/main.rs b/examples/okd_cluster_alerts/src/main.rs new file mode 100644 index 0000000..0d5241c --- /dev/null +++ b/examples/okd_cluster_alerts/src/main.rs @@ -0,0 +1,26 @@ +use harmony::{ + inventory::Inventory, + modules::monitoring::{ + alert_channel::discord_alert_channel::DiscordWebhook, + okd::cluster_monitoring::OpenshiftClusterAlertScore, + }, + topology::K8sAnywhereTopology, +}; +use harmony_macros::hurl; + +#[tokio::main] +async fn main() { + harmony_cli::run( + Inventory::autoload(), + K8sAnywhereTopology::from_env(), + vec![Box::new(OpenshiftClusterAlertScore { + receivers: vec![Box::new(DiscordWebhook { + name: "Webhook example".to_string(), + url: hurl!("http://something.o"), + })], + })], + None, + ) + .await + .unwrap(); +} diff --git a/harmony/src/domain/topology/k8s.rs b/harmony/src/domain/topology/k8s.rs index 4a91559..35ab211 100644 --- a/harmony/src/domain/topology/k8s.rs +++ b/harmony/src/domain/topology/k8s.rs @@ -91,6 +91,23 @@ impl K8sClient { Ok(resource.get(name).await?) } + pub async fn get_secret_json_value( + &self, + name: &str, + namespace: Option<&str>, + ) -> Result { + self.get_resource_json_value( + name, + namespace, + &GroupVersionKind { + group: "".to_string(), + version: "v1".to_string(), + kind: "Secret".to_string(), + }, + ) + .await + } + pub async fn get_deployment( &self, name: &str,