From 112c8703e5107083ed1bfbb43b208bd5bfa5d4d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Goinvic?= <97093369+gaelgatelement@users.noreply.github.com> Date: Mon, 8 Jan 2024 09:09:45 +0100 Subject: [PATCH] fix(helmv3): add --force-update when adding a repo (#26512) --- .../__snapshots__/artifacts.spec.ts.snap | 30 +++++++++---------- lib/modules/manager/helmv3/artifacts.spec.ts | 10 +++---- lib/modules/manager/helmv3/artifacts.ts | 2 +- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/lib/modules/manager/helmv3/__snapshots__/artifacts.spec.ts.snap b/lib/modules/manager/helmv3/__snapshots__/artifacts.spec.ts.snap index 974ad178fb26482..61454159f84dc4e 100644 --- a/lib/modules/manager/helmv3/__snapshots__/artifacts.spec.ts.snap +++ b/lib/modules/manager/helmv3/__snapshots__/artifacts.spec.ts.snap @@ -3,7 +3,7 @@ exports[`modules/manager/helmv3/artifacts alias name is picked, when repository is as alias and dependency defined 1`] = ` [ { - "cmd": "helm repo add repo1 https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable --username basicUser --password secret", + "cmd": "helm repo add repo1 https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable --force-update --username basicUser --password secret", "options": { "cwd": "/tmp/github/some/repo", "encoding": "utf-8", @@ -52,7 +52,7 @@ exports[`modules/manager/helmv3/artifacts alias name is picked, when repository exports[`modules/manager/helmv3/artifacts do not add registryAliases to repository list 1`] = ` [ { - "cmd": "helm repo add jetstack https://charts.jetstack.io", + "cmd": "helm repo add jetstack https://charts.jetstack.io --force-update", "options": { "cwd": "/tmp/github/some/repo", "encoding": "utf-8", @@ -74,7 +74,7 @@ exports[`modules/manager/helmv3/artifacts do not add registryAliases to reposito }, }, { - "cmd": "helm repo add nginx https://kubernetes.github.io/ingress-nginx", + "cmd": "helm repo add nginx https://kubernetes.github.io/ingress-nginx --force-update", "options": { "cwd": "/tmp/github/some/repo", "encoding": "utf-8", @@ -145,7 +145,7 @@ exports[`modules/manager/helmv3/artifacts log into private registries and reposi }, }, { - "cmd": "helm repo add repo-test https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable --username basicUser --password secret", + "cmd": "helm repo add repo-test https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable --force-update --username basicUser --password secret", "options": { "cwd": "/tmp/github/some/repo", "encoding": "utf-8", @@ -216,7 +216,7 @@ exports[`modules/manager/helmv3/artifacts log into private registries and reposi }, }, { - "cmd": "helm repo add stable the_stable_url", + "cmd": "helm repo add stable the_stable_url --force-update", "options": { "cwd": "/tmp/github/some/repo", "encoding": "utf-8", @@ -238,7 +238,7 @@ exports[`modules/manager/helmv3/artifacts log into private registries and reposi }, }, { - "cmd": "helm repo add repo1 https://the_repo1_url --username basicUser --password secret", + "cmd": "helm repo add repo1 https://the_repo1_url --force-update --username basicUser --password secret", "options": { "cwd": "/tmp/github/some/repo", "encoding": "utf-8", @@ -260,7 +260,7 @@ exports[`modules/manager/helmv3/artifacts log into private registries and reposi }, }, { - "cmd": "helm repo add repo-test https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable", + "cmd": "helm repo add repo-test https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable --force-update", "options": { "cwd": "/tmp/github/some/repo", "encoding": "utf-8", @@ -309,7 +309,7 @@ exports[`modules/manager/helmv3/artifacts log into private registries and reposi exports[`modules/manager/helmv3/artifacts returns null if unchanged 1`] = ` [ { - "cmd": "helm repo add repo-test https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable", + "cmd": "helm repo add repo-test https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable --force-update", "options": { "cwd": "/tmp/github/some/repo", "encoding": "utf-8", @@ -358,7 +358,7 @@ exports[`modules/manager/helmv3/artifacts returns null if unchanged 1`] = ` exports[`modules/manager/helmv3/artifacts returns updated Chart.lock 1`] = ` [ { - "cmd": "helm repo add repo-test https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable", + "cmd": "helm repo add repo-test https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable --force-update", "options": { "cwd": "/tmp/github/some/repo", "encoding": "utf-8", @@ -407,7 +407,7 @@ exports[`modules/manager/helmv3/artifacts returns updated Chart.lock 1`] = ` exports[`modules/manager/helmv3/artifacts returns updated Chart.lock for lockfile maintenance 1`] = ` [ { - "cmd": "helm repo add repo-test https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable", + "cmd": "helm repo add repo-test https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable --force-update", "options": { "cwd": "/tmp/github/some/repo", "encoding": "utf-8", @@ -468,7 +468,7 @@ exports[`modules/manager/helmv3/artifacts returns updated Chart.lock with docker }, }, { - "cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v "/tmp/github/some/repo":"/tmp/github/some/repo" -v "/tmp/renovate/cache":"/tmp/renovate/cache" -e HELM_EXPERIMENTAL_OCI -e HELM_REGISTRY_CONFIG -e HELM_REPOSITORY_CONFIG -e HELM_REPOSITORY_CACHE -e CONTAINERBASE_CACHE_DIR -w "/tmp/github/some/repo" ghcr.io/containerbase/sidecar bash -l -c "install-tool helm v3.7.2 && helm repo add repo-test https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable && helm dependency update ''"", + "cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v "/tmp/github/some/repo":"/tmp/github/some/repo" -v "/tmp/renovate/cache":"/tmp/renovate/cache" -e HELM_EXPERIMENTAL_OCI -e HELM_REGISTRY_CONFIG -e HELM_REPOSITORY_CONFIG -e HELM_REPOSITORY_CACHE -e CONTAINERBASE_CACHE_DIR -w "/tmp/github/some/repo" ghcr.io/containerbase/sidecar bash -l -c "install-tool helm v3.7.2 && helm repo add repo-test https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable --force-update && helm dependency update ''"", "options": { "cwd": "/tmp/github/some/repo", "encoding": "utf-8", @@ -496,7 +496,7 @@ exports[`modules/manager/helmv3/artifacts returns updated Chart.lock with docker exports[`modules/manager/helmv3/artifacts sets repositories from registryAliases 1`] = ` [ { - "cmd": "helm repo add stable the_stable_url", + "cmd": "helm repo add stable the_stable_url --force-update", "options": { "cwd": "/tmp/github/some/repo", "encoding": "utf-8", @@ -518,7 +518,7 @@ exports[`modules/manager/helmv3/artifacts sets repositories from registryAliases }, }, { - "cmd": "helm repo add repo1 the_repo1_url", + "cmd": "helm repo add repo1 the_repo1_url --force-update", "options": { "cwd": "/tmp/github/some/repo", "encoding": "utf-8", @@ -540,7 +540,7 @@ exports[`modules/manager/helmv3/artifacts sets repositories from registryAliases }, }, { - "cmd": "helm repo add repo-test https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable", + "cmd": "helm repo add repo-test https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable --force-update", "options": { "cwd": "/tmp/github/some/repo", "encoding": "utf-8", @@ -601,7 +601,7 @@ exports[`modules/manager/helmv3/artifacts sets repositories from registryAliases }, }, { - "cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v "/tmp/github/some/repo":"/tmp/github/some/repo" -v "/tmp/renovate/cache":"/tmp/renovate/cache" -e HELM_EXPERIMENTAL_OCI -e HELM_REGISTRY_CONFIG -e HELM_REPOSITORY_CONFIG -e HELM_REPOSITORY_CACHE -e CONTAINERBASE_CACHE_DIR -w "/tmp/github/some/repo" ghcr.io/containerbase/sidecar bash -l -c "install-tool helm v3.7.2 && helm repo add stable the_stable_url && helm repo add repo1 the_repo1_url && helm repo add repo-test https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable && helm dependency update ''"", + "cmd": "docker run --rm --name=renovate_sidecar --label=renovate_child -v "/tmp/github/some/repo":"/tmp/github/some/repo" -v "/tmp/renovate/cache":"/tmp/renovate/cache" -e HELM_EXPERIMENTAL_OCI -e HELM_REGISTRY_CONFIG -e HELM_REPOSITORY_CONFIG -e HELM_REPOSITORY_CACHE -e CONTAINERBASE_CACHE_DIR -w "/tmp/github/some/repo" ghcr.io/containerbase/sidecar bash -l -c "install-tool helm v3.7.2 && helm repo add stable the_stable_url --force-update && helm repo add repo1 the_repo1_url --force-update && helm repo add repo-test https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable --force-update && helm dependency update ''"", "options": { "cwd": "/tmp/github/some/repo", "encoding": "utf-8", diff --git a/lib/modules/manager/helmv3/artifacts.spec.ts b/lib/modules/manager/helmv3/artifacts.spec.ts index dcc9351d49a27fe..2a551f1c4b6898b 100644 --- a/lib/modules/manager/helmv3/artifacts.spec.ts +++ b/lib/modules/manager/helmv3/artifacts.spec.ts @@ -290,7 +290,7 @@ describe('modules/manager/helmv3/artifacts', () => { ]); expect(execSnapshots).toMatchObject([ { - cmd: 'helm repo add repo-test https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable', + cmd: 'helm repo add repo-test https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable --force-update', }, { cmd: "helm dependency update ''", @@ -343,7 +343,7 @@ describe('modules/manager/helmv3/artifacts', () => { ]); expect(execSnapshots).toMatchObject([ { - cmd: 'helm repo add repo-test https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable', + cmd: 'helm repo add repo-test https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable --force-update', options: { env: { HELM_EXPERIMENTAL_OCI: '1', @@ -411,7 +411,7 @@ describe('modules/manager/helmv3/artifacts', () => { ]); expect(execSnapshots).toMatchObject([ { - cmd: 'helm repo add repo-test https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable', + cmd: 'helm repo add repo-test https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable --force-update', options: { env: { HELM_EXPERIMENTAL_OCI: '1', @@ -486,7 +486,7 @@ describe('modules/manager/helmv3/artifacts', () => { ]); expect(execSnapshots).toMatchObject([ { - cmd: 'helm repo add repo-test https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable', + cmd: 'helm repo add repo-test https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable --force-update', options: { env: { HELM_EXPERIMENTAL_OCI: '1', @@ -546,7 +546,7 @@ describe('modules/manager/helmv3/artifacts', () => { ).toBeNull(); expect(execSnapshots).toMatchObject([ { - cmd: 'helm repo add repo-test https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable', + cmd: 'helm repo add repo-test https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable --force-update', options: { env: { HELM_EXPERIMENTAL_OCI: '1', diff --git a/lib/modules/manager/helmv3/artifacts.ts b/lib/modules/manager/helmv3/artifacts.ts index 0228d5f9d82da3b..f7d18c092efe0b4 100644 --- a/lib/modules/manager/helmv3/artifacts.ts +++ b/lib/modules/manager/helmv3/artifacts.ts @@ -70,7 +70,7 @@ async function helmCommands( // add helm repos if an alias or credentials for the url are defined classicRepositories.forEach((value) => { const { username, password } = value.hostRule; - const parameters = [`${value.repository}`]; + const parameters = [`${value.repository}`, `--force-update`]; const isPrivateRepo = username && password; if (isPrivateRepo) { parameters.push(`--username ${quote(username)}`);