Skip to content

Commit cef8969

Browse files
authored
add support to scaffold oci helm registry charts (#6999)
Signed-off-by: Adam D. Cornett <adc@redhat.com>
1 parent 8eddc56 commit cef8969

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

internal/plugins/helm/v1/api.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ func (p *createAPISubcommand) UpdateMetadata(cliMeta plugin.CLIMetadata, subcmdM
108108
109109
$ %[1]s create api \
110110
--helm-chart=/path/to/local/chart-archives/app-1.2.3.tgz
111+
112+
$ %[1]s create api \
113+
--helm-chart=oci://charts.mycompany.com/example-namespace/app:1.2.3
111114
`, cliMeta.CommandName)
112115
}
113116

internal/plugins/helm/v1/chartutil/chart.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"helm.sh/helm/v3/pkg/cli"
2828
"helm.sh/helm/v3/pkg/downloader"
2929
"helm.sh/helm/v3/pkg/getter"
30+
"helm.sh/helm/v3/pkg/registry"
3031
"helm.sh/helm/v3/pkg/repo"
3132
)
3233

@@ -126,11 +127,19 @@ func LoadChart(opts Options) (*chart.Chart, error) {
126127
func downloadChart(destDir string, opts Options) (string, error) {
127128
settings := cli.New()
128129
getters := getter.All(settings)
130+
131+
// Create registry client for OCI registry support
132+
registryClient, err := registry.NewClient()
133+
if err != nil {
134+
return "", fmt.Errorf("failed to create registry client: %w", err)
135+
}
136+
129137
c := downloader.ChartDownloader{
130138
Out: os.Stderr,
131139
Getters: getters,
132140
RepositoryConfig: settings.RepositoryConfig,
133141
RepositoryCache: settings.RepositoryCache,
142+
RegistryClient: registryClient,
134143
}
135144

136145
if opts.Repo != "" {
@@ -182,13 +191,20 @@ func fetchChartDependencies(chartPath string) error {
182191
settings := cli.New()
183192
getters := getter.All(settings)
184193

194+
// Create registry client for OCI registry support
195+
registryClient, err := registry.NewClient()
196+
if err != nil {
197+
return fmt.Errorf("failed to create registry client: %w", err)
198+
}
199+
185200
out := &bytes.Buffer{}
186201
man := &downloader.Manager{
187202
Out: out,
188203
ChartPath: chartPath,
189204
Getters: getters,
190205
RepositoryConfig: settings.RepositoryConfig,
191206
RepositoryCache: settings.RepositoryCache,
207+
RegistryClient: registryClient,
192208
}
193209
if err := man.Build(); err != nil {
194210
fmt.Println(out.String())

0 commit comments

Comments
 (0)