From 12914f49b849b8df3484f4d866cee5ec71412113 Mon Sep 17 00:00:00 2001 From: Sushil Kumar Date: Wed, 7 Jun 2017 14:28:35 -0700 Subject: [PATCH] .tgz will now be downloaded to "$HELM_HOME/cache/archive" directory Fixes https://github.com/kubernetes/helm/issues/2142 --- cmd/helm/install.go | 6 +++++- pkg/helm/helmpath/helmhome.go | 5 +++++ pkg/helm/helmpath/helmhome_unix_test.go | 1 + pkg/helm/helmpath/helmhome_windows_test.go | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) 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") }