From ac27e2e6fe5a9a443a10f458f17dc39475e4f107 Mon Sep 17 00:00:00 2001 From: "Adam D. Cornett" Date: Fri, 5 Sep 2025 11:36:41 -0700 Subject: [PATCH] add support to scaffold oci helm registry charts Signed-off-by: Adam D. Cornett --- internal/plugins/helm/v1/api.go | 3 +++ internal/plugins/helm/v1/chartutil/chart.go | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/internal/plugins/helm/v1/api.go b/internal/plugins/helm/v1/api.go index 696d7bcca0d..d38f795ec89 100644 --- a/internal/plugins/helm/v1/api.go +++ b/internal/plugins/helm/v1/api.go @@ -108,6 +108,9 @@ func (p *createAPISubcommand) UpdateMetadata(cliMeta plugin.CLIMetadata, subcmdM $ %[1]s create api \ --helm-chart=/path/to/local/chart-archives/app-1.2.3.tgz + + $ %[1]s create api \ + --helm-chart=oci://charts.mycompany.com/example-namespace/app:1.2.3 `, cliMeta.CommandName) } diff --git a/internal/plugins/helm/v1/chartutil/chart.go b/internal/plugins/helm/v1/chartutil/chart.go index 5587c2175e1..59a3b8bafd5 100644 --- a/internal/plugins/helm/v1/chartutil/chart.go +++ b/internal/plugins/helm/v1/chartutil/chart.go @@ -27,6 +27,7 @@ import ( "helm.sh/helm/v3/pkg/cli" "helm.sh/helm/v3/pkg/downloader" "helm.sh/helm/v3/pkg/getter" + "helm.sh/helm/v3/pkg/registry" "helm.sh/helm/v3/pkg/repo" ) @@ -126,11 +127,19 @@ func LoadChart(opts Options) (*chart.Chart, error) { func downloadChart(destDir string, opts Options) (string, error) { settings := cli.New() getters := getter.All(settings) + + // Create registry client for OCI registry support + registryClient, err := registry.NewClient() + if err != nil { + return "", fmt.Errorf("failed to create registry client: %w", err) + } + c := downloader.ChartDownloader{ Out: os.Stderr, Getters: getters, RepositoryConfig: settings.RepositoryConfig, RepositoryCache: settings.RepositoryCache, + RegistryClient: registryClient, } if opts.Repo != "" { @@ -182,6 +191,12 @@ func fetchChartDependencies(chartPath string) error { settings := cli.New() getters := getter.All(settings) + // Create registry client for OCI registry support + registryClient, err := registry.NewClient() + if err != nil { + return fmt.Errorf("failed to create registry client: %w", err) + } + out := &bytes.Buffer{} man := &downloader.Manager{ Out: out, @@ -189,6 +204,7 @@ func fetchChartDependencies(chartPath string) error { Getters: getters, RepositoryConfig: settings.RepositoryConfig, RepositoryCache: settings.RepositoryCache, + RegistryClient: registryClient, } if err := man.Build(); err != nil { fmt.Println(out.String())