-
Notifications
You must be signed in to change notification settings - Fork 359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Region to Provider #25
Add Region to Provider #25
Conversation
This commit adds the region argument to the OpenStack provider. This enables a user to specify the region once at the provider-level and have all resources within that provider be built in that region. If a resource-level region was specified, it is still recognized and will override the provider-level region.
I've finally had a chance to test this out in an environment with a multi-region catalog and I'm happy with how it works. It's quite safe and I was unable to accidentally destroy resources. It's still possible there are edge cases here, so there will be a warning in the CHANGELOG to do a @fatmcgav Let me know if you see any problems with this. @mcanevet I found some resources that weren't setting the region in their state, notably the If neither of you see any issues with this, I'll go ahead and merge it. It's a big change, so I want to get this one in first in order to avoid a lot of rebasing / merge conflicts :) |
@jtopjian I'll not have time to port all my custom providers to 0.10.0-dev in the nexts few days, but IIRC I add to add |
openstack/util.go
Outdated
// GetRegion returns the region from either d.Get("region") or OS_REGION_NAME | ||
func GetRegion(d *schema.ResourceData) string { | ||
// GetRegion returns the region from either d.Get("region") or config.Region | ||
// which is either specified in the config or pulled from OS_REGION_NAME. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jtopjian Is the reference to OS_REGION_NAME
still accurate here?
Is which is either specified in the resource config or pulled from provider config.
more accurate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'll clean this up.
@@ -135,44 +137,55 @@ func (c *Config) loadAndValidate() error { | |||
return nil | |||
} | |||
|
|||
func (c *Config) determineRegion(region string) string { | |||
// If a resource-level region was not specified, and a provider-level region was set, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to get an 'empty' region in here?
Do we need to check for that condition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's still possible to not set a region at all. I've tested this and it works as expected. I'll update the docs to mention no region is possible for single-region catalogs.
@jtopjian Had a quick run through the code and a couple of comments... I'll try and get a 0.10-dev build done later to day and test in anger :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New docs look good. I haven't yet had chance to test in anger though...
No worries - take your time. Building the new release isn't difficult, just a few new steps. Just do a |
@jtopjian I'm not sure if I'm missing something, but I've tried to run the 0.10.0-dev, and I can't get it to pick up the provider... :( I can see the Any pointers? Cheers |
@fatmcgav are you sure you're running |
@jtopjian Ah, good shout... I was running from So I'm guessing it's looking for provider plugins in the same dir as the |
So I've had a quick test with various combinations, and they all seem to work for me :) I've tried:
Haven't yet had chance to try a multi-region plan, but that'll take me a bit of time to get some test configs written up... Happy for this to be merged though... :) |
Add Region to Provider
This commit adds the region argument to the OpenStack provider.
This enables a user to specify the region once at the provider-level
and have all resources within that provider be built in that region.
If a resource-level region was specified, it is still recognized
and will override the provider-level region.
Fixes #17