diff --git a/lib/modules/manager/helmfile/extract.spec.ts b/lib/modules/manager/helmfile/extract.spec.ts index 5564da312696a2bb343c567812a947c0f6b54dfd..c00387ea03b2dc28389b9f9c798043f639504a17 100644 --- a/lib/modules/manager/helmfile/extract.spec.ts +++ b/lib/modules/manager/helmfile/extract.spec.ts @@ -280,6 +280,46 @@ describe('modules/manager/helmfile/extract', () => { }); }); + it('parses a chart with an oci repository and non-oci one', () => { + const content = ` + repositories: + - name: oci-repo + url: ghcr.io/example/oci-repo + oci: true + - name: jenkins + url: https://charts.jenkins.io + + releases: + - name: example + version: 0.1.0 + chart: oci-repo/example + - name: jenkins + chart: jenkins/jenkins + version: 3.3.0 + `; + const fileName = 'helmfile.yaml'; + const result = extractPackageFile(content, fileName, { + aliases: { + 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', + }, + { + currentValue: '3.3.0', + depName: 'jenkins', + }, + ], + }); + }); + it('parses and replaces templating strings', () => { const filename = 'helmfile.yaml'; const result = extractPackageFile( diff --git a/lib/modules/manager/helmfile/extract.ts b/lib/modules/manager/helmfile/extract.ts index 05d5ac465349edf64cf62951e01e0238a2670fd4..feeff943ebd2fadc956062b771d76153384d57ca 100644 --- a/lib/modules/manager/helmfile/extract.ts +++ b/lib/modules/manager/helmfile/extract.ts @@ -2,6 +2,7 @@ import is from '@sindresorhus/is'; import { loadAll } from 'js-yaml'; import { logger } from '../../../logger'; import { regEx } from '../../../util/regex'; +import { DockerDatasource } from '../../datasource/docker'; import { HelmDatasource } from '../../datasource/helm'; import type { ExtractConfig, PackageDependency, PackageFile } from '../types'; import type { Doc } from './types'; @@ -86,6 +87,15 @@ export function extractPackageFile( .filter(is.string), }; + // 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 (repository?.oci) { + res.datasource = DockerDatasource.id; + res.packageName = aliases[repoName] + '/' + depName; + } + // By definition on helm the chart name should be lowercase letter + number + - // However helmfile support templating of that field if (!isValidChartName(res.depName)) { diff --git a/lib/modules/manager/helmfile/index.ts b/lib/modules/manager/helmfile/index.ts index 915cbcf5b01c7d7dcdddf8d676d258490b3b5c79..7de71e75bf0078b1003b2fee1cbd8dd5037ae73d 100644 --- a/lib/modules/manager/helmfile/index.ts +++ b/lib/modules/manager/helmfile/index.ts @@ -1,3 +1,4 @@ +import { DockerDatasource } from '../../datasource/docker'; import { HelmDatasource } from '../../datasource/helm'; export { extractPackageFile } from './extract'; @@ -9,4 +10,4 @@ export const defaultConfig = { fileMatch: ['(^|/)helmfile.yaml$'], }; -export const supportedDatasources = [HelmDatasource.id]; +export const supportedDatasources = [HelmDatasource.id, DockerDatasource.id]; diff --git a/lib/modules/manager/helmfile/types.ts b/lib/modules/manager/helmfile/types.ts index c84d8377f97189500858f3ce8ff032c9af68e0f4..f2a9593e7cd509130f9fbd6ea93fcfc28acb55cf 100644 --- a/lib/modules/manager/helmfile/types.ts +++ b/lib/modules/manager/helmfile/types.ts @@ -1,11 +1,16 @@ +interface Release { + name: string; + chart: string; + version: string; +} + +interface Repository { + name: string; + url: string; + oci?: boolean; +} + export interface Doc { - releases?: { - name: string; - chart: string; - version: string; - }[]; - repositories?: { - name: string; - url: string; - }[]; + releases?: Release[]; + repositories?: Repository[]; }