Skip to content

Commit e5e101c

Browse files
heyLuMarcAntoineRaymond
authored andcommitted
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>
1 parent 73c269f commit e5e101c

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

cmd/helm/pull_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,18 @@ func TestPullCmd(t *testing.T) {
147147
failExpect: "Failed to fetch chart version",
148148
wantError: true,
149149
},
150+
{
151+
name: "Chart fetch using repo URL with untardir",
152+
args: "signtest --version=0.1.0 --untar --untardir repo-url-test --repo " + srv.URL(),
153+
expectFile: "./signtest",
154+
expectDir: true,
155+
},
156+
{
157+
name: "Chart fetch using repo URL with untardir and previous pull",
158+
args: "signtest --version=0.1.0 --untar --untardir repo-url-test --repo " + srv.URL(),
159+
failExpect: "failed to untar",
160+
wantError: true,
161+
},
150162
{
151163
name: "Fetch OCI Chart",
152164
args: fmt.Sprintf("oci://%s/u/ocitestuser/oci-dependent-chart --version 0.1.0", ociSrv.RegistryURL),

pkg/action/pull.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,16 @@ func (p *Pull) Run(chartRef string) (string, error) {
121121
defer os.RemoveAll(dest)
122122
}
123123

124+
downloadSourceRef := chartRef
124125
if p.RepoURL != "" {
125126
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))
126127
if err != nil {
127128
return out.String(), err
128129
}
129-
chartRef = chartURL
130+
downloadSourceRef = chartURL
130131
}
131132

132-
saved, v, err := c.DownloadTo(chartRef, p.Version, dest)
133+
saved, v, err := c.DownloadTo(downloadSourceRef, p.Version, dest)
133134
if err != nil {
134135
return out.String(), err
135136
}

0 commit comments

Comments
 (0)