From 950ae7e5baaa3eae8e9d046a5d182b40a9d67693 Mon Sep 17 00:00:00 2001 From: The Magician Date: Thu, 6 May 2021 12:47:52 -0700 Subject: [PATCH] Add conflicts with, node_version only works on the default node pool (#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 --- .changelog/4762.txt | 3 +++ google/resource_container_cluster.go | 9 +++++++++ 2 files changed, 12 insertions(+) create mode 100644 .changelog/4762.txt diff --git a/.changelog/4762.txt b/.changelog/4762.txt new file mode 100644 index 00000000000..157d8e015a2 --- /dev/null +++ b/.changelog/4762.txt @@ -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` +``` diff --git a/google/resource_container_cluster.go b/google/resource_container_cluster.go index 80398c1bafd..ee28728880e 100644 --- a/google/resource_container_cluster.go +++ b/google/resource_container_cluster.go @@ -105,6 +105,7 @@ func resourceContainerCluster() *schema.Resource { resourceNodeConfigEmptyGuestAccelerator, containerClusterPrivateClusterConfigCustomDiff, containerClusterAutopilotCustomizeDiff, + containerClusterNodeVersionRemoveDefaultCustomizeDiff, ), Timeouts: &schema.ResourceTimeout{ @@ -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 +}