Skip to content

Commit

Permalink
feat(manager/terraform): support OCI registry in helm_release `reposi…
Browse files Browse the repository at this point in the history
…tory` (#20237)

Co-authored-by: Sebastian Poxhofer <secustor@users.noreply.github.com>
  • Loading branch information
jalaziz and secustor authored Feb 7, 2023
1 parent f805a82 commit c127ead
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
8 changes: 8 additions & 0 deletions lib/modules/manager/terraform/__fixtures__/helm.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,11 @@ resource "helm_release" "karpenter" {
chart = "oci://public.ecr.aws/karpenter/karpenter"
version = "v0.22.1"
}

## chart in OCI registry
resource "helm_release" "karpenter_oci_repo" {
name = "karpenter"
repository = "oci://public.ecr.aws/karpenter"
chart = "karpenter"
version = "v0.22.1"
}
9 changes: 8 additions & 1 deletion lib/modules/manager/terraform/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ describe('modules/manager/terraform/extract', () => {

it('extract helm releases', async () => {
const res = await extractPackageFile(helm, 'helm.tf', {});
expect(res?.deps).toHaveLength(7);
expect(res?.deps).toHaveLength(8);
expect(res?.deps.filter((dep) => dep.skipReason)).toHaveLength(2);
expect(res?.deps).toIncludeAllPartialMembers([
{
Expand Down Expand Up @@ -623,6 +623,13 @@ describe('modules/manager/terraform/extract', () => {
depName: 'public.ecr.aws/karpenter/karpenter',
depType: 'helm_release',
},
{
currentValue: 'v0.22.1',
datasource: 'docker',
depName: 'karpenter',
depType: 'helm_release',
registryUrls: ['https://public.ecr.aws/karpenter'],
},
]);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,15 @@ export class HelmReleaseExtractor extends DependencyExtractor {
datasource: HelmDatasource.id,
};
if (is.nonEmptyString(helmRelease.repository)) {
dep.registryUrls = [helmRelease.repository];
if (isOCIRegistry(helmRelease.repository)) {
// For oci repos, we remove the oci:// and use the docker datasource
dep.registryUrls = [
helmRelease.repository.replace('oci://', 'https://'),
];
dep.datasource = DockerDatasource.id;
} else {
dep.registryUrls = [helmRelease.repository];
}
}
if (!helmRelease.chart) {
dep.skipReason = 'invalid-name';
Expand Down

0 comments on commit c127ead

Please sign in to comment.