Make region required for rackspace but not other providers

Update test to make it pass.
This commit is contained in:
Marc Abramowitz 2014-08-15 11:19:04 -07:00
parent 69500b6943
commit 9bd33d1e0b
2 changed files with 16 additions and 1 deletions

View File

@ -115,6 +115,12 @@ func (c *AccessConfig) Prepare(t *packer.ConfigTemplate) []error {
}
}
if strings.HasPrefix(c.Provider, "rackspace") {
if c.Region() == "" {
errs = append(errs, fmt.Errorf("region must be specified when using rackspace"))
}
}
if len(errs) > 0 {
return errs
}

View File

@ -8,13 +8,22 @@ func testAccessConfig() *AccessConfig {
return &AccessConfig{}
}
func TestAccessConfigPrepare_NoRegion(t *testing.T) {
func TestAccessConfigPrepare_NoRegion_Rackspace(t *testing.T) {
c := testAccessConfig()
c.Provider = "rackspace-us"
if err := c.Prepare(nil); err == nil {
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) {
dfw := "DFW"
c := testAccessConfig()