Merge pull request #76627 from timoreimann/handle-missing-gce-lb-flag-gracefully

Suppress registering GCE LB provider flag if missing on CommandLine.
k3s-v1.15.3
Kubernetes Prow Robot 2019-05-03 21:01:39 -07:00 committed by GitHub
commit e1fa195451
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -18,6 +18,7 @@ package app
import (
"context"
"flag"
"fmt"
"net/http"
"os"
@ -86,9 +87,12 @@ the cloud specific control loops shipped with Kubernetes.`,
namedFlagSets := s.Flags(KnownControllers(), ControllersDisabledByDefault.List())
verflag.AddFlags(namedFlagSets.FlagSet("global"))
globalflag.AddGlobalFlags(namedFlagSets.FlagSet("global"), cmd.Name())
// hoist this flag from the global flagset to preserve the commandline until
// the gce cloudprovider is removed.
globalflag.Register(namedFlagSets.FlagSet("generic"), "cloud-provider-gce-lb-src-cidrs")
if flag.CommandLine.Lookup("cloud-provider-gce-lb-src-cidrs") != nil {
// hoist this flag from the global flagset to preserve the commandline until
// the gce cloudprovider is removed.
globalflag.Register(namedFlagSets.FlagSet("generic"), "cloud-provider-gce-lb-src-cidrs")
}
for _, f := range namedFlagSets.FlagSets {
fs.AddFlagSet(f)
}