Skip to content

Commit

Permalink
Add conflicts with, node_version only works on the default node pool (#…
Browse files Browse the repository at this point in the history
…4762) (#9100)

* Add conflicts with, node_version only works on the default node pool

* Use customizediff rather than conflicts with

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored May 6, 2021
1 parent 8736b31 commit 950ae7e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/4762.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
container: added validation to check that both `node_version` and `remove_default_node_pool` cannot be set on `google_container_cluster`
```
9 changes: 9 additions & 0 deletions google/resource_container_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func resourceContainerCluster() *schema.Resource {
resourceNodeConfigEmptyGuestAccelerator,
containerClusterPrivateClusterConfigCustomDiff,
containerClusterAutopilotCustomizeDiff,
containerClusterNodeVersionRemoveDefaultCustomizeDiff,
),

Timeouts: &schema.ResourceTimeout{
Expand Down Expand Up @@ -3439,3 +3440,11 @@ func containerClusterAutopilotCustomizeDiff(_ context.Context, d *schema.Resourc
}
return nil
}

// node_version only applies to the default node pool, so it should conflict with remove_default_node_pool = true
func containerClusterNodeVersionRemoveDefaultCustomizeDiff(_ context.Context, d *schema.ResourceDiff, meta interface{}) error {
if d.Get("node_version").(string) != "" && d.Get("remove_default_node_pool").(bool) {
return fmt.Errorf("node_version can only be specified if remove_default_node_pool is not true")
}
return nil
}

0 comments on commit 950ae7e

Please sign in to comment.