{{- if and .Values.api.enabled (not .Values.api.secret.name) }}
apiVersion: v1
kind: Secret
type: Opaque
metadata:
  name: kargo-api
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "kargo.labels" . | nindent 4 }}
    {{- include "kargo.api.labels" . | nindent 4 }}
{{- if .Values.api.adminAccount.enabled }}
stringData:
  {{- if not .Values.api.adminAccount.passwordHash }}
    {{- fail "A value MUST be provided for api.adminAccount.passwordHash" }}
  {{- end }}  
  ADMIN_ACCOUNT_PASSWORD_HASH: {{ quote .Values.api.adminAccount.passwordHash }}
  {{- if not .Values.api.adminAccount.tokenSigningKey }}
    {{- fail "A value MUST be provided for api.adminAccount.tokenSigningKey" }}
  {{- end }}  
  ADMIN_ACCOUNT_TOKEN_SIGNING_KEY: {{ quote .Values.api.adminAccount.tokenSigningKey }}
{{- else }}
stringData: {}
{{- end }}
{{- end }}
