Skip to content

Commit

Permalink
Merge pull request kubeedge#5547 from luomengY/log_level
Browse files Browse the repository at this point in the history
Add a parent flag --log-level to the keadm and make it hidden for debug.
  • Loading branch information
kubeedge-bot authored Jun 21, 2024
2 parents 1666b68 + 86139f2 commit 6a21c37
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions keadm/cmd/keadm/app/keadm.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,33 @@ package app

import (
"flag"
"fmt"

"github.com/spf13/pflag"
cliflag "k8s.io/component-base/cli/flag"
"k8s.io/klog/v2"
"sigs.k8s.io/apiserver-network-proxy/pkg/util"

"github.com/kubeedge/kubeedge/keadm/cmd/keadm/app/cmd"
)

// Run executes the keadm command
func Run() error {
flagSet := pflag.NewFlagSet("keadm", pflag.ExitOnError)
flagSet.AddGoFlagSet(flag.CommandLine)

flagSet := flag.NewFlagSet("keadm", flag.ExitOnError)
cmd := cmd.NewKubeedgeCommand()
flags := cmd.Flags()
klog.InitFlags(flagSet)
err := flagSet.Set("v", "0")
if err != nil {
return fmt.Errorf("error setting klog flags: %v", err)
}

flagSet.Visit(func(fl *flag.Flag) {
fl.Name = util.Normalize(fl.Name)
flags.AddGoFlag(fl)
})

pflag.CommandLine.SetNormalizeFunc(cliflag.WordSepNormalizeFunc)
pflag.CommandLine.AddFlagSet(flags)
return cmd.Execute()
}

0 comments on commit 6a21c37

Please sign in to comment.