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 // 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 // locally, to development environment from a CI, to staging, and to production with settings
// that automatically adapt to each environment grade. // that automatically adapt to each environment grade.
let mut maestro = Maestro::<K8sAnywhereTopology>::initialize( let maestro = Maestro::<K8sAnywhereTopology>::initialize(
Inventory::autoload(), Inventory::autoload(),
K8sAnywhereTopology::from_env(), K8sAnywhereTopology::from_env(),
) )

View File

@ -19,7 +19,9 @@ pub struct AlertingInterpret<S: AlertSender> {
} }
#[async_trait] #[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( async fn execute(
&self, &self,
inventory: &Inventory, inventory: &Inventory,

View File

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

View File

@ -1,7 +1,6 @@
use serde::Serialize; 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)] #[derive(Debug, Clone, Serialize)]
pub struct KubePrometheusConfig { pub struct KubePrometheusConfig {

View File

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

View File

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

View File

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