From a3da4e232dbd1dd5378536d4f95a7b41ea5b0ea9 Mon Sep 17 00:00:00 2001 From: Houston Putman Date: Mon, 21 Mar 2022 15:41:01 -0400 Subject: [PATCH] Apply provenance file ending to URL path Signed-off-by: Houston Putman --- pkg/downloader/chart_downloader.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/pkg/downloader/chart_downloader.go b/pkg/downloader/chart_downloader.go index 3feb5b702..b3ca5b032 100644 --- a/pkg/downloader/chart_downloader.go +++ b/pkg/downloader/chart_downloader.go @@ -116,13 +116,21 @@ func (c *ChartDownloader) DownloadTo(ref, version, dest string) (string, *proven // If provenance is requested, verify it. ver := &provenance.Verification{} if c.Verify > VerifyNever { - body, err := g.Get(u.String() + ".prov") + initialURL := u.String() + u.Path += ".prov" + body, err := g.Get(u.String()) if err != nil { - if c.Verify == VerifyAlways { - return destfile, ver, errors.Errorf("failed to fetch provenance %q", u.String()+".prov") + // Try again adding the ".prov" to the end of the URL (not the path). + // This maintains backwards-compatibility with chart Repos built to work with older versions of Helm + var retryErr error + body, retryErr = g.Get(initialURL + ".prov") + if retryErr != nil { + if c.Verify == VerifyAlways { + return destfile, ver, errors.Errorf("failed to fetch provenance %q", u.String()) + } + fmt.Fprintf(c.Out, "WARNING: Verification not found for %s: %s\n", ref, err) + return destfile, ver, nil } - fmt.Fprintf(c.Out, "WARNING: Verification not found for %s: %s\n", ref, err) - return destfile, ver, nil } provfile := destfile + ".prov" if err := fileutil.AtomicWriteFile(provfile, body, 0644); err != nil {