charts/common/templates/_images.tpl (50 lines of code) (raw):

{{/* vim: set filetype=mustache: */}} {{/* Return the proper image name {{ include "hf.common.images.image" ( dict "imageRoot" .Values.path.to.the.image "global" .Values.global "tag" .Chart.AppVersion ) }} */}} {{- define "hf.common.images.image" -}} {{- $useGlobalRegistry := or (not (hasKey .imageRoot "useGlobalRegistry")) .imageRoot.useGlobalRegistry -}} {{- $registryName := .imageRoot.registry -}} {{- $repositoryName := .imageRoot.repository -}} {{- $separator := ":" -}} {{- $termination := .imageRoot.tag | default .tag | toString -}} {{- if .global }} {{- if and .global.imageRegistry $useGlobalRegistry }} {{- $registryName = .global.imageRegistry -}} {{- end -}} {{- end -}} {{- if .imageRoot.digest }} {{- $separator = "@" -}} {{- $termination = .imageRoot.digest | toString -}} {{- end -}} {{- if $registryName -}} {{- printf "%s/%s%s%s" $registryName $repositoryName $separator $termination -}} {{- else -}} {{- printf "%s%s%s" $repositoryName $separator $termination -}} {{- end -}} {{- end -}} {{/* Return the proper Docker Image Registry Secret Names evaluating values as templates {{ include "hf.common.images.renderPullSecrets" ( dict "images" (list .Values.path.to.the.image1, .Values.path.to.the.image2) "context" $) }} */}} {{- define "hf.common.images.renderPullSecrets" -}} {{- $pullSecrets := list }} {{- $context := .context }} {{- if and $context $context.Values $context.Values.global $context.Values.global.huggingface $context.Values.global.huggingface.imagePullSecrets }} {{- range $context.Values.global.huggingface.imagePullSecrets -}} {{- $pullSecrets = append $pullSecrets (include "hf.common.tplvalues.render" (dict "value" . "context" $context)) -}} {{- end -}} {{- end -}} {{- range .images -}} {{- range .pullSecrets -}} {{- $pullSecrets = append $pullSecrets (include "hf.common.tplvalues.render" (dict "value" . "context" $context)) -}} {{- end -}} {{- end -}} {{- if (not (empty $pullSecrets)) }} imagePullSecrets: {{- range $pullSecrets }} - name: {{ . }} {{- end }} {{- end }} {{- end -}}