From 7fca7d505f29e419d758710443cfca1fc1417d7b Mon Sep 17 00:00:00 2001 From: Douglas Camata <159076+douglascamata@users.noreply.github.com> Date: Fri, 25 Jul 2025 15:54:56 +0200 Subject: [PATCH] Remove `CachePath` from `Entry` It will have to be customized manually in `ChartRepository` after its creation. Signed-off-by: Douglas Camata <159076+douglascamata@users.noreply.github.com> --- pkg/repo/chartrepo.go | 12 ++++-------- pkg/repo/chartrepo_test.go | 7 ++++--- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/pkg/repo/chartrepo.go b/pkg/repo/chartrepo.go index 6fb917701..251bf534d 100644 --- a/pkg/repo/chartrepo.go +++ b/pkg/repo/chartrepo.go @@ -48,7 +48,6 @@ type Entry struct { CAFile string `json:"caFile"` InsecureSkipTLSverify bool `json:"insecure_skip_tls_verify"` PassCredentialsAll bool `json:"pass_credentials_all"` - CachePath string `json:"cache_path"` } // ChartRepository represents a chart repository @@ -72,16 +71,11 @@ func NewChartRepository(cfg *Entry, getters getter.Providers) (*ChartRepository, return nil, errors.Errorf("could not find protocol handler for: %s", u.Scheme) } - cachePath := helmpath.CachePath("repository") - if cfg.CachePath != "" { - cachePath = cfg.CachePath - } - return &ChartRepository{ Config: cfg, IndexFile: NewIndexFile(), Client: client, - CachePath: cachePath, + CachePath: helmpath.CachePath("repository"), }, nil } @@ -245,12 +239,14 @@ func FindChartInAuthAndTLSAndPassRepoURL(repoURL, username, password, chartName, CAFile: caFile, Name: name, InsecureSkipTLSverify: insecureSkipTLSverify, - CachePath: cachePath, } r, err := NewChartRepository(&c, getters) if err != nil { return "", err } + if cachePath != "" { + r.CachePath = cachePath + } idx, err := r.DownloadIndexFile() if err != nil { return "", errors.Wrapf(err, "looks like %q is not a valid chart repository or cannot be reached", repoURL) diff --git a/pkg/repo/chartrepo_test.go b/pkg/repo/chartrepo_test.go index 9cc91be03..49d57cce0 100644 --- a/pkg/repo/chartrepo_test.go +++ b/pkg/repo/chartrepo_test.go @@ -83,14 +83,15 @@ func TestNewChartRepositoryWithCachePath(t *testing.T) { cacheDir := t.TempDir() r, err := NewChartRepository(&Entry{ - Name: testRepository, - URL: srv.URL, - CachePath: cacheDir, + Name: testRepository, + URL: srv.URL, }, getter.All(&cli.EnvSettings{})) if err != nil { t.Errorf("Problem creating chart repository from %s: %v", testRepository, err) } + r.CachePath = cacheDir + if err := r.Load(); err != nil { t.Errorf("Problem loading chart repository from %s: %v", testRepository, err) }