Skip to content

Commit

Permalink
feat(helm): Add support for OCI chart repositories (#445)
Browse files Browse the repository at this point in the history
Signed-off-by: João Fernandes <[email protected]>
  • Loading branch information
jcsf authored Oct 27, 2023
1 parent 10aaf46 commit 0cb17e5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`:
Expand All @@ -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
```
Expand Down
8 changes: 8 additions & 0 deletions pkg/tool/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package tool

import (
"fmt"
"strings"

"github.com/helm/chart-testing/v3/pkg/exec"
)
Expand All @@ -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)
}

Expand Down

0 comments on commit 0cb17e5

Please sign in to comment.