global:
  imagePullSecrets: []
  image:
    tag: "" # used if component image.tag is empty; else Chart appVersion
    # pullPolicy: always    # optional; default IfNotPresent. Use always (any casing) for same-tag registry updates.
  # rollme: ""              # optional; when Always — fixed rollme; bump manually to roll
  # rolloutNonce: ""       # optional; when Always — set per CI run (e.g. build id) if you apply frozen manifests (git-rendered YAML); changes rollme without re-helm timing

nameOverride: ""
fullnameOverride: ""

# Server ConfigMap (appsettings.json); referenced from components.server.configMapFile when tpl: true
certsServerConfig:
  allowedHosts: "*"
  logging:
    default: Information
    microsoftAspNetCore: Warning
  configuration:
    auth:
      issuer: ""
      audience: ""
      expiration: 15
      refreshExpiration: 180
    agent:
      agentHostname: ""
      agentPort: 5000
      serviceToReload: haproxy
    production: "https://acme-v02.api.letsencrypt.org/directory"
    staging: "https://acme-staging-v02.api.letsencrypt.org/directory"
    acmeFolder: /acme
    cacheFolder: /cache
    dataFolder: /data
    settingsFile: /data/settings.json

# Server Secret (appsecrets.json); referenced from components.server.secretsFile when tpl: true
certsServerSecrets:
  authSecret: changeme-generate-a-long-random-string
  authPepper: ""
  agentKey: ""

# Client ConfigMap (config.js); referenced when tpl: true
certsClientRuntime:
  apiUrl: "http://certs-ui.example.com/api"

components:
  server:
    image:
      registry: cr.maks-it.com
      repository: certs-ui/server
      tag: ""
    env:
      - name: ASPNETCORE_ENVIRONMENT
        value: Production
      - name: ASPNETCORE_HTTP_PORTS
        value: "5000"
    service:
      enabled: true
      type: ClusterIP
      port: 5000
      targetPort: 5000
    persistence:
      storageClass: local-path
      volumes:
        - name: acme
          mountPath: /acme
          type: pvc
          pvc:
            create: true
            keep: true
            size: 50Mi
            accessModes: [ReadWriteOnce]
        - name: cache
          mountPath: /cache
          type: pvc
          pvc:
            create: true
            keep: true
            size: 50Mi
            accessModes: [ReadWriteOnce]
        - name: data
          mountPath: /data
          type: pvc
          pvc:
            create: true
            keep: true
            size: 50Mi
            accessModes: [ReadWriteOnce]
    secretsFile:
      key: appsecrets.json
      mountPath: /secrets/appsecrets.json
      tpl: true
      keep: true
      existingSecret: ""
      content: |
        {
          "Configuration": {
            "Auth": {
              "Secret": {{ .Values.certsServerSecrets.authSecret | toJson }},
              "Pepper": {{ .Values.certsServerSecrets.authPepper | toJson }}
            },
            "Agent": {
              "AgentKey": {{ .Values.certsServerSecrets.agentKey | toJson }}
            }
          }
        }
    configMapFile:
      key: appsettings.json
      mountPath: /configMap/appsettings.json
      tpl: true
      keep: true
      existingConfigMap: ""
      content: |
        {
          "Logging": {
            "LogLevel": {
              "Default": {{ .Values.certsServerConfig.logging.default | toJson }},
              "Microsoft.AspNetCore": {{ .Values.certsServerConfig.logging.microsoftAspNetCore | toJson }}
            }
          },
          "AllowedHosts": {{ .Values.certsServerConfig.allowedHosts | toJson }},
          "Configuration": {
            "Auth": {
              "Issuer": {{ .Values.certsServerConfig.configuration.auth.issuer | toJson }},
              "Audience": {{ .Values.certsServerConfig.configuration.auth.audience | toJson }},
              "Expiration": {{ .Values.certsServerConfig.configuration.auth.expiration }},
              "RefreshExpiration": {{ .Values.certsServerConfig.configuration.auth.refreshExpiration }}
            },
            "Agent": {
              "AgentHostname": {{ .Values.certsServerConfig.configuration.agent.agentHostname | toJson }},
              "AgentPort": {{ .Values.certsServerConfig.configuration.agent.agentPort }},
              "ServiceToReload": {{ .Values.certsServerConfig.configuration.agent.serviceToReload | toJson }}
            },
            "Production": {{ .Values.certsServerConfig.configuration.production | toJson }},
            "Staging": {{ .Values.certsServerConfig.configuration.staging | toJson }},
            "CacheFolder": {{ .Values.certsServerConfig.configuration.cacheFolder | toJson }},
            "AcmeFolder": {{ .Values.certsServerConfig.configuration.acmeFolder | toJson }},
            "DataFolder": {{ .Values.certsServerConfig.configuration.dataFolder | toJson }},
            "SettingsFile": {{ .Values.certsServerConfig.configuration.settingsFile | toJson }}
          }
        }

  client:
    image:
      registry: cr.maks-it.com
      repository: certs-ui/client
      tag: ""
    service:
      enabled: true
      type: ClusterIP
      port: 5173
      targetPort: 5173
    configMapFile:
      key: config.js
      mountPath: /app/dist/config.js
      tpl: true
      keep: true
      existingConfigMap: ""
      content: |
        window.RUNTIME_CONFIG = {
          API_URL: {{ .Values.certsClientRuntime.apiUrl | toJson }}
        };

  reverseproxy:
    image:
      registry: cr.maks-it.com
      repository: certs-ui/reverseproxy
      tag: ""
    env:
      - name: ASPNETCORE_ENVIRONMENT
        value: Production
      - name: ASPNETCORE_HTTP_PORTS
        value: "8080"
    service:
      enabled: true
      type: ClusterIP
      port: 8080
      targetPort: 8080
