Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(helmfile): support case with oci repository in different document #30215

Merged
merged 38 commits into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0c8f60f
fix(worker): don't coerce valid semver versions
viceice Jun 5, 2023
a41862e
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Jul 12, 2023
ebdbd00
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Jul 24, 2023
f963606
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Aug 2, 2023
89fa0b8
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Aug 3, 2023
b7837af
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Aug 8, 2023
4634ff3
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Aug 9, 2023
aeba91b
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Aug 15, 2023
3d430bf
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Aug 16, 2023
5b94272
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Aug 21, 2023
ca8bce3
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Aug 21, 2023
64fe0cf
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Sep 14, 2023
5a8aed2
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Oct 26, 2023
d7ded40
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Nov 1, 2023
602a2df
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Nov 16, 2023
a002cbb
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Nov 21, 2023
0864d5e
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Feb 4, 2024
9c4c2c1
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Mar 3, 2024
6fa5fc3
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Mar 14, 2024
e9f6bb7
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Apr 2, 2024
a6d9d2f
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed May 7, 2024
7d0e609
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed May 15, 2024
cad83ed
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed May 22, 2024
0743eda
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed May 22, 2024
0ab6813
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Jun 26, 2024
a477e91
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Jun 27, 2024
7fa2fff
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Jul 14, 2024
9b1e584
Merge branch 'main' of https://github.com/renovateBot/renovate
PhilipAbed Jul 17, 2024
6878f57
fix helmfile unsupported case
PhilipAbed Jul 17, 2024
1af1e9f
registry aliases should be created for printing only in order to not …
PhilipAbed Jul 17, 2024
ce3a2e9
lint-fix
PhilipAbed Jul 17, 2024
5a59a08
fix comments
PhilipAbed Jul 17, 2024
5d773d2
type fix
PhilipAbed Jul 17, 2024
1d6de93
urljoin on package name as well
PhilipAbed Jul 17, 2024
5de51d7
urljoin again
PhilipAbed Jul 21, 2024
02e47b5
urljoin again
PhilipAbed Jul 21, 2024
86d8f76
change to block
PhilipAbed Jul 21, 2024
a90e135
Update lib/modules/manager/helmfile/extract.spec.ts
secustor Jul 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions lib/modules/manager/helmfile/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,37 @@ describe('modules/manager/helmfile/extract', () => {
});
});

it('parses a chart with an oci repository with ---', async () => {
const content = codeBlock`
repositories:
- name: oci-repo
url: ghcr.io/example/oci-repo
oci: true
---
releases:
- name: example
version: 0.1.0
chart: oci-repo/example
`;
const fileName = 'helmfile.yaml';
const result = await extractPackageFile(content, fileName, {
registryAliases: {
stable: 'https://charts.helm.sh/stable',
},
});
expect(result).toMatchObject({
datasource: 'helm',
deps: [
{
currentValue: '0.1.0',
depName: 'example',
datasource: 'docker',
packageName: 'ghcr.io/example/oci-repo/example',
},
],
});
});

it('parses and replaces templating strings', async () => {
const filename = 'helmfile.yaml';
fs.localPathExists.mockReturnValue(Promise.resolve(true));
Expand Down
28 changes: 15 additions & 13 deletions lib/modules/manager/helmfile/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import is from '@sindresorhus/is';
import { logger } from '../../../logger';
import { coerceArray } from '../../../util/array';
import { regEx } from '../../../util/regex';
import { joinUrlParts } from '../../../util/url';
import { parseYaml } from '../../../util/yaml';
import { DockerDatasource } from '../../datasource/docker';
import { HelmDatasource } from '../../datasource/helm';
Expand All @@ -11,7 +12,7 @@ import type {
PackageDependency,
PackageFileContent,
} from '../types';
import type { Doc } from './schema';
import type { Doc, HelmRepository } from './schema';
import { Doc as documentSchema } from './schema';
import {
kustomizationsKeysUsed,
Expand All @@ -34,7 +35,7 @@ export async function extractPackageFile(
): Promise<PackageFileContent | null> {
const deps: PackageDependency[] = [];
let docs: Doc[];
let registryAliases: Record<string, string> = {};
let registryData: Record<string, HelmRepository> = {};
// Record kustomization usage for all deps, since updating artifacts is run on the helmfile.yaml as a whole.
let needKustomize = false;
try {
Expand All @@ -51,15 +52,16 @@ export async function extractPackageFile(
);
return null;
}

for (const doc of docs) {
// Always check for repositories in the current document and override the existing ones if any (as YAML does)
if (doc.repositories) {
registryAliases = {};
registryData = {};
secustor marked this conversation as resolved.
Show resolved Hide resolved
for (let i = 0; i < doc.repositories.length; i += 1) {
registryAliases[doc.repositories[i].name] = doc.repositories[i].url;
registryData[doc.repositories[i].name] = doc.repositories[i];
}
logger.debug(
{ registryAliases, packageFile },
{ registryAliases: registryData, packageFile },
`repositories discovered.`,
);
}
Expand Down Expand Up @@ -106,23 +108,23 @@ export async function extractPackageFile(
const res: PackageDependency = {
depName,
currentValue: dep.version,
registryUrls: [registryAliases[repoName]]
registryUrls: [registryData[repoName]?.url]
.concat([config.registryAliases?.[repoName]] as string[])
.filter(is.string),
};
if (kustomizationsKeysUsed(dep)) {
needKustomize = true;
}
// in case of OCI repository, we need a PackageDependency with a DockerDatasource and a packageName
const repository = doc.repositories?.find(
(repo) => repo.name === repoName,
);

if (isOCIRegistry(dep.chart)) {
res.datasource = DockerDatasource.id;
res.packageName = repoName + '/' + depName;
} else if (repository?.oci) {
res.packageName = joinUrlParts(repoName, depName);
} else if (registryData[repoName]?.oci) {
res.datasource = DockerDatasource.id;
res.packageName = registryAliases[repoName] + '/' + depName;
const alias = registryData[repoName]?.url;
if (alias) {
res.packageName = joinUrlParts(alias, depName);
}
}

// By definition on helm the chart name should be lowercase letter + number + -
Expand Down