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(manager/argocd): allow the apiVersion to be quoted #24355

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
54 changes: 54 additions & 0 deletions lib/modules/manager/argocd/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,60 @@ describe('modules/manager/argocd/extract', () => {
expect(result).toBeNull();
});

it('return result for double quoted argoproj.io apiVersion reference', () => {
const result = extractPackageFile(
`
apiVersion: "argoproj.io/v1alpha1"
kind: Application
spec:
source:
chart: kube-state-metrics
repoURL: https://prometheus-community.github.io/helm-charts
targetRevision: 2.4.1
`,
'applications.yml'
);
expect(result).toMatchObject({
deps: [
{
currentValue: '2.4.1',
datasource: 'helm',
depName: 'kube-state-metrics',
registryUrls: [
'https://prometheus-community.github.io/helm-charts',
],
},
],
});
});

it('return result for single quoted argoproj.io apiVersion reference', () => {
const result = extractPackageFile(
`
apiVersion: 'argoproj.io/v1alpha1'
kind: Application
spec:
source:
chart: kube-state-metrics
repoURL: https://prometheus-community.github.io/helm-charts
targetRevision: 2.4.1
`,
'applications.yml'
);
expect(result).toMatchObject({
deps: [
{
currentValue: '2.4.1',
datasource: 'helm',
depName: 'kube-state-metrics',
registryUrls: [
'https://prometheus-community.github.io/helm-charts',
],
},
],
});
});

it('full test', () => {
const result = extractPackageFile(validApplication, 'applications.yml');
expect(result).toEqual({
Expand Down
3 changes: 3 additions & 0 deletions lib/modules/manager/argocd/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export function extractPackageFile(
): PackageFileContent | null {
// check for argo reference. API version for the kind attribute is used
if (fileTestRegex.test(content) === false) {
logger.debug(
`Skip file ${packageFile} as no argoproj.io apiVersion could be found in matched file`
);
return null;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/modules/manager/argocd/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import { regEx } from '../../../util/regex';
export const keyValueExtractionRegex = regEx(
/^\s*(?<key>[^\s]+):\s+"?(?<value>[^"\s]+)"?\s*$/
);
// looks for `apiVersion: argoproj.io/
export const fileTestRegex = regEx(/\s*apiVersion:\s*argoproj.io\/\s*/);
// looks for `apiVersion: argoproj.io/` with optional quoting of the value
export const fileTestRegex = regEx(/\s*apiVersion:\s*'?"?argoproj.io\//);