Merge pull request #125179 from SataQiu/clean-20240528

kubeadm: only add the klog flags that are still supported for kubeadm, rather than disabling the unwanted flags
This commit is contained in:
Kubernetes Prow Robot 2024-05-29 20:14:55 -07:00 committed by GitHub
commit 83c2db067e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -30,24 +30,19 @@ import (
// Run creates and executes new kubeadm command
func Run() error {
klog.InitFlags(nil)
var allFlags flag.FlagSet
klog.InitFlags(&allFlags)
// only add the flags that are still supported for kubeadm
allFlags.VisitAll(func(f *flag.Flag) {
switch f.Name {
case "v", "add_dir_header", "skip_headers":
flag.CommandLine.Var(f.Value, f.Name, f.Usage)
}
})
pflag.CommandLine.SetNormalizeFunc(cliflag.WordSepNormalizeFunc)
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
pflag.Set("logtostderr", "true")
// We do not want these flags to show up in --help
// These MarkHidden calls must be after the lines above
pflag.CommandLine.MarkHidden("alsologtostderr")
pflag.CommandLine.MarkHidden("log-backtrace-at")
pflag.CommandLine.MarkHidden("log-dir")
pflag.CommandLine.MarkHidden("logtostderr")
pflag.CommandLine.MarkHidden("log-file") //nolint:errcheck
pflag.CommandLine.MarkHidden("log-file-max-size") //nolint:errcheck
pflag.CommandLine.MarkHidden("one-output") //nolint:errcheck
pflag.CommandLine.MarkHidden("skip-log-headers") //nolint:errcheck
pflag.CommandLine.MarkHidden("stderrthreshold")
pflag.CommandLine.MarkHidden("vmodule")
cmd := cmd.NewKubeadmCommand(os.Stdin, os.Stdout, os.Stderr)
return cmd.Execute()
}