From 1597fcb0bce2a135f0aa5ffacbc04a4da1d7d96d Mon Sep 17 00:00:00 2001 From: Ryan Payton Date: Fri, 25 Aug 2017 15:49:40 -0700 Subject: [PATCH 1/3] added a RelativeIndex() func to helmhome to return a relative path to the index files. Also updated repo_add.go to use this new fun --- cmd/helm/repo_add.go | 2 +- pkg/helm/helmpath/helmhome.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/helm/repo_add.go b/cmd/helm/repo_add.go index b172d016c..7fb20d02d 100644 --- a/cmd/helm/repo_add.go +++ b/cmd/helm/repo_add.go @@ -86,7 +86,7 @@ func addRepository(name, url string, home helmpath.Home, certFile, keyFile, caFi return fmt.Errorf("repository name (%s) already exists, please specify a different name", name) } - cif := home.CacheIndex(name) + cif := home.RelativeIndex(name) c := repo.Entry{ Name: name, Cache: cif, diff --git a/pkg/helm/helmpath/helmhome.go b/pkg/helm/helmpath/helmhome.go index b5ec4909e..3c35c3b69 100644 --- a/pkg/helm/helmpath/helmhome.go +++ b/pkg/helm/helmpath/helmhome.go @@ -61,6 +61,12 @@ func (h Home) CacheIndex(name string) string { return h.Path("repository", "cache", target) } +// RelativeIndex returns the relative path to an index for the given named repository. +func (h Home) RelativeIndex(name string) string { + target := fmt.Sprintf("%s-index.yaml", name) + return filepath.Join(target) +} + // Starters returns the path to the Helm starter packs. func (h Home) Starters() string { return h.Path("starters") From a7930fd90672eb7888fcad56dea94363f16d903b Mon Sep 17 00:00:00 2001 From: Ryan Payton Date: Mon, 28 Aug 2017 19:06:18 -0700 Subject: [PATCH 2/3] adding unit tests for #2839 --- pkg/helm/helmpath/helmhome_unix_test.go | 1 + pkg/helm/helmpath/helmhome_windows_test.go | 1 + 2 files changed, 2 insertions(+) diff --git a/pkg/helm/helmpath/helmhome_unix_test.go b/pkg/helm/helmpath/helmhome_unix_test.go index 494d0f6b4..634faeef7 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.RelativeIndex("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..43db9b8f1 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.RelativeIndex("t"), "t-index.yaml") isEq(t, hh.Starters(), "r:\\starters") isEq(t, hh.Archive(), "r:\\cache\\archive") isEq(t, hh.TLSCaCert(), "r:\\ca.pem") From 984dd548389eecfacbdc97eb1b797176655849d5 Mon Sep 17 00:00:00 2001 From: "Christopher A. Stelma" Date: Thu, 8 Mar 2018 17:57:40 -0800 Subject: [PATCH 3/3] rename and use CacheRelativeIndex to do something --- cmd/helm/repo_add.go | 2 +- pkg/helm/helmpath/helmhome.go | 7 +++---- pkg/helm/helmpath/helmhome_unix_test.go | 2 +- pkg/helm/helmpath/helmhome_windows_test.go | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/cmd/helm/repo_add.go b/cmd/helm/repo_add.go index 7fb20d02d..669df9b56 100644 --- a/cmd/helm/repo_add.go +++ b/cmd/helm/repo_add.go @@ -86,7 +86,7 @@ func addRepository(name, url string, home helmpath.Home, certFile, keyFile, caFi return fmt.Errorf("repository name (%s) already exists, please specify a different name", name) } - cif := home.RelativeIndex(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 3c35c3b69..9d2899e4c 100644 --- a/pkg/helm/helmpath/helmhome.go +++ b/pkg/helm/helmpath/helmhome.go @@ -57,12 +57,11 @@ func (h Home) Cache() string { // CacheIndex returns the path to an index for the given named repository. func (h Home) CacheIndex(name string) string { - target := fmt.Sprintf("%s-index.yaml", name) - return h.Path("repository", "cache", target) + return h.Path("repository", "cache", h.CacheRelativeIndex(name)) } -// RelativeIndex returns the relative path to an index for the given named repository. -func (h Home) RelativeIndex(name string) string { +// 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 filepath.Join(target) } diff --git a/pkg/helm/helmpath/helmhome_unix_test.go b/pkg/helm/helmpath/helmhome_unix_test.go index 634faeef7..6a0d77bb6 100644 --- a/pkg/helm/helmpath/helmhome_unix_test.go +++ b/pkg/helm/helmpath/helmhome_unix_test.go @@ -36,7 +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.RelativeIndex("t"), "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 43db9b8f1..fd7b27e63 100644 --- a/pkg/helm/helmpath/helmhome_windows_test.go +++ b/pkg/helm/helmpath/helmhome_windows_test.go @@ -33,7 +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.RelativeIndex("t"), "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")