Skip to content

Commit 63ebb5e

Browse files
committed
Add '--version' flag
Provide a quick and easy way to check the version of the binary from the CLI. Signed-off-by: Stephen Finucane <[email protected]>
1 parent 3c742d2 commit 63ebb5e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ var (
7070
healthAddr string
7171
lbProvider string
7272
caCertsPath string
73+
showVersion bool
7374
logOptions = logs.NewOptions()
7475
)
7576

@@ -135,6 +136,8 @@ func InitFlags(fs *pflag.FlagSet) {
135136
"The name of the load balancer provider (amphora or ovn) to use (defaults to amphora).")
136137

137138
fs.StringVar(&caCertsPath, "ca-certs", "", "The path to a PEM-encoded CA Certificate file to supply as default for each request.")
139+
140+
fs.BoolVar(&showVersion, "version", false, "Show current version and exit.")
138141
}
139142

140143
func main() {
@@ -143,6 +146,11 @@ func main() {
143146
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
144147
pflag.Parse()
145148

149+
if showVersion {
150+
fmt.Println(version.Get().String()) //nolint:forbidigo
151+
os.Exit(0)
152+
}
153+
146154
if err := logsv1.ValidateAndApply(logOptions, nil); err != nil {
147155
setupLog.Error(err, "unable to start manager")
148156
os.Exit(1)

0 commit comments

Comments
 (0)