cloud: validate that there are not positional arguments
flag.Parse() parses arguments after boolean flags as positional argument.
This produces unexpected behaviour like this:
```
> -a "true" -b "true"
a: false
> -a -b "true"
b: true
```
Change-Id: I0f8555fc45acf305a5efd365a6eae03eb8930942
Reviewed-on: https://review.monogon.dev/c/monogon/+/1798
Reviewed-by: Serge Bazanski <serge@monogon.tech>
Tested-by: Jenkins CI
diff --git a/cloud/apigw/main.go b/cloud/apigw/main.go
index d560c0c..9c0ebff 100644
--- a/cloud/apigw/main.go
+++ b/cloud/apigw/main.go
@@ -4,6 +4,8 @@
"context"
"flag"
+ "k8s.io/klog/v2"
+
"source.monogon.dev/cloud/apigw/server"
)
@@ -11,6 +13,9 @@
s := &server.Server{}
s.Config.RegisterFlags()
flag.Parse()
+ if flag.NArg() > 0 {
+ klog.Exitf("unexpected positional arguments: %v", flag.Args())
+ }
ctx, ctxC := context.WithCancel(context.Background())
// TODO: context cancel on interrupt.