From df7553970da59c109e886e9a96713f880cadd802 Mon Sep 17 00:00:00 2001 From: Adam Reese Date: Mon, 12 Aug 2019 13:07:35 -0700 Subject: [PATCH] ref(cmd/helm): unify log functions Signed-off-by: Adam Reese --- cmd/helm/helm.go | 12 ++++++------ cmd/helm/printer.go | 4 ---- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index 75382b089..398b38b64 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -53,7 +53,7 @@ func init() { log.SetFlags(log.Lshortfile) } -func logf(format string, v ...interface{}) { +func debug(format string, v ...interface{}) { if settings.Debug { format = fmt.Sprintf("[debug] %s\n", format) log.Output(2, fmt.Sprintf(format, v...)) @@ -78,14 +78,14 @@ func main() { initActionConfig(actionConfig, false) if err := cmd.Execute(); err != nil { - logf("%+v", err) + debug("%+v", err) os.Exit(1) } } func initActionConfig(actionConfig *action.Configuration, allNamespaces bool) { kc := kube.New(kubeConfig()) - kc.Log = logf + kc.Log = debug clientset, err := kc.Factory.KubernetesClientSet() if err != nil { @@ -101,11 +101,11 @@ func initActionConfig(actionConfig *action.Configuration, allNamespaces bool) { switch os.Getenv("HELM_DRIVER") { case "secret", "secrets", "": d := driver.NewSecrets(clientset.CoreV1().Secrets(namespace)) - d.Log = logf + d.Log = debug store = storage.Init(d) case "configmap", "configmaps": d := driver.NewConfigMaps(clientset.CoreV1().ConfigMaps(namespace)) - d.Log = logf + d.Log = debug store = storage.Init(d) case "memory": d := driver.NewMemory() @@ -118,7 +118,7 @@ func initActionConfig(actionConfig *action.Configuration, allNamespaces bool) { actionConfig.RESTClientGetter = kubeConfig() actionConfig.KubeClient = kc actionConfig.Releases = store - actionConfig.Log = logf + actionConfig.Log = debug } func kubeConfig() genericclioptions.RESTClientGetter { diff --git a/cmd/helm/printer.go b/cmd/helm/printer.go index 0f89293d4..4d47f1c13 100644 --- a/cmd/helm/printer.go +++ b/cmd/helm/printer.go @@ -79,7 +79,3 @@ func tpl(t string, vals map[string]interface{}, out io.Writer) error { } return tt.Execute(out, vals) } - -func debug(format string, args ...interface{}) { - logf(format, args...) -}