diff --git a/lib/modules/manager/argocd/extract.spec.ts b/lib/modules/manager/argocd/extract.spec.ts index 003276cd78b521..7d6537b92d067f 100644 --- a/lib/modules/manager/argocd/extract.spec.ts +++ b/lib/modules/manager/argocd/extract.spec.ts @@ -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({ diff --git a/lib/modules/manager/argocd/extract.ts b/lib/modules/manager/argocd/extract.ts index 92947d8ce8657e..4bdb704d78bbda 100644 --- a/lib/modules/manager/argocd/extract.ts +++ b/lib/modules/manager/argocd/extract.ts @@ -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; } diff --git a/lib/modules/manager/argocd/util.ts b/lib/modules/manager/argocd/util.ts index 6bc7fd344b18fe..720db2bddfeea8 100644 --- a/lib/modules/manager/argocd/util.ts +++ b/lib/modules/manager/argocd/util.ts @@ -3,5 +3,5 @@ import { regEx } from '../../../util/regex'; export const keyValueExtractionRegex = regEx( /^\s*(?[^\s]+):\s+"?(?[^"\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\//);