{{- if not .Values.web.existingSecret }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ template "concourse.web.fullname" . }}
  namespace: {{ .Release.Namespace | quote }}
  labels: {{- include "common.labels.standard" . | nindent 4 }}
    app.kubernetes.io/component: web
    {{- if .Values.commonLabels }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
    {{- end }}
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
type: Opaque
data:
  host_key: {{ .Values.secrets.hostKey | b64enc | quote }}
  session_signing_key: {{ .Values.secrets.sessionSigningKey | b64enc | quote }}
  worker_key.pub: {{ .Values.secrets.workerKeyPub | b64enc | quote }}
  {{- if .Values.secrets.localAuth.enabled }}
  {{- if .Values.secrets.localUsers }}
  local-users: {{ .Values.secrets.localUsers | b64enc | quote }}
  {{- else }}
  local-users: {{ printf "user:%s" (randAlphaNum 10) | b64enc | quote }}
  {{- end }}
  {{- end }}
{{- end }}
