diff --git a/charts/common/templates/_images.tpl b/charts/common/templates/_images.tpl index d3cd372..1de0885 100644 --- a/charts/common/templates/_images.tpl +++ b/charts/common/templates/_images.tpl @@ -1,14 +1,14 @@ {{/* vim: set filetype=mustache: */}} {{/* Return the proper image name -{{ include "hf.common.images.image" ( dict "imageRoot" .Values.path.to.the.image "global" .Values.global ) }} +{{ 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 | toString -}} +{{- $termination := .imageRoot.tag | default .tag | toString -}} {{- if .global }} {{- if and .global.imageRegistry $useGlobalRegistry }} {{- $registryName = .global.imageRegistry -}} @@ -33,7 +33,7 @@ Return the proper Docker Image Registry Secret Names evaluating values as templa {{- $pullSecrets := list }} {{- $context := .context }} - {{- if $context.Values.global.huggingface }} + {{- 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 -}} @@ -51,4 +51,4 @@ imagePullSecrets: - name: {{ . }} {{- end }} {{- end }} -{{- end -}} \ No newline at end of file +{{- end -}} diff --git a/charts/unit-tests/templates/_helpers.yaml b/charts/unit-tests/templates/_helpers.yaml index 470d143..aeae612 100644 --- a/charts/unit-tests/templates/_helpers.yaml +++ b/charts/unit-tests/templates/_helpers.yaml @@ -7,9 +7,13 @@ {{- end -}} {{- define "appManager.image" -}} -{{ include "hf.common.images.image" (dict "imageRoot" .Values.images.appManager "global" .Values.global.huggingface) | quote }} +{{ include "hf.common.images.image" (dict "imageRoot" .Values.images.appManager "global" .Values.global.huggingface "tag" .Chart.AppVersion) | quote }} +{{- end -}} + +{{- define "someApp.image" -}} +{{ include "hf.common.images.image" (dict "imageRoot" .Values.images.someApp "global" .Values.global.huggingface "tag" .Chart.AppVersion) | quote }} {{- end -}} {{- define "test.imagePullSecrets" -}} {{ include "hf.common.images.renderPullSecrets" (dict "images" (list .Values.images) "context" $) }} -{{- end -}} \ No newline at end of file +{{- end -}} diff --git a/charts/unit-tests/templates/deployment.yaml b/charts/unit-tests/templates/deployment.yaml index 8e313c8..3ccdfff 100644 --- a/charts/unit-tests/templates/deployment.yaml +++ b/charts/unit-tests/templates/deployment.yaml @@ -21,4 +21,7 @@ spec: imagePullPolicy: {{ .Values.images.pullPolicy }} - name: test-global-registry image: {{ include "appManager.image" . }} - imagePullPolicy: {{ .Values.images.pullPolicy }} \ No newline at end of file + imagePullPolicy: {{ .Values.images.pullPolicy }} + - name: hello-world + image: {{ include "someApp.image" . }} + imagePullPolicy: {{ .Values.images.pullPolicy }} diff --git a/charts/unit-tests/tests/deployment_test.yaml b/charts/unit-tests/tests/deployment_test.yaml index 8a1de19..039733a 100644 --- a/charts/unit-tests/tests/deployment_test.yaml +++ b/charts/unit-tests/tests/deployment_test.yaml @@ -65,6 +65,18 @@ tests: path: spec.template.spec.containers[2].image value: spaces/app-manager:latest + - it: deployment should have the correct image tag reflecting chart appVersion + values: + - test-values.yaml + template: deployment.yaml + asserts: + - equal: + path: spec.template.spec.containers[3].name + value: hello-world + - equal: + path: spec.template.spec.containers[3].image + value: hello/world:1.0.0 + - it: deployment shouldn't have imagePullSecret values: - test-values.yaml diff --git a/charts/unit-tests/tests/test-values.yaml b/charts/unit-tests/tests/test-values.yaml index 06d0af0..4f13c3a 100644 --- a/charts/unit-tests/tests/test-values.yaml +++ b/charts/unit-tests/tests/test-values.yaml @@ -21,3 +21,5 @@ images: appManager: repository: spaces/app-manager tag: latest + someApp: + repository: hello/world