-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
#1300 Supporting regional clusters for node pools #1320
Merged
nat-henderson
merged 28 commits into
hashicorp:master
from
darrenhaken:regional_node_pools
Apr 25, 2018
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
b450384
WIP for supporting regional clusters
darrenhaken b312a0c
Check if location is zone and set fields as needed
darrenhaken 8df3682
Fix update and delete functions to support regionals
darrenhaken 6e8b290
Create regional node pools.
darrenhaken 6dd0ae3
Finished regional clusters.
darrenhaken 6b6c9ab
Updated the docs for regional node pools
darrenhaken 2a8c44a
Merge branch 'master' of github.com:terraform-providers/terraform-pro…
darrenhaken 70d4b3a
Fix fmt issue
darrenhaken 4d3e0be
Resolve some of the points raised during review:
darrenhaken 9ffd2d8
Extract lock key logic into struct
darrenhaken b8f4c1c
Merge remote-tracking branch 'upstream/master' into regional_node_pools
darrenhaken c50b7ad
Add retry handlers to create/delete node pools
darrenhaken ef4b6e4
Merge remote-tracking branch 'upstream/master' into regional_node_pools
darrenhaken 5de8bf1
Change node pool update to use the cluster name passed in and the ID now
darrenhaken c30cdb8
Increase number of retries for deleting node pools
darrenhaken 0d18c77
Add cluster test for regional cluster with nested node pool
darrenhaken 84e29b0
Fix panic conditions on TestAccContainerCluster_withAddons and other
darrenhaken 80f4690
Fix `TestAccContainerNodePool_autoscaling` on node pool
darrenhaken 7693a28
Add test for regional node pool with an update
darrenhaken 18bb8d1
Merge remote-tracking branch 'upstream/master' into regional_node_pools
darrenhaken ac4098d
Merge remote-tracking branch 'upstream/master' into regional_node_pools
darrenhaken 855fec4
Fix TestAccContainerNodePool_version
darrenhaken 1aba204
Merge remote-tracking branch 'upstream/master' into regional_node_pools
darrenhaken 7436f8c
Fix FMT
darrenhaken fd447e2
Add retry to cluster deletion
darrenhaken 512f49f
Merge remote-tracking branch 'upstream/master' into regional_node_pools
darrenhaken 96e5385
Add diff suppress to taint so that GPU test passes.
nat-henderson b8138ea
remove log statements.
nat-henderson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package google | ||
|
||
import ( | ||
"fmt" | ||
"github.com/hashicorp/terraform/helper/schema" | ||
"strings" | ||
) | ||
|
||
//These functions are used by both the `resource_container_node_pool` and `resource_container_cluster` for handling regional clusters | ||
|
||
func isZone(location string) bool { | ||
return len(strings.Split(location, "-")) == 3 | ||
} | ||
|
||
func getLocation(d *schema.ResourceData, config *Config) (string, error) { | ||
if v, isRegionalCluster := d.GetOk("region"); isRegionalCluster { | ||
return v.(string), nil | ||
} else { | ||
// If region is not explicitly set, use "zone" (or fall back to the provider-level zone). | ||
// For now, to avoid confusion, we require region to be set in the config to create a regional | ||
// cluster rather than falling back to the provider-level region. | ||
return getZone(d, config) | ||
} | ||
} | ||
|
||
// getZone reads the "zone" value from the given resource data and falls back | ||
// to provider's value if not given. If neither is provided, returns an error. | ||
func getZone(d TerraformResourceData, config *Config) (string, error) { | ||
res, ok := d.GetOk("zone") | ||
if !ok { | ||
if config.Zone != "" { | ||
return config.Zone, nil | ||
} | ||
return "", fmt.Errorf("Cannot determine zone: set in this resource, or set provider-level zone.") | ||
} | ||
return GetResourceNameFromSelfLink(res.(string)), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I'd prefer the more explicit "matches the regex for 'contains two dashes with alphanumeric (lowercase) text between and after them'."
edit: I see that this isn't your code and you just extracted it - I still prefer this, but if you would rather not then I'll make the change later.
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.
I didn't think some of these functions were particularly robust, if I get time I can look to use Regex instead. If I do that I'll add unit tests for the function too.