From 2812936d34d98267b91b8308534354c538b9528a Mon Sep 17 00:00:00 2001 From: Justin Santa Barbara Date: Fri, 27 Mar 2015 08:59:49 -0700 Subject: [PATCH] Simplify logic of pd.go --- pkg/cloudprovider/aws/aws.go | 6 +++--- test/e2e/pd.go | 18 ++++++------------ 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/pkg/cloudprovider/aws/aws.go b/pkg/cloudprovider/aws/aws.go index b5a68b4a91a..849fafea782 100644 --- a/pkg/cloudprovider/aws/aws.go +++ b/pkg/cloudprovider/aws/aws.go @@ -240,9 +240,9 @@ func newAWSCloud(config io.Reader, authFunc AuthFunc, instanceId string, metadat ec2 := &goamzEC2{ec2: ec2.New(auth, region)} awsCloud := &AWSCloud{ - ec2: ec2, - cfg: cfg, - region: region, + ec2: ec2, + cfg: cfg, + region: region, availabilityZone: zone, } diff --git a/test/e2e/pd.go b/test/e2e/pd.go index 5d4d4379130..1a832b8847a 100644 --- a/test/e2e/pd.go +++ b/test/e2e/pd.go @@ -186,16 +186,14 @@ func createPD() (string, error) { return "", err } return pdName, nil - } else if testContext.provider == "aws" { + } else { volumes, ok := testContext.cloudConfig.Provider.(aws_cloud.Volumes) if !ok { - return "", fmt.Errorf("Provider does not implement volumes interface") + return "", fmt.Errorf("Provider does not support volumes") } volumeOptions := &aws_cloud.VolumeOptions{} volumeOptions.CapacityMB = 10 * 1024 return volumes.CreateVolume(volumeOptions) - } else { - return "", fmt.Errorf("Unsupported provider type") } } @@ -205,14 +203,12 @@ func deletePD(pdName string) error { // TODO: make this hit the compute API directly. return exec.Command("gcloud", "compute", "disks", "delete", "--zone="+zone, pdName).Run() - } else if testContext.provider == "aws" { + } else { volumes, ok := testContext.cloudConfig.Provider.(aws_cloud.Volumes) if !ok { - return fmt.Errorf("Provider does not implement volumes interface") + return "", fmt.Errorf("Provider does not support volumes") } return volumes.DeleteVolume(pdName) - } else { - return fmt.Errorf("Unsupported provider type") } } @@ -224,14 +220,12 @@ func detachPD(hostName, pdName string) error { // TODO: make this hit the compute API directly. return exec.Command("gcloud", "compute", "instances", "detach-disk", "--zone="+zone, "--disk="+pdName, instanceName).Run() - } else if testContext.provider == "aws" { + } else { volumes, ok := testContext.cloudConfig.Provider.(aws_cloud.Volumes) if !ok { - return fmt.Errorf("Provider does not implement volumes interface") + return "", fmt.Errorf("Provider does not support volumes") } return volumes.DetachDisk(hostName, pdName) - } else { - return fmt.Errorf("Unsupported provider type") } }