diff --git a/cmd/nginx/flag_test.go b/cmd/nginx/flag_test.go index 77c2504d45..6e826b9328 100644 --- a/cmd/nginx/flag_test.go +++ b/cmd/nginx/flag_test.go @@ -62,3 +62,16 @@ func TestDefaults(t *testing.T) { func TestSetupSSLProxy(t *testing.T) { // TODO } + +func TestFlagConflict(t *testing.T) { + resetForTesting(func() { t.Fatal("Parsing failed") }) + + oldArgs := os.Args + defer func() { os.Args = oldArgs }() + os.Args = []string{"cmd", "--publish-service", "namespace/test", "--http-port", "0", "--https-port", "0", "--publish-status-address", "1.1.1.1"} + + _, _, err := parseFlags() + if err == nil { + t.Fatalf("Expected an error parsing flags but none returned") + } +} diff --git a/cmd/nginx/flags.go b/cmd/nginx/flags.go index 450b00e175..780bd546fe 100644 --- a/cmd/nginx/flags.go +++ b/cmd/nginx/flags.go @@ -205,6 +205,10 @@ Feature backed by OpenResty Lua libraries. Requires that OCSP stapling is not en dynamic certificates functionality is enabled. Please check the flags --enable-ssl-chain-completion and --enable-dynamic-configuration`) } + if *publishSvc != "" && *publishStatusAddress != "" { + return false, nil, fmt.Errorf("Flags --publish-service and --publish-status-address are mutually exclusive") + } + // LuaJIT is not available on arch s390x and ppc64le disableLua := false if runtime.GOARCH == "s390x" || runtime.GOARCH == "ppc64le" {