Remove klog flags

Signed-off-by: George Jenkins <gvjenkins@gmail.com>
pull/31441/head
George Jenkins 11 months ago
parent f4c5220d99
commit f7003c4ec1

@ -46,7 +46,7 @@ require (
k8s.io/apiserver v0.34.1
k8s.io/cli-runtime v0.34.1
k8s.io/client-go v0.34.1
k8s.io/klog/v2 v2.130.1
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kubectl v0.34.1
oras.land/oras-go/v2 v2.6.0
sigs.k8s.io/controller-runtime v0.22.3

@ -17,7 +17,6 @@ limitations under the License.
package cmd
import (
"flag"
"fmt"
"log"
"log/slog"
@ -28,8 +27,6 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"k8s.io/klog/v2"
"helm.sh/helm/v4/pkg/action"
"helm.sh/helm/v4/pkg/cli"
"helm.sh/helm/v4/pkg/cli/output"
@ -284,24 +281,3 @@ func compVersionFlag(chartRef string, _ string) ([]string, cobra.ShellCompDirect
return versions, cobra.ShellCompDirectiveNoFileComp
}
// addKlogFlags adds flags from k8s.io/klog
// marks the flags as hidden to avoid polluting the help text
func addKlogFlags(fs *pflag.FlagSet) {
local := flag.NewFlagSet("klog", flag.ExitOnError)
klog.InitFlags(local)
local.VisitAll(func(fl *flag.Flag) {
fl.Name = normalize(fl.Name)
if fs.Lookup(fl.Name) != nil {
return
}
newflag := pflag.PFlagFromGoFlag(fl)
newflag.Hidden = true
fs.AddFlag(newflag)
})
}
// normalize replaces underscores with hyphens
func normalize(s string) string {
return strings.ReplaceAll(s, "_", "-")
}

@ -168,7 +168,6 @@ func newRootCmdWithConfig(actionConfig *action.Configuration, out io.Writer, arg
flags := cmd.PersistentFlags()
settings.AddFlags(flags)
addKlogFlags(flags)
// We can safely ignore any errors that flags.Parse encounters since
// those errors will be caught later during the call to cmd.Execution.

Loading…
Cancel
Save