Commit f476f83e authored by Sushil Kumar's avatar Sushil Kumar Committed by Adam Reese

<chart>.tgz will now be downloaded to "$HELM_HOME/cache/archive" directory (#2558)

* <chart>.tgz  will now be downloaded to "$HELM_HOME/cache/archive" directory

Fixes https://github.com/kubernetes/helm/issues/2142

* Added archive location to helm init
parent 9c8a99b5
...@@ -273,6 +273,7 @@ func ensureDirectories(home helmpath.Home, out io.Writer) error { ...@@ -273,6 +273,7 @@ func ensureDirectories(home helmpath.Home, out io.Writer) error {
home.LocalRepository(), home.LocalRepository(),
home.Plugins(), home.Plugins(),
home.Starters(), home.Starters(),
home.Archive(),
} }
for _, p := range configDirectories { for _, p := range configDirectories {
if fi, err := os.Stat(p); err != nil { if fi, err := os.Stat(p); err != nil {
......
...@@ -399,7 +399,11 @@ func locateChartPath(repoURL, name, version string, verify bool, keyring, ...@@ -399,7 +399,11 @@ func locateChartPath(repoURL, name, version string, verify bool, keyring,
name = chartURL 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 { if err == nil {
lname, err := filepath.Abs(filename) lname, err := filepath.Abs(filename)
if err != nil { if err != nil {
......
...@@ -81,3 +81,8 @@ func (h Home) LocalRepository(elem ...string) string { ...@@ -81,3 +81,8 @@ func (h Home) LocalRepository(elem ...string) string {
func (h Home) Plugins() string { func (h Home) Plugins() string {
return h.Path("plugins") return h.Path("plugins")
} }
// Archive returns the path to download chart archives
func (h Home) Archive() string {
return h.Path("cache", "archive")
}
...@@ -37,6 +37,7 @@ func TestHelmHome(t *testing.T) { ...@@ -37,6 +37,7 @@ func TestHelmHome(t *testing.T) {
isEq(t, hh.Cache(), "/r/repository/cache") isEq(t, hh.Cache(), "/r/repository/cache")
isEq(t, hh.CacheIndex("t"), "/r/repository/cache/t-index.yaml") isEq(t, hh.CacheIndex("t"), "/r/repository/cache/t-index.yaml")
isEq(t, hh.Starters(), "/r/starters") isEq(t, hh.Starters(), "/r/starters")
isEq(t, hh.Archive(), "/r/cache/archive")
} }
func TestHelmHome_expand(t *testing.T) { func TestHelmHome_expand(t *testing.T) {
......
...@@ -34,4 +34,5 @@ func TestHelmHome(t *testing.T) { ...@@ -34,4 +34,5 @@ func TestHelmHome(t *testing.T) {
isEq(t, hh.Cache(), "r:\\repository\\cache") isEq(t, hh.Cache(), "r:\\repository\\cache")
isEq(t, hh.CacheIndex("t"), "r:\\repository\\cache\\t-index.yaml") isEq(t, hh.CacheIndex("t"), "r:\\repository\\cache\\t-index.yaml")
isEq(t, hh.Starters(), "r:\\starters") isEq(t, hh.Starters(), "r:\\starters")
isEq(t, hh.Archive(), "r:\\cache\\archive")
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment