diff --git a/cmd/helm/repo_add.go b/cmd/helm/repo_add.go index 77a64cc89..47b7f5996 100644 --- a/cmd/helm/repo_add.go +++ b/cmd/helm/repo_add.go @@ -90,7 +90,7 @@ func addRepository(name, url, username, password string, home helmpath.Home, cer return fmt.Errorf("repository name (%s) already exists, please specify a different name", name) } - cif := home.CacheIndex(name) + cif := home.CacheRelativeIndex(name) c := repo.Entry{ Name: name, Cache: cif, diff --git a/pkg/helm/helmpath/helmhome.go b/pkg/helm/helmpath/helmhome.go index b5ec4909e..9d2899e4c 100644 --- a/pkg/helm/helmpath/helmhome.go +++ b/pkg/helm/helmpath/helmhome.go @@ -57,8 +57,13 @@ func (h Home) Cache() string { // CacheIndex returns the path to an index for the given named repository. func (h Home) CacheIndex(name string) string { + return h.Path("repository", "cache", h.CacheRelativeIndex(name)) +} + +// CacheRelativeIndex returns the relative path to an index for the given named repository from the cache path. +func (h Home) CacheRelativeIndex(name string) string { target := fmt.Sprintf("%s-index.yaml", name) - return h.Path("repository", "cache", target) + return filepath.Join(target) } // Starters returns the path to the Helm starter packs. diff --git a/pkg/helm/helmpath/helmhome_unix_test.go b/pkg/helm/helmpath/helmhome_unix_test.go index 494d0f6b4..6a0d77bb6 100644 --- a/pkg/helm/helmpath/helmhome_unix_test.go +++ b/pkg/helm/helmpath/helmhome_unix_test.go @@ -36,6 +36,7 @@ func TestHelmHome(t *testing.T) { isEq(t, hh.LocalRepository(), "/r/repository/local") isEq(t, hh.Cache(), "/r/repository/cache") isEq(t, hh.CacheIndex("t"), "/r/repository/cache/t-index.yaml") + isEq(t, hh.CacheRelativeIndex("t"), "t-index.yaml") isEq(t, hh.Starters(), "/r/starters") isEq(t, hh.Archive(), "/r/cache/archive") isEq(t, hh.TLSCaCert(), "/r/ca.pem") diff --git a/pkg/helm/helmpath/helmhome_windows_test.go b/pkg/helm/helmpath/helmhome_windows_test.go index e416bfd58..fd7b27e63 100644 --- a/pkg/helm/helmpath/helmhome_windows_test.go +++ b/pkg/helm/helmpath/helmhome_windows_test.go @@ -33,6 +33,7 @@ func TestHelmHome(t *testing.T) { isEq(t, hh.LocalRepository(), "r:\\repository\\local") isEq(t, hh.Cache(), "r:\\repository\\cache") isEq(t, hh.CacheIndex("t"), "r:\\repository\\cache\\t-index.yaml") + isEq(t, hh.CacheRelativeIndex("t"), "t-index.yaml") isEq(t, hh.Starters(), "r:\\starters") isEq(t, hh.Archive(), "r:\\cache\\archive") isEq(t, hh.TLSCaCert(), "r:\\ca.pem")