Cloud provider should return an error

Not fatal - makes cloud provider useful in methods that
can return error.
This commit is contained in:
Clayton Coleman
2015-07-01 14:41:49 -04:00
parent 7689391c68
commit d8bb4552de
5 changed files with 22 additions and 9 deletions

View File

@@ -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
}