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>
pull/31092/head
Douglas Camata 2 months ago
parent fecf20e668
commit 7fca7d505f
No known key found for this signature in database

@ -48,7 +48,6 @@ type Entry struct {
CAFile string `json:"caFile"` CAFile string `json:"caFile"`
InsecureSkipTLSverify bool `json:"insecure_skip_tls_verify"` InsecureSkipTLSverify bool `json:"insecure_skip_tls_verify"`
PassCredentialsAll bool `json:"pass_credentials_all"` PassCredentialsAll bool `json:"pass_credentials_all"`
CachePath string `json:"cache_path"`
} }
// ChartRepository represents a chart repository // 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) 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{ return &ChartRepository{
Config: cfg, Config: cfg,
IndexFile: NewIndexFile(), IndexFile: NewIndexFile(),
Client: client, Client: client,
CachePath: cachePath, CachePath: helmpath.CachePath("repository"),
}, nil }, nil
} }
@ -245,12 +239,14 @@ func FindChartInAuthAndTLSAndPassRepoURL(repoURL, username, password, chartName,
CAFile: caFile, CAFile: caFile,
Name: name, Name: name,
InsecureSkipTLSverify: insecureSkipTLSverify, InsecureSkipTLSverify: insecureSkipTLSverify,
CachePath: cachePath,
} }
r, err := NewChartRepository(&c, getters) r, err := NewChartRepository(&c, getters)
if err != nil { if err != nil {
return "", err return "", err
} }
if cachePath != "" {
r.CachePath = cachePath
}
idx, err := r.DownloadIndexFile() idx, err := r.DownloadIndexFile()
if err != nil { if err != nil {
return "", errors.Wrapf(err, "looks like %q is not a valid chart repository or cannot be reached", repoURL) return "", errors.Wrapf(err, "looks like %q is not a valid chart repository or cannot be reached", repoURL)

@ -83,14 +83,15 @@ func TestNewChartRepositoryWithCachePath(t *testing.T) {
cacheDir := t.TempDir() cacheDir := t.TempDir()
r, err := NewChartRepository(&Entry{ r, err := NewChartRepository(&Entry{
Name: testRepository, Name: testRepository,
URL: srv.URL, URL: srv.URL,
CachePath: cacheDir,
}, getter.All(&cli.EnvSettings{})) }, getter.All(&cli.EnvSettings{}))
if err != nil { if err != nil {
t.Errorf("Problem creating chart repository from %s: %v", testRepository, err) t.Errorf("Problem creating chart repository from %s: %v", testRepository, err)
} }
r.CachePath = cacheDir
if err := r.Load(); err != nil { if err := r.Load(); err != nil {
t.Errorf("Problem loading chart repository from %s: %v", testRepository, err) t.Errorf("Problem loading chart repository from %s: %v", testRepository, err)
} }

Loading…
Cancel
Save