{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}

{{- if not .Values.web.existingSecret }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ template "concourse.web.fullname" . }}
  namespace: {{ include "common.names.namespace" . | quote }}
  labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
    app.kubernetes.io/component: web
  {{- 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 }}
  {{- if .Values.web.conjur.enabled }}
  conjur_account: {{ default "" .Values.secrets.conjurAccount | b64enc | quote }}
  conjur_authn_login: {{ default "" .Values.secrets.conjurAuthnLogin | b64enc | quote }}
  conjur_authn_api_key: {{ default "" .Values.secrets.conjurAuthnApiKey | b64enc | quote }}
  conjur_authn_token_file: {{ default "" .Values.secrets.conjurAuthnTokenFile | b64enc | quote }}
  conjur_ca_cert: {{ default "" .Values.secrets.conjurCACert | b64enc | quote }}
  {{- end }}
{{- end }}
