From e6b28915dca0822d33002a465c142080a6577d85 Mon Sep 17 00:00:00 2001 From: SataQiu Date: Tue, 22 Jan 2019 13:34:41 +0800 Subject: [PATCH] make sure a plugin command name does not already exist Signed-off-by: SataQiu --- cmd/helm/load_plugins.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/helm/load_plugins.go b/cmd/helm/load_plugins.go index 158a69c88..caac1b7a3 100644 --- a/cmd/helm/load_plugins.go +++ b/cmd/helm/load_plugins.go @@ -62,6 +62,7 @@ func loadPlugins(baseCmd *cobra.Command, out io.Writer) { } // Now we create commands for all of these. +loop: for _, plug := range found { plug := plug md := plug.Metadata @@ -117,7 +118,12 @@ func loadPlugins(baseCmd *cobra.Command, out io.Writer) { } } - // TODO: Make sure a command with this name does not already exist. + // Make sure a command with this name does not already exist. + for _, cmd := range baseCmd.Commands() { + if cmd.Name() == md.Name { + continue loop + } + } baseCmd.AddCommand(c) } }