Improve docker registry secret management
[oom.git] / kubernetes / common / common / templates / _repository.tpl
index e054b57..364ba7d 100644 (file)
   {{else}}
     {{- default .Values.repository .Values.global.repository -}}
   {{end}}
-{{- end -}}
\ No newline at end of file
+{{- end -}}
+
+
+{{/*
+  Resolve the image repository secret token.
+  The value for .Values.global.repositoryCred is used:
+  repositoryCred:
+    user: user
+    password: password
+    mail: email (optional)
+*/}}
+{{- define "common.repository.secret" -}}
+  {{- $repo := include "common.repository" . }}
+  {{- $cred := .Values.global.repositoryCred }}
+  {{- $mail := default "@" $cred.mail }}
+  {{- $auth := printf "%s:%s" $cred.user $cred.password | b64enc }}
+  {{- printf "{\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}}" $repo $cred.user $cred.password $mail $auth | b64enc -}}
+{{- end -}}