diff --git a/cmd/helm/install.go b/cmd/helm/install.go index f438ebe04..30db2082c 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -399,7 +399,11 @@ func locateChartPath(repoURL, name, version string, verify bool, keyring, name = chartURL } - filename, _, err := dl.DownloadTo(name, version, ".") + if _, err := os.Stat(settings.Home.Archive()); os.IsNotExist(err) { + os.MkdirAll(settings.Home.Archive(), 0744) + } + + filename, _, err := dl.DownloadTo(name, version, settings.Home.Archive()) if err == nil { lname, err := filepath.Abs(filename) if err != nil { diff --git a/pkg/helm/helmpath/helmhome.go b/pkg/helm/helmpath/helmhome.go index c9aad70c6..2f9877f85 100644 --- a/pkg/helm/helmpath/helmhome.go +++ b/pkg/helm/helmpath/helmhome.go @@ -81,3 +81,8 @@ func (h Home) LocalRepository(elem ...string) string { func (h Home) Plugins() string { return h.Path("plugins") } + +// Archive returns the path to download chart archives +func (h Home) Archive() string { + return h.Path("cache", "archive") +} diff --git a/pkg/helm/helmpath/helmhome_unix_test.go b/pkg/helm/helmpath/helmhome_unix_test.go index 9c31a9c07..153e506e0 100644 --- a/pkg/helm/helmpath/helmhome_unix_test.go +++ b/pkg/helm/helmpath/helmhome_unix_test.go @@ -37,6 +37,7 @@ func TestHelmHome(t *testing.T) { isEq(t, hh.Cache(), "/r/repository/cache") isEq(t, hh.CacheIndex("t"), "/r/repository/cache/t-index.yaml") isEq(t, hh.Starters(), "/r/starters") + isEq(t, hh.Archive(), "/r/cache/archive") } func TestHelmHome_expand(t *testing.T) { diff --git a/pkg/helm/helmpath/helmhome_windows_test.go b/pkg/helm/helmpath/helmhome_windows_test.go index 11b2e9686..d29c29b60 100644 --- a/pkg/helm/helmpath/helmhome_windows_test.go +++ b/pkg/helm/helmpath/helmhome_windows_test.go @@ -34,4 +34,5 @@ func TestHelmHome(t *testing.T) { isEq(t, hh.Cache(), "r:\\repository\\cache") isEq(t, hh.CacheIndex("t"), "r:\\repository\\cache\\t-index.yaml") isEq(t, hh.Starters(), "r:\\starters") + isEq(t, hh.Archive(), "r:\\cache\\archive") }