diff --git a/cmd/helm/pull_test.go b/cmd/helm/pull_test.go index 8fc5d1ed4..1aca66100 100644 --- a/cmd/helm/pull_test.go +++ b/cmd/helm/pull_test.go @@ -163,7 +163,7 @@ func TestPullCmd(t *testing.T) { if err != nil { if tt.wantError { if tt.wantErrorMsg != "" && tt.wantErrorMsg == err.Error() { - t.Fatalf("%q reported error not equel wantErr, reported: %s, wanted: %s", tt.name, err, tt.wantErrorMsg) + t.Fatalf("Actual error %s, not equal to expected error %s", err, tt.wantErrorMsg) } return } diff --git a/pkg/action/pull.go b/pkg/action/pull.go index 360786153..fada49395 100644 --- a/pkg/action/pull.go +++ b/pkg/action/pull.go @@ -109,13 +109,18 @@ func (p *Pull) Run(chartRef string) (string, error) { if !filepath.IsAbs(ud) { ud = filepath.Join(p.DestDir, ud) } - if _, err := os.Stat(ud); err != nil { - if err := os.MkdirAll(ud, 0755); err != nil { + // Let udCheck to check conflict file/dir without replacing ud when untarDir is . + udCheck := ud + if udCheck == "." { + _, udCheck = filepath.Split(chartRef) + } + if _, err := os.Stat(udCheck); err != nil { + if err := os.MkdirAll(udCheck, 0755); err != nil { return out.String(), errors.Wrap(err, "failed to untar (mkdir)") } - } else if ud != "." { - return out.String(), errors.Errorf("failed to untar: a file or directory with the name %s already exists", ud) + } else { + return out.String(), errors.Errorf("failed to untar: a file or directory with the name %s already exists", udCheck) } return out.String(), chartutil.ExpandFile(ud, saved)