add GetRootCmd function

Signed-off-by: SataQiu <qiushida@beyondcent.com>
pull/5195/head
SataQiu 7 years ago
parent c2c16fceb4
commit 6de8852b96

@ -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
}

@ -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)

Loading…
Cancel
Save