Pass in nil instead of the interface
This commit is contained in:
parent
26fd12a81c
commit
acf87ef9d5
1 changed files with 17 additions and 13 deletions
|
@ -241,23 +241,27 @@ func NewClusterManager(
|
||||||
defaultBackendNodePort int64,
|
defaultBackendNodePort int64,
|
||||||
defaultHealthCheckPath string) (*ClusterManager, error) {
|
defaultHealthCheckPath string) (*ClusterManager, error) {
|
||||||
|
|
||||||
var config *os.File
|
|
||||||
var err error
|
|
||||||
if configFilePath != "" {
|
|
||||||
glog.Infof("Reading config from path %v", configFilePath)
|
|
||||||
config, err = os.Open(configFilePath)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer config.Close()
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Make this more resilient. Currently we create the cloud client
|
// TODO: Make this more resilient. Currently we create the cloud client
|
||||||
// and pass it through to all the pools. This makes unittesting easier.
|
// and pass it through to all the pools. This makes unittesting easier.
|
||||||
// However if the cloud client suddenly fails, we should try to re-create it
|
// However if the cloud client suddenly fails, we should try to re-create it
|
||||||
// and continue.
|
// and continue.
|
||||||
cloud := getGCEClient(config)
|
var cloud *gce.GCECloud
|
||||||
glog.Infof("Successfully loaded cloudprovider using config %q", configFilePath)
|
if configFilePath != "" {
|
||||||
|
glog.Infof("Reading config from path %v", configFilePath)
|
||||||
|
config, err := os.Open(configFilePath)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer config.Close()
|
||||||
|
cloud = getGCEClient(config)
|
||||||
|
glog.Infof("Successfully loaded cloudprovider using config %q", configFilePath)
|
||||||
|
} else {
|
||||||
|
// While you might be tempted to refactor so we simply assing nil to the
|
||||||
|
// config and only invoke getGCEClient once, that will not do the right
|
||||||
|
// thing because a nil check against an interface isn't true in golang.
|
||||||
|
cloud = getGCEClient(nil)
|
||||||
|
glog.Infof("Created GCE client without a confi file")
|
||||||
|
}
|
||||||
|
|
||||||
// Names are fundamental to the cluster, the uid allocator makes sure names don't collide.
|
// Names are fundamental to the cluster, the uid allocator makes sure names don't collide.
|
||||||
cluster := ClusterManager{ClusterNamer: &utils.Namer{name}}
|
cluster := ClusterManager{ClusterNamer: &utils.Namer{name}}
|
||||||
|
|
Loading…
Reference in a new issue