Cloud provider should return an error
Not fatal - makes cloud provider useful in methods that can return error.
This commit is contained in:
@@ -17,6 +17,7 @@ limitations under the License.
|
||||
package cloudprovider
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"sync"
|
||||
@@ -62,12 +63,12 @@ func GetCloudProvider(name string, config io.Reader) (Interface, error) {
|
||||
}
|
||||
|
||||
// InitCloudProvider creates an instance of the named cloud provider.
|
||||
func InitCloudProvider(name string, configFilePath string) Interface {
|
||||
func InitCloudProvider(name string, configFilePath string) (Interface, error) {
|
||||
var cloud Interface
|
||||
|
||||
if name == "" {
|
||||
glog.Info("No cloud provider specified.")
|
||||
return nil
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
var err error
|
||||
@@ -87,11 +88,11 @@ func InitCloudProvider(name string, configFilePath string) Interface {
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
glog.Fatalf("Couldn't init cloud provider %q: %v", name, err)
|
||||
return nil, fmt.Errorf("could not init cloud provider %q: %v", name, err)
|
||||
}
|
||||
if cloud == nil {
|
||||
glog.Fatalf("Unknown cloud provider: %s", name)
|
||||
return nil, fmt.Errorf("unknown cloud provider %q", name)
|
||||
}
|
||||
|
||||
return cloud
|
||||
return cloud, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user