Skip to content

Commit

Permalink
fix(manager/argocd): allow the apiVersion to be quoted (#24355)
Browse files Browse the repository at this point in the history
  • Loading branch information
secustor authored Sep 11, 2023
1 parent d5db1c6 commit 23bb573
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 2 deletions.
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\//);

0 comments on commit 23bb573

Please sign in to comment.