Merge pull request #1426 from zgfh/fix-kubectl-karmada-log

fix bug: fix can not use '-v 6' to set log level when run kubectl-karmada
This commit is contained in:
karmada-bot 2022-03-07 09:38:18 +08:00 committed by GitHub
commit 0ef339011d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -7,8 +7,10 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/pflag" "github.com/spf13/pflag"
"k8s.io/client-go/tools/clientcmd" "k8s.io/client-go/tools/clientcmd"
apiserverflag "k8s.io/component-base/cli/flag" apiserverflag "k8s.io/component-base/cli/flag"
"k8s.io/klog/v2"
"github.com/karmada-io/karmada/pkg/karmadactl/cmdinit" "github.com/karmada-io/karmada/pkg/karmadactl/cmdinit"
"github.com/karmada-io/karmada/pkg/version/sharedcommand" "github.com/karmada-io/karmada/pkg/version/sharedcommand"
@ -30,6 +32,9 @@ func NewKarmadaCtlCommand(out io.Writer, cmdUse, parentCommand string) *cobra.Co
RunE: runHelp, RunE: runHelp,
} }
// Init log flags
klog.InitFlags(flag.CommandLine)
// Add the command line flags from other dependencies (e.g., klog), but do not // Add the command line flags from other dependencies (e.g., klog), but do not
// warn if they contain underscores. // warn if they contain underscores.
pflag.CommandLine.SetNormalizeFunc(apiserverflag.WordSepNormalizeFunc) pflag.CommandLine.SetNormalizeFunc(apiserverflag.WordSepNormalizeFunc)