use non_blank_string_rs::NonBlankString;
use std::str::FromStr;

use crate::modules::helm::chart::{HelmChartScore, HelmRepository};

pub fn ntfy_helm_chart_score(namespace: String) -> HelmChartScore {
    let values = format!(
        r#"
replicaCount: 1

image:
  repository: binwiederhier/ntfy
  pullPolicy: IfNotPresent
  # Overrides the image tag whose default is the chart appVersion.
  tag: "v2.12.0"

serviceAccount:
  # Specifies whether a service account should be created
  create: true
  # Annotations to add to the service account
  # annotations:
  # The name of the service account to use.
  # If not set and create is true, a name is generated using the fullname template
  # name: ""

service:
  type: ClusterIP
  port: 80

ingress:
  enabled: false
#  annotations:
    # kubernetes.io/ingress.class: nginx
    # kubernetes.io/tls-acme: "true"
  hosts:
    - host: ntfy.host.com
      paths:
        - path: /
          pathType: ImplementationSpecific
  tls: []
  #  - secretName: chart-example-tls
  #    hosts:
  #      - chart-example.local


autoscaling:
  enabled: false

config:
  enabled: true
  data:
#    base-url: "https://ntfy.something.com"
    auth-file: "/var/cache/ntfy/user.db"
    auth-default-access: "deny-all"
    cache-file: "/var/cache/ntfy/cache.db"
    attachment-cache-dir: "/var/cache/ntfy/attachments"
    behind-proxy: true
    # web-root: "disable"
    enable-signup: false
    enable-login: "true"

persistence:
  enabled: true
  size: 200Mi
"#,
    );

    HelmChartScore {
        namespace: Some(NonBlankString::from_str(&namespace).unwrap()),
        release_name: NonBlankString::from_str("ntfy").unwrap(),
        chart_name: NonBlankString::from_str("sarab97/ntfy").unwrap(),
        chart_version: Some(NonBlankString::from_str("0.1.7").unwrap()),
        values_overrides: None,
        values_yaml: Some(values.to_string()),
        create_namespace: true,
        install_only: false,
        repository: Some(HelmRepository::new(
            "sarab97".to_string(),
            url::Url::parse("https://charts.sarabsingh.com").unwrap(),
            true,
        )),
    }
}
