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

40 lines
1.8 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" . }}
labels:
{{ include "stackstate-k8s-agent.global.extraLabels" . | indent 4 }}
annotations:
{{ include "stackstate-k8s-agent.global.extraAnnotations" . | indent 4 }}
data:
.dockerconfigjson: {{ $dockerAuthsDocuments | toJson | b64enc | quote }}
type: kubernetes.io/dockerconfigjson