Merge pull request #1490 from jtopjian/openstack-allow-blank-region

provider/openstack: Allow Blank Region
This commit is contained in:
Mitchell Hashimoto 2015-04-14 08:28:03 -07:00
commit 710d1113eb
19 changed files with 27 additions and 21 deletions

View File

@ -111,3 +111,10 @@ func envDefaultFunc(k string) schema.SchemaDefaultFunc {
return nil, nil
}
}
func envDefaultFuncAllowMissing(k string) schema.SchemaDefaultFunc {
return func() (interface{}, error) {
v := os.Getenv(k)
return v, nil
}
}

View File

@ -40,10 +40,9 @@ func testAccPreCheck(t *testing.T) {
}
v = os.Getenv("OS_REGION_NAME")
if v == "" {
t.Fatal("OS_REGION_NAME must be set for acceptance tests")
if v != "" {
OS_REGION_NAME = v
}
OS_REGION_NAME = v
v1 := os.Getenv("OS_IMAGE_ID")
v2 := os.Getenv("OS_IMAGE_NAME")

View File

@ -26,7 +26,7 @@ func resourceBlockStorageVolumeV1() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
},
"size": &schema.Schema{
Type: schema.TypeInt,

View File

@ -20,7 +20,7 @@ func resourceComputeFloatingIPV2() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
},
"pool": &schema.Schema{

View File

@ -36,7 +36,7 @@ func resourceComputeInstanceV2() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
},
"name": &schema.Schema{
Type: schema.TypeString,

View File

@ -19,7 +19,7 @@ func resourceComputeKeypairV2() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
},
"name": &schema.Schema{
Type: schema.TypeString,

View File

@ -23,7 +23,7 @@ func resourceComputeSecGroupV2() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
},
"name": &schema.Schema{
Type: schema.TypeString,

View File

@ -23,7 +23,7 @@ func resourceFWFirewallV1() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
},
"name": &schema.Schema{
Type: schema.TypeString,

View File

@ -23,7 +23,7 @@ func resourceFWPolicyV1() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
},
"name": &schema.Schema{
Type: schema.TypeString,

View File

@ -21,7 +21,7 @@ func resourceFWRuleV1() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
},
"name": &schema.Schema{
Type: schema.TypeString,

View File

@ -21,7 +21,7 @@ func resourceLBMonitorV1() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
},
"tenant_id": &schema.Schema{
Type: schema.TypeString,

View File

@ -24,7 +24,7 @@ func resourceLBPoolV1() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
},
"name": &schema.Schema{
Type: schema.TypeString,
@ -61,7 +61,7 @@ func resourceLBPoolV1() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
},
"tenant_id": &schema.Schema{
Type: schema.TypeString,

View File

@ -22,7 +22,7 @@ func resourceLBVipV1() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
},
"name": &schema.Schema{
Type: schema.TypeString,

View File

@ -21,7 +21,7 @@ func resourceNetworkingFloatingIPV2() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
},
"address": &schema.Schema{
Type: schema.TypeString,

View File

@ -21,7 +21,7 @@ func resourceNetworkingNetworkV2() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
},
"name": &schema.Schema{
Type: schema.TypeString,

View File

@ -21,7 +21,7 @@ func resourceNetworkingRouterInterfaceV2() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
},
"router_id": &schema.Schema{
Type: schema.TypeString,

View File

@ -22,7 +22,7 @@ func resourceNetworkingRouterV2() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
},
"name": &schema.Schema{
Type: schema.TypeString,

View File

@ -22,7 +22,7 @@ func resourceNetworkingSubnetV2() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
},
"network_id": &schema.Schema{
Type: schema.TypeString,

View File

@ -20,7 +20,7 @@ func resourceObjectStorageContainerV1() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
DefaultFunc: envDefaultFunc("OS_REGION_NAME"),
DefaultFunc: envDefaultFuncAllowMissing("OS_REGION_NAME"),
},
"name": &schema.Schema{
Type: schema.TypeString,