From 996e4a6e579746d816220681f1ecbe5ec12f4376 Mon Sep 17 00:00:00 2001 From: RahulGautamSingh <rahultesnik@gmail.com> Date: Fri, 10 Jun 2022 10:44:49 +0530 Subject: [PATCH] feat: rename aliases to registryAliases (#15877) --- docs/usage/configuration-options.md | 38 ++++++++++--------- lib/config/migrations/migrations-service.ts | 1 + lib/config/options/index.ts | 4 +- lib/config/validation.spec.ts | 16 ++++---- lib/config/validation.ts | 2 +- .../manager/helm-requirements/extract.spec.ts | 18 ++++----- .../manager/helm-requirements/extract.ts | 2 +- .../manager/helm-requirements/index.ts | 2 +- .../manager/helm-requirements/readme.md | 2 +- lib/modules/manager/helmfile/extract.spec.ts | 26 ++++++------- lib/modules/manager/helmfile/extract.ts | 12 +++--- lib/modules/manager/helmfile/index.ts | 2 +- lib/modules/manager/helmfile/readme.md | 2 +- .../__snapshots__/artifacts.spec.ts.snap | 20 +++++----- lib/modules/manager/helmv3/artifacts.spec.ts | 22 +++++------ lib/modules/manager/helmv3/artifacts.ts | 6 +-- lib/modules/manager/helmv3/extract.spec.ts | 24 ++++++------ lib/modules/manager/helmv3/extract.ts | 2 +- lib/modules/manager/helmv3/index.ts | 2 +- lib/modules/manager/helmv3/readme.md | 2 +- lib/modules/manager/helmv3/utils.ts | 14 +++---- lib/modules/manager/types.ts | 4 +- lib/workers/global/config/parse/cli.ts | 1 + lib/workers/global/config/parse/env.ts | 1 + 24 files changed, 116 insertions(+), 109 deletions(-) diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index d2161a9bb2..008fdbc694 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -94,23 +94,6 @@ You normally don't need to configure this, but one example where it can be usefu In contrast to `reviewers`, this option adds to the existing reviewer list, rather than replacing it. This makes it suitable for augmenting a preset or base list without displacing the original, for example when adding focused reviewers for a specific package group. -## aliases - -The `aliases` object is used for configuring registry aliases. -Currently it is needed/supported for the `helm-requirements`, `helmv3` and `helmfile` managers only. - -The above managers include this default alias: - -```json -{ - "aliases": { - "stable": "https://charts.helm.sh/stable" - } -} -``` - -Alias values must be properly formatted URIs. - ## assignAutomerge By default, Renovate will not assign reviewers and assignees to an automerge-enabled PR unless it fails status checks. @@ -2215,6 +2198,27 @@ If the `versioning` field is missing, then Renovate defaults to using `semver` v For more details and examples, see our [documentation for the `regex` manager](/modules/manager/regex/). For template fields, use the triple brace `{{{ }}}` notation to avoid Handlebars escaping any special characters. +## registryAliases + +You can use the `registryAliases` object to set registry aliases. +This feature only works with these managers: + +- `helm-requirements` +- `helmv3` +- `helmfile` + +The managers listed above all have this default registryAlias: + +```json +{ + "registryAliases": { + "stable": "https://charts.helm.sh/stable" + } +} +``` + +Alias values must be properly formatted URIs. + ### matchStrings `matchStrings` should each be a valid regular expression, optionally with named capture groups. diff --git a/lib/config/migrations/migrations-service.ts b/lib/config/migrations/migrations-service.ts index 91535db83c..60eb6f7b27 100644 --- a/lib/config/migrations/migrations-service.ts +++ b/lib/config/migrations/migrations-service.ts @@ -74,6 +74,7 @@ export class MigrationsService { ['separatePatchReleases', 'separateMinorPatch'], ['versionScheme', 'versioning'], ['lookupNameTemplate', 'packageNameTemplate'], + ['aliases', 'registryAliases'], ]); static readonly customMigrations: ReadonlyArray<MigrationConstructor> = [ diff --git a/lib/config/options/index.ts b/lib/config/options/index.ts index e2c4624f5e..949f2d7982 100644 --- a/lib/config/options/index.ts +++ b/lib/config/options/index.ts @@ -795,8 +795,8 @@ const options: RenovateOptions[] = [ globalOnly: true, }, { - name: 'aliases', - description: 'Aliases for registries, package manager specific.', + name: 'registryAliases', + description: 'Aliases for registries.', type: 'object', default: {}, additionalProperties: { diff --git a/lib/config/validation.spec.ts b/lib/config/validation.spec.ts index e61740dc75..7e564265a2 100644 --- a/lib/config/validation.spec.ts +++ b/lib/config/validation.spec.ts @@ -507,9 +507,9 @@ describe('config/validation', () => { expect(errors).toHaveLength(0); }); - it('validates valid alias objects', async () => { + it('validates valid registryAlias objects', async () => { const config = { - aliases: { + registryAliases: { example1: 'http://www.example.com', example2: 'https://www.example2.com/example', }, @@ -521,9 +521,9 @@ describe('config/validation', () => { expect(errors).toHaveLength(0); }); - it('errors if aliases depth is more than 1', async () => { + it('errors if registryAliases depth is more than 1', async () => { const config = { - aliases: { + registryAliases: { sample: { example1: 'http://www.example.com', }, @@ -536,15 +536,15 @@ describe('config/validation', () => { expect(errors).toMatchObject([ { message: - 'Invalid `aliases.aliases.sample` configuration: value is not a url', + 'Invalid `registryAliases.registryAliases.sample` configuration: value is not a url', topic: 'Configuration Error', }, ]); }); - it('errors if aliases have invalid url', async () => { + it('errors if registryAliases have invalid url', async () => { const config = { - aliases: { + registryAliases: { example1: 'noturl', example2: 'http://www.example.com', }, @@ -556,7 +556,7 @@ describe('config/validation', () => { expect(errors).toMatchObject([ { message: - 'Invalid `aliases.aliases.example1` configuration: value is not a url', + 'Invalid `registryAliases.registryAliases.example1` configuration: value is not a url', topic: 'Configuration Error', }, ]); diff --git a/lib/config/validation.ts b/lib/config/validation.ts index 1ca4e9157e..23be22ec6a 100644 --- a/lib/config/validation.ts +++ b/lib/config/validation.ts @@ -534,7 +534,7 @@ export async function validateConfig( currentPath !== 'force.constraints' ) { if (is.plainObject(val)) { - if (key === 'aliases') { + if (key === 'registryAliases') { const res = validateAliasObject(val); if (res !== true) { errors.push({ diff --git a/lib/modules/manager/helm-requirements/extract.spec.ts b/lib/modules/manager/helm-requirements/extract.spec.ts index 657f64dc6f..ad90c0c438 100644 --- a/lib/modules/manager/helm-requirements/extract.spec.ts +++ b/lib/modules/manager/helm-requirements/extract.spec.ts @@ -26,7 +26,7 @@ describe('modules/manager/helm-requirements/extract', () => { `; const fileName = 'requirements.yaml'; const result = extractPackageFile(content, fileName, { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable/', }, }); @@ -57,7 +57,7 @@ describe('modules/manager/helm-requirements/extract', () => { `; const fileName = 'requirements.yaml'; const result = extractPackageFile(content, fileName, { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable/', }, }); @@ -85,7 +85,7 @@ describe('modules/manager/helm-requirements/extract', () => { `; const fileName = 'requirements.yaml'; const result = extractPackageFile(content, fileName, { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable/', }, }); @@ -107,7 +107,7 @@ describe('modules/manager/helm-requirements/extract', () => { `); const fileName = 'requirements.yaml'; const result = extractPackageFile('', fileName, { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable/', }, }); @@ -133,7 +133,7 @@ describe('modules/manager/helm-requirements/extract', () => { `; const fileName = 'requirements.yaml'; const result = extractPackageFile(content, fileName, { - aliases: { + registryAliases: { placeholder: 'https://my-registry.gcr.io/', longalias: 'https://registry.example.com/', }, @@ -162,7 +162,7 @@ describe('modules/manager/helm-requirements/extract', () => { `; const fileName = 'requirements.yaml'; const result = extractPackageFile(content, fileName, { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable/', }, }); @@ -187,7 +187,7 @@ describe('modules/manager/helm-requirements/extract', () => { `; const fileName = 'requirements.yaml'; const result = extractPackageFile(content, fileName, { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable/', }, }); @@ -209,7 +209,7 @@ describe('modules/manager/helm-requirements/extract', () => { `; const fileName = 'requirements.yaml'; const result = extractPackageFile(content, fileName, { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable/', }, }); @@ -220,7 +220,7 @@ describe('modules/manager/helm-requirements/extract', () => { const content = ''; const fileName = 'requirements.yaml'; const result = extractPackageFile(content, fileName, { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable/', }, }); diff --git a/lib/modules/manager/helm-requirements/extract.ts b/lib/modules/manager/helm-requirements/extract.ts index 7bdfe2c127..0eef769f9b 100644 --- a/lib/modules/manager/helm-requirements/extract.ts +++ b/lib/modules/manager/helm-requirements/extract.ts @@ -57,7 +57,7 @@ export function extractPackageFile( const repoWithPrefixRemoved = dep.repository.slice( dep.repository[0] === '@' ? 1 : 6 ); - const alias = config.aliases?.[repoWithPrefixRemoved]; + const alias = config.registryAliases?.[repoWithPrefixRemoved]; if (alias) { res.registryUrls = [alias]; return res; diff --git a/lib/modules/manager/helm-requirements/index.ts b/lib/modules/manager/helm-requirements/index.ts index 186ec412d9..e9df003fad 100644 --- a/lib/modules/manager/helm-requirements/index.ts +++ b/lib/modules/manager/helm-requirements/index.ts @@ -2,7 +2,7 @@ import { HelmDatasource } from '../../datasource/helm'; export { extractPackageFile } from './extract'; export const defaultConfig = { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable', }, commitMessageTopic: 'helm chart {{depName}}', diff --git a/lib/modules/manager/helm-requirements/readme.md b/lib/modules/manager/helm-requirements/readme.md index 0b029c8d12..ab2b5a0e38 100644 --- a/lib/modules/manager/helm-requirements/readme.md +++ b/lib/modules/manager/helm-requirements/readme.md @@ -1,6 +1,6 @@ Renovate supports updating Helm Chart references within `requirements.yaml` files. -If your Helm charts make use of repository Aliases then you will need to configure an `aliases` object in your config to tell Renovate where to look for them. +If your Helm charts make use of repository aliases then you will need to configure an `registryAliases` object in your config to tell Renovate where to look for them. If you need to change the versioning format, read the [versioning](https://docs.renovatebot.com/modules/versioning/) documentation to learn more. diff --git a/lib/modules/manager/helmfile/extract.spec.ts b/lib/modules/manager/helmfile/extract.spec.ts index c00387ea03..89f4560a2b 100644 --- a/lib/modules/manager/helmfile/extract.spec.ts +++ b/lib/modules/manager/helmfile/extract.spec.ts @@ -15,7 +15,7 @@ describe('modules/manager/helmfile/extract', () => { `; const fileName = 'helmfile.yaml'; const result = extractPackageFile(content, fileName, { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable', }, }); @@ -32,7 +32,7 @@ describe('modules/manager/helmfile/extract', () => { `; const fileName = 'helmfile.yaml'; const result = extractPackageFile(content, fileName, { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable', }, }); @@ -51,7 +51,7 @@ describe('modules/manager/helmfile/extract', () => { `; const fileName = 'helmfile.yaml'; const result = extractPackageFile(content, fileName, { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable', }, }); @@ -75,7 +75,7 @@ describe('modules/manager/helmfile/extract', () => { `; const fileName = 'helmfile.yaml'; const result = extractPackageFile(content, fileName, { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable', }, }); @@ -106,7 +106,7 @@ describe('modules/manager/helmfile/extract', () => { `; const fileName = 'helmfile.yaml'; const result = extractPackageFile(content, fileName, { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable', }, }); @@ -127,7 +127,7 @@ describe('modules/manager/helmfile/extract', () => { `; const fileName = 'helmfile.yaml'; const result = extractPackageFile(content, fileName, { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable', }, }); @@ -151,7 +151,7 @@ describe('modules/manager/helmfile/extract', () => { `; const fileName = 'helmfile.yaml'; const result = extractPackageFile(content, fileName, { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable', }, }); @@ -171,7 +171,7 @@ describe('modules/manager/helmfile/extract', () => { `; const fileName = 'helmfile.yaml'; const result = extractPackageFile(content, fileName, { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable', }, }); @@ -186,7 +186,7 @@ describe('modules/manager/helmfile/extract', () => { Fixtures.get('multidoc.yaml'), fileName, { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable', }, } @@ -222,7 +222,7 @@ describe('modules/manager/helmfile/extract', () => { `; const fileName = 'helmfile.yaml'; const result = extractPackageFile(content, fileName, { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable', }, }); @@ -259,7 +259,7 @@ describe('modules/manager/helmfile/extract', () => { `; const fileName = 'helmfile.yaml'; const result = extractPackageFile(content, fileName, { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable', }, }); @@ -299,7 +299,7 @@ describe('modules/manager/helmfile/extract', () => { `; const fileName = 'helmfile.yaml'; const result = extractPackageFile(content, fileName, { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable', }, }); @@ -326,7 +326,7 @@ describe('modules/manager/helmfile/extract', () => { Fixtures.get('go-template.yaml'), filename, { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable', }, } diff --git a/lib/modules/manager/helmfile/extract.ts b/lib/modules/manager/helmfile/extract.ts index feeff943eb..d085123199 100644 --- a/lib/modules/manager/helmfile/extract.ts +++ b/lib/modules/manager/helmfile/extract.ts @@ -22,7 +22,7 @@ export function extractPackageFile( ): PackageFile | null { let deps: PackageDependency[] = []; let docs: Doc[]; - const aliases: Record<string, string> = {}; + const registryAliases: Record<string, string> = {}; try { docs = loadAll(extractYaml(content), null, { json: true }) as Doc[]; } catch (err) { @@ -36,10 +36,10 @@ export function extractPackageFile( if (doc.repositories) { for (let i = 0; i < doc.repositories.length; i += 1) { - aliases[doc.repositories[i].name] = doc.repositories[i].url; + registryAliases[doc.repositories[i].name] = doc.repositories[i].url; } } - logger.debug({ aliases }, 'repositories discovered.'); + logger.debug({ registryAliases }, 'repositories discovered.'); deps = doc.releases.map((dep) => { let depName = dep.chart; @@ -82,8 +82,8 @@ export function extractPackageFile( const res: PackageDependency = { depName, currentValue: dep.version, - registryUrls: [aliases[repoName]] - .concat([config.aliases?.[repoName]] as string[]) + registryUrls: [registryAliases[repoName]] + .concat([config.registryAliases?.[repoName]] as string[]) .filter(is.string), }; @@ -93,7 +93,7 @@ export function extractPackageFile( ); if (repository?.oci) { res.datasource = DockerDatasource.id; - res.packageName = aliases[repoName] + '/' + depName; + res.packageName = registryAliases[repoName] + '/' + depName; } // By definition on helm the chart name should be lowercase letter + number + - diff --git a/lib/modules/manager/helmfile/index.ts b/lib/modules/manager/helmfile/index.ts index 7de71e75bf..36e82e44ff 100644 --- a/lib/modules/manager/helmfile/index.ts +++ b/lib/modules/manager/helmfile/index.ts @@ -3,7 +3,7 @@ import { HelmDatasource } from '../../datasource/helm'; export { extractPackageFile } from './extract'; export const defaultConfig = { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable', }, commitMessageTopic: 'helm chart {{depName}}', diff --git a/lib/modules/manager/helmfile/readme.md b/lib/modules/manager/helmfile/readme.md index 62f58c0458..e560becc12 100644 --- a/lib/modules/manager/helmfile/readme.md +++ b/lib/modules/manager/helmfile/readme.md @@ -1,5 +1,5 @@ Checks `helmfile.yaml` files and extracts dependencies for the `helm` datasource. -If your Helm charts make use of repository Aliases then you will need to configure an `aliases` object in your config to tell Renovate where to look for them. +If your Helm charts make use of repository aliases then you will need to configure an `registryAliases` object in your config to tell Renovate where to look for them. If you need to change the versioning format, read the [versioning](https://docs.renovatebot.com/modules/versioning/) documentation to learn more. diff --git a/lib/modules/manager/helmv3/__snapshots__/artifacts.spec.ts.snap b/lib/modules/manager/helmv3/__snapshots__/artifacts.spec.ts.snap index 55931625e1..e5becd956f 100644 --- a/lib/modules/manager/helmv3/__snapshots__/artifacts.spec.ts.snap +++ b/lib/modules/manager/helmv3/__snapshots__/artifacts.spec.ts.snap @@ -75,7 +75,7 @@ Array [ ] `; -exports[`modules/manager/helmv3/artifacts do not add aliases to repository list 1`] = ` +exports[`modules/manager/helmv3/artifacts do not add registryAliases to repository list 1`] = ` Array [ Object { "file": Object { @@ -96,7 +96,7 @@ generated: \\"2022-01-20T17:48:47.610371241+01:00\\" ] `; -exports[`modules/manager/helmv3/artifacts do not add aliases to repository list 2`] = ` +exports[`modules/manager/helmv3/artifacts do not add registryAliases to repository list 2`] = ` Array [ Object { "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", @@ -158,7 +158,7 @@ Array [ ] `; -exports[`modules/manager/helmv3/artifacts log into private registries and repositories NOT defined in aliases 1`] = ` +exports[`modules/manager/helmv3/artifacts log into private registries and repositories NOT defined in registryAliases 1`] = ` Array [ Object { "file": Object { @@ -179,7 +179,7 @@ generated: \\"2022-01-20T17:48:47.610371241+01:00\\" ] `; -exports[`modules/manager/helmv3/artifacts log into private registries and repositories NOT defined in aliases 2`] = ` +exports[`modules/manager/helmv3/artifacts log into private registries and repositories NOT defined in registryAliases 2`] = ` Array [ Object { "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", @@ -241,7 +241,7 @@ Array [ ] `; -exports[`modules/manager/helmv3/artifacts log into private registries and repositories already defined in aliases 1`] = ` +exports[`modules/manager/helmv3/artifacts log into private registries and repositories already defined in registryAliases 1`] = ` Array [ Object { "file": Object { @@ -262,7 +262,7 @@ generated: \\"2022-01-20T17:48:47.610371241+01:00\\" ] `; -exports[`modules/manager/helmv3/artifacts log into private registries and repositories already defined in aliases 2`] = ` +exports[`modules/manager/helmv3/artifacts log into private registries and repositories already defined in registryAliases 2`] = ` Array [ Object { "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", @@ -590,7 +590,7 @@ Array [ ] `; -exports[`modules/manager/helmv3/artifacts sets repositories from aliases 1`] = ` +exports[`modules/manager/helmv3/artifacts sets repositories from registryAliases 1`] = ` Array [ Object { "file": Object { @@ -611,7 +611,7 @@ generated: \\"2022-01-20T17:48:47.610371241+01:00\\" ] `; -exports[`modules/manager/helmv3/artifacts sets repositories from aliases 2`] = ` +exports[`modules/manager/helmv3/artifacts sets repositories from registryAliases 2`] = ` Array [ Object { "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", @@ -692,7 +692,7 @@ Array [ ] `; -exports[`modules/manager/helmv3/artifacts sets repositories from aliases with docker 1`] = ` +exports[`modules/manager/helmv3/artifacts sets repositories from registryAliases with docker 1`] = ` Array [ Object { "file": Object { @@ -713,7 +713,7 @@ generated: \\"2022-01-20T17:48:47.610371241+01:00\\" ] `; -exports[`modules/manager/helmv3/artifacts sets repositories from aliases with docker 2`] = ` +exports[`modules/manager/helmv3/artifacts sets repositories from registryAliases with docker 2`] = ` Array [ Object { "cmd": "docker pull renovate/sidecar", diff --git a/lib/modules/manager/helmv3/artifacts.spec.ts b/lib/modules/manager/helmv3/artifacts.spec.ts index 715343be12..f23943b10b 100644 --- a/lib/modules/manager/helmv3/artifacts.spec.ts +++ b/lib/modules/manager/helmv3/artifacts.spec.ts @@ -211,7 +211,7 @@ describe('modules/manager/helmv3/artifacts', () => { ]); }); - it('sets repositories from aliases', async () => { + it('sets repositories from registryAliases', async () => { fs.privateCacheDir.mockReturnValue( '/tmp/renovate/cache/__renovate-private-cache' ); @@ -228,7 +228,7 @@ describe('modules/manager/helmv3/artifacts', () => { config: { ...config, updateType: 'lockFileMaintenance', - aliases: { stable: 'the_stable_url', repo1: 'the_repo1_url' }, + registryAliases: { stable: 'the_stable_url', repo1: 'the_repo1_url' }, }, }) ).toMatchSnapshot([ @@ -244,7 +244,7 @@ describe('modules/manager/helmv3/artifacts', () => { expect(execSnapshots).toMatchSnapshot(); }); - it('sets repositories from aliases with docker', async () => { + it('sets repositories from registryAliases with docker', async () => { GlobalConfig.set({ ...adminConfig, binarySource: 'docker' }); fs.getSiblingFileName.mockReturnValueOnce('Chart.lock'); fs.readLocalFile.mockResolvedValueOnce(ociLockFile1 as never); @@ -265,7 +265,7 @@ describe('modules/manager/helmv3/artifacts', () => { config: { ...config, updateType: 'lockFileMaintenance', - aliases: { stable: 'the_stable_url', repo1: 'the_repo1_url' }, + registryAliases: { stable: 'the_stable_url', repo1: 'the_repo1_url' }, }, }) ).toMatchSnapshot([ @@ -281,7 +281,7 @@ describe('modules/manager/helmv3/artifacts', () => { expect(execSnapshots).toMatchSnapshot(); }); - it('log into private registries and repositories already defined in aliases', async () => { + it('log into private registries and repositories already defined in registryAliases', async () => { hostRules.add({ username: 'test', password: 'aPassword', @@ -310,7 +310,7 @@ describe('modules/manager/helmv3/artifacts', () => { config: { ...config, updateType: 'lockFileMaintenance', - aliases: { + registryAliases: { stable: 'the_stable_url', oci: 'oci://registry.example.com/organization', repo1: 'https://the_repo1_url', @@ -330,7 +330,7 @@ describe('modules/manager/helmv3/artifacts', () => { expect(execSnapshots).toMatchSnapshot(); }); - it('log into private registries and repositories NOT defined in aliases', async () => { + it('log into private registries and repositories NOT defined in registryAliases', async () => { hostRules.add({ username: 'registryUser', password: 'password', @@ -360,7 +360,7 @@ describe('modules/manager/helmv3/artifacts', () => { config: { ...config, updateType: 'lockFileMaintenance', - aliases: {}, + registryAliases: {}, }, }) ).toMatchSnapshot([ @@ -400,7 +400,7 @@ describe('modules/manager/helmv3/artifacts', () => { config: { ...config, updateType: 'lockFileMaintenance', - aliases: { + registryAliases: { repo1: 'https://gitlab.com/api/v4/projects/xxxxxxx/packages/helm/stable', }, @@ -431,7 +431,7 @@ describe('modules/manager/helmv3/artifacts', () => { expect(execSnapshots).toMatchSnapshot(); }); - it('do not add aliases to repository list', async () => { + it('do not add registryAliases to repository list', async () => { fs.getSiblingFileName.mockReturnValueOnce('Chart.lock'); fs.readLocalFile.mockResolvedValueOnce(ociLockFile1Alias as never); const execSnapshots = mockExecAll(exec); @@ -448,7 +448,7 @@ describe('modules/manager/helmv3/artifacts', () => { config: { ...config, updateType: 'lockFileMaintenance', - aliases: { + registryAliases: { jetstack: 'https://charts.jetstack.io', }, }, diff --git a/lib/modules/manager/helmv3/artifacts.ts b/lib/modules/manager/helmv3/artifacts.ts index 8a1139841a..d6fc559727 100644 --- a/lib/modules/manager/helmv3/artifacts.ts +++ b/lib/modules/manager/helmv3/artifacts.ts @@ -129,10 +129,10 @@ export async function updateArtifacts({ const locks = yaml.load(existingLockFileContent) as ChartDefinition; //TODO #9610 const chartDefinitions: ChartDefinition[] = []; - // prioritize alias naming for Helm repositories - if (config.aliases) { + // prioritize registryAlias naming for Helm repositories + if (config.registryAliases) { chartDefinitions.push({ - dependencies: aliasRecordToRepositories(config.aliases), + dependencies: aliasRecordToRepositories(config.registryAliases), }); } chartDefinitions.push(packages, locks); diff --git a/lib/modules/manager/helmv3/extract.spec.ts b/lib/modules/manager/helmv3/extract.spec.ts index 9cb3978559..f97a2fd371 100644 --- a/lib/modules/manager/helmv3/extract.spec.ts +++ b/lib/modules/manager/helmv3/extract.spec.ts @@ -30,7 +30,7 @@ describe('modules/manager/helmv3/extract', () => { `; const fileName = 'Chart.yaml'; const result = await extractPackageFile(content, fileName, { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable', }, }); @@ -58,7 +58,7 @@ describe('modules/manager/helmv3/extract', () => { `; const fileName = 'Chart.yaml'; const result = await extractPackageFile(content, fileName, { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable', }, }); @@ -91,7 +91,7 @@ describe('modules/manager/helmv3/extract', () => { `; const fileName = 'Chart.yaml'; const result = await extractPackageFile(content, fileName, { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable', }, }); @@ -127,7 +127,7 @@ describe('modules/manager/helmv3/extract', () => { `; const fileName = 'Chart.yaml'; const result = await extractPackageFile(content, fileName, { - aliases: { + registryAliases: { placeholder: 'https://my-registry.gcr.io/', longalias: 'https://registry.example.com/', ociRegistry: 'oci://quay.example.com/organization', @@ -146,7 +146,7 @@ describe('modules/manager/helmv3/extract', () => { `; const fileName = 'Chart.yaml'; const result = await extractPackageFile(content, fileName, { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable', }, }); @@ -170,7 +170,7 @@ describe('modules/manager/helmv3/extract', () => { `; const fileName = 'Chart.yaml'; const result = await extractPackageFile(content, fileName, { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable', }, }); @@ -195,7 +195,7 @@ describe('modules/manager/helmv3/extract', () => { `; const fileName = 'Chart.yaml'; const result = await extractPackageFile(content, fileName, { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable', }, }); @@ -215,7 +215,7 @@ describe('modules/manager/helmv3/extract', () => { `; const fileName = 'Chart.yaml'; const result = await extractPackageFile(content, fileName, { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable', }, }); @@ -235,7 +235,7 @@ describe('modules/manager/helmv3/extract', () => { `; const fileName = 'Chart.yaml'; const result = await extractPackageFile(content, fileName, { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable', }, }); @@ -246,7 +246,7 @@ describe('modules/manager/helmv3/extract', () => { const content = ''; const fileName = 'Chart.yaml'; const result = await extractPackageFile(content, fileName, { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable', }, }); @@ -263,7 +263,7 @@ describe('modules/manager/helmv3/extract', () => { `; const fileName = 'Chart.yaml'; const result = await extractPackageFile(content, fileName, { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable', }, }); @@ -284,7 +284,7 @@ describe('modules/manager/helmv3/extract', () => { `; const fileName = 'Chart.yaml'; const result = await extractPackageFile(content, fileName, { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable', }, }); diff --git a/lib/modules/manager/helmv3/extract.ts b/lib/modules/manager/helmv3/extract.ts index 25da3ef9c8..4a6f32a44a 100644 --- a/lib/modules/manager/helmv3/extract.ts +++ b/lib/modules/manager/helmv3/extract.ts @@ -62,7 +62,7 @@ export async function extractPackageFile( } // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion - const repository = resolveAlias(dep.repository, config.aliases!); + const repository = resolveAlias(dep.repository, config.registryAliases!); if (!repository) { res.skipReason = 'placeholder-url'; return res; diff --git a/lib/modules/manager/helmv3/index.ts b/lib/modules/manager/helmv3/index.ts index d0ef5e718d..b0714f85cf 100644 --- a/lib/modules/manager/helmv3/index.ts +++ b/lib/modules/manager/helmv3/index.ts @@ -7,7 +7,7 @@ export { bumpPackageVersion } from './update'; export const supportsLockFileMaintenance = true; export const defaultConfig = { - aliases: { + registryAliases: { stable: 'https://charts.helm.sh/stable', }, commitMessageTopic: 'helm chart {{depName}}', diff --git a/lib/modules/manager/helmv3/readme.md b/lib/modules/manager/helmv3/readme.md index 9854d75628..ea0c9e915d 100644 --- a/lib/modules/manager/helmv3/readme.md +++ b/lib/modules/manager/helmv3/readme.md @@ -1,6 +1,6 @@ Renovate supports updating Helm Chart references within `requirements.yaml` (Helm v2) and `Chart.yaml` (Helm v3) files. -If your Helm charts make use of repository Aliases then you will need to configure an `aliases` object in your config to tell Renovate where to look for them. +If your Helm charts make use of repository aliases then you will need to configure an `registryAliases` object in your config to tell Renovate where to look for them. If you need to change the versioning format, read the [versioning](https://docs.renovatebot.com/modules/versioning/) documentation to learn more. diff --git a/lib/modules/manager/helmv3/utils.ts b/lib/modules/manager/helmv3/utils.ts index c95520ad15..e002d6c92b 100644 --- a/lib/modules/manager/helmv3/utils.ts +++ b/lib/modules/manager/helmv3/utils.ts @@ -33,20 +33,20 @@ export function parseRepository( * Resolves alias in repository string. * * @param repository to be resolved string - * @param aliases Records containing aliases as key and to be resolved URLs as values + * @param registryAliases Records containing registryAliases as key and to be resolved URLs as values * - * @returns resolved alias. If repository does not contain an alias the repository string will be returned. Should it contain an alias which can not be resolved using `aliases`, null will be returned + * @returns resolved alias. If repository does not contain an alias the repository string will be returned. Should it contain an alias which can not be resolved using `registryAliases`, null will be returned */ export function resolveAlias( repository: string, - aliases: Record<string, string> + registryAliases: Record<string, string> ): string | null { if (!isAlias(repository)) { return repository; } const repoWithPrefixRemoved = repository.slice(repository[0] === '@' ? 1 : 6); - const alias = aliases[repoWithPrefixRemoved]; + const alias = registryAliases[repoWithPrefixRemoved]; if (alias) { return alias; } @@ -57,7 +57,7 @@ export function getRepositories(definitions: ChartDefinition[]): Repository[] { const repositoryList = definitions .flatMap((value) => value.dependencies) .filter((dependency) => dependency.repository) // only keep non-local references --> if no repository is defined the chart will be searched in charts/<name> - .filter((dependency) => !isAlias(dependency.repository)) // do not add aliases + .filter((dependency) => !isAlias(dependency.repository)) // do not add registryAliases .filter((dependency) => !dependency.repository.startsWith('file:')) // skip repositories which are locally referenced .map((dependency) => { // remove additional keys to prevent interference at deduplication @@ -86,9 +86,9 @@ export function isOCIRegistry(repository: Repository): boolean { } export function aliasRecordToRepositories( - aliases: Record<string, string> + registryAliases: Record<string, string> ): Repository[] { - return Object.entries(aliases).map(([alias, url]) => { + return Object.entries(registryAliases).map(([alias, url]) => { return { name: alias, repository: url, diff --git a/lib/modules/manager/types.ts b/lib/modules/manager/types.ts index 94d641da38..cd92661139 100644 --- a/lib/modules/manager/types.ts +++ b/lib/modules/manager/types.ts @@ -15,7 +15,7 @@ export interface ManagerData<T> { } export interface ExtractConfig { - aliases?: Record<string, string>; + registryAliases?: Record<string, string>; npmrc?: string; npmrcMerge?: boolean; skipInstalls?: boolean; @@ -49,7 +49,7 @@ export interface UpdateArtifactsConfig { newValue?: string; newVersion?: string; newMajor?: number; - aliases?: Record<string, string>; + registryAliases?: Record<string, string>; } export interface RangeConfig<T = Record<string, any>> extends ManagerData<T> { diff --git a/lib/workers/global/config/parse/cli.ts b/lib/workers/global/config/parse/cli.ts index 9a5adc71ad..fb790c4315 100644 --- a/lib/workers/global/config/parse/cli.ts +++ b/lib/workers/global/config/parse/cli.ts @@ -31,6 +31,7 @@ export function getConfig(input: string[]): AllConfig { .replace('--git-lab-automerge', '--platform-automerge') // migrate: gitLabAutomerge .replace(/^--dry-run$/, '--dry-run=true') .replace(/^--require-config$/, '--require-config=true') + .replace('--aliases', '--registry-aliases') ) .filter((a) => !a.startsWith('--git-fs')); const options = getOptions(); diff --git a/lib/workers/global/config/parse/env.ts b/lib/workers/global/config/parse/env.ts index ccbb22105a..0b9c1fef77 100644 --- a/lib/workers/global/config/parse/env.ts +++ b/lib/workers/global/config/parse/env.ts @@ -35,6 +35,7 @@ export function getEnvName(option: ParseConfigOptions): string { } const renameKeys = { + aliases: 'registryAliases', azureAutoComplete: 'platformAutomerge', // migrate: azureAutoComplete gitLabAutomerge: 'platformAutomerge', // migrate: gitLabAutomerge }; -- GitLab