From 06c34a6524c98d9ca7231ee54524819674100e8e Mon Sep 17 00:00:00 2001 From: Wei Fu Date: Mon, 13 May 2024 03:23:31 +0000 Subject: [PATCH] helmcli: introduce debug log Carry: #74 Signed-off-by: Wei Fu --- helmcli/delete.go | 2 +- helmcli/get.go | 2 +- helmcli/list.go | 2 +- helmcli/release.go | 10 ++++++---- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/helmcli/delete.go b/helmcli/delete.go index 9791d13..f27b05f 100644 --- a/helmcli/delete.go +++ b/helmcli/delete.go @@ -25,7 +25,7 @@ func NewDeleteCli(kubeconfigPath string, namespace string) (*DeleteCli, error) { }, namespace, "secret", - noopLog, + debugLog, ); err != nil { return nil, fmt.Errorf("failed to init action config: %w", err) } diff --git a/helmcli/get.go b/helmcli/get.go index 0d63f51..ed377c2 100644 --- a/helmcli/get.go +++ b/helmcli/get.go @@ -24,7 +24,7 @@ func NewGetCli(kubeconfigPath string, namespace string) (*GetCli, error) { }, namespace, "secret", - noopLog, + debugLog, ); err != nil { return nil, fmt.Errorf("failed to init action config: %w", err) } diff --git a/helmcli/list.go b/helmcli/list.go index 0ca764b..03b940c 100644 --- a/helmcli/list.go +++ b/helmcli/list.go @@ -24,7 +24,7 @@ func NewListCli(kubeconfigPath string, namespace string) (*ListCli, error) { }, namespace, "secret", - noopLog, + debugLog, ); err != nil { return nil, fmt.Errorf("failed to init action config: %w", err) } diff --git a/helmcli/release.go b/helmcli/release.go index 6dfd902..b90d212 100644 --- a/helmcli/release.go +++ b/helmcli/release.go @@ -12,9 +12,12 @@ import ( "helm.sh/helm/v3/pkg/storage/driver" "helm.sh/helm/v3/pkg/strvals" "k8s.io/cli-runtime/pkg/genericclioptions" + "k8s.io/klog/v2" ) -var noopLog action.DebugLog = func(_ string, _ ...interface{}) {} +var debugLog action.DebugLog = func(fmt string, args ...interface{}) { + klog.V(2).Infof(fmt, args...) +} // ValuesApplier is to apply new key/values to existing chart's values. type ValuesApplier func(values map[string]interface{}) error @@ -96,8 +99,7 @@ type ReleaseCli struct { // NewReleaseCli returns new ReleaseCli instance. // // TODO: -// 1. show debug log. -// 2. add flag to disable Wait +// 1. add flag to disable Wait func NewReleaseCli( kubeconfigPath string, namespace string, @@ -125,7 +127,7 @@ func NewReleaseCli( }, namespace, "secret", - noopLog, + debugLog, ); err != nil { return nil, fmt.Errorf("failed to init action config: %w", err) }