apiVersion: v1
kind: Secret
metadata:
  name: {{ include "drone.fullname" . }}
type: Opaque
stringData:

  {{- if not (hasKey .Values "config") -}}
  {{- $_ := set .Values "config" dict -}}
  {{- end -}}

  {{- if not (hasKey .Values.config "DRONE_SERVER_HOST") -}}
  {{- $_ := set .Values.config "DRONE_SERVER_HOST" (index .Values.ingress.hosts 0).host -}}
  {{- end -}}

  {{- if not (hasKey .Values.config "DRONE_SERVER_PROTO") -}}
  {{- $_ := set .Values.config "DRONE_SERVER_PROTO" "https" -}}
  {{- end -}}

  {{/* SETUP CONFIG */}}
  {{ range $key, $value := .Values.config }}
  {{ upper $key}}: {{ quote $value }}
  {{ end }}