Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(helm): Add support for OCI chart repositories #445

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading