apiVersion: v1
kind: Secret
metadata:
  name: {{ include "harbor.registry" . }}
  namespace: {{ .Release.Namespace | quote }}
  labels: {{- include "common.labels.standard" . | nindent 4 }}
    {{- 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:
  REGISTRY_HTPASSWD: {{ .Values.registry.credentials.htpasswd | b64enc | quote }}
  REGISTRY_HTTP_SECRET: {{ include "common.secrets.passwords.manage" (dict "secret" (include "harbor.registry" .) "key" "REGISTRY_HTTP_SECRET" "length" 16 "providedValues" (list "registry.secret") "context" $) }}
  REGISTRY_REDIS_PASSWORD: {{ (include "harbor.redis.rawPassword" .) | b64enc | quote }}
  {{- if eq .Values.persistence.imageChartStorage.type "azure" }}
  REGISTRY_STORAGE_AZURE_ACCOUNTKEY: {{ .Values.persistence.imageChartStorage.azure.accountkey | b64enc | quote }}
  {{- else if eq .Values.persistence.imageChartStorage.type "gcs" }}
  {{- if .Values.persistence.imageChartStorage.gcs.encodedkey }}
  GCS_KEY_DATA: {{ .Values.persistence.imageChartStorage.gcs.encodedkey | quote }}
  {{- end }}
  {{- else if eq .Values.persistence.imageChartStorage.type "s3" }}
  {{- if .Values.persistence.imageChartStorage.s3.accesskey }}
  REGISTRY_STORAGE_S3_ACCESSKEY: {{ .Values.persistence.imageChartStorage.s3.accesskey | b64enc | quote }}
  {{- end }}
  {{- if .Values.persistence.imageChartStorage.s3.secretkey }}
  REGISTRY_STORAGE_S3_SECRETKEY: {{ .Values.persistence.imageChartStorage.s3.secretkey | b64enc | quote }}
  {{- end }}
  {{- else if eq .Values.persistence.imageChartStorage.type "swift" }}
  REGISTRY_STORAGE_SWIFT_PASSWORD: {{ .Values.persistence.imageChartStorage.swift.password | b64enc | quote }}
  {{- if .Values.persistence.imageChartStorage.swift.secretkey }}
  REGISTRY_STORAGE_SWIFT_SECRETKEY: {{ .Values.persistence.imageChartStorage.swift.secretkey | b64enc | quote }}
  {{- end }}
  {{- if .Values.persistence.imageChartStorage.swift.accesskey }}
  REGISTRY_STORAGE_SWIFT_ACCESSKEY: {{ .Values.persistence.imageChartStorage.swift.accesskey | b64enc | quote }}
  {{- end }}
  {{- else if eq .Values.persistence.imageChartStorage.type "oss" }}
  REGISTRY_STORAGE_OSS_ACCESSKEYSECRET: {{ .Values.persistence.imageChartStorage.oss.accesskeysecret | b64enc | quote }}
  {{- end }}
