diff --git a/pkg/action/install.go b/pkg/action/install.go index 7e38de913..605915324 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -991,6 +991,11 @@ func (c *ChartPathOptions) LocateChart(name string, settings *cli.EnvSettings) ( if c.resolvedSource == nil && c.RepoURL != "" { c.resolvedSource = &rcommon.ChartSource{RepoURL: c.RepoURL} } + // Fallback for direct OCI references (e.g. oci://registry.com/chart:tag) + // where RepoURL is empty and the downloader may not have populated it. + if c.resolvedSource == nil && registry.IsOCI(name) { + c.resolvedSource = &rcommon.ChartSource{RegistryRef: name} + } lname, err := filepath.Abs(filename) if err != nil { diff --git a/pkg/downloader/chart_downloader.go b/pkg/downloader/chart_downloader.go index 0334b7534..99acca228 100644 --- a/pkg/downloader/chart_downloader.go +++ b/pkg/downloader/chart_downloader.go @@ -150,6 +150,15 @@ func (c *ChartDownloader) DownloadTo(ref, version, dest string) (string, *proven } } + // Populate source provenance for cached OCI charts. + // The ref and digest are already known from ResolveChartVersion. + if found && u.Scheme == registry.OCIScheme { + c.ResolvedSource = &rcommon.ChartSource{ + RegistryRef: ref, + Digest: hash, + } + } + if !found { c.Options = append(c.Options, getter.WithAcceptHeader("application/gzip,application/octet-stream")) @@ -266,6 +275,14 @@ func (c *ChartDownloader) DownloadToCache(ref, version string) (string, *provena pth, err = c.Cache.Get(digest32, CacheChart) if err == nil { slog.Debug("found chart in cache", "id", digestString) + + // Populate source provenance for cached OCI charts. + if u.Scheme == registry.OCIScheme { + c.ResolvedSource = &rcommon.ChartSource{ + RegistryRef: ref, + Digest: digestString, + } + } } } if len(digest) == 0 || err != nil {