Skip to content

Commit b9fed09

Browse files
committed
add support to scaffold oci helm registry charts
Signed-off-by: Adam D. Cornett <adc@redhat.com>
1 parent e27207c commit b9fed09

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

internal/plugins/helm/v1/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ func (p *createAPISubcommand) UpdateMetadata(cliMeta plugin.CLIMetadata, subcmdM
115115
func (p *createAPISubcommand) BindFlags(fs *pflag.FlagSet) {
116116
fs.SortFlags = false
117117

118-
fs.StringVar(&p.options.chartOptions.Chart, helmChartFlag, "", "helm chart")
119-
fs.StringVar(&p.options.chartOptions.Repo, helmChartRepoFlag, "", "helm chart repository")
118+
fs.StringVar(&p.options.chartOptions.Chart, helmChartFlag, "", "helm chart, if using an OCI registry, this needs to contain the entire chart address, just like the helm cli")
119+
fs.StringVar(&p.options.chartOptions.Repo, helmChartRepoFlag, "", "helm chart repository, only provide for non-OCI repositories")
120120
fs.StringVar(&p.options.chartOptions.Version, helmChartVersionFlag, "", "helm chart version (default: latest)")
121121

122122
fs.StringVar(&p.options.CRDVersion, crdVersionFlag, defaultCrdVersion, "crd version to generate")

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)