diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index ab06841e0..d521d6b34 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -42,10 +42,9 @@ import ( var ( tillerTunnel *kube.Tunnel settings helm_env.EnvSettings + rootCmd *cobra.Command ) -var RootCmd *cobra.Command - var globalUsage = `The Kubernetes package manager To begin working with Helm, run the 'helm init' command: @@ -159,7 +158,7 @@ func newRootCmd(args []string) *cobra.Command { // Find and add plugins loadPlugins(cmd, out) - RootCmd = cmd + rootCmd = cmd return cmd } @@ -295,3 +294,8 @@ func newClient() helm.Interface { } return helm.NewClient(options...) } + +// GetRootCmd returns the root cobra command +func GetRootCmd() *cobra.Command { + return rootCmd +} diff --git a/cmd/helm/plugin_install.go b/cmd/helm/plugin_install.go index 558cda8d2..87df4a64c 100644 --- a/cmd/helm/plugin_install.go +++ b/cmd/helm/plugin_install.go @@ -86,7 +86,8 @@ func (pcmd *pluginInstallCmd) run() error { // Make sure a command with this name does not already exist. pluginCmdName := p.Metadata.Name - for _, cmd := range RootCmd.Commands() { + rootCmd := GetRootCmd() + for _, cmd := range rootCmd.Commands() { if cmd.Name() == pluginCmdName { os.Remove(p.Dir) err = fmt.Errorf("Plugin <%s> not installed as plugin with that name is already installed.", pluginCmdName)