diff --git a/hack/capi-upgrade-chart_test.bats b/hack/capi-upgrade-chart_test.bats index 964561d7e..043b27027 100644 --- a/hack/capi-upgrade-chart_test.bats +++ b/hack/capi-upgrade-chart_test.bats @@ -47,6 +47,15 @@ setup() { jq --slurp --exit-status 'length == 2 and all(.[]; .metadata.labels == {"provider.cluster.x-k8s.io/version": .metadata.name})' } +@test "the hook image follows the cluster images registry" { + local image mirrored + image="$(yq --no-doc 'select(.kind == "Job") | .spec.template.spec.containers[0].image' "$RENDERED")" + [ "$image" = "$(yq '.upgrade.image' "$CORE/values.yaml")" ] + mirrored="$(helm template capi-providers-core "$CORE" --namespace test-capi --kube-version 1.33.0 --set-string '_cluster.images-registry=registry.example.test' | + yq --no-doc 'select(.kind == "Job") | .spec.template.spec.containers[0].image')" + [ "$mirrored" = "registry.example.test/$image" ] +} + @test "the hook has no cluster-wide or secret permissions" { local roles roles="$(yq --output-format=json --no-doc 'select(.kind == "Role") | .rules' "$RENDERED")" diff --git a/packages/system/capi-providers-core/charts/cozy-lib b/packages/system/capi-providers-core/charts/cozy-lib new file mode 120000 index 000000000..e18135098 --- /dev/null +++ b/packages/system/capi-providers-core/charts/cozy-lib @@ -0,0 +1 @@ +../../../library/cozy-lib \ No newline at end of file diff --git a/packages/system/capi-providers-core/templates/upgrade-hook.yaml b/packages/system/capi-providers-core/templates/upgrade-hook.yaml index cb7e1dea8..d6e86cf77 100644 --- a/packages/system/capi-providers-core/templates/upgrade-hook.yaml +++ b/packages/system/capi-providers-core/templates/upgrade-hook.yaml @@ -106,7 +106,7 @@ spec: type: RuntimeDefault containers: - name: upgrade - image: {{ .Values.upgrade.image | quote }} + image: {{ include "cozy-lib.image" (list .Values.upgrade.image $) | quote }} command: [bash, /scripts/upgrade-providers.sh] env: - name: HOME