Skip to content

Commit

Permalink
fix(kubectl): add klog arbitrary flags
Browse files Browse the repository at this point in the history
`cmd.NewDefaultKubectlCommandWithArgs()` does not inject log arbitrary flags required by args like "-v=10".

I had a look on  how `kubectl` is originally run and found `logs.AddFlags(kubectlCmd.PersistentFlags())` call here -
in the https://github.com/kubernetes/component-base/blob/55c45bc78189d14353588befc15715b156914ce7/cli/run.go#L85C1-L118C1

Fix bug werf#6319
  • Loading branch information
drey committed Nov 14, 2024
1 parent 9681751 commit a50f3a2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/werf/kubectl/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/component-base/logs"
"k8s.io/kubectl/pkg/cmd"
"k8s.io/kubectl/pkg/cmd/plugin"
"k8s.io/kubectl/pkg/cmd/util"
Expand All @@ -33,6 +34,8 @@ func NewCmd(ctx context.Context) *cobra.Command {
IOStreams: genericclioptions.IOStreams{In: os.Stdin, Out: os.Stdout, ErrOut: os.Stderr},
})

logs.AddFlags(kubectlCmd.PersistentFlags())

common.SetupHomeDir(&commonCmdData, kubectlCmd, common.SetupHomeDirOptions{Persistent: true})
common.SetupTmpDir(&commonCmdData, kubectlCmd, common.SetupTmpDirOptions{Persistent: true})
common.SetupKubeConfigBase64(&commonCmdData, kubectlCmd)
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ require (
github.com/aws/smithy-go v1.22.0 // indirect
github.com/aymanbagabas/go-udiff v0.2.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/bugsnag/bugsnag-go v2.2.0+incompatible // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chai2010/gettext-go v1.0.2 // indirect
Expand Down

0 comments on commit a50f3a2

Please sign in to comment.