diff --git a/harmony/src/domain/maestro/mod.rs b/harmony/src/domain/maestro/mod.rs index 721fb40..d9587c8 100644 --- a/harmony/src/domain/maestro/mod.rs +++ b/harmony/src/domain/maestro/mod.rs @@ -84,10 +84,8 @@ impl Maestro { self.topology.name(), ); } - debug!("Running score {score:?}"); - let interpret = score.create_interpret(); - debug!("Launching interpret {interpret:?}"); - let result = interpret.execute(&self.inventory, &self.topology).await; + debug!("Interpreting score {score:?}"); + let result = score.interpret(&self.inventory, &self.topology).await; debug!("Got result {result:?}"); result } diff --git a/harmony/src/domain/score.rs b/harmony/src/domain/score.rs index a7eb9c7..00bb063 100644 --- a/harmony/src/domain/score.rs +++ b/harmony/src/domain/score.rs @@ -1,15 +1,32 @@ use std::collections::BTreeMap; +use async_trait::async_trait; use serde::Serialize; use serde_value::Value; -use super::{interpret::Interpret, topology::Topology}; +use super::{ + interpret::{Interpret, InterpretError, Outcome}, + inventory::Inventory, + topology::Topology, +}; +#[async_trait] pub trait Score: std::fmt::Debug + ScoreToString + Send + Sync + CloneBoxScore + SerializeScore { - fn create_interpret(&self) -> Box>; + async fn interpret( + &self, + inventory: &Inventory, + topology: &T, + ) -> Result { + let interpret = self.create_interpret(); + interpret.execute(inventory, topology).await + } + fn name(&self) -> String; + + #[doc(hidden)] + fn create_interpret(&self) -> Box>; } pub trait SerializeScore { diff --git a/harmony/src/domain/topology/k8s_anywhere.rs b/harmony/src/domain/topology/k8s_anywhere.rs index 4df1ef2..b21f385 100644 --- a/harmony/src/domain/topology/k8s_anywhere.rs +++ b/harmony/src/domain/topology/k8s_anywhere.rs @@ -86,8 +86,7 @@ impl PrometheusApplicationMonitoring for K8sAnywhereTopology { let result = self .get_k8s_prometheus_application_score(sender.clone(), receivers) .await - .create_interpret() - .execute(inventory, self) + .interpret(inventory, self) .await; match result { @@ -173,8 +172,7 @@ impl K8sAnywhereTopology { async fn try_install_k3d(&self) -> Result<(), PreparationError> { let result = self .get_k3d_installation_score() - .create_interpret() - .execute(&Inventory::empty(), self) + .interpret(&Inventory::empty(), self) .await; match result { @@ -293,10 +291,7 @@ impl K8sAnywhereTopology { debug!("installing prometheus operator"); let op_score = prometheus_operator_helm_chart_score(sender.namespace.clone()); - let result = op_score - .create_interpret() - .execute(&Inventory::empty(), self) - .await; + let result = op_score.interpret(&Inventory::empty(), self).await; return match result { Ok(outcome) => match outcome.status { diff --git a/harmony/src/domain/topology/tenant/k8s.rs b/harmony/src/domain/topology/tenant/k8s.rs index 9b08b66..f2edb05 100644 --- a/harmony/src/domain/topology/tenant/k8s.rs +++ b/harmony/src/domain/topology/tenant/k8s.rs @@ -236,7 +236,7 @@ impl K8sTenantManager { //need to find a way to automatically detect the ip address from the docker //network "ipBlock": { - "cidr": "172.24.0.0/16", + "cidr": "172.18.0.0/16", } } ] diff --git a/harmony/src/modules/application/features/continuous_delivery.rs b/harmony/src/modules/application/features/continuous_delivery.rs index de778fb..e53bd36 100644 --- a/harmony/src/modules/application/features/continuous_delivery.rs +++ b/harmony/src/modules/application/features/continuous_delivery.rs @@ -193,8 +193,7 @@ impl< })], }; score - .create_interpret() - .execute(&Inventory::empty(), topology) + .interpret(&Inventory::empty(), topology) .await .unwrap(); } diff --git a/harmony/src/modules/application/features/helm_argocd_score.rs b/harmony/src/modules/application/features/helm_argocd_score.rs index ff79740..66b23f0 100644 --- a/harmony/src/modules/application/features/helm_argocd_score.rs +++ b/harmony/src/modules/application/features/helm_argocd_score.rs @@ -51,10 +51,7 @@ impl Interpret for ArgoInterpret { topology: &T, ) -> Result { error!("Uncomment below, only disabled for debugging"); - self.score - .create_interpret() - .execute(inventory, topology) - .await?; + self.score.interpret(inventory, topology).await?; let k8s_client = topology.k8s_client().await?; k8s_client diff --git a/harmony/src/modules/application/features/monitoring.rs b/harmony/src/modules/application/features/monitoring.rs index 4c7632c..1ffdace 100644 --- a/harmony/src/modules/application/features/monitoring.rs +++ b/harmony/src/modules/application/features/monitoring.rs @@ -57,8 +57,7 @@ impl< namespace: namespace.clone(), host: "localhost".to_string(), }; - ntfy.create_interpret() - .execute(&Inventory::empty(), topology) + ntfy.interpret(&Inventory::empty(), topology) .await .expect("couldn't create interpret for ntfy"); @@ -95,8 +94,7 @@ impl< alerting_score.receivers.push(Box::new(ntfy_receiver)); alerting_score - .create_interpret() - .execute(&Inventory::empty(), topology) + .interpret(&Inventory::empty(), topology) .await .unwrap(); Ok(()) diff --git a/harmony/src/modules/lamp.rs b/harmony/src/modules/lamp.rs index 29228d8..09c4592 100644 --- a/harmony/src/modules/lamp.rs +++ b/harmony/src/modules/lamp.rs @@ -128,10 +128,7 @@ impl Interpret for LAMPInterpret { info!("Deploying score {deployment_score:#?}"); - deployment_score - .create_interpret() - .execute(inventory, topology) - .await?; + deployment_score.interpret(inventory, topology).await?; info!("LAMP deployment_score {deployment_score:?}"); @@ -153,10 +150,7 @@ impl Interpret for LAMPInterpret { .map(|nbs| fqdn!(nbs.to_string().as_str())), }; - lamp_ingress - .create_interpret() - .execute(inventory, topology) - .await?; + lamp_ingress.interpret(inventory, topology).await?; info!("LAMP lamp_ingress {lamp_ingress:?}"); @@ -215,7 +209,7 @@ impl LAMPInterpret { repository: None, }; - score.create_interpret().execute(inventory, topology).await + score.interpret(inventory, topology).await } fn build_dockerfile(&self, score: &LAMPScore) -> Result> { let mut dockerfile = Dockerfile::new(); diff --git a/harmony/src/modules/monitoring/kube_prometheus/prometheus.rs b/harmony/src/modules/monitoring/kube_prometheus/prometheus.rs index 4cf2b47..98970e6 100644 --- a/harmony/src/modules/monitoring/kube_prometheus/prometheus.rs +++ b/harmony/src/modules/monitoring/kube_prometheus/prometheus.rs @@ -119,8 +119,7 @@ impl KubePrometheus { topology: &T, ) -> Result { kube_prometheus_helm_chart_score(self.config.clone()) - .create_interpret() - .execute(inventory, topology) + .interpret(inventory, topology) .await } } diff --git a/harmony/src/modules/monitoring/ntfy/ntfy.rs b/harmony/src/modules/monitoring/ntfy/ntfy.rs index a640bf4..f57e680 100644 --- a/harmony/src/modules/monitoring/ntfy/ntfy.rs +++ b/harmony/src/modules/monitoring/ntfy/ntfy.rs @@ -96,8 +96,7 @@ impl Interpret for NtfyInterpret { topology: &T, ) -> Result { ntfy_helm_chart_score(self.score.namespace.clone(), self.score.host.clone()) - .create_interpret() - .execute(inventory, topology) + .interpret(inventory, topology) .await?; debug!("installed ntfy helm chart"); diff --git a/harmony/src/modules/monitoring/prometheus/prometheus.rs b/harmony/src/modules/monitoring/prometheus/prometheus.rs index 934f1ae..a207d5a 100644 --- a/harmony/src/modules/monitoring/prometheus/prometheus.rs +++ b/harmony/src/modules/monitoring/prometheus/prometheus.rs @@ -100,8 +100,7 @@ impl Prometheus { topology: &T, ) -> Result { prometheus_helm_chart_score(self.config.clone()) - .create_interpret() - .execute(inventory, topology) + .interpret(inventory, topology) .await } pub async fn install_grafana( @@ -116,8 +115,7 @@ impl Prometheus { if let Some(ns) = namespace.as_deref() { grafana_helm_chart_score(ns) - .create_interpret() - .execute(inventory, topology) + .interpret(inventory, topology) .await } else { Err(InterpretError::new(