# helm_charts_secret.registry.yaml
{{- range $name, $cred := dict "db" (.Values.image.credentials) "init-certs" (.Values.tls.init.image.credentials) }}
{{- if not (empty $cred) }}
{{- if or (and (eq $name "init-certs") $.Values.tls.enabled) (ne $name "init-certs") }}
---
kind: Secret
apiVersion: v1
metadata:
  name: {{ template "cockroachdb.fullname" $ }}.{{ $name }}.registry
  namespace: {{ $.Release.Namespace | quote }}
  labels:
    helm.sh/chart: {{ template "cockroachdb.chart" $ }}
    app.kubernetes.io/name: {{ template "cockroachdb.name" $ }}
    app.kubernetes.io/instance: {{ $.Release.Name | quote }}
    app.kubernetes.io/managed-by: {{ $.Release.Service | quote }}
  {{- with $.Values.labels }}
    {{- toYaml . | nindent 4 }}
  {{- end }}
type: kubernetes.io/dockerconfigjson
data:
  .dockerconfigjson: {{ printf `{"auths":{%s:{"auth":"%s"}}}` ($cred.registry | quote) (printf "%s:%s" $cred.username $cred.password | b64enc) | b64enc | quote }}
{{- end }}
{{- end }}
{{- end }}