From 0cb17e5aa89e2d6cf49cb4e7f09b602af58adfbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20=22Pisco=22=20Fernandes?= Date: Fri, 27 Oct 2023 13:13:16 +0100 Subject: [PATCH] feat(helm): Add support for OCI chart repositories (#445) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: João Fernandes --- README.md | 2 ++ pkg/tool/helm.go | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/README.md b/README.md index 8d6a8201..cc3d36e3 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,7 @@ Notice that if no config file is specified, then `ct.yaml` (or any of the suppor #### Using private chart repositories When adding chart-repos you can specify additional arguments for the `helm repo add` command using `helm-repo-extra-args` on a per-repo basis. +You can also specify OCI registries which will be added using the `helm registry login` command, they also support the `helm-repo-extra-args` for authentication. This could for example be used to authenticate a private chart repository. `config.yaml`: @@ -140,6 +141,7 @@ chart-repos: - incubator=https://incubator.io - basic-auth=https://private.com - ssl-repo=https://self-signed.ca + - oci-registry=oci://nice-oci-registry.pt helm-repo-extra-args: - ssl-repo=--ca-file ./my-ca.crt ``` diff --git a/pkg/tool/helm.go b/pkg/tool/helm.go index 92e26e9c..2f22986d 100644 --- a/pkg/tool/helm.go +++ b/pkg/tool/helm.go @@ -16,6 +16,7 @@ package tool import ( "fmt" + "strings" "github.com/helm/chart-testing/v3/pkg/exec" ) @@ -35,6 +36,13 @@ func NewHelm(exec exec.ProcessExecutor, extraArgs []string, extraSetArgs []strin } func (h Helm) AddRepo(name string, url string, extraArgs []string) error { + const ociPrefix string = "oci://" + + if strings.HasPrefix(url, ociPrefix) { + registryDomain := url[len(ociPrefix):] + return h.exec.RunProcess("helm", "registry", "login", registryDomain, extraArgs) + } + return h.exec.RunProcess("helm", "repo", "add", name, url, extraArgs) }