diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index f7628e44c..ab06841e0 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -44,6 +44,8 @@ var ( settings helm_env.EnvSettings ) +var RootCmd *cobra.Command + var globalUsage = `The Kubernetes package manager To begin working with Helm, run the 'helm init' command: @@ -157,6 +159,8 @@ func newRootCmd(args []string) *cobra.Command { // Find and add plugins loadPlugins(cmd, out) + RootCmd = cmd + return cmd } diff --git a/cmd/helm/load_plugins.go b/cmd/helm/load_plugins.go index 1f2a08131..158a69c88 100644 --- a/cmd/helm/load_plugins.go +++ b/cmd/helm/load_plugins.go @@ -23,22 +23,12 @@ import ( "path/filepath" "strings" "syscall" - "text/template" "github.com/spf13/cobra" "k8s.io/helm/pkg/plugin" ) -var pluginLoadWarningTemp = template.Must(template.New("plugin").Parse(` -Helm Client Plugin Load Warning(s): -{{range $_, $warning := .Warnings}} -- {{ $warning }} -{{end}} -In order to eliminate this warning(s), please try to uninstall or reinstall the plugin(s) in question. ------------------------------------------------------------------------------------------------------- -`)) - type pluginError struct { error code int @@ -72,8 +62,6 @@ func loadPlugins(baseCmd *cobra.Command, out io.Writer) { } // Now we create commands for all of these. - warnings := []string{} -loop: for _, plug := range found { plug := plug md := plug.Metadata @@ -129,22 +117,9 @@ loop: } } - // Make sure a command with this name does not already exist. - for _, cmd := range baseCmd.Commands() { - if cmd.Name() == md.Name { - warning := fmt.Sprintf("A command with the name of [%s] already exists, so the plugin at [%s] will not be loaded.", md.Name, plug.Dir) - warnings = append(warnings, warning) - continue loop - } - } + // TODO: Make sure a command with this name does not already exist. baseCmd.AddCommand(c) } - - ctx := map[string]interface{}{ - "Warnings": warnings, - } - - pluginLoadWarningTemp.Execute(out, ctx) } // manuallyProcessArgs processes an arg array, removing special args. diff --git a/cmd/helm/plugin_install.go b/cmd/helm/plugin_install.go index 7d77be3fc..558cda8d2 100644 --- a/cmd/helm/plugin_install.go +++ b/cmd/helm/plugin_install.go @@ -18,6 +18,7 @@ package main import ( "fmt" "io" + "os" "k8s.io/helm/pkg/helm/helmpath" "k8s.io/helm/pkg/plugin" @@ -83,10 +84,20 @@ func (pcmd *pluginInstallCmd) run() error { return err } + // Make sure a command with this name does not already exist. + pluginCmdName := p.Metadata.Name + 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) + return err + } + } + if err := runHook(p, plugin.Install); err != nil { return err } - fmt.Fprintf(pcmd.out, "Installed plugin: %s\n", p.Metadata.Name) + fmt.Fprintf(pcmd.out, "Installed plugin: %s\n", pluginCmdName) return nil }