Skip to content

Commit

Permalink
fix(chart-testing): Fix helm-chart testing workflow
Browse files Browse the repository at this point in the history
- Add hidden variable `ci`  which removes annotations and creates docker config
- Add hidden variables to pass docker user, password and server
  • Loading branch information
mjasion committed Jul 6, 2023
1 parent 1ae31dc commit b0471b8
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
12 changes: 2 additions & 10 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,8 @@ jobs:
if: steps.list-changed.outputs.changed == 'true'
uses: helm/kind-action@v1.7.0

- name: Configure docker credentials
if: steps.list-changed.outputs.changed == 'true'
run: |
kubectl create secret docker-registry iterativeai \
--docker-server=docker.iterative.ai \
--docker-username="${{ secrets.ITERATIVE_DOCKER_REGISTRY_USER }}" \
--docker-password="${{ secrets.ITERATIVE_DOCKER_REGISTRY_PASSWORD }}"
- name: Run chart-testing (install)
if: steps.list-changed.outputs.changed == 'true'
run: |
ct install --namespace default --target-branch ${{ github.event.repository.default_branch }} --upgrade --debug \
--helm-extra-set-args '--set imagePullSecrets[0].name=iterativeai'
ct lint-and-install --target-branch ${{ github.event.repository.default_branch }} --upgrade --debug \
--helm-extra-set-args '--set ci=true --set imagePullSecrets[0].name=iterativeai --set dockerUsername="${{ secrets.ITERATIVE_DOCKER_REGISTRY_USER }}" --set dockerPassword="${{ secrets.ITERATIVE_DOCKER_REGISTRY_PASSWORD }}" --set dockerServer=docker.iterative.ai'
2 changes: 1 addition & 1 deletion charts/studio/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.2.3
version: 0.2.4

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
4 changes: 4 additions & 0 deletions charts/studio/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,7 @@ checksum/secret-studio: {{ include (print $.Template.BasePath "/secret-studio.ya
{{- define "studio.basePath" -}}
{{- printf "%s" .Values.global.basePath | trimPrefix "/" | trimSuffix "/" }}
{{- end }}

{{- define "dockerconfig" -}}
{{- printf "{\"auths\": {\"%s\": {\"auth\": \"%s\"}}}" .Values.dockerServer (printf "%s:%s" .Values.dockerUsername .Values.dockerPassword | b64enc) }}
{{- end }}
9 changes: 9 additions & 0 deletions charts/studio/templates/secret-docker-registry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{- if (hasKey .Values "ci") }}
apiVersion: v1
data:
.dockerconfigjson: {{ include "dockerconfig" . | b64enc | quote }}
kind: Secret
metadata:
name: iterativeai
type: kubernetes.io/dockerconfigjson
{{- end }}
2 changes: 2 additions & 0 deletions charts/studio/templates/secret-studio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ apiVersion: v1
kind: Secret
metadata:
name: studio
{{ if (not (hasKey .Values "ci")) }}
annotations:
"helm.sh/resource-policy": "keep"
{{ end }}
labels:
{{- include "studio.labels" . | nindent 4 }}
type: Opaque
Expand Down

0 comments on commit b0471b8

Please sign in to comment.