Fix `helm pull` untar dir check with repo urls

The existing check worked for `helm pull downloaded-repo/chart-name`,
but often does not work when using `--repo-url`, depending on the urls
used by the charts.

Signed-off-by: Luna Stadler <luc@spreadshirt.net>
(cherry picked from commit 1031b67fff)
pull/31573/head
Luna Stadler 6 months ago committed by Matt Farina
parent 5dff7ce71b
commit 8112d47cbb

@ -147,6 +147,18 @@ func TestPullCmd(t *testing.T) {
failExpect: "Failed to fetch chart version",
wantError: true,
},
{
name: "Chart fetch using repo URL with untardir",
args: "signtest --version=0.1.0 --untar --untardir repo-url-test --repo " + srv.URL(),
expectFile: "./signtest",
expectDir: true,
},
{
name: "Chart fetch using repo URL with untardir and previous pull",
args: "signtest --version=0.1.0 --untar --untardir repo-url-test --repo " + srv.URL(),
failExpect: "failed to untar",
wantError: true,
},
{
name: "Fetch OCI Chart",
args: fmt.Sprintf("oci://%s/u/ocitestuser/oci-dependent-chart --version 0.1.0", ociSrv.RegistryURL),

@ -121,15 +121,16 @@ func (p *Pull) Run(chartRef string) (string, error) {
defer os.RemoveAll(dest)
}
downloadSourceRef := chartRef
if p.RepoURL != "" {
chartURL, err := repo.FindChartInAuthAndTLSAndPassRepoURL(p.RepoURL, p.Username, p.Password, chartRef, p.Version, p.CertFile, p.KeyFile, p.CaFile, p.InsecureSkipTLSverify, p.PassCredentialsAll, getter.All(p.Settings))
if err != nil {
return out.String(), err
}
chartRef = chartURL
downloadSourceRef = chartURL
}
saved, v, err := c.DownloadTo(chartRef, p.Version, dest)
saved, v, err := c.DownloadTo(downloadSourceRef, p.Version, dest)
if err != nil {
return out.String(), err
}

Loading…
Cancel
Save