diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index 3d86c58b9fbf2899c49e257e786e6b6105e013fc..260821db1ab18cfec65b173296213cd991af3d68 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -76,6 +76,7 @@ Common actions from this point include: Environment: $HELM_HOME set an alternative location for Helm files. By default, these are stored in ~/.helm $HELM_HOST set an alternative Tiller host. The format is host:port + $HELM_NO_PLUGINS disable plugins. Set HELM_NO_PLUGINS=1 to disable plugins. $TILLER_NAMESPACE set an alternative Tiller namespace (default "kube-namespace") $KUBECONFIG set an alternative Kubernetes configuration file (default "~/.kube/config") ` diff --git a/cmd/helm/plugins.go b/cmd/helm/plugins.go index 8ffeb788d09261d382b589f04ee6aa0ea1ba052f..6e308aed66faaa0c0eb6d3fd2fd5dc10c8ce3359 100644 --- a/cmd/helm/plugins.go +++ b/cmd/helm/plugins.go @@ -37,6 +37,12 @@ const pluginEnvVar = "HELM_PLUGIN" // to inspect its environment and then add commands to the base command // as it finds them. func loadPlugins(baseCmd *cobra.Command, home helmpath.Home, out io.Writer) { + + // If HELM_NO_PLUGINS is set to 1, do not load plugins. + if os.Getenv("HELM_NO_PLUGINS") == "1" { + return + } + plugdirs := os.Getenv(pluginEnvVar) if plugdirs == "" { plugdirs = home.Plugins() diff --git a/cmd/helm/plugins_test.go b/cmd/helm/plugins_test.go index 4d2eaa9a8d6719e7f397f2041eafe80273f88272..f7cd178481918433cd9446cf543d0a8565765357 100644 --- a/cmd/helm/plugins_test.go +++ b/cmd/helm/plugins_test.go @@ -134,6 +134,28 @@ func TestLoadPlugins(t *testing.T) { } } +func TestLoadPlugins_HelmNoPlugins(t *testing.T) { + os.Setenv("HELM_NO_PLUGINS", "1") + defer os.Setenv("HELM_NO_PLUGINS", "0") + + // Set helm home to point to testdata + old := helmHome + helmHome = "testdata/helmhome" + defer func() { + helmHome = old + }() + hh := helmpath.Home(homePath()) + + out := bytes.NewBuffer(nil) + cmd := &cobra.Command{} + loadPlugins(cmd, hh, out) + plugins := cmd.Commands() + + if len(plugins) != 0 { + t.Fatalf("Expected 0 plugins, got %d", len(plugins)) + } +} + func TestSetupEnv(t *testing.T) { name := "pequod" hh := helmpath.Home("testdata/helmhome")