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) }