apiVersion: v1
kind: Secret
metadata:
  name: {{ include "harbor.core" . }}
  labels: {{- include "common.labels.standard" . | nindent 4 }}
    {{- if .Values.commonLabels }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
    {{- end }}
    app.kubernetes.io/component: core
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
type: Opaque
data:
  {{- if .Values.core.secretKey }}
  secretKey: {{ .Values.core.secretKey | b64enc | quote }}
  {{- else if (not .Values.forcePassword) }}
  secretKey: {{ randAlphaNum 16 | b64enc | quote }}
  {{- else }}
  secretKey: {{ required "A secret key is required!" .Values.core.secretKey }}
  {{- end }}

  {{- if .Values.core.secret }}
  secret: {{ .Values.core.secret | b64enc | quote }}
  {{- else if (not .Values.forcePassword) }}
  secret: {{ randAlphaNum 16 | b64enc | quote }}
  {{- else }}
  secret: {{ required "A secret is required!" .Values.core.secret }}
  {{- end }}

  {{- if not .Values.core.secretName }}
  tls.crt: {{ .Files.Get "cert/tls.crt" | b64enc }}
  tls.key: {{ .Files.Get "cert/tls.key" | b64enc }}
  {{- end }}
