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

apiVersion: {{ template "common.capabilities.deployment.apiVersion" . }}
kind: Deployment
metadata:
  name: {{ include "harbor.registry" . }}
  namespace: {{ include "common.names.namespace" . | quote }}
  {{- $versionLabel := dict "app.kubernetes.io/version" ( include "common.images.version" ( dict "imageRoot" .Values.registry.server.image "chart" .Chart ) ) }}
  {{- $labels := include "common.tplvalues.merge" ( dict "values" ( list .Values.commonLabels $versionLabel ) "context" . ) }}
  labels: {{- include "common.labels.standard" ( dict "customLabels" $labels "context" $ ) | nindent 4 }}
    app.kubernetes.io/component: registry
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
spec:
  replicas: {{ .Values.registry.replicaCount }}
  {{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.registry.podLabels .Values.commonLabels $versionLabel ) "context" . ) }}
  selector:
    matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
      app.kubernetes.io/component: registry
  {{- if .Values.registry.updateStrategy }}
  strategy: {{- toYaml .Values.registry.updateStrategy | nindent 4 }}
  {{- end }}
  template:
    metadata:
      labels: {{- include "common.labels.standard" ( dict "customLabels" $podLabels "context" $ ) | nindent 8 }}
        app.kubernetes.io/component: registry
      annotations:
        checksum/configmap: {{ include (print $.Template.BasePath "/registry/registry-cm.yaml") . | sha256sum }}
        checksum/secret: {{ include (print $.Template.BasePath "/registry/registry-secret.yaml") . | sha256sum }}
        checksum/secret-jobservice: {{ include (print $.Template.BasePath "/jobservice/jobservice-secrets.yaml") . | sha256sum }}
        checksum/secret-core: {{ include (print $.Template.BasePath "/core/core-secret.yaml") . | sha256sum }}
        {{- if and .Values.internalTLS.enabled (not .Values.registry.tls.existingSecret) }}
        checksum/tls: {{ include (print $.Template.BasePath "/internal/internal-crt-secret.yaml") . | sha256sum }}
        {{- end }}
        {{- if .Values.registry.podAnnotations }}
        {{- include "common.tplvalues.render" (dict "value" .Values.registry.podAnnotations "context" $) | nindent 8 }}
        {{- end }}
    spec:
      {{- include "harbor.imagePullSecrets" . | nindent 6 }}
      automountServiceAccountToken: {{ .Values.registry.automountServiceAccountToken }}
      {{- if .Values.registry.hostAliases }}
      hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.registry.hostAliases "context" $) | nindent 8 }}
      {{- end }}
      {{- if .Values.registry.affinity }}
      affinity: {{- include "common.tplvalues.render" (dict "value" .Values.registry.affinity "context" $) | nindent 8 }}
      {{- else }}
      affinity:
        podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.registry.podAffinityPreset "component" "registry" "customLabels" $podLabels "context" $) | nindent 10 }}
        podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.registry.podAntiAffinityPreset "component" "registry" "customLabels" $podLabels "context" $) | nindent 10 }}
        nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.registry.nodeAffinityPreset.type "key" .Values.registry.nodeAffinityPreset.key "values" .Values.registry.nodeAffinityPreset.values) | nindent 10 }}
      {{- end }}
      {{- if .Values.registry.nodeSelector }}
      nodeSelector: {{- include "common.tplvalues.render" (dict "value" .Values.registry.nodeSelector "context" $) | nindent 8 }}
      {{- end }}
      {{- if .Values.registry.tolerations }}
      tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.registry.tolerations "context" $) | nindent 8 }}
      {{- end }}
      {{- if .Values.registry.topologySpreadConstraints }}
      topologySpreadConstraints: {{- include "common.tplvalues.render" (dict "value" .Values.registry.topologySpreadConstraints "context" .) | nindent 8 }}
      {{- end }}
      {{- if .Values.registry.priorityClassName }}
      priorityClassName: {{ .Values.registry.priorityClassName | quote }}
      {{- end }}
      {{- if .Values.registry.schedulerName }}
      schedulerName: {{ .Values.registry.schedulerName }}
      {{- end }}
      serviceAccountName: {{ include "harbor.registry.serviceAccountName" . }}
      {{- if .Values.registry.podSecurityContext.enabled }}
      securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.registry.podSecurityContext "context" $) | nindent 8 }}
      {{- end }}
      initContainers:
        {{- if and .Values.volumePermissions.enabled .Values.persistence.enabled }}
        - name: volume-permissions
          image: {{ include "harbor.volumePermissions.image" . }}
          imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }}
          command:
            - /bin/bash
          args:
            - -ec
            - |
              mkdir -p {{ .Values.persistence.imageChartStorage.filesystem.rootdirectory }}
              find {{ .Values.persistence.imageChartStorage.filesystem.rootdirectory }} -mindepth 1 -maxdepth 1 -not -name ".snapshot" -not -name "lost+found" | xargs -r chown -R {{ .Values.registry.server.containerSecurityContext.runAsUser }}:{{ .Values.registry.podSecurityContext.fsGroup }}
          {{- if .Values.volumePermissions.containerSecurityContext.enabled }}
          securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.volumePermissions.containerSecurityContext "context" $) | nindent 12 }}
          {{- end }}
          {{- if .Values.volumePermissions.resources }}
          resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }}
          {{- else if ne .Values.volumePermissions.resourcesPreset "none" }}
          resources: {{- include "common.resources.preset" (dict "type" .Values.volumePermissions.resourcesPreset) | nindent 12 }}
          {{- end }}
          volumeMounts:
            - name: empty-dir
              mountPath: /tmp
              subPath: tmp-dir
            - name: registry-data
              mountPath: {{ .Values.persistence.imageChartStorage.filesystem.rootdirectory }}
              subPath: {{ .Values.persistence.persistentVolumeClaim.registry.subPath }}
        {{- end }}
        - name: certificate-volume-server
          image: {{ include "harbor.registry.server.image" . }}
          imagePullPolicy: {{ .Values.registry.server.image.pullPolicy | quote }}
          command:
            - /bin/bash
          args:
            - -ec
            - cp -r /etc/ssl/certs/* /certs
          {{- if .Values.registry.server.containerSecurityContext.enabled }}
          securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.registry.server.containerSecurityContext "context" $) | nindent 12 }}
          {{- end }}
          {{- if .Values.certificateVolume.resources }}
          resources: {{- toYaml .Values.certificateVolume.resources | nindent 12 }}
          {{- else if ne .Values.certificateVolume.resourcesPreset "none" }}
          resources: {{- include "common.resources.preset" (dict "type" .Values.certificateVolume.resourcesPreset) | nindent 12 }}
          {{- end }}
          volumeMounts:
            - name: empty-dir
              mountPath: /certs
              subPath: etc-ssl-certs-server
        - name: certificate-volume-controller
          image: {{ include "harbor.registry.controller.image" . }}
          imagePullPolicy: {{ .Values.registry.controller.image.pullPolicy | quote }}
          command:
            - /bin/bash
          args:
            - -ec
            - cp -r /etc/ssl/certs/* /certs
          {{- if .Values.registry.controller.containerSecurityContext.enabled }}
          securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.registry.controller.containerSecurityContext "context" $) | nindent 12 }}
          {{- end }}
          {{- if .Values.certificateVolume.resources }}
          resources: {{- toYaml .Values.certificateVolume.resources | nindent 12 }}
          {{- else if ne .Values.certificateVolume.resourcesPreset "none" }}
          resources: {{- include "common.resources.preset" (dict "type" .Values.certificateVolume.resourcesPreset) | nindent 12 }}
          {{- end }}
          volumeMounts:
            - name: empty-dir
              mountPath: /certs
              subPath: etc-ssl-certs-controller
        {{- if .Values.registry.initContainers }}
        {{- include "common.tplvalues.render" (dict "value" .Values.registry.initContainers "context" $) | nindent 8 }}
        {{- end }}
      containers:
        - name: registry
          image: {{ include "harbor.registry.server.image" . }}
          imagePullPolicy: {{ .Values.registry.server.image.pullPolicy | quote }}
          {{- if .Values.registry.server.containerSecurityContext.enabled }}
          securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.registry.server.containerSecurityContext "context" $) | nindent 12 }}
          {{- end }}
          {{- if .Values.diagnosticMode.enabled }}
          command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
          {{- else if .Values.registry.server.command }}
          command: {{- include "common.tplvalues.render" (dict "value" .Values.registry.server.command "context" $) | nindent 12 }}
          {{- end }}
          {{- if .Values.diagnosticMode.enabled }}
          args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
          {{- else if .Values.registry.server.args }}
          args: {{- include "common.tplvalues.render" (dict "value" .Values.registry.server.args "context" $) | nindent 12 }}
          {{- end }}
          env:
            - name: BITNAMI_DEBUG
              value: {{ ternary "true" "false" .Values.registry.server.image.debug | quote }}
            {{- if .Values.internalTLS.enabled }}
            - name: INTERNAL_TLS_ENABLED
              value: "true"
            - name: INTERNAL_TLS_KEY_PATH
              value: /etc/harbor/ssl/registry/tls.key
            - name: INTERNAL_TLS_CERT_PATH
              value: /etc/harbor/ssl/registry/tls.crt
            - name: INTERNAL_TLS_TRUST_CA_PATH
              value: /etc/harbor/ssl/registry/ca.crt
            {{- end }}
            {{- if .Values.registry.server.extraEnvVars }}
            {{- include "common.tplvalues.render" (dict "value" .Values.registry.server.extraEnvVars "context" $) | nindent 12 }}
            {{- end }}
          envFrom:
            - secretRef:
                {{- if .Values.registry.existingSecret }}
                name: {{ .Values.registry.existingSecret }}
                {{- else }}
                name: {{ include "harbor.registry" . }}
                {{- end }}
            {{- if .Values.registry.server.extraEnvVarsCM }}
            - configMapRef:
                name: {{ include "common.tplvalues.render" (dict "value" .Values.registry.server.extraEnvVarsCM "context" $) }}
            {{- end }}
            {{- if .Values.registry.server.extraEnvVarsSecret }}
            - secretRef:
                name: {{ include "common.tplvalues.render" (dict "value" .Values.registry.server.extraEnvVarsSecret "context" $) }}
            {{- end }}
          ports:
            - containerPort: {{ ternary .Values.registry.server.containerPorts.https .Values.registry.server.containerPorts.http .Values.internalTLS.enabled }}
              name: registry
            - containerPort: {{ .Values.registry.server.containerPorts.debug }}
              name: debug
            {{- if .Values.metrics.enabled }}
            - containerPort: {{ .Values.registry.server.containerPorts.metrics }}
              name: metrics
            {{- end }}
          {{- if not .Values.diagnosticMode.enabled }}
          {{- if .Values.registry.server.customStartupProbe }}
          startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.registry.server.customStartupProbe "context" $) | nindent 12 }}
          {{- else if .Values.registry.server.startupProbe.enabled }}
          startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.registry.server.startupProbe "enabled") "context" $) | nindent 12 }}
            tcpSocket:
              port: {{ ternary "https" "http" .Values.internalTLS.enabled }}
          {{- end }}
          {{- if .Values.registry.server.customLivenessProbe }}
          livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.registry.server.customLivenessProbe "context" $) | nindent 12 }}
          {{- else if .Values.registry.server.livenessProbe.enabled }}
          livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.registry.server.livenessProbe "enabled") "context" $) | nindent 12 }}
            tcpSocket:
              port: registry
          {{- end }}
          {{- if .Values.registry.server.customReadinessProbe }}
          readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.registry.server.customReadinessProbe "context" $) | nindent 12 }}
          {{- else if .Values.registry.server.readinessProbe.enabled }}
          readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.registry.server.readinessProbe "enabled") "context" $) | nindent 12 }}
            httpGet:
              path: /
              scheme: {{ ternary "https" "http" .Values.internalTLS.enabled | upper }}
              port: registry
          {{- end }}
          {{- end }}
          {{- if .Values.registry.server.lifecycleHooks }}
          lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.registry.server.lifecycleHooks "context" $) | nindent 12 }}
          {{- end }}
          {{- if .Values.registry.server.resources }}
          resources: {{- toYaml .Values.registry.server.resources | nindent 12 }}
          {{- else if ne .Values.registry.server.resourcesPreset "none" }}
          resources: {{- include "common.resources.preset" (dict "type" .Values.registry.server.resourcesPreset) | nindent 12 }}
          {{- end }}
          volumeMounts:
            - name: empty-dir
              mountPath: /tmp
              subPath: tmp-dir
            - name: empty-dir
              mountPath: /etc/ssl/certs
              subPath: etc-ssl-certs-server
            - name: registry-data
              mountPath: {{ .Values.persistence.imageChartStorage.filesystem.rootdirectory }}
              subPath: {{ .Values.persistence.persistentVolumeClaim.registry.subPath }}
            - name: registry-root-certificate
              mountPath: /etc/registry/root.crt
              subPath: tls.crt
            - name: registry-htpasswd
              mountPath: /etc/registry/passwd
              subPath: passwd
            - name: registry-config
              mountPath: /etc/registry/config.yml
              subPath: config.yml
            {{- if .Values.internalTLS.enabled }}
            - name: internal-tls-certs
              mountPath: /etc/harbor/ssl/registry
            {{- end }}
            {{- if .Values.internalTLS.caBundleSecret }}
            {{- include "harbor.caBundleVolumeMount" . | nindent 12 }}
            {{- end }}
            {{- if and .Values.persistence.enabled (eq .Values.persistence.imageChartStorage.type "gcs") }}
            {{- if .Values.persistence.imageChartStorage.gcs.encodedkey }}
            - name: gcs-key
              mountPath: /etc/registry/gcs-key.json
              subPath: gcs-key.json
            {{- end }}
            {{- end }}
            {{- if .Values.persistence.imageChartStorage.caBundleSecret }}
            - name: storage-service-ca
              mountPath: /harbor_cust_cert/custom-ca-bundle.crt
              subPath: ca.crt
            {{- end }}
            {{- if .Values.registry.middleware.enabled }}
            {{- if eq .Values.registry.middleware.type "cloudFront" }}
            - name: cloudfront-key
              mountPath: /etc/registry/pk.pem
              subPath: pk.pem
            {{- end }}
            {{- end }}
            {{- include "harbor.redis.caVolumeMount" ( dict "context" . "component" "registry" ) | nindent 12 }}
            {{- if .Values.registry.server.extraVolumeMounts }}
            {{- include "common.tplvalues.render" (dict "value" .Values.registry.server.extraVolumeMounts "context" $) | nindent 12 }}
            {{- end }}
        - name: registryctl
          image: {{ include "harbor.registry.controller.image" . }}
          imagePullPolicy: {{ .Values.registry.controller.image.pullPolicy | quote }}
          {{- if .Values.registry.controller.containerSecurityContext.enabled }}
          securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.registry.controller.containerSecurityContext "context" $) | nindent 12 }}
          {{- end }}
          {{- if .Values.diagnosticMode.enabled }}
          command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
          {{- else if .Values.registry.controller.command }}
          command: {{- include "common.tplvalues.render" (dict "value" .Values.registry.controller.command "context" $) | nindent 12 }}
          {{- end }}
          {{- if .Values.diagnosticMode.enabled }}
          args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
          {{- else if .Values.registry.controller.args }}
          args: {{- include "common.tplvalues.render" (dict "value" .Values.registry.controller.args "context" $) | nindent 12 }}
          {{- end }}
          envFrom:
            {{- if .Values.tracing.enabled }}
            - configMapRef:
                name: {{ printf "%s-ctl-envvars" (include "harbor.registry" .) }}
            {{- end }}
            - secretRef:
                {{- if .Values.registry.existingSecret }}
                name: {{  .Values.registry.existingSecret }}
                {{- else }}
                name: {{ include "harbor.registry" . }}
                {{- end }}
            {{- if .Values.registry.controller.extraEnvVarsCM }}
            - configMapRef:
                name: {{ include "common.tplvalues.render" (dict "value" .Values.registry.controller.extraEnvVarsCM "context" $) }}
            {{- end }}
            {{- if .Values.registry.controller.extraEnvVarsSecret }}
            - secretRef:
                name: {{ include "common.tplvalues.render" (dict "value" .Values.registry.controller.extraEnvVarsSecret "context" $) }}
            {{- end }}
          env:
            - name: BITNAMI_DEBUG
              value: {{ ternary "true" "false" .Values.registry.controller.image.debug | quote }}
            - name: CORE_SECRET
              valueFrom:
                secretKeyRef:
                  name: {{ template "harbor.core.secretName" . }}
                  key: secret
            - name: JOBSERVICE_SECRET
              valueFrom:
                secretKeyRef:
                  name: {{ template "harbor.jobservice.secretName" . }}
                  key: secret
            {{- if .Values.internalTLS.enabled }}
            - name: INTERNAL_TLS_ENABLED
              value: "true"
            - name: INTERNAL_TLS_KEY_PATH
              value: /etc/harbor/ssl/registry/tls.key
            - name: INTERNAL_TLS_CERT_PATH
              value: /etc/harbor/ssl/registry/tls.crt
            - name: INTERNAL_TLS_TRUST_CA_PATH
              value: /etc/harbor/ssl/registry/ca.crt
            {{- end }}
            {{- if .Values.registry.controller.extraEnvVars }}
            {{- include "common.tplvalues.render" (dict "value" .Values.registry.controller.extraEnvVars "context" $) | nindent 12 }}
            {{- end }}
          ports:
            - containerPort: {{ ternary .Values.registry.controller.containerPorts.https .Values.registry.controller.containerPorts.http .Values.internalTLS.enabled }}
              name: registryctl
          {{- if not .Values.diagnosticMode.enabled }}
          {{- if .Values.registry.controller.customStartupProbe }}
          startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.registry.controller.customStartupProbe "context" $) | nindent 12 }}
          {{- else if .Values.registry.controller.startupProbe.enabled }}
          startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.registry.controller.startupProbe "enabled") "context" $) | nindent 12 }}
            tcpSocket:
              port: {{ ternary "https" "http" .Values.internalTLS.enabled }}
          {{- end }}
          {{- if .Values.registry.controller.customLivenessProbe }}
          livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.registry.controller.customLivenessProbe "context" $) | nindent 12 }}
          {{- else if .Values.registry.controller.livenessProbe.enabled }}
          livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.registry.controller.livenessProbe "enabled") "context" $) | nindent 12 }}
            tcpSocket:
              port: registryctl
          {{- end }}
          {{- if .Values.registry.controller.customReadinessProbe }}
          readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.registry.controller.customReadinessProbe "context" $) | nindent 12 }}
          {{- else if .Values.registry.controller.readinessProbe.enabled }}
          readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.registry.controller.readinessProbe "enabled") "context" $) | nindent 12 }}
            httpGet:
              path: /api/health
              scheme: {{ ternary "https" "http" .Values.internalTLS.enabled | upper }}
              port: registryctl
          {{- end }}
          {{- end }}
          {{- if .Values.registry.controller.lifecycleHooks }}
          lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.registry.controller.lifecycleHooks "context" $) | nindent 12 }}
          {{- end }}
          {{- if .Values.registry.controller.resources }}
          resources: {{- toYaml .Values.registry.controller.resources | nindent 12 }}
          {{- else if ne .Values.registry.controller.resourcesPreset "none" }}
          resources: {{- include "common.resources.preset" (dict "type" .Values.registry.controller.resourcesPreset) | nindent 12 }}
          {{- end }}
          volumeMounts:
            - name: empty-dir
              mountPath: /tmp
              subPath: tmp-dir
            - name: empty-dir
              mountPath: /etc/ssl/certs
              subPath: etc-ssl-certs-controller
            - name: registry-data
              mountPath: {{ .Values.persistence.imageChartStorage.filesystem.rootdirectory }}
              subPath: {{ .Values.persistence.persistentVolumeClaim.registry.subPath }}
            {{- if .Values.internalTLS.enabled }}
            - name: internal-tls-certs
              mountPath: /etc/harbor/ssl/registry
            {{- end }}
            - name: registry-config
              mountPath: /etc/registry/config.yml
              subPath: config.yml
            - name: registry-config
              mountPath: /etc/registryctl/config.yml
              subPath: ctl-config.yml
            {{- if .Values.persistence.imageChartStorage.caBundleSecret }}
            - name: storage-service-ca
              mountPath: /harbor_cust_cert/custom-ca-bundle.crt
              subPath: ca.crt
            {{- end }}
            {{- if .Values.internalTLS.caBundleSecret }}
            {{- include "harbor.caBundleVolumeMount" . | nindent 12 }}
            {{- end }}
            {{- if and .Values.persistence.enabled (eq .Values.persistence.imageChartStorage.type "gcs") }}
            {{- if .Values.persistence.imageChartStorage.gcs.encodedkey }}
            - name: gcs-key
              mountPath: /etc/registry/gcs-key.json
              subPath: gcs-key.json
            {{- end }}
            {{- end }}
            {{- include "harbor.redis.caVolumeMount" ( dict "context" . "component" "registry" ) | nindent 12 }}
            {{- if .Values.registry.controller.extraVolumeMounts }}
            {{- include "common.tplvalues.render" (dict "value" .Values.registry.controller.extraVolumeMounts "context" $) | nindent 12 }}
            {{- end }}
        {{- if .Values.registry.sidecars }}
        {{- include "common.tplvalues.render" (dict "value" .Values.registry.sidecars "context" $) | nindent 8 }}
        {{- end }}
      volumes:
        - name: empty-dir
          emptyDir: {}
        - name: registry-htpasswd
          secret:
            {{- if .Values.registry.existingSecret }}
            secretName: {{ .Values.registry.existingSecret }}
            {{- else }}
            secretName: {{ template "harbor.registry" . }}
            {{- end }}
            items:
              - key: REGISTRY_HTPASSWD
                path: passwd
        - name: registry-root-certificate
          secret:
            {{- if .Values.core.secretName }}
            secretName: {{ .Values.core.secretName }}
            {{- else }}
            secretName: {{ include "harbor.core" . }}
            {{- end }}
        {{- if .Values.internalTLS.enabled }}
        - name: internal-tls-certs
          secret:
            secretName: {{ include "harbor.registry.tls.secretName" . }}
        {{- end }}
        - name: registry-config
          configMap:
            name: {{ include "harbor.registry" . }}
        - name: registry-data
        {{- if and .Values.persistence.enabled (eq .Values.persistence.imageChartStorage.type "filesystem") }}
          persistentVolumeClaim:
            claimName: {{ .Values.persistence.persistentVolumeClaim.registry.existingClaim | default (include "harbor.registry" .) }}
        {{- else }}
          emptyDir: {}
        {{- end }}
        {{- if .Values.internalTLS.caBundleSecret }}
        {{- include "harbor.caBundleVolume" . | nindent 8 }}
        {{- end }}
        {{- if and .Values.persistence.enabled (eq .Values.persistence.imageChartStorage.type "gcs") }}
        {{- if .Values.persistence.imageChartStorage.gcs.encodedkey }}
        - name: gcs-key
          secret:
            secretName: {{ include "harbor.registry" . }}
            items:
              - key: GCS_KEY_DATA
                path: gcs-key.json
        {{- end }}
        {{- end }}
        {{- if .Values.persistence.imageChartStorage.caBundleSecret }}
        - name: storage-service-ca
          secret:
            secretName: {{ .Values.persistence.imageChartStorage.caBundleSecret }}
        {{- end }}
        {{- if .Values.registry.middleware.enabled }}
        {{- if eq .Values.registry.middleware.type "cloudFront" }}
        - name: cloudfront-key
          secret:
            secretName: {{ .Values.registry.middleware.cloudFront.privateKeySecret }}
            items:
              - key: CLOUDFRONT_KEY_DATA
                path: pk.pem
        {{- end }}
        {{- end }}
      {{- include "harbor.redis.caVolume" ( dict "context" . "component" "registry" ) | nindent 8 }}
      {{- if .Values.registry.extraVolumes }}
      {{- include "common.tplvalues.render" (dict "value" .Values.registry.extraVolumes "context" $) | nindent 8 }}
      {{- end }}
