Commit 1c58f8f2 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

Merge pull request #1418 from msabramo/openstack_builder_region_not_mandatory

builder/openstack: Make region not required if not rackspace
parents 2bd41206 9bd33d1e
...@@ -115,8 +115,10 @@ func (c *AccessConfig) Prepare(t *packer.ConfigTemplate) []error { ...@@ -115,8 +115,10 @@ func (c *AccessConfig) Prepare(t *packer.ConfigTemplate) []error {
} }
} }
if c.Region() == "" { if strings.HasPrefix(c.Provider, "rackspace") {
errs = append(errs, fmt.Errorf("region must be specified")) if c.Region() == "" {
errs = append(errs, fmt.Errorf("region must be specified when using rackspace"))
}
} }
if len(errs) > 0 { if len(errs) > 0 {
......
...@@ -8,13 +8,22 @@ func testAccessConfig() *AccessConfig { ...@@ -8,13 +8,22 @@ func testAccessConfig() *AccessConfig {
return &AccessConfig{} return &AccessConfig{}
} }
func TestAccessConfigPrepare_NoRegion(t *testing.T) { func TestAccessConfigPrepare_NoRegion_Rackspace(t *testing.T) {
c := testAccessConfig() c := testAccessConfig()
c.Provider = "rackspace-us"
if err := c.Prepare(nil); err == nil { if err := c.Prepare(nil); err == nil {
t.Fatalf("shouldn't have err: %s", err) t.Fatalf("shouldn't have err: %s", err)
} }
} }
func TestAccessConfigPrepare_NoRegion_PrivateCloud(t *testing.T) {
c := testAccessConfig()
c.Provider = "http://some-keystone-server:5000/v2.0"
if err := c.Prepare(nil); err != nil {
t.Fatalf("shouldn't have err: %s", err)
}
}
func TestAccessConfigPrepare_Region(t *testing.T) { func TestAccessConfigPrepare_Region(t *testing.T) {
dfw := "DFW" dfw := "DFW"
c := testAccessConfig() c := testAccessConfig()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment