From 705a4d71ac93f5b11da7d9d45b951e5e027b22b2 Mon Sep 17 00:00:00 2001 From: Reinaldo de Souza Jr Date: Fri, 25 Sep 2020 19:00:38 +0200 Subject: [PATCH] Add --chart-cache config option Signed-off-by: Reinaldo de Souza Jr --- cmd/helm/plugin_test.go | 2 ++ cmd/helm/root.go | 1 + cmd/helm/testdata/helmhome/helm/plugins/fullenv/fullenv.sh | 1 + cmd/helm/testdata/output/env-comp.txt | 1 + pkg/cli/environment.go | 5 +++++ 5 files changed, 10 insertions(+) diff --git a/cmd/helm/plugin_test.go b/cmd/helm/plugin_test.go index 0bf867f2a..945608cfb 100644 --- a/cmd/helm/plugin_test.go +++ b/cmd/helm/plugin_test.go @@ -86,6 +86,7 @@ func TestLoadPlugins(t *testing.T) { settings.PluginsDirectory = "testdata/helmhome/helm/plugins" settings.RepositoryConfig = "testdata/helmhome/helm/repositories.yaml" settings.RepositoryCache = "testdata/helmhome/helm/repository" + settings.ChartCache = "testdata/helmhome/helm/charts" var ( out bytes.Buffer @@ -99,6 +100,7 @@ func TestLoadPlugins(t *testing.T) { "testdata/helmhome/helm/plugins", "testdata/helmhome/helm/repositories.yaml", "testdata/helmhome/helm/repository", + "testdata/helmhome/helm/charts", os.Args[0], }, "\n") diff --git a/cmd/helm/root.go b/cmd/helm/root.go index cc97a5541..dc176214c 100644 --- a/cmd/helm/root.go +++ b/cmd/helm/root.go @@ -54,6 +54,7 @@ Environment variables: | $HELM_MAX_HISTORY | set the maximum number of helm release history. | | $HELM_NAMESPACE | set the namespace used for the helm operations. | | $HELM_NO_PLUGINS | disable plugins. Set HELM_NO_PLUGINS=1 to disable plugins. | +| $HELM_CHART_CACHE | set the path to the chart cache directory | | $HELM_PLUGINS | set the path to the plugins directory | | $HELM_REGISTRY_CONFIG | set the path to the registry config file. | | $HELM_REPOSITORY_CACHE | set the path to the repository cache directory | diff --git a/cmd/helm/testdata/helmhome/helm/plugins/fullenv/fullenv.sh b/cmd/helm/testdata/helmhome/helm/plugins/fullenv/fullenv.sh index 2efad9b3c..6d997cfc8 100755 --- a/cmd/helm/testdata/helmhome/helm/plugins/fullenv/fullenv.sh +++ b/cmd/helm/testdata/helmhome/helm/plugins/fullenv/fullenv.sh @@ -4,4 +4,5 @@ echo $HELM_PLUGIN_DIR echo $HELM_PLUGINS echo $HELM_REPOSITORY_CONFIG echo $HELM_REPOSITORY_CACHE +echo $HELM_CHART_CACHE echo $HELM_BIN diff --git a/cmd/helm/testdata/output/env-comp.txt b/cmd/helm/testdata/output/env-comp.txt index 3739d8bc1..6ca63e1b3 100644 --- a/cmd/helm/testdata/output/env-comp.txt +++ b/cmd/helm/testdata/output/env-comp.txt @@ -1,5 +1,6 @@ HELM_BIN HELM_CACHE_HOME +HELM_CHART_CACHE HELM_CONFIG_HOME HELM_DATA_HOME HELM_DEBUG diff --git a/pkg/cli/environment.go b/pkg/cli/environment.go index 4f3abc08b..20c598586 100644 --- a/pkg/cli/environment.go +++ b/pkg/cli/environment.go @@ -62,6 +62,8 @@ type EnvSettings struct { RepositoryConfig string // RepositoryCache is the path to the repository cache directory. RepositoryCache string + // ChartCache is the path to the chart cache directory. + ChartCache string // PluginsDirectory is the path to the plugins directory. PluginsDirectory string // MaxHistory is the max release history maintained. @@ -81,6 +83,7 @@ func New() *EnvSettings { RegistryConfig: envOr("HELM_REGISTRY_CONFIG", helmpath.ConfigPath("registry.json")), RepositoryConfig: envOr("HELM_REPOSITORY_CONFIG", helmpath.ConfigPath("repositories.yaml")), RepositoryCache: envOr("HELM_REPOSITORY_CACHE", helmpath.CachePath("repository")), + ChartCache: envOr("HELM_CHART_CACHE", helmpath.CachePath("charts")), } env.Debug, _ = strconv.ParseBool(os.Getenv("HELM_DEBUG")) @@ -110,6 +113,7 @@ func (s *EnvSettings) AddFlags(fs *pflag.FlagSet) { fs.StringVar(&s.RegistryConfig, "registry-config", s.RegistryConfig, "path to the registry config file") fs.StringVar(&s.RepositoryConfig, "repository-config", s.RepositoryConfig, "path to the file containing repository names and URLs") fs.StringVar(&s.RepositoryCache, "repository-cache", s.RepositoryCache, "path to the file containing cached repository indexes") + fs.StringVar(&s.ChartCache, "chart-cache", s.ChartCache, "path to the chart cache directory") } func envOr(name, def string) string { @@ -146,6 +150,7 @@ func (s *EnvSettings) EnvVars() map[string]string { "HELM_CONFIG_HOME": helmpath.ConfigPath(""), "HELM_DATA_HOME": helmpath.DataPath(""), "HELM_DEBUG": fmt.Sprint(s.Debug), + "HELM_CHART_CACHE": s.ChartCache, "HELM_PLUGINS": s.PluginsDirectory, "HELM_REGISTRY_CONFIG": s.RegistryConfig, "HELM_REPOSITORY_CACHE": s.RepositoryCache,