refactor(manager/helmv3): use env variables for directory control and extract functions for reusability (#22510)

Co-authored-by: Sebastian Poxhofer <secustor@users.noreply.github.com>
This commit is contained in:
mugi 2023-06-01 20:17:02 +09:00 committed by GitHub
parent 25999bf5a4
commit 2e8d2816f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 238 additions and 65 deletions

View file

@ -3,12 +3,15 @@
exports[`modules/manager/helmv3/artifacts alias name is picked, when repository is as alias and dependency defined 1`] = `
[
{
"cmd": "helm repo add repo1 --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories --username basicUser --password secret https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable",
"cmd": "helm repo add repo1 https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable --username basicUser --password secret",
"options": {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
"env": {
"HELM_EXPERIMENTAL_OCI": "1",
"HELM_REGISTRY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/registry.json",
"HELM_REPOSITORY_CACHE": "/tmp/renovate/cache/__renovate-private-cache/repositories",
"HELM_REPOSITORY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/repositories.yaml",
"HOME": "/home/user",
"HTTPS_PROXY": "https://example.com",
"HTTP_PROXY": "http://example.com",
@ -22,12 +25,15 @@ exports[`modules/manager/helmv3/artifacts alias name is picked, when repository
},
},
{
"cmd": "helm dependency update --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories ''",
"cmd": "helm dependency update ''",
"options": {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
"env": {
"HELM_EXPERIMENTAL_OCI": "1",
"HELM_REGISTRY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/registry.json",
"HELM_REPOSITORY_CACHE": "/tmp/renovate/cache/__renovate-private-cache/repositories",
"HELM_REPOSITORY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/repositories.yaml",
"HOME": "/home/user",
"HTTPS_PROXY": "https://example.com",
"HTTP_PROXY": "http://example.com",
@ -46,12 +52,15 @@ 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 --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories https://charts.jetstack.io",
"cmd": "helm repo add jetstack https://charts.jetstack.io",
"options": {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
"env": {
"HELM_EXPERIMENTAL_OCI": "1",
"HELM_REGISTRY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/registry.json",
"HELM_REPOSITORY_CACHE": "/tmp/renovate/cache/__renovate-private-cache/repositories",
"HELM_REPOSITORY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/repositories.yaml",
"HOME": "/home/user",
"HTTPS_PROXY": "https://example.com",
"HTTP_PROXY": "http://example.com",
@ -65,12 +74,15 @@ exports[`modules/manager/helmv3/artifacts do not add registryAliases to reposito
},
},
{
"cmd": "helm repo add nginx --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories https://kubernetes.github.io/ingress-nginx",
"cmd": "helm repo add nginx https://kubernetes.github.io/ingress-nginx",
"options": {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
"env": {
"HELM_EXPERIMENTAL_OCI": "1",
"HELM_REGISTRY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/registry.json",
"HELM_REPOSITORY_CACHE": "/tmp/renovate/cache/__renovate-private-cache/repositories",
"HELM_REPOSITORY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/repositories.yaml",
"HOME": "/home/user",
"HTTPS_PROXY": "https://example.com",
"HTTP_PROXY": "http://example.com",
@ -84,12 +96,15 @@ exports[`modules/manager/helmv3/artifacts do not add registryAliases to reposito
},
},
{
"cmd": "helm dependency update --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories ''",
"cmd": "helm dependency update ''",
"options": {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
"env": {
"HELM_EXPERIMENTAL_OCI": "1",
"HELM_REGISTRY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/registry.json",
"HELM_REPOSITORY_CACHE": "/tmp/renovate/cache/__renovate-private-cache/repositories",
"HELM_REPOSITORY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/repositories.yaml",
"HOME": "/home/user",
"HTTPS_PROXY": "https://example.com",
"HTTP_PROXY": "http://example.com",
@ -108,12 +123,15 @@ exports[`modules/manager/helmv3/artifacts do not add registryAliases to reposito
exports[`modules/manager/helmv3/artifacts log into private registries and repositories NOT defined in registryAliases 1`] = `
[
{
"cmd": "helm registry login --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories --username registryUser --password password registry.gitlab.com/user/oci-helm-test",
"cmd": "helm registry login --username registryUser --password password registry.gitlab.com/user/oci-helm-test",
"options": {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
"env": {
"HELM_EXPERIMENTAL_OCI": "1",
"HELM_REGISTRY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/registry.json",
"HELM_REPOSITORY_CACHE": "/tmp/renovate/cache/__renovate-private-cache/repositories",
"HELM_REPOSITORY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/repositories.yaml",
"HOME": "/home/user",
"HTTPS_PROXY": "https://example.com",
"HTTP_PROXY": "http://example.com",
@ -127,12 +145,15 @@ exports[`modules/manager/helmv3/artifacts log into private registries and reposi
},
},
{
"cmd": "helm repo add repo-test --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories --username basicUser --password secret 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 --username basicUser --password secret",
"options": {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
"env": {
"HELM_EXPERIMENTAL_OCI": "1",
"HELM_REGISTRY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/registry.json",
"HELM_REPOSITORY_CACHE": "/tmp/renovate/cache/__renovate-private-cache/repositories",
"HELM_REPOSITORY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/repositories.yaml",
"HOME": "/home/user",
"HTTPS_PROXY": "https://example.com",
"HTTP_PROXY": "http://example.com",
@ -146,12 +167,15 @@ exports[`modules/manager/helmv3/artifacts log into private registries and reposi
},
},
{
"cmd": "helm dependency update --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories ''",
"cmd": "helm dependency update ''",
"options": {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
"env": {
"HELM_EXPERIMENTAL_OCI": "1",
"HELM_REGISTRY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/registry.json",
"HELM_REPOSITORY_CACHE": "/tmp/renovate/cache/__renovate-private-cache/repositories",
"HELM_REPOSITORY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/repositories.yaml",
"HOME": "/home/user",
"HTTPS_PROXY": "https://example.com",
"HTTP_PROXY": "http://example.com",
@ -170,12 +194,15 @@ exports[`modules/manager/helmv3/artifacts log into private registries and reposi
exports[`modules/manager/helmv3/artifacts log into private registries and repositories already defined in registryAliases 1`] = `
[
{
"cmd": "helm registry login --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories --username test --password aPassword registry.example.com/organization",
"cmd": "helm registry login --username test --password aPassword registry.example.com/organization",
"options": {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
"env": {
"HELM_EXPERIMENTAL_OCI": "1",
"HELM_REGISTRY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/registry.json",
"HELM_REPOSITORY_CACHE": "/tmp/renovate/cache/__renovate-private-cache/repositories",
"HELM_REPOSITORY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/repositories.yaml",
"HOME": "/home/user",
"HTTPS_PROXY": "https://example.com",
"HTTP_PROXY": "http://example.com",
@ -189,12 +216,15 @@ exports[`modules/manager/helmv3/artifacts log into private registries and reposi
},
},
{
"cmd": "helm repo add stable --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories the_stable_url",
"cmd": "helm repo add stable the_stable_url",
"options": {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
"env": {
"HELM_EXPERIMENTAL_OCI": "1",
"HELM_REGISTRY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/registry.json",
"HELM_REPOSITORY_CACHE": "/tmp/renovate/cache/__renovate-private-cache/repositories",
"HELM_REPOSITORY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/repositories.yaml",
"HOME": "/home/user",
"HTTPS_PROXY": "https://example.com",
"HTTP_PROXY": "http://example.com",
@ -208,12 +238,15 @@ exports[`modules/manager/helmv3/artifacts log into private registries and reposi
},
},
{
"cmd": "helm repo add repo1 --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories --username basicUser --password secret https://the_repo1_url",
"cmd": "helm repo add repo1 https://the_repo1_url --username basicUser --password secret",
"options": {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
"env": {
"HELM_EXPERIMENTAL_OCI": "1",
"HELM_REGISTRY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/registry.json",
"HELM_REPOSITORY_CACHE": "/tmp/renovate/cache/__renovate-private-cache/repositories",
"HELM_REPOSITORY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/repositories.yaml",
"HOME": "/home/user",
"HTTPS_PROXY": "https://example.com",
"HTTP_PROXY": "http://example.com",
@ -227,12 +260,15 @@ exports[`modules/manager/helmv3/artifacts log into private registries and reposi
},
},
{
"cmd": "helm repo add repo-test --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories 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",
"options": {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
"env": {
"HELM_EXPERIMENTAL_OCI": "1",
"HELM_REGISTRY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/registry.json",
"HELM_REPOSITORY_CACHE": "/tmp/renovate/cache/__renovate-private-cache/repositories",
"HELM_REPOSITORY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/repositories.yaml",
"HOME": "/home/user",
"HTTPS_PROXY": "https://example.com",
"HTTP_PROXY": "http://example.com",
@ -246,12 +282,15 @@ exports[`modules/manager/helmv3/artifacts log into private registries and reposi
},
},
{
"cmd": "helm dependency update --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories ''",
"cmd": "helm dependency update ''",
"options": {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
"env": {
"HELM_EXPERIMENTAL_OCI": "1",
"HELM_REGISTRY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/registry.json",
"HELM_REPOSITORY_CACHE": "/tmp/renovate/cache/__renovate-private-cache/repositories",
"HELM_REPOSITORY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/repositories.yaml",
"HOME": "/home/user",
"HTTPS_PROXY": "https://example.com",
"HTTP_PROXY": "http://example.com",
@ -270,12 +309,15 @@ 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 --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories 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",
"options": {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
"env": {
"HELM_EXPERIMENTAL_OCI": "1",
"HELM_REGISTRY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/registry.json",
"HELM_REPOSITORY_CACHE": "/tmp/renovate/cache/__renovate-private-cache/repositories",
"HELM_REPOSITORY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/repositories.yaml",
"HOME": "/home/user",
"HTTPS_PROXY": "https://example.com",
"HTTP_PROXY": "http://example.com",
@ -289,12 +331,15 @@ exports[`modules/manager/helmv3/artifacts returns null if unchanged 1`] = `
},
},
{
"cmd": "helm dependency update --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories ''",
"cmd": "helm dependency update ''",
"options": {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
"env": {
"HELM_EXPERIMENTAL_OCI": "1",
"HELM_REGISTRY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/registry.json",
"HELM_REPOSITORY_CACHE": "/tmp/renovate/cache/__renovate-private-cache/repositories",
"HELM_REPOSITORY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/repositories.yaml",
"HOME": "/home/user",
"HTTPS_PROXY": "https://example.com",
"HTTP_PROXY": "http://example.com",
@ -313,12 +358,15 @@ 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 --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories 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",
"options": {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
"env": {
"HELM_EXPERIMENTAL_OCI": "1",
"HELM_REGISTRY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/registry.json",
"HELM_REPOSITORY_CACHE": "/tmp/renovate/cache/__renovate-private-cache/repositories",
"HELM_REPOSITORY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/repositories.yaml",
"HOME": "/home/user",
"HTTPS_PROXY": "https://example.com",
"HTTP_PROXY": "http://example.com",
@ -332,12 +380,15 @@ exports[`modules/manager/helmv3/artifacts returns updated Chart.lock 1`] = `
},
},
{
"cmd": "helm dependency update --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories ''",
"cmd": "helm dependency update ''",
"options": {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
"env": {
"HELM_EXPERIMENTAL_OCI": "1",
"HELM_REGISTRY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/registry.json",
"HELM_REPOSITORY_CACHE": "/tmp/renovate/cache/__renovate-private-cache/repositories",
"HELM_REPOSITORY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/repositories.yaml",
"HOME": "/home/user",
"HTTPS_PROXY": "https://example.com",
"HTTP_PROXY": "http://example.com",
@ -356,12 +407,15 @@ 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 --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories 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",
"options": {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
"env": {
"HELM_EXPERIMENTAL_OCI": "1",
"HELM_REGISTRY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/registry.json",
"HELM_REPOSITORY_CACHE": "/tmp/renovate/cache/__renovate-private-cache/repositories",
"HELM_REPOSITORY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/repositories.yaml",
"HOME": "/home/user",
"HTTPS_PROXY": "https://example.com",
"HTTP_PROXY": "http://example.com",
@ -375,12 +429,15 @@ exports[`modules/manager/helmv3/artifacts returns updated Chart.lock for lockfil
},
},
{
"cmd": "helm dependency update --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories ''",
"cmd": "helm dependency update ''",
"options": {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
"env": {
"HELM_EXPERIMENTAL_OCI": "1",
"HELM_REGISTRY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/registry.json",
"HELM_REPOSITORY_CACHE": "/tmp/renovate/cache/__renovate-private-cache/repositories",
"HELM_REPOSITORY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/repositories.yaml",
"HOME": "/home/user",
"HTTPS_PROXY": "https://example.com",
"HTTP_PROXY": "http://example.com",
@ -411,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 BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w "/tmp/github/some/repo" containerbase/sidecar bash -l -c "install-tool helm v3.7.2 && helm repo add repo-test --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable && helm dependency update --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories ''"",
"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 BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w "/tmp/github/some/repo" 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 ''"",
"options": {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
@ -419,6 +476,9 @@ exports[`modules/manager/helmv3/artifacts returns updated Chart.lock with docker
"BUILDPACK_CACHE_DIR": "/tmp/renovate/cache/containerbase",
"CONTAINERBASE_CACHE_DIR": "/tmp/renovate/cache/containerbase",
"HELM_EXPERIMENTAL_OCI": "1",
"HELM_REGISTRY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/registry.json",
"HELM_REPOSITORY_CACHE": "/tmp/renovate/cache/__renovate-private-cache/repositories",
"HELM_REPOSITORY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/repositories.yaml",
"HOME": "/home/user",
"HTTPS_PROXY": "https://example.com",
"HTTP_PROXY": "http://example.com",
@ -437,12 +497,15 @@ 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 --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories the_stable_url",
"cmd": "helm repo add stable the_stable_url",
"options": {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
"env": {
"HELM_EXPERIMENTAL_OCI": "1",
"HELM_REGISTRY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/registry.json",
"HELM_REPOSITORY_CACHE": "/tmp/renovate/cache/__renovate-private-cache/repositories",
"HELM_REPOSITORY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/repositories.yaml",
"HOME": "/home/user",
"HTTPS_PROXY": "https://example.com",
"HTTP_PROXY": "http://example.com",
@ -456,12 +519,15 @@ exports[`modules/manager/helmv3/artifacts sets repositories from registryAliases
},
},
{
"cmd": "helm repo add repo1 --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories the_repo1_url",
"cmd": "helm repo add repo1 the_repo1_url",
"options": {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
"env": {
"HELM_EXPERIMENTAL_OCI": "1",
"HELM_REGISTRY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/registry.json",
"HELM_REPOSITORY_CACHE": "/tmp/renovate/cache/__renovate-private-cache/repositories",
"HELM_REPOSITORY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/repositories.yaml",
"HOME": "/home/user",
"HTTPS_PROXY": "https://example.com",
"HTTP_PROXY": "http://example.com",
@ -475,12 +541,15 @@ exports[`modules/manager/helmv3/artifacts sets repositories from registryAliases
},
},
{
"cmd": "helm repo add repo-test --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories 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",
"options": {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
"env": {
"HELM_EXPERIMENTAL_OCI": "1",
"HELM_REGISTRY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/registry.json",
"HELM_REPOSITORY_CACHE": "/tmp/renovate/cache/__renovate-private-cache/repositories",
"HELM_REPOSITORY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/repositories.yaml",
"HOME": "/home/user",
"HTTPS_PROXY": "https://example.com",
"HTTP_PROXY": "http://example.com",
@ -494,12 +563,15 @@ exports[`modules/manager/helmv3/artifacts sets repositories from registryAliases
},
},
{
"cmd": "helm dependency update --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories ''",
"cmd": "helm dependency update ''",
"options": {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
"env": {
"HELM_EXPERIMENTAL_OCI": "1",
"HELM_REGISTRY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/registry.json",
"HELM_REPOSITORY_CACHE": "/tmp/renovate/cache/__renovate-private-cache/repositories",
"HELM_REPOSITORY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/repositories.yaml",
"HOME": "/home/user",
"HTTPS_PROXY": "https://example.com",
"HTTP_PROXY": "http://example.com",
@ -530,7 +602,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 BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w "/tmp/github/some/repo" containerbase/sidecar bash -l -c "install-tool helm v3.7.2 && helm repo add stable --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories the_stable_url && helm repo add repo1 --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories the_repo1_url && helm repo add repo-test --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable && helm dependency update --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories ''"",
"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 BUILDPACK_CACHE_DIR -e CONTAINERBASE_CACHE_DIR -w "/tmp/github/some/repo" 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 ''"",
"options": {
"cwd": "/tmp/github/some/repo",
"encoding": "utf-8",
@ -538,6 +610,9 @@ exports[`modules/manager/helmv3/artifacts sets repositories from registryAliases
"BUILDPACK_CACHE_DIR": "/tmp/renovate/cache/containerbase",
"CONTAINERBASE_CACHE_DIR": "/tmp/renovate/cache/containerbase",
"HELM_EXPERIMENTAL_OCI": "1",
"HELM_REGISTRY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/registry.json",
"HELM_REPOSITORY_CACHE": "/tmp/renovate/cache/__renovate-private-cache/repositories",
"HELM_REPOSITORY_CONFIG": "/tmp/renovate/cache/__renovate-private-cache/repositories.yaml",
"HOME": "/home/user",
"HTTPS_PROXY": "https://example.com",
"HTTP_PROXY": "http://example.com",

View file

@ -265,10 +265,10 @@ describe('modules/manager/helmv3/artifacts', () => {
]);
expect(execSnapshots).toMatchObject([
{
cmd: 'helm repo add repo-test --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories 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',
},
{
cmd: "helm dependency update --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories ''",
cmd: "helm dependency update ''",
},
]);
});
@ -318,10 +318,32 @@ describe('modules/manager/helmv3/artifacts', () => {
]);
expect(execSnapshots).toMatchObject([
{
cmd: 'helm repo add repo-test --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories 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',
options: {
env: {
HELM_EXPERIMENTAL_OCI: '1',
HELM_REGISTRY_CONFIG:
'/tmp/renovate/cache/__renovate-private-cache/registry.json',
HELM_REPOSITORY_CONFIG:
'/tmp/renovate/cache/__renovate-private-cache/repositories.yaml',
HELM_REPOSITORY_CACHE:
'/tmp/renovate/cache/__renovate-private-cache/repositories',
},
},
},
{
cmd: "helm dependency update --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories ''",
cmd: "helm dependency update ''",
options: {
env: {
HELM_EXPERIMENTAL_OCI: '1',
HELM_REGISTRY_CONFIG:
'/tmp/renovate/cache/__renovate-private-cache/registry.json',
HELM_REPOSITORY_CONFIG:
'/tmp/renovate/cache/__renovate-private-cache/repositories.yaml',
HELM_REPOSITORY_CACHE:
'/tmp/renovate/cache/__renovate-private-cache/repositories',
},
},
},
]);
});
@ -364,10 +386,32 @@ describe('modules/manager/helmv3/artifacts', () => {
]);
expect(execSnapshots).toMatchObject([
{
cmd: 'helm repo add repo-test --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories 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',
options: {
env: {
HELM_EXPERIMENTAL_OCI: '1',
HELM_REGISTRY_CONFIG:
'/tmp/renovate/cache/__renovate-private-cache/registry.json',
HELM_REPOSITORY_CONFIG:
'/tmp/renovate/cache/__renovate-private-cache/repositories.yaml',
HELM_REPOSITORY_CACHE:
'/tmp/renovate/cache/__renovate-private-cache/repositories',
},
},
},
{
cmd: "helm dependency update --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories ''",
cmd: "helm dependency update ''",
options: {
env: {
HELM_EXPERIMENTAL_OCI: '1',
HELM_REGISTRY_CONFIG:
'/tmp/renovate/cache/__renovate-private-cache/registry.json',
HELM_REPOSITORY_CONFIG:
'/tmp/renovate/cache/__renovate-private-cache/repositories.yaml',
HELM_REPOSITORY_CACHE:
'/tmp/renovate/cache/__renovate-private-cache/repositories',
},
},
},
]);
});
@ -417,10 +461,32 @@ describe('modules/manager/helmv3/artifacts', () => {
]);
expect(execSnapshots).toMatchObject([
{
cmd: 'helm repo add repo-test --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories 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',
options: {
env: {
HELM_EXPERIMENTAL_OCI: '1',
HELM_REGISTRY_CONFIG:
'/tmp/renovate/cache/__renovate-private-cache/registry.json',
HELM_REPOSITORY_CONFIG:
'/tmp/renovate/cache/__renovate-private-cache/repositories.yaml',
HELM_REPOSITORY_CACHE:
'/tmp/renovate/cache/__renovate-private-cache/repositories',
},
},
},
{
cmd: "helm dependency update --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories ''",
cmd: "helm dependency update ''",
options: {
env: {
HELM_EXPERIMENTAL_OCI: '1',
HELM_REGISTRY_CONFIG:
'/tmp/renovate/cache/__renovate-private-cache/registry.json',
HELM_REPOSITORY_CONFIG:
'/tmp/renovate/cache/__renovate-private-cache/repositories.yaml',
HELM_REPOSITORY_CACHE:
'/tmp/renovate/cache/__renovate-private-cache/repositories',
},
},
},
]);
});
@ -455,10 +521,32 @@ describe('modules/manager/helmv3/artifacts', () => {
).toBeNull();
expect(execSnapshots).toMatchObject([
{
cmd: 'helm repo add repo-test --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories 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',
options: {
env: {
HELM_EXPERIMENTAL_OCI: '1',
HELM_REGISTRY_CONFIG:
'/tmp/renovate/cache/__renovate-private-cache/registry.json',
HELM_REPOSITORY_CONFIG:
'/tmp/renovate/cache/__renovate-private-cache/repositories.yaml',
HELM_REPOSITORY_CACHE:
'/tmp/renovate/cache/__renovate-private-cache/repositories',
},
},
},
{
cmd: "helm dependency update --registry-config /tmp/renovate/cache/__renovate-private-cache/registry.json --repository-config /tmp/renovate/cache/__renovate-private-cache/repositories.yaml --repository-cache /tmp/renovate/cache/__renovate-private-cache/repositories ''",
cmd: "helm dependency update ''",
options: {
env: {
HELM_EXPERIMENTAL_OCI: '1',
HELM_REGISTRY_CONFIG:
'/tmp/renovate/cache/__renovate-private-cache/registry.json',
HELM_REPOSITORY_CONFIG:
'/tmp/renovate/cache/__renovate-private-cache/repositories.yaml',
HELM_REPOSITORY_CACHE:
'/tmp/renovate/cache/__renovate-private-cache/repositories',
},
},
},
]);
});

View file

@ -1,7 +1,6 @@
import is from '@sindresorhus/is';
import yaml from 'js-yaml';
import { quote } from 'shlex';
import upath from 'upath';
import { TEMPORARY_ERROR } from '../../../constants/error-messages';
import { logger } from '../../../logger';
import { exec } from '../../../util/exec';
@ -9,7 +8,6 @@ import type { ExecOptions, ToolConstraint } from '../../../util/exec/types';
import {
getParentDir,
getSiblingFileName,
privateCacheDir,
readLocalFile,
writeLocalFile,
} from '../../../util/fs';
@ -18,6 +16,7 @@ import * as hostRules from '../../../util/host-rules';
import { DockerDatasource } from '../../datasource/docker';
import { HelmDatasource } from '../../datasource/helm';
import type { UpdateArtifact, UpdateArtifactsResult } from '../types';
import { generateHelmEnvs, generateLoginCmd } from './common';
import type { ChartDefinition, Repository, RepositoryRule } from './types';
import {
aliasRecordToRepositories,
@ -32,13 +31,6 @@ async function helmCommands(
repositories: Repository[]
): Promise<void> {
const cmd: string[] = [];
// set cache and config files to a path in privateCacheDir to prevent file and credential leakage
const helmConfigParameters = [
`--registry-config ${upath.join(privateCacheDir(), 'registry.json')}`,
`--repository-config ${upath.join(privateCacheDir(), 'repositories.yaml')}`,
`--repository-cache ${upath.join(privateCacheDir(), 'repositories')}`,
];
// get OCI registries and detect host rules
const registries: RepositoryRule[] = repositories
.filter(isOCIRegistry)
@ -55,15 +47,9 @@ async function helmCommands(
// if credentials for the registry have been found, log into it
registries.forEach((value) => {
const { username, password } = value.hostRule;
const parameters = [...helmConfigParameters];
if (username && password) {
parameters.push(`--username ${quote(username)}`);
parameters.push(`--password ${quote(password)}`);
cmd.push(
`helm registry login ${parameters.join(' ')} ${value.repository}`
);
const loginCmd = generateLoginCmd(value, 'helm registry login');
if (loginCmd) {
cmd.push(loginCmd);
}
});
@ -83,23 +69,17 @@ 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 = [...helmConfigParameters];
const parameters = [`${value.repository}`];
const isPrivateRepo = username && password;
if (isPrivateRepo) {
parameters.push(`--username ${quote(username)}`);
parameters.push(`--password ${quote(password)}`);
}
cmd.push(
`helm repo add ${value.name} ${parameters.join(' ')} ${value.repository}`
);
cmd.push(`helm repo add ${value.name} ${parameters.join(' ')}`);
});
cmd.push(
`helm dependency update ${helmConfigParameters.join(' ')} ${quote(
getParentDir(manifestPath)
)}`
);
cmd.push(`helm dependency update ${quote(getParentDir(manifestPath))}`);
await exec(cmd, execOptions);
}
@ -158,9 +138,7 @@ export async function updateArtifacts({
const execOptions: ExecOptions = {
docker: {},
extraEnv: {
HELM_EXPERIMENTAL_OCI: '1',
},
extraEnv: generateHelmEnvs(),
toolConstraints: [helmToolConstraint],
};
await helmCommands(execOptions, packageFileName, repositories);

View file

@ -0,0 +1,32 @@
import { quote } from 'shlex';
import upath from 'upath';
import type { ExtraEnv } from '../../../util/exec/types';
import { privateCacheDir } from '../../../util/fs';
import type { RepositoryRule } from './types';
export function generateLoginCmd(
repositoryRule: RepositoryRule,
loginCMD: string
): string | null {
const { username, password } = repositoryRule.hostRule;
if (username && password) {
return `${loginCMD} --username ${quote(username)} --password ${quote(
password
)} ${repositoryRule.repository}`;
}
return null;
}
export function generateHelmEnvs(): ExtraEnv {
return {
HELM_EXPERIMENTAL_OCI: '1',
// set cache and config files to a path in privateCacheDir to prevent file and credential leakage
HELM_REGISTRY_CONFIG: `${upath.join(privateCacheDir(), 'registry.json')}`,
HELM_REPOSITORY_CONFIG: `${upath.join(
privateCacheDir(),
'repositories.yaml'
)}`,
HELM_REPOSITORY_CACHE: `${upath.join(privateCacheDir(), 'repositories')}`,
};
}