use std::str::FromStr;

use non_blank_string_rs::NonBlankString;
use url::Url;

use crate::modules::helm::chart::HelmChartScore;

pub fn discord_alert_manager_score(
    webhook_url: Url,
    namespace: String,
    name: String,
) -> HelmChartScore {
    let values = format!(
        r#"
environment:
  - name: "DISCORD_WEBHOOK"
    value: "{webhook_url}"
"#,
    );

    HelmChartScore {
        namespace: Some(NonBlankString::from_str(&namespace).unwrap()),
        release_name: NonBlankString::from_str(&name).unwrap(),
        chart_name: NonBlankString::from_str(
            "oci://hub.nationtech.io/library/alertmanager-discord",
        )
        .unwrap(),
        chart_version: None,
        values_overrides: None,
        values_yaml: Some(values.to_string()),
        create_namespace: true,
        install_only: true,
        repository: None,
    }
}
