Skip to content

Commit

Permalink
Implement flags grouping for karmada-aggregated-apiserver
Browse files Browse the repository at this point in the history
Signed-off-by: AllenZMC <zhongming.chang@daocloud.io>

Implement flags grouping for karmada-aggregated-apiserver

Signed-off-by: AllenZMC <zhongming.chang@daocloud.io>
  • Loading branch information
AllenZMC committed Mar 18, 2022
1 parent 82c2fdd commit 8d2ef8e
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions cmd/aggregated-apiserver/app/aggregated-apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ package app

import (
"context"
"flag"
"os"

"github.com/spf13/cobra"
cliflag "k8s.io/component-base/cli/flag"
"k8s.io/component-base/term"

"github.com/karmada-io/karmada/cmd/aggregated-apiserver/app/options"
"github.com/karmada-io/karmada/pkg/sharedcli"
"github.com/karmada-io/karmada/pkg/sharedcli/klogflag"
"github.com/karmada-io/karmada/pkg/version/sharedcommand"
)

Expand All @@ -32,8 +35,20 @@ func NewAggregatedApiserverCommand(ctx context.Context) *cobra.Command {
},
}

opts.AddFlags(cmd.Flags())
fss := cliflag.NamedFlagSets{}

genericFlagSet := fss.FlagSet("generic")
opts.AddFlags(genericFlagSet)

// Set klog flags
logsFlagSet := fss.FlagSet("logs")
klogflag.Add(logsFlagSet)

cmd.AddCommand(sharedcommand.NewCmdVersion(os.Stdout, "karmada-aggregated-apiserver"))
cmd.Flags().AddGoFlagSet(flag.CommandLine)
cmd.Flags().AddFlagSet(genericFlagSet)
cmd.Flags().AddFlagSet(logsFlagSet)

cols, _, _ := term.TerminalSize(cmd.OutOrStdout())
sharedcli.SetUsageAndHelpFunc(cmd, fss, cols)
return cmd
}

0 comments on commit 8d2ef8e

Please sign in to comment.