Skip to content

Commit 92619e4

Browse files
authored
[release-1.28] Remove duplicate pflag.Parse calls (#2467)
* client-keystone-auth: Remove duplicate pflag.Parse call This is already handled by the earlier call to the (confusingly named) 'InitFlags' function provided by 'k8s.io/component-base/cli/flag' [1]. [1] https://github.com/kubernetes/component-base/blob/v0.28.1/cli/flag/flags.go#L51-L59 Signed-off-by: Stephen Finucane <[email protected]> (cherry picked from commit d0fc449) * k8s-keystone-auth: Remove duplicate pflag.Parse call This is already handled by the earlier call to the (confusingly named) 'InitFlags' function provided by 'k8s.io/component-base/cli/flag' [1]. We need to move the handling for the '--version' flag to after this to ensure we parse the flags first. [1] https://github.com/kubernetes/component-base/blob/v0.28.1/cli/flag/flags.go#L51-L59 Signed-off-by: Stephen Finucane <[email protected]> (cherry picked from commit de63646)
1 parent 23bb1df commit 92619e4

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

cmd/client-keystone-auth/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,8 @@ func main() {
187187
logs.AddFlags(pflag.CommandLine)
188188

189189
pflag.CommandLine.AddGoFlagSet(klogFlags)
190-
kflag.InitFlags()
191190

192-
pflag.Parse()
191+
kflag.InitFlags()
193192

194193
if showVersion {
195194
fmt.Println(version.Version)

cmd/k8s-keystone-auth/main.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,19 @@ func main() {
5555
}
5656
})
5757

58-
pflag.Parse()
59-
60-
if showVersion {
61-
fmt.Println(version.Version)
62-
os.Exit(0)
63-
}
64-
6558
logs.InitLogs()
6659
defer logs.FlushLogs()
6760

6861
config := keystone.NewConfig()
6962
config.AddFlags(pflag.CommandLine)
63+
7064
kflag.InitFlags()
7165

66+
if showVersion {
67+
fmt.Println(version.Version)
68+
os.Exit(0)
69+
}
70+
7271
if err := config.ValidateFlags(); err != nil {
7372
klog.Errorf("%v", err)
7473
os.Exit(1)

0 commit comments

Comments
 (0)