From 24cefc7fd5466295f8f075bc3b9d213b7e86673a Mon Sep 17 00:00:00 2001 From: yxxhero Date: Sun, 18 Sep 2022 11:27:27 +0800 Subject: [PATCH] remove flags.Parse in cobra Signed-off-by: yxxhero --- cmd/root.go | 8 -------- go.mod | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 5a027843..defcda0e 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -68,16 +68,8 @@ func NewRootCmd(globalConfig *config.GlobalOptions, args []string) (*cobra.Comma // Set the global options for the root command. setGlobalOptionsForRootCmd(flags, globalConfig) - // We can safely ignore any errors that flags.Parse encounters since - // those errors will be caught later during the call to cmd.Execution. - // This call is required to gather configuration information prior to - // execution. flags.ParseErrorsWhitelist.UnknownFlags = true - err := flags.Parse(args) - if err != nil { - return nil, err - } globalImpl := config.NewGlobalImpl(globalConfig) cmd.AddCommand( NewApplyCmd(globalImpl), diff --git a/go.mod b/go.mod index 9b442157..d22ee5d1 100644 --- a/go.mod +++ b/go.mod @@ -33,6 +33,7 @@ require ( golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 gopkg.in/yaml.v2 v2.4.0 gotest.tools v2.2.0+incompatible + helm.sh/helm/v3 v3.8.1 k8s.io/apimachinery v0.24.4 ) @@ -188,7 +189,6 @@ require ( go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871 // indirect gopkg.in/inf.v0 v0.9.1 // indirect - helm.sh/helm/v3 v3.8.1 // indirect k8s.io/api v0.23.4 // indirect k8s.io/cli-runtime v0.23.4 // indirect k8s.io/client-go v0.23.4 // indirect