From 0971f8443f853165251fe9b009c20183b8464b57 Mon Sep 17 00:00:00 2001 From: Manuel Alejandro de Brito Fontes Date: Mon, 8 Oct 2018 15:00:38 -0300 Subject: [PATCH] Flags publish-service and publish-status-address are mutually exclusive --- cmd/nginx/flag_test.go | 13 +++++++++++++ cmd/nginx/flags.go | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/cmd/nginx/flag_test.go b/cmd/nginx/flag_test.go index 77c2504d4..6e826b932 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 450b00e17..780bd546f 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" {