Skip to content

Commit

Permalink
KCP: Migrate from flags to pflags
Browse files Browse the repository at this point in the history
  • Loading branch information
Sedef committed Mar 12, 2020
1 parent d02e821 commit 206b77b
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions controlplane/kubeadm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"os"
"time"

"github.com/spf13/pflag"
"k8s.io/apimachinery/pkg/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
Expand Down Expand Up @@ -64,29 +65,33 @@ var (
webhookPort int
)

func main() {
flag.StringVar(&metricsAddr, "metrics-addr", ":8080",
// InitFlags initializes the flags.
func InitFlags(fs *pflag.FlagSet) {
fs.StringVar(&metricsAddr, "metrics-addr", ":8080",
"The address the metric endpoint binds to.")

flag.BoolVar(&enableLeaderElection, "enable-leader-election", false,
fs.BoolVar(&enableLeaderElection, "enable-leader-election", false,
"Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.")

flag.StringVar(&watchNamespace, "namespace", "",
fs.StringVar(&watchNamespace, "namespace", "",
"Namespace that the controller watches to reconcile cluster-api objects. If unspecified, the controller watches for cluster-api objects across all namespaces.")

flag.StringVar(&profilerAddress, "profiler-address", "",
fs.StringVar(&profilerAddress, "profiler-address", "",
"Bind address to expose the pprof profiler (e.g. localhost:6060)")

flag.IntVar(&kubeadmControlPlaneConcurrency, "kubeadmcontrolplane-concurrency", 10,
fs.IntVar(&kubeadmControlPlaneConcurrency, "kubeadmcontrolplane-concurrency", 10,
"Number of kubeadm control planes to process simultaneously")

flag.DurationVar(&syncPeriod, "sync-period", 10*time.Minute,
fs.DurationVar(&syncPeriod, "sync-period", 10*time.Minute,
"The minimum interval at which watched resources are reconciled (e.g. 15m)")

flag.IntVar(&webhookPort, "webhook-port", 0,
fs.IntVar(&webhookPort, "webhook-port", 0,
"Webhook Server port, disabled by default. When enabled, the manager will only work as webhook server, no reconcilers are installed.")

flag.Parse()
}
func main() {
InitFlags(pflag.CommandLine)
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
pflag.Parse()

ctrl.SetLogger(klogr.New())

Expand Down

0 comments on commit 206b77b

Please sign in to comment.