Skip to content

Commit

Permalink
fix: pull secret render
Browse files Browse the repository at this point in the history
  • Loading branch information
rtrompier committed Feb 22, 2023
1 parent 000d0c2 commit f4d5534
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 6 deletions.
4 changes: 2 additions & 2 deletions charts/common/templates/_images.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
Expand Down
6 changes: 5 additions & 1 deletion charts/unit-tests/templates/_helpers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
3 changes: 3 additions & 0 deletions charts/unit-tests/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
49 changes: 47 additions & 2 deletions charts/unit-tests/tests/deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
7 changes: 6 additions & 1 deletion charts/unit-tests/tests/test-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
tag: latest

0 comments on commit f4d5534

Please sign in to comment.