Files
renovate/lib/modules/manager/sveltos/extract.ts
Sebastian Poxhofer be13c9f5f7 feat(manager): share OCI Helm chart resolution across managers (#45760)
* feat(manager): share OCI Helm chart resolution across managers

Add getOciChartDep() to helmv3/oci.ts and use it in argocd, fleet, flux,
helmfile, helmsman, helmv3, kustomize, sveltos, terraform and vendir.

- set pinDigests: false for OCI charts in all of them
- apply registryAliases to OCI charts in argocd, helmfile and helmsman
- keep the registry port in terraform helm_release repositories
- skip fleet OCI charts without a version instead of using 'undefined'

* docs(manager/helmv3): correct the OCI chart pinDigests rationale

* refactor(manager/helmfile): drop redundant OCI repository url guard

The repository schema already requires url to be a string, so the falsy
branch could not be reached by parsed input and left the patch partially
covered.
2026-09-09 13:51:30 +00:00

89 lines
2.2 KiB
TypeScript

import { coerceArray } from '../../../util/array.ts';
import { parseYaml } from '../../../util/yaml.ts';
import { HelmDatasource } from '../../datasource/helm/index.ts';
import { getOciChartDep, isOCIRegistry } from '../helmv3/oci.ts';
import type {
ExtractConfig,
PackageDependency,
PackageFileContent,
} from '../types.ts';
import { ProfileDefinition, type SveltosHelmSource } from './schema.ts';
import { removeRepositoryName } from './util.ts';
export function extractPackageFile(
content: string,
packageFile: string,
config?: ExtractConfig,
): PackageFileContent | null {
const definitions = parseYaml(content, {
customSchema: ProfileDefinition,
failureBehaviour: 'filter',
});
const deps: PackageDependency[] = [];
for (const definition of definitions) {
const extractedDeps = extractDefinition(definition, config);
deps.push(...extractedDeps);
}
return deps.length ? { deps } : null;
}
export function extractDefinition(
definition: ProfileDefinition,
config?: ExtractConfig,
): PackageDependency[] {
return processAppSpec(definition, config);
}
function processHelmCharts(
source: SveltosHelmSource,
registryAliases: Record<string, string> | undefined,
): PackageDependency {
const dep: PackageDependency = {
depName: source.chartName,
currentValue: source.chartVersion,
};
if (isOCIRegistry(source.repositoryURL)) {
return {
...dep,
...getOciChartDep(
source.repositoryURL,
source.chartName,
registryAliases,
),
};
}
return {
...dep,
packageName: removeRepositoryName(source.repositoryName, source.chartName),
registryUrls: [source.repositoryURL],
datasource: HelmDatasource.id,
};
}
function processAppSpec(
definition: ProfileDefinition,
config?: ExtractConfig,
): PackageDependency[] {
const deps: PackageDependency[] = [];
const depType = definition.kind;
const helmCharts =
definition.kind === 'ClusterPromotion'
? definition.spec?.profileSpec?.helmCharts
: definition.spec?.helmCharts;
for (const source of coerceArray(helmCharts)) {
const dep = processHelmCharts(source, config?.registryAliases);
dep.depType = depType;
deps.push(dep);
}
return deps;
}