diff --git a/pkg/downloader/chart_downloader.go b/pkg/downloader/chart_downloader.go index f5d1deac9..35405dfbb 100644 --- a/pkg/downloader/chart_downloader.go +++ b/pkg/downloader/chart_downloader.go @@ -164,6 +164,10 @@ func (c *ChartDownloader) ResolveChartVersion(ref, version string) (*url.URL, er } if registry.IsOCI(u.String()) { + if c.RegistryClient == nil { + return nil, fmt.Errorf("unable to resolve chart version for %s, missing registry client", ref) + } + return c.RegistryClient.ValidateReference(ref, version, u) } diff --git a/pkg/downloader/chart_downloader_test.go b/pkg/downloader/chart_downloader_test.go index 26dcc58ff..0762650cf 100644 --- a/pkg/downloader/chart_downloader_test.go +++ b/pkg/downloader/chart_downloader_test.go @@ -20,6 +20,8 @@ import ( "path/filepath" "testing" + "github.com/stretchr/testify/assert" + "helm.sh/helm/v4/internal/test/ensure" "helm.sh/helm/v4/pkg/cli" "helm.sh/helm/v4/pkg/getter" @@ -324,6 +326,22 @@ func TestDownloadTo_VerifyLater(t *testing.T) { } } +func TestDownloadTo_MissingRegistryClient(t *testing.T) { + c := ChartDownloader{ + Getters: getter.Providers{ + getter.Provider{ + Schemes: []string{"oci"}, + New: getter.NewOCIGetter, + }, + }, + } + + ref := "oci://someurl" + version := "latest" + _, _, err := c.DownloadTo(ref, version, t.TempDir()) + assert.Error(t, err) +} + func TestScanReposForURL(t *testing.T) { c := ChartDownloader{ Out: os.Stderr,