From d5478ecf2dc7d477e1cf9ace0fd1233835f1282a Mon Sep 17 00:00:00 2001 From: "Thomas P." Date: Fri, 15 Nov 2024 18:36:08 +0100 Subject: [PATCH] fix: node pool options cannot be set to falsy terraform's toset seems to strip falsy values from maps. Use a for expression instead, it's simpler and works too --- autogen/main/main.tf.tmpl | 6 ++---- main.tf | 6 ++---- modules/beta-private-cluster-update-variant/main.tf | 6 ++---- modules/beta-private-cluster/main.tf | 6 ++---- modules/beta-public-cluster-update-variant/main.tf | 6 ++---- modules/beta-public-cluster/main.tf | 6 ++---- modules/private-cluster-update-variant/main.tf | 6 ++---- modules/private-cluster/main.tf | 6 ++---- 8 files changed, 16 insertions(+), 32 deletions(-) diff --git a/autogen/main/main.tf.tmpl b/autogen/main/main.tf.tmpl index e3ff1813e6..772cd1e548 100644 --- a/autogen/main/main.tf.tmpl +++ b/autogen/main/main.tf.tmpl @@ -54,10 +54,8 @@ locals { master_version = var.regional ? local.master_version_regional : local.master_version_zonal {% if autopilot_cluster != true %} // Build a map of maps of node pools from a list of objects - node_pool_names = [for np in toset(var.node_pools) : np.name] - node_pools = zipmap(local.node_pool_names, tolist(toset(var.node_pools))) - windows_node_pool_names = [for np in toset(var.windows_node_pools) : np.name] - windows_node_pools = zipmap(local.windows_node_pool_names, tolist(toset(var.windows_node_pools))) + node_pools = {for np in var.node_pools: np.name => np} + windows_node_pools = {for np in var.windows_node_pools: np.name => np} {% endif %} fleet_membership = var.fleet_project != null ? google_container_cluster.primary.fleet[0].membership : null diff --git a/main.tf b/main.tf index c310b6edf8..ef235581f1 100644 --- a/main.tf +++ b/main.tf @@ -49,10 +49,8 @@ locals { master_version_zonal = var.kubernetes_version != "latest" ? var.kubernetes_version : data.google_container_engine_versions.zone.latest_master_version master_version = var.regional ? local.master_version_regional : local.master_version_zonal // Build a map of maps of node pools from a list of objects - node_pool_names = [for np in toset(var.node_pools) : np.name] - node_pools = zipmap(local.node_pool_names, tolist(toset(var.node_pools))) - windows_node_pool_names = [for np in toset(var.windows_node_pools) : np.name] - windows_node_pools = zipmap(local.windows_node_pool_names, tolist(toset(var.windows_node_pools))) + node_pools = { for np in var.node_pools : np.name => np } + windows_node_pools = { for np in var.windows_node_pools : np.name => np } fleet_membership = var.fleet_project != null ? google_container_cluster.primary.fleet[0].membership : null diff --git a/modules/beta-private-cluster-update-variant/main.tf b/modules/beta-private-cluster-update-variant/main.tf index c7759b2d41..96cb1aa8fe 100644 --- a/modules/beta-private-cluster-update-variant/main.tf +++ b/modules/beta-private-cluster-update-variant/main.tf @@ -49,10 +49,8 @@ locals { master_version_zonal = var.kubernetes_version != "latest" ? var.kubernetes_version : data.google_container_engine_versions.zone.latest_master_version master_version = var.regional ? local.master_version_regional : local.master_version_zonal // Build a map of maps of node pools from a list of objects - node_pool_names = [for np in toset(var.node_pools) : np.name] - node_pools = zipmap(local.node_pool_names, tolist(toset(var.node_pools))) - windows_node_pool_names = [for np in toset(var.windows_node_pools) : np.name] - windows_node_pools = zipmap(local.windows_node_pool_names, tolist(toset(var.windows_node_pools))) + node_pools = { for np in var.node_pools : np.name => np } + windows_node_pools = { for np in var.windows_node_pools : np.name => np } fleet_membership = var.fleet_project != null ? google_container_cluster.primary.fleet[0].membership : null diff --git a/modules/beta-private-cluster/main.tf b/modules/beta-private-cluster/main.tf index c7759b2d41..96cb1aa8fe 100644 --- a/modules/beta-private-cluster/main.tf +++ b/modules/beta-private-cluster/main.tf @@ -49,10 +49,8 @@ locals { master_version_zonal = var.kubernetes_version != "latest" ? var.kubernetes_version : data.google_container_engine_versions.zone.latest_master_version master_version = var.regional ? local.master_version_regional : local.master_version_zonal // Build a map of maps of node pools from a list of objects - node_pool_names = [for np in toset(var.node_pools) : np.name] - node_pools = zipmap(local.node_pool_names, tolist(toset(var.node_pools))) - windows_node_pool_names = [for np in toset(var.windows_node_pools) : np.name] - windows_node_pools = zipmap(local.windows_node_pool_names, tolist(toset(var.windows_node_pools))) + node_pools = { for np in var.node_pools : np.name => np } + windows_node_pools = { for np in var.windows_node_pools : np.name => np } fleet_membership = var.fleet_project != null ? google_container_cluster.primary.fleet[0].membership : null diff --git a/modules/beta-public-cluster-update-variant/main.tf b/modules/beta-public-cluster-update-variant/main.tf index d5a37b118e..a425742d18 100644 --- a/modules/beta-public-cluster-update-variant/main.tf +++ b/modules/beta-public-cluster-update-variant/main.tf @@ -49,10 +49,8 @@ locals { master_version_zonal = var.kubernetes_version != "latest" ? var.kubernetes_version : data.google_container_engine_versions.zone.latest_master_version master_version = var.regional ? local.master_version_regional : local.master_version_zonal // Build a map of maps of node pools from a list of objects - node_pool_names = [for np in toset(var.node_pools) : np.name] - node_pools = zipmap(local.node_pool_names, tolist(toset(var.node_pools))) - windows_node_pool_names = [for np in toset(var.windows_node_pools) : np.name] - windows_node_pools = zipmap(local.windows_node_pool_names, tolist(toset(var.windows_node_pools))) + node_pools = { for np in var.node_pools : np.name => np } + windows_node_pools = { for np in var.windows_node_pools : np.name => np } fleet_membership = var.fleet_project != null ? google_container_cluster.primary.fleet[0].membership : null diff --git a/modules/beta-public-cluster/main.tf b/modules/beta-public-cluster/main.tf index d5a37b118e..a425742d18 100644 --- a/modules/beta-public-cluster/main.tf +++ b/modules/beta-public-cluster/main.tf @@ -49,10 +49,8 @@ locals { master_version_zonal = var.kubernetes_version != "latest" ? var.kubernetes_version : data.google_container_engine_versions.zone.latest_master_version master_version = var.regional ? local.master_version_regional : local.master_version_zonal // Build a map of maps of node pools from a list of objects - node_pool_names = [for np in toset(var.node_pools) : np.name] - node_pools = zipmap(local.node_pool_names, tolist(toset(var.node_pools))) - windows_node_pool_names = [for np in toset(var.windows_node_pools) : np.name] - windows_node_pools = zipmap(local.windows_node_pool_names, tolist(toset(var.windows_node_pools))) + node_pools = { for np in var.node_pools : np.name => np } + windows_node_pools = { for np in var.windows_node_pools : np.name => np } fleet_membership = var.fleet_project != null ? google_container_cluster.primary.fleet[0].membership : null diff --git a/modules/private-cluster-update-variant/main.tf b/modules/private-cluster-update-variant/main.tf index c52f9ea1ee..77d2d8a2e0 100644 --- a/modules/private-cluster-update-variant/main.tf +++ b/modules/private-cluster-update-variant/main.tf @@ -49,10 +49,8 @@ locals { master_version_zonal = var.kubernetes_version != "latest" ? var.kubernetes_version : data.google_container_engine_versions.zone.latest_master_version master_version = var.regional ? local.master_version_regional : local.master_version_zonal // Build a map of maps of node pools from a list of objects - node_pool_names = [for np in toset(var.node_pools) : np.name] - node_pools = zipmap(local.node_pool_names, tolist(toset(var.node_pools))) - windows_node_pool_names = [for np in toset(var.windows_node_pools) : np.name] - windows_node_pools = zipmap(local.windows_node_pool_names, tolist(toset(var.windows_node_pools))) + node_pools = { for np in var.node_pools : np.name => np } + windows_node_pools = { for np in var.windows_node_pools : np.name => np } fleet_membership = var.fleet_project != null ? google_container_cluster.primary.fleet[0].membership : null diff --git a/modules/private-cluster/main.tf b/modules/private-cluster/main.tf index c52f9ea1ee..77d2d8a2e0 100644 --- a/modules/private-cluster/main.tf +++ b/modules/private-cluster/main.tf @@ -49,10 +49,8 @@ locals { master_version_zonal = var.kubernetes_version != "latest" ? var.kubernetes_version : data.google_container_engine_versions.zone.latest_master_version master_version = var.regional ? local.master_version_regional : local.master_version_zonal // Build a map of maps of node pools from a list of objects - node_pool_names = [for np in toset(var.node_pools) : np.name] - node_pools = zipmap(local.node_pool_names, tolist(toset(var.node_pools))) - windows_node_pool_names = [for np in toset(var.windows_node_pools) : np.name] - windows_node_pools = zipmap(local.windows_node_pool_names, tolist(toset(var.windows_node_pools))) + node_pools = { for np in var.node_pools : np.name => np } + windows_node_pools = { for np in var.windows_node_pools : np.name => np } fleet_membership = var.fleet_project != null ? google_container_cluster.primary.fleet[0].membership : null