remove unnecessary configure_receivers method from trait

This commit is contained in:
Ian Letourneau 2025-08-01 18:26:05 -04:00
parent 961a300154
commit 4b6bebcaf1
3 changed files with 14 additions and 19 deletions

View File

@ -72,17 +72,6 @@ impl K8sclient for K8sAnywhereTopology {
#[async_trait]
impl PrometheusApplicationMonitoring<CRDPrometheus> for K8sAnywhereTopology {
async fn configure_receivers(
&self,
receivers: Option<Vec<Box<dyn AlertReceiver<CRDPrometheus>>>>,
) -> Option<Vec<Box<dyn CRDAlertManagerReceiver>>> {
let Some(receivers) = receivers else {
return None;
};
todo!()
}
async fn install_prometheus(
&self,
sender: &CRDPrometheus,
@ -141,7 +130,7 @@ impl K8sAnywhereTopology {
receivers: self
.configure_receivers(receivers)
.await
.unwrap_or_else(|| vec![]),
.unwrap_or_else(Vec::new),
service_monitors: vec![],
prometheus_rules: vec![],
}
@ -319,6 +308,17 @@ impl K8sAnywhereTopology {
"prometheus operator present in cluster".to_string(),
))
}
async fn configure_receivers(
&self,
receivers: Option<Vec<Box<dyn AlertReceiver<CRDPrometheus>>>>,
) -> Option<Vec<Box<dyn CRDAlertManagerReceiver>>> {
let Some(receivers) = receivers else {
return None;
};
todo!()
}
}
#[derive(Clone, Debug)]

View File

@ -564,7 +564,7 @@ impl K8sPrometheusCRDAlertingInterpret {
) -> Result<Outcome, InterpretError> {
for receiver in receivers.iter() {
let alertmanager_config: AlertmanagerConfig = receiver
.configure_receiver(&client, self.sender.namespace.clone().clone())
.configure_receiver(client, self.sender.namespace.clone())
.await;
let sender = CRDPrometheus {
alertmanager_configs: alertmanager_config,
@ -575,6 +575,6 @@ impl K8sPrometheusCRDAlertingInterpret {
InterpretError::new(format!("failed to install receiver: {}", err))
})?;
}
Ok(Outcome::success(format!("successfully deployed receivers")))
Ok(Outcome::success("successfully deployed receivers".into()))
}
}

View File

@ -3,16 +3,11 @@ use async_trait::async_trait;
use crate::{
interpret::{InterpretError, Outcome},
inventory::Inventory,
modules::monitoring::kube_prometheus::crd::crd_alertmanager_config::CRDAlertManagerReceiver,
topology::oberservability::monitoring::{AlertReceiver, AlertSender},
};
#[async_trait]
pub trait PrometheusApplicationMonitoring<S: AlertSender> {
async fn configure_receivers(
&self,
receivers: Option<Vec<Box<dyn AlertReceiver<S>>>>,
) -> Option<Vec<Box<dyn CRDAlertManagerReceiver>>>;
async fn install_prometheus(
&self,
sender: &S,