From 273befc61cac39e58b747cf2087a5663e40abfec Mon Sep 17 00:00:00 2001 From: Willem Date: Thu, 19 Jun 2025 09:03:39 -0400 Subject: [PATCH] fix: deleted outdated monitoring and alerting score --- .../modules/monitoring/monitoring_alerting.rs | 158 ------------------ 1 file changed, 158 deletions(-) delete mode 100644 harmony/src/modules/monitoring/monitoring_alerting.rs diff --git a/harmony/src/modules/monitoring/monitoring_alerting.rs b/harmony/src/modules/monitoring/monitoring_alerting.rs deleted file mode 100644 index bdddb7d..0000000 --- a/harmony/src/modules/monitoring/monitoring_alerting.rs +++ /dev/null @@ -1,158 +0,0 @@ -use async_trait::async_trait; -use email_address::EmailAddress; - -use log::info; -use serde::Serialize; -use url::Url; - -use crate::{ - data::{Id, Version}, - interpret::{Interpret, InterpretError, InterpretName, InterpretStatus, Outcome}, - inventory::Inventory, - score::Score, - topology::{HelmCommand, Topology}, -}; - -use super::{config::KubePrometheusConfig, kube_prometheus::kube_prometheus_helm_chart_score}; - -#[derive(Debug, Clone, Serialize)] -pub enum AlertChannel { - Discord { - name: String, - webhook_url: Url, - }, - Slack { - slack_channel: String, - webhook_url: Url, - }, - //TODO test and implement in helm chart - //currently does not work - Smpt { - email_address: EmailAddress, - service_name: String, - }, -} - -#[derive(Debug, Clone, Serialize)] -pub struct MonitoringAlertingStackScore { - pub alert_channel: Vec, - pub namespace: Option, -} - -impl MonitoringAlertingStackScore { - pub fn new() -> Self { - Self { - alert_channel: Vec::new(), - namespace: None, - } - } -} - -impl Score for MonitoringAlertingStackScore { - fn create_interpret(&self) -> Box> { - Box::new(MonitoringAlertingStackInterpret { - score: self.clone(), - }) - } - fn name(&self) -> String { - format!("MonitoringAlertingStackScore") - } -} - -#[derive(Debug, Clone, Serialize)] -struct MonitoringAlertingStackInterpret { - score: MonitoringAlertingStackScore, -} - -impl MonitoringAlertingStackInterpret { - async fn build_kube_prometheus_helm_chart_config(&self) -> KubePrometheusConfig { - let mut config = KubePrometheusConfig::new(); - if let Some(ns) = &self.score.namespace { - config.namespace = ns.clone(); - } - config.alert_channel = self.score.alert_channel.clone(); - config - } - - async fn deploy_kube_prometheus_helm_chart_score( - &self, - inventory: &Inventory, - topology: &T, - config: &KubePrometheusConfig, - ) -> Result { - let helm_chart = kube_prometheus_helm_chart_score(config); - helm_chart - .create_interpret() - .execute(inventory, topology) - .await - } - - async fn deploy_alert_channel_service( - &self, - inventory: &Inventory, - topology: &T, - config: &KubePrometheusConfig, - ) -> Result { - //let mut outcomes = vec![]; - - //for channel in &self.score.alert_channel { - // let outcome = match channel { - // AlertChannel::Discord { .. } => { - // discord_alert_manager_score(config) - // .create_interpret() - // .execute(inventory, topology) - // .await - // } - // AlertChannel::Slack { .. } => Ok(Outcome::success( - // "No extra configs for slack alerting".to_string(), - // )), - // AlertChannel::Smpt { .. } => { - // todo!() - // } - // }; - // outcomes.push(outcome); - //} - //for result in outcomes { - // result?; - //} - - Ok(Outcome::success("All alert channels deployed".to_string())) - } -} - -#[async_trait] -impl Interpret for MonitoringAlertingStackInterpret { - async fn execute( - &self, - inventory: &Inventory, - topology: &T, - ) -> Result { - let config = self.build_kube_prometheus_helm_chart_config().await; - info!("Built kube prometheus config"); - info!("Installing kube prometheus chart"); - self.deploy_kube_prometheus_helm_chart_score(inventory, topology, &config) - .await?; - info!("Installing alert channel service"); - self.deploy_alert_channel_service(inventory, topology, &config) - .await?; - Ok(Outcome::success(format!( - "succesfully deployed monitoring and alerting stack" - ))) - } - - fn get_name(&self) -> InterpretName { - todo!() - } - - fn get_version(&self) -> Version { - todo!() - } - - fn get_status(&self) -> InterpretStatus { - todo!() - } - - fn get_children(&self) -> Vec { - todo!() - } -}