{{- define "imagePullSecret" }}
{{- printf "{\"auths\": {\"%s\": {\"auth\": \"%s\"}}}" .registry (printf "%s:%s" .username .password | b64enc) | b64enc }}
{{- end }}
{{- $root := . -}}
{{- range $image, $imageValue := .Values.images }}
{{- if $imageValue.regcred }}
---
apiVersion: v1
kind: Secret
type: kubernetes.io/dockerconfigjson
metadata:
  labels:
    app.kuberentes.io/name: {{ include "owprov.name" $root }}
    helm.sh/chart: {{ include "owprov.chart" $root }}
    app.kubernetes.io/instance: {{ $root.Release.Name }}
    app.kubernetes.io/managed-by: {{ $root.Release.Service }}
  name: {{ include "owprov.fullname" $root }}-{{ $image }}-regcred
data:
  .dockerconfigjson: {{ template "imagePullSecret" $imageValue.regcred }}
{{- end }}
{{- end }}
