From 99d3c9e63c4a266ab2385d42bbabf4b1000944ee Mon Sep 17 00:00:00 2001 From: Kimmo Lehto Date: Tue, 30 Nov 2021 14:17:32 +0200 Subject: [PATCH] Expose NewRootCmd Signed-off-by: Kimmo Lehto Signed-off-by: Kimmo Lehto --- cmd/helm/helm.go | 8 +++----- cmd/helm/helm_test.go | 2 +- cmd/helm/root.go | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index 1766f8646..b00c0389f 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -43,10 +43,6 @@ const FeatureGateOCI = gates.Gate("HELM_EXPERIMENTAL_OCI") var settings = cli.New() -func init() { - log.SetFlags(log.Lshortfile) -} - func debug(format string, v ...interface{}) { if settings.Debug { format = fmt.Sprintf("[debug] %s\n", format) @@ -60,6 +56,8 @@ func warning(format string, v ...interface{}) { } func main() { + log.SetFlags(log.Lshortfile) + // Setting the name of the app for managedFields in the Kubernetes client. // It is set here to the full name of "helm" so that renaming of helm to // another name (e.g., helm2 or helm3) does not change the name of the @@ -67,7 +65,7 @@ func main() { kube.ManagedFieldsManager = "helm" actionConfig := new(action.Configuration) - cmd, err := newRootCmd(actionConfig, os.Stdout, os.Args[1:]) + cmd, err := NewRootCmd(actionConfig, os.Stdout, os.Args[1:]) if err != nil { warning("%+v", err) os.Exit(1) diff --git a/cmd/helm/helm_test.go b/cmd/helm/helm_test.go index 5e59c41ed..ad3444d96 100644 --- a/cmd/helm/helm_test.go +++ b/cmd/helm/helm_test.go @@ -115,7 +115,7 @@ func executeActionCommandStdinC(store *storage.Storage, in *os.File, cmd string) Log: func(format string, v ...interface{}) {}, } - root, err := newRootCmd(actionConfig, buf, args) + root, err := NewRootCmd(actionConfig, buf, args) if err != nil { return nil, "", err } diff --git a/cmd/helm/root.go b/cmd/helm/root.go index 0de4a738a..ee9559339 100644 --- a/cmd/helm/root.go +++ b/cmd/helm/root.go @@ -83,7 +83,7 @@ By default, the default directories depend on the Operating System. The defaults | Windows | %TEMP%\helm | %APPDATA%\helm | %APPDATA%\helm | ` -func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string) (*cobra.Command, error) { +func NewRootCmd(actionConfig *action.Configuration, out io.Writer, args []string) (*cobra.Command, error) { cmd := &cobra.Command{ Use: "helm", Short: "The Helm package manager for Kubernetes.",