From a50f3a2cb7bcdc7a911a135759c0118a1a35c2c7 Mon Sep 17 00:00:00 2001 From: Ilya Drey Date: Thu, 14 Nov 2024 15:34:49 +0300 Subject: [PATCH] fix(kubectl): add klog arbitrary flags `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 #6319 --- cmd/werf/kubectl/kubectl.go | 3 +++ go.mod | 1 + 2 files changed, 4 insertions(+) diff --git a/cmd/werf/kubectl/kubectl.go b/cmd/werf/kubectl/kubectl.go index 6b2a880dc1..8f58a97177 100644 --- a/cmd/werf/kubectl/kubectl.go +++ b/cmd/werf/kubectl/kubectl.go @@ -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" @@ -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) diff --git a/go.mod b/go.mod index 47f276bded..4a7fd6bdeb 100644 --- a/go.mod +++ b/go.mod @@ -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