Skip to content
Snippets Groups Projects
Unverified Commit af7bd08c authored by Christoph Obexer's avatar Christoph Obexer Committed by GitHub
Browse files

fix: helm: add support for "alias:" repositories (#9316)

parent 4da8581b
No related branches found
No related tags found
No related merge requests found
...@@ -33,6 +33,13 @@ Object { ...@@ -33,6 +33,13 @@ Object {
"https://my-registry.gcr.io/", "https://my-registry.gcr.io/",
], ],
}, },
Object {
"currentValue": "1.0.0",
"depName": "example",
"registryUrls": Array [
"https://registry.example.com/",
],
},
], ],
} }
`; `;
......
...@@ -93,11 +93,15 @@ describe('lib/manager/helm-requirements/extract', () => { ...@@ -93,11 +93,15 @@ describe('lib/manager/helm-requirements/extract', () => {
- name: redis - name: redis
version: 0.9.0 version: 0.9.0
repository: '@placeholder' repository: '@placeholder'
- name: example
version: 1.0.0
repository: alias:longalias
`; `;
const fileName = 'requirements.yaml'; const fileName = 'requirements.yaml';
const result = extractPackageFile(content, fileName, { const result = extractPackageFile(content, fileName, {
aliases: { aliases: {
placeholder: 'https://my-registry.gcr.io/', placeholder: 'https://my-registry.gcr.io/',
longalias: 'https://registry.example.com/',
}, },
}); });
expect(result).not.toBeNull(); expect(result).not.toBeNull();
......
...@@ -44,9 +44,11 @@ export function extractPackageFile( ...@@ -44,9 +44,11 @@ export function extractPackageFile(
} }
res.registryUrls = [dep.repository]; res.registryUrls = [dep.repository];
if (dep.repository.startsWith('@')) { if (dep.repository.startsWith('@') || dep.repository.startsWith('alias:')) {
const repoWithAtRemoved = dep.repository.slice(1); const repoWithPrefixRemoved = dep.repository.slice(
const alias = config.aliases[repoWithAtRemoved]; dep.repository[0] === '@' ? 1 : 6
);
const alias = config.aliases[repoWithPrefixRemoved];
if (alias) { if (alias) {
res.registryUrls = [alias]; res.registryUrls = [alias];
return res; return res;
......
...@@ -34,6 +34,13 @@ Object { ...@@ -34,6 +34,13 @@ Object {
"https://my-registry.gcr.io/", "https://my-registry.gcr.io/",
], ],
}, },
Object {
"currentValue": "1.0.0",
"depName": "example",
"registryUrls": Array [
"https://registry.example.com/",
],
},
], ],
"packageFileVersion": "0.1.0", "packageFileVersion": "0.1.0",
} }
......
...@@ -73,11 +73,15 @@ describe('lib/manager/helm-requirements/extract', () => { ...@@ -73,11 +73,15 @@ describe('lib/manager/helm-requirements/extract', () => {
- name: redis - name: redis
version: 0.9.0 version: 0.9.0
repository: '@placeholder' repository: '@placeholder'
- name: example
version: 1.0.0
repository: alias:longalias
`; `;
const fileName = 'Chart.yaml'; const fileName = 'Chart.yaml';
const result = await extractPackageFile(content, fileName, { const result = await extractPackageFile(content, fileName, {
aliases: { aliases: {
placeholder: 'https://my-registry.gcr.io/', placeholder: 'https://my-registry.gcr.io/',
longalias: 'https://registry.example.com/',
}, },
}); });
expect(result).not.toBeNull(); expect(result).not.toBeNull();
......
...@@ -58,9 +58,14 @@ export async function extractPackageFile( ...@@ -58,9 +58,14 @@ export async function extractPackageFile(
}; };
if (dep.repository) { if (dep.repository) {
res.registryUrls = [dep.repository]; res.registryUrls = [dep.repository];
if (dep.repository.startsWith('@')) { if (
const repoWithAtRemoved = dep.repository.slice(1); dep.repository.startsWith('@') ||
const alias = config.aliases[repoWithAtRemoved]; dep.repository.startsWith('alias:')
) {
const repoWithPrefixRemoved = dep.repository.slice(
dep.repository[0] === '@' ? 1 : 6
);
const alias = config.aliases[repoWithPrefixRemoved];
if (alias) { if (alias) {
res.registryUrls = [alias]; res.registryUrls = [alias];
return res; return res;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment