diff --git a/lib/modules/manager/argocd/__fixtures__/validApplicationSet.yml b/lib/modules/manager/argocd/__fixtures__/validApplicationSet.yml new file mode 100644 index 00000000000000..e17a7e7bdc7fc7 --- /dev/null +++ b/lib/modules/manager/argocd/__fixtures__/validApplicationSet.yml @@ -0,0 +1,75 @@ +--- +apiVersion: argoproj.io/v1alpha1 +kind: ApplicationSet +spec: + template: + spec: + source: + chart: kube-state-metrics + repoURL: https://prometheus-community.github.io/helm-charts + targetRevision: 2.4.1 +--- +# applicationset with helm values +apiVersion: argoproj.io/v1alpha1 +kind: ApplicationSet +spec: + template: + spec: + source: + chart: {{ .Values.chart }} + repoURL: {{ .Values.repoUrl}} + targetRevision: {{ .Values.targetRevision }} +--- +apiVersion: argoproj.io/v1alpha1 +kind: ApplicationSet +spec: + template: + spec: + source: + chart: traefik + helm: + values: | + traefik: + service: + spec: + loadBalancerIP: 1.2.3.4 + repoURL: https://helm.traefik.io/traefik + targetRevision: 10.14.2 +--- +apiVersion: argoproj.io/v1alpha1 +kind: ApplicationSet +spec: + template: + spec: + source: + repoURL: https://git.example.com/foo/bar.git + targetRevision: v1.2.0 +--- +# malformed applicationset as the source section is missing +apiVersion: argoproj.io/v1alpha1 +kind: ApplicationSet +spec: + template: + spec: + target: + namespace: testing +--- +apiVersion: argoproj.io/v1alpha1 +kind: ApplicationSet +metadata: + name: podinfo +spec: + generators: + - clusters: {} + template: + metadata: + name: '{{name}}-podinfo' + spec: + project: default + source: + repoURL: https://stefanprodan.github.io/podinfo + targetRevision: 6.0.0 + chart: podinfo + destination: + name: '{{server}}' + namespace: podinfo diff --git a/lib/modules/manager/argocd/extract.spec.ts b/lib/modules/manager/argocd/extract.spec.ts index d1841263c97d3a..6e11eb5f044ef1 100644 --- a/lib/modules/manager/argocd/extract.spec.ts +++ b/lib/modules/manager/argocd/extract.spec.ts @@ -4,6 +4,7 @@ import { extractPackageFile } from './extract'; const validApplication = Fixtures.get('validApplication.yml'); const malformedApplication = Fixtures.get('malformedApplications.yml'); const randomManifest = Fixtures.get('randomManifest.yml'); +const validApplicationSet = Fixtures.get('validApplicationSet.yml'); describe('modules/manager/argocd/extract', () => { describe('extractPackageFile()', () => { @@ -30,5 +31,41 @@ describe('modules/manager/argocd/extract', () => { expect(result.deps).toBeArrayOfSize(3); expect(result.deps).toMatchSnapshot(); }); + + it('supports applicationsets', () => { + const result = extractPackageFile( + validApplicationSet, + 'applicationsets.yml' + ); + expect(result).toEqual({ + deps: [ + { + currentValue: '2.4.1', + datasource: 'helm', + depName: 'kube-state-metrics', + registryUrls: [ + 'https://prometheus-community.github.io/helm-charts', + ], + }, + { + currentValue: '10.14.2', + datasource: 'helm', + depName: 'traefik', + registryUrls: ['https://helm.traefik.io/traefik'], + }, + { + currentValue: 'v1.2.0', + datasource: 'git-tags', + depName: 'https://git.example.com/foo/bar.git', + }, + { + currentValue: '6.0.0', + datasource: 'helm', + depName: 'podinfo', + registryUrls: ['https://stefanprodan.github.io/podinfo'], + }, + ], + }); + }); }); }); diff --git a/lib/modules/manager/argocd/extract.ts b/lib/modules/manager/argocd/extract.ts index b4b0839fc2260f..06d8fb796a4a6b 100644 --- a/lib/modules/manager/argocd/extract.ts +++ b/lib/modules/manager/argocd/extract.ts @@ -3,13 +3,21 @@ import { loadAll } from 'js-yaml'; import { GitTagsDatasource } from '../../datasource/git-tags'; import { HelmDatasource } from '../../datasource/helm'; import type { ExtractConfig, PackageDependency, PackageFile } from '../types'; -import type { ApplicationDefinition } from './types'; +import type { ApplicationDefinition, ApplicationSource } from './types'; import { fileTestRegex } from './util'; function createDependency( definition: ApplicationDefinition ): PackageDependency { - const source = definition?.spec?.source; + let source: ApplicationSource; + switch (definition.kind) { + case 'Application': + source = definition?.spec?.source; + break; + case 'ApplicationSet': + source = definition?.spec?.template?.spec?.source; + break; + } if ( !source || diff --git a/lib/modules/manager/argocd/types.ts b/lib/modules/manager/argocd/types.ts index 8a84291575d077..95420e8c0fd59f 100644 --- a/lib/modules/manager/argocd/types.ts +++ b/lib/modules/manager/argocd/types.ts @@ -1,9 +1,29 @@ -export interface ApplicationDefinition { +export interface KubernetesResource { + apiVersion: string; +} + +export interface ApplicationSource { + chart?: string; + repoURL: string; + targetRevision: string; +} + +export interface Application extends KubernetesResource { + kind: 'Application'; + spec: { + source: ApplicationSource; + }; +} + +export interface ApplicationSet extends KubernetesResource { + kind: 'ApplicationSet'; spec: { - source: { - chart?: string; - repoURL: string; - targetRevision: string; + template: { + spec: { + source: ApplicationSource; + }; }; }; } + +export type ApplicationDefinition = Application | ApplicationSet;