fix checks
All checks were successful
Run Check Script / check (pull_request) Successful in 1m32s

This commit is contained in:
tahahawa 2025-06-20 16:10:16 -04:00
parent 2cb95151ae
commit dec4b76b57
7 changed files with 33 additions and 31 deletions

View File

@ -43,7 +43,7 @@ async fn main() {
// K8sAnywhereTopology as it is the most automatic one that enables you to easily deploy
// locally, to development environment from a CI, to staging, and to production with settings
// that automatically adapt to each environment grade.
let mut maestro = Maestro::<K8sAnywhereTopology>::initialize(
let maestro = Maestro::<K8sAnywhereTopology>::initialize(
Inventory::autoload(),
K8sAnywhereTopology::from_env(),
)

View File

@ -19,7 +19,9 @@ pub struct AlertingInterpret<S: AlertSender> {
}
#[async_trait]
impl<S: AlertSender + Installable<T>, T: Topology + HelmCommand> Interpret<T> for AlertingInterpret<S> {
impl<S: AlertSender + Installable<T>, T: Topology + HelmCommand> Interpret<T>
for AlertingInterpret<S>
{
async fn execute(
&self,
inventory: &Inventory,

View File

@ -1,4 +1,5 @@
use async_trait::async_trait;
use serde::Serialize;
use serde_yaml::{Mapping, Value};
use crate::{
@ -10,7 +11,7 @@ use crate::{
topology::{Url, oberservability::monitoring::AlertReceiver},
};
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Serialize)]
pub struct DiscordWebhook {
pub name: String,
pub url: Url,
@ -52,7 +53,6 @@ impl AlertChannelConfig for DiscordWebhook {
}
impl DiscordWebhook {
async fn alert_channel_route(&self) -> serde_yaml::Value {
let mut route = Mapping::new();
route.insert(
@ -93,15 +93,15 @@ impl DiscordWebhook {
mod tests {
use super::*;
#[test]
fn discord_serialize_should_match() {
#[tokio::test]
async fn discord_serialize_should_match() {
let discord_receiver = DiscordWebhook {
name: "test-discord".to_string(),
url: Url::Url(url::Url::parse("https://discord.i.dont.exist.com").unwrap()),
};
let discord_receiver_receiver =
serde_yaml::to_string(&discord_receiver.alert_channel_receiver()).unwrap();
serde_yaml::to_string(&discord_receiver.alert_channel_receiver().await).unwrap();
println!("receiver \n{:#}", discord_receiver_receiver);
let discord_receiver_receiver_yaml = r#"name: test-discord
discord_configs:
@ -110,7 +110,7 @@ discord_configs:
.to_string();
let discord_receiver_route =
serde_yaml::to_string(&discord_receiver.alert_channel_route()).unwrap();
serde_yaml::to_string(&discord_receiver.alert_channel_route().await).unwrap();
println!("route \n{:#}", discord_receiver_route);
let discord_receiver_route_yaml = r#"receiver: test-discord
matchers:

View File

@ -1,7 +1,6 @@
use serde::Serialize;
use serde_yaml::Value;
use crate::modules::monitoring::kube_prometheus::{prometheus::PrometheusReceiver, types::AlertManagerChannelConfig};
use crate::modules::monitoring::kube_prometheus::types::AlertManagerChannelConfig;
#[derive(Debug, Clone, Serialize)]
pub struct KubePrometheusConfig {

View File

@ -10,8 +10,7 @@ use std::{
use crate::modules::{
helm::chart::HelmChartScore,
monitoring::kube_prometheus::types::{
AlertManager, AlertManagerChannelConfig, AlertManagerConfig, AlertManagerRoute,
AlertManagerValues,
AlertManager, AlertManagerConfig, AlertManagerRoute, AlertManagerValues,
},
};
@ -157,18 +156,16 @@ prometheus:
"#,
);
let mut null_receiver = Mapping::new();
null_receiver.insert(
Value::String("receiver".to_string()),
Value::String("null".to_string()),
);
null_receiver.insert(
Value::String("matchers".to_string()),
Value::Sequence(vec![Value::String("alertname!=Watchdog".to_string())]),
);
null_receiver.insert(Value::String("continue".to_string()), Value::Bool(true));
null_receiver.insert(
Value::String("receiver".to_string()),
Value::String("null".to_string()),
);
null_receiver.insert(
Value::String("matchers".to_string()),
Value::Sequence(vec![Value::String("alertname!=Watchdog".to_string())]),
);
null_receiver.insert(Value::String("continue".to_string()), Value::Bool(true));
let mut alert_manager_channel_config = AlertManagerConfig {
global: Mapping::new(),

View File

@ -6,7 +6,6 @@ use crate::{
score::Score,
topology::{
HelmCommand, Topology,
installable::Installable,
oberservability::monitoring::{AlertReceiver, AlertingInterpret},
},
};

View File

@ -2,23 +2,24 @@ use std::sync::{Arc, Mutex};
use async_trait::async_trait;
use log::debug;
use serde_yaml::Value;
use crate::{
interpret::{InterpretError, Outcome},
inventory::Inventory,
score,
topology::{
HelmCommand, K8sAnywhereTopology, Topology, installable::Installable,
oberservability::monitoring::AlertSender,
HelmCommand, Topology, installable::Installable, oberservability::monitoring::AlertSender,
},
};
use score::Score;
use super::{helm::{
config::KubePrometheusConfig, kube_prometheus_helm_chart::kube_prometheus_helm_chart_score,
}, types::AlertManagerChannelConfig};
use super::{
helm::{
config::KubePrometheusConfig, kube_prometheus_helm_chart::kube_prometheus_helm_chart_score,
},
types::AlertManagerChannelConfig,
};
#[async_trait]
impl AlertSender for Prometheus {
@ -29,7 +30,11 @@ impl AlertSender for Prometheus {
#[async_trait]
impl<T: Topology + HelmCommand> Installable<T> for Prometheus {
async fn ensure_installed(&self, inventory: &Inventory, topology: &T) -> Result<(), InterpretError> {
async fn ensure_installed(
&self,
inventory: &Inventory,
topology: &T,
) -> Result<(), InterpretError> {
//install_prometheus
self.install_prometheus(inventory, topology).await?;
Ok(())