diff --git a/charts/common/templates/_images.tpl b/charts/common/templates/_images.tpl index 4dafe46..e1cc411 100644 --- a/charts/common/templates/_images.tpl +++ b/charts/common/templates/_images.tpl @@ -33,8 +33,8 @@ Return the proper Docker Image Registry Secret Names evaluating values as templa {{- $pullSecrets := list }} {{- $context := .context }} - {{- if $context.Values.global }} - {{- range $context.Values.global.imagePullSecrets -}} + {{- if $context.Values.global.huggingface }} + {{- range $context.Values.global.huggingface.imagePullSecrets -}} {{- $pullSecrets = append $pullSecrets (include "common.tplvalues.render" (dict "value" . "context" $context)) -}} {{- end -}} {{- end -}} diff --git a/charts/unit-tests/templates/_helpers.yaml b/charts/unit-tests/templates/_helpers.yaml index 0396fc4..470d143 100644 --- a/charts/unit-tests/templates/_helpers.yaml +++ b/charts/unit-tests/templates/_helpers.yaml @@ -2,10 +2,14 @@ {{ include "hf.common.images.image" (dict "imageRoot" .Values.images.nginx "global" .Values.global.huggingface) | quote }} {{- end -}} +{{- define "admin.image" -}} +{{ include "hf.common.images.image" (dict "imageRoot" .Values.images.admin "global" .Values.global.huggingface) | quote }} +{{- end -}} + {{- define "appManager.image" -}} {{ include "hf.common.images.image" (dict "imageRoot" .Values.images.appManager "global" .Values.global.huggingface) | quote }} {{- end -}} {{- define "test.imagePullSecrets" -}} -{{ include "hf.common.images.renderPullSecrets" (dict "images" (list .Values.images) "global" .Values.global.huggingface) }} +{{ include "hf.common.images.renderPullSecrets" (dict "images" (list .Values.images) "context" $) }} {{- end -}} \ No newline at end of file diff --git a/charts/unit-tests/templates/deployment.yaml b/charts/unit-tests/templates/deployment.yaml index 0745773..8e313c8 100644 --- a/charts/unit-tests/templates/deployment.yaml +++ b/charts/unit-tests/templates/deployment.yaml @@ -16,6 +16,9 @@ spec: - name: test-public-image image: {{ include "nginx.image" . }} imagePullPolicy: {{ .Values.images.pullPolicy }} + - name: test-huggingface-public-image + image: {{ include "admin.image" . }} + imagePullPolicy: {{ .Values.images.pullPolicy }} - name: test-global-registry image: {{ include "appManager.image" . }} imagePullPolicy: {{ .Values.images.pullPolicy }} \ No newline at end of file diff --git a/charts/unit-tests/tests/deployment_test.yaml b/charts/unit-tests/tests/deployment_test.yaml index f1996d0..8a1de19 100644 --- a/charts/unit-tests/tests/deployment_test.yaml +++ b/charts/unit-tests/tests/deployment_test.yaml @@ -16,6 +16,19 @@ tests: path: metadata.name value: test-release-unit-tests + - it: deployment should have the correct metadata labels + values: + - test-values.yaml + template: deployment.yaml + asserts: + - equal: + path: metadata.labels + value: + app.kubernetes.io/name: test-release-unit-tests + helm.sh/chart: unit-tests + app.kubernetes.io/instance: test-release + app.kubernetes.io/managed-by: Helm + - it: deployment should have the correct public image name values: - test-values.yaml @@ -28,14 +41,46 @@ tests: path: spec.template.spec.containers[0].image value: nginx:1.22 - - it: deployment should have the correct global image name + - it: deployment should have the correct huggingface public image name values: - test-values.yaml template: deployment.yaml asserts: - equal: path: spec.template.spec.containers[1].name - value: test-global-registry + value: test-huggingface-public-image - equal: path: spec.template.spec.containers[1].image + value: huggingface/datasets-server-services-admin:sha-27ad2f7 + + - it: deployment should have the correct global image name + values: + - test-values.yaml + template: deployment.yaml + asserts: + - equal: + path: spec.template.spec.containers[2].name + value: test-global-registry + - equal: + path: spec.template.spec.containers[2].image value: spaces/app-manager:latest + + - it: deployment shouldn't have imagePullSecret + values: + - test-values.yaml + template: deployment.yaml + asserts: + - isNull: + path: spec.template.spec.imagePullSecrets + + - it: deployment should have a correct imagePullSecret + values: + - test-values.yaml + set: + images.pullSecrets: [regcred] + template: deployment.yaml + asserts: + - contains: + path: spec.template.spec.imagePullSecrets + content: + name: regcred diff --git a/charts/unit-tests/tests/test-values.yaml b/charts/unit-tests/tests/test-values.yaml index bf5d407..06d0af0 100644 --- a/charts/unit-tests/tests/test-values.yaml +++ b/charts/unit-tests/tests/test-values.yaml @@ -13,6 +13,11 @@ images: useGlobalRegistry: false repository: nginx tag: "1.22" + admin: + registry: huggingface + useGlobalRegistry: false + repository: datasets-server-services-admin + tag: sha-27ad2f7 appManager: repository: spaces/app-manager - tag: latest \ No newline at end of file + tag: latest