Skip to content

Commit

Permalink
Merge pull request #3204 from aledbf/conflict-flags
Browse files Browse the repository at this point in the history
Flags publish-service and publish-status-address are mutually exclusive
  • Loading branch information
k8s-ci-robot authored Oct 9, 2018
2 parents f3a2e50 + 0971f84 commit c8f407a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cmd/nginx/flag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
4 changes: 4 additions & 0 deletions cmd/nginx/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down

0 comments on commit c8f407a

Please sign in to comment.