Skip to content

Commit

Permalink
pkg: flagcodec: always use normalization
Browse files Browse the repository at this point in the history
Always enable normalization in the deployer codebase.
The golang flag package also allows single or double dash
for single-letter flags: https://pkg.go.dev/flag#hdr-Command_line_flag_syntax

Signed-off-by: Francesco Romani <[email protected]>
  • Loading branch information
ffromani committed Nov 29, 2023
1 parent c600f30 commit 99b7fc6
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pkg/manifests/yaml/sched/scheduler/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ spec:
- args:
- /bin/kube-scheduler
- --config=/etc/kubernetes/scheduler-config.yaml
- --v=4
- -v=4
image: k8s.gcr.io/scheduler-plugins/kube-scheduler:v0.24.9
livenessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion pkg/objectupdate/nfd/nfd.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func UpdaterDaemonSet(ds *appsv1.DaemonSet, opts objectupdate.DaemonSetOptions)
c.ImagePullPolicy = corev1.PullIfNotPresent
}

flags := flagcodec.ParseArgvKeyValue(c.Args)
flags := flagcodec.ParseArgvKeyValue(c.Args, flagcodec.WithFlagNormalization)
flags.SetOption("-v", fmt.Sprintf("%d", opts.Verbose))
if opts.UpdateInterval > 0 {
flags.SetOption("--sleep-interval", fmt.Sprintf("%v", opts.UpdateInterval))
Expand Down
2 changes: 1 addition & 1 deletion pkg/objectupdate/rte/rte.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func DaemonSet(ds *appsv1.DaemonSet, plat platform.Platform, configMapName strin
})
}

flags := flagcodec.ParseArgvKeyValue(cntSpec.Args)
flags := flagcodec.ParseArgvKeyValue(cntSpec.Args, flagcodec.WithFlagNormalization)
flags.SetOption("-v", fmt.Sprintf("%d", opts.Verbose))
if opts.UpdateInterval > 0 {
flags.SetOption("--sleep-interval", fmt.Sprintf("%v", opts.UpdateInterval))
Expand Down
4 changes: 2 additions & 2 deletions pkg/objectupdate/sched/sched.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ func SchedulerDeployment(dp *appsv1.Deployment, pullIfNotPresent, ctrlPlaneAffin
cnt.Image = images.SchedulerPluginSchedulerImage
cnt.ImagePullPolicy = pullPolicy(pullIfNotPresent)

flags := flagcodec.ParseArgvKeyValue(cnt.Args)
flags.SetOption("--v", fmt.Sprintf("%d", verbose)) // TODO: keep in sync with the manifest (-v vs --v)
flags := flagcodec.ParseArgvKeyValue(cnt.Args, flagcodec.WithFlagNormalization)
flags.SetOption("-v", fmt.Sprintf("%d", verbose))
cnt.Args = flags.Argv()

if ctrlPlaneAffinity {
Expand Down
6 changes: 3 additions & 3 deletions pkg/objectupdate/sched/sched_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ spec:
- args:
- /bin/kube-scheduler
- --config=/etc/kubernetes/scheduler-config.yaml
- --v=4
- -v=4
image: test.com/image:latest
imagePullPolicy: Always
livenessProbe:
Expand Down Expand Up @@ -176,7 +176,7 @@ spec:
- args:
- /bin/kube-scheduler
- --config=/etc/kubernetes/scheduler-config.yaml
- --v=4
- -v=4
image: test.com/image:latest
imagePullPolicy: Always
livenessProbe:
Expand Down Expand Up @@ -239,7 +239,7 @@ spec:
- args:
- /bin/kube-scheduler
- --config=/etc/kubernetes/scheduler-config.yaml
- --v=6
- -v=6
image: test.com/image:latest
imagePullPolicy: Always
livenessProbe:
Expand Down

0 comments on commit 99b7fc6

Please sign in to comment.