rancher-partner-charts/charts/stackstate/stackstate-k8s-agent/templates/pull-secret.yaml

36 lines
1.6 KiB
YAML

{{- $defaultRegistry := .Values.global.imageRegistry }}
{{- $top := . }}
{{- $registryAuthMap := dict }}
{{- range $registry, $credentials := .Values.global.imagePullCredentials }}
{{- $registryAuthDocument := dict -}}
{{- $_ := set $registryAuthDocument "username" $credentials.username }}
{{- $_ := set $registryAuthDocument "password" $credentials.password }}
{{- $authMessage := printf "%s:%s" $registryAuthDocument.username $registryAuthDocument.password | b64enc }}
{{- $_ := set $registryAuthDocument "auth" $authMessage }}
{{- if eq $registry "default" }}
{{- $registryAuthMap := set $registryAuthMap (include "stackstate-k8s-agent.imageRegistry" $top) $registryAuthDocument }}
{{ else }}
{{- $registryAuthMap := set $registryAuthMap $registry $registryAuthDocument }}
{{- end }}
{{- end }}
{{- if .Values.all.image.pullSecretUsername }}
{{- $registryAuthDocument := dict -}}
{{- $_ := set $registryAuthDocument "username" .Values.all.image.pullSecretUsername }}
{{- $_ := set $registryAuthDocument "password" .Values.all.image.pullSecretPassword }}
{{- $authMessage := printf "%s:%s" $registryAuthDocument.username $registryAuthDocument.password | b64enc }}
{{- $_ := set $registryAuthDocument "auth" $authMessage }}
{{- $registryAuthMap := set $registryAuthMap (include "stackstate-k8s-agent.imageRegistry" $top) $registryAuthDocument }}
{{- end }}
{{- $dockerAuthsDocuments := dict "auths" $registryAuthMap }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "stackstate-k8s-agent.pull-secret.name" . }}
data:
.dockerconfigjson: {{ $dockerAuthsDocuments | toJson | b64enc | quote }}
type: kubernetes.io/dockerconfigjson