fix: populate chart source provenance for cached OCI charts

Addresses review feedback on ResolvedSource not being populated when
OCI charts are served from the local cache. Also adds a fallback for
direct oci:// references when --repo is not used.

- DownloadTo: populate ResolvedSource on cache-hit path
- DownloadToCache: populate ResolvedSource on cache-hit path
- LocateChart: add OCI ref fallback when RepoURL is empty

Signed-off-by: iammehrabsandhu <user.127.888@users.noreply.github.com>
pull/32018/head
iammehrabsandhu 4 days ago
parent d5cc5137af
commit c48942801e

@ -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 {

@ -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 {

Loading…
Cancel
Save