Skip to content

Commit a745e01

Browse files
committed
Simplify how cluster_name_computed is generated
1 parent 93aeeea commit a745e01

File tree

9 files changed

+9
-25
lines changed

9 files changed

+9
-25
lines changed

autogen/main/main.tf.tmpl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,7 @@ locals {
202202
cluster_zones = sort(local.cluster_output_zones)
203203

204204
{% if autopilot_cluster != true %}
205-
// node pool ID is in the form projects/<project-id>/locations/<location>/clusters/<cluster-name>/nodePools/<nodepool-name>
206-
cluster_name_parts_from_nodepool = length(var.node_pools) == 0 ? [] : split("/", element(values(google_container_node_pool.pools)[*].id, 0))
207-
cluster_name_computed = length(var.node_pools) == 0 ? var.name : element(local.cluster_name_parts_from_nodepool, length(local.cluster_name_parts_from_nodepool) - 3)
205+
cluster_name_computed = var.name
208206
{% else %}
209207
// cluster ID is in the form project/location/name
210208
cluster_name_computed = element(split("/", local.cluster_id), length(split("/", local.cluster_id)) - 1)

main.tf

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,7 @@ locals {
144144
cluster_region = var.regional ? var.region : join("-", slice(split("-", local.cluster_location), 0, 2))
145145
cluster_zones = sort(local.cluster_output_zones)
146146

147-
// node pool ID is in the form projects/<project-id>/locations/<location>/clusters/<cluster-name>/nodePools/<nodepool-name>
148-
cluster_name_parts_from_nodepool = length(var.node_pools) == 0 ? [] : split("/", element(values(google_container_node_pool.pools)[*].id, 0))
149-
cluster_name_computed = length(var.node_pools) == 0 ? var.name : element(local.cluster_name_parts_from_nodepool, length(local.cluster_name_parts_from_nodepool) - 3)
147+
cluster_name_computed = var.name
150148
cluster_network_tag = "gke-${var.name}"
151149
cluster_ca_certificate = local.cluster_master_auth_map["cluster_ca_certificate"]
152150
cluster_master_version = local.cluster_output_master_version

modules/beta-private-cluster-update-variant/main.tf

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,7 @@ locals {
168168
cluster_region = var.regional ? var.region : join("-", slice(split("-", local.cluster_location), 0, 2))
169169
cluster_zones = sort(local.cluster_output_zones)
170170

171-
// node pool ID is in the form projects/<project-id>/locations/<location>/clusters/<cluster-name>/nodePools/<nodepool-name>
172-
cluster_name_parts_from_nodepool = length(var.node_pools) == 0 ? [] : split("/", element(values(google_container_node_pool.pools)[*].id, 0))
173-
cluster_name_computed = length(var.node_pools) == 0 ? var.name : element(local.cluster_name_parts_from_nodepool, length(local.cluster_name_parts_from_nodepool) - 3)
171+
cluster_name_computed = var.name
174172
cluster_network_tag = "gke-${var.name}"
175173
cluster_ca_certificate = local.cluster_master_auth_map["cluster_ca_certificate"]
176174
cluster_master_version = local.cluster_output_master_version

modules/beta-private-cluster/main.tf

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,7 @@ locals {
168168
cluster_region = var.regional ? var.region : join("-", slice(split("-", local.cluster_location), 0, 2))
169169
cluster_zones = sort(local.cluster_output_zones)
170170

171-
// node pool ID is in the form projects/<project-id>/locations/<location>/clusters/<cluster-name>/nodePools/<nodepool-name>
172-
cluster_name_parts_from_nodepool = length(var.node_pools) == 0 ? [] : split("/", element(values(google_container_node_pool.pools)[*].id, 0))
173-
cluster_name_computed = length(var.node_pools) == 0 ? var.name : element(local.cluster_name_parts_from_nodepool, length(local.cluster_name_parts_from_nodepool) - 3)
171+
cluster_name_computed = var.name
174172
cluster_network_tag = "gke-${var.name}"
175173
cluster_ca_certificate = local.cluster_master_auth_map["cluster_ca_certificate"]
176174
cluster_master_version = local.cluster_output_master_version

modules/beta-public-cluster-update-variant/main.tf

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,7 @@ locals {
161161
cluster_region = var.regional ? var.region : join("-", slice(split("-", local.cluster_location), 0, 2))
162162
cluster_zones = sort(local.cluster_output_zones)
163163

164-
// node pool ID is in the form projects/<project-id>/locations/<location>/clusters/<cluster-name>/nodePools/<nodepool-name>
165-
cluster_name_parts_from_nodepool = length(var.node_pools) == 0 ? [] : split("/", element(values(google_container_node_pool.pools)[*].id, 0))
166-
cluster_name_computed = length(var.node_pools) == 0 ? var.name : element(local.cluster_name_parts_from_nodepool, length(local.cluster_name_parts_from_nodepool) - 3)
164+
cluster_name_computed = var.name
167165
cluster_network_tag = "gke-${var.name}"
168166
cluster_ca_certificate = local.cluster_master_auth_map["cluster_ca_certificate"]
169167
cluster_master_version = local.cluster_output_master_version

modules/beta-public-cluster/main.tf

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,7 @@ locals {
161161
cluster_region = var.regional ? var.region : join("-", slice(split("-", local.cluster_location), 0, 2))
162162
cluster_zones = sort(local.cluster_output_zones)
163163

164-
// node pool ID is in the form projects/<project-id>/locations/<location>/clusters/<cluster-name>/nodePools/<nodepool-name>
165-
cluster_name_parts_from_nodepool = length(var.node_pools) == 0 ? [] : split("/", element(values(google_container_node_pool.pools)[*].id, 0))
166-
cluster_name_computed = length(var.node_pools) == 0 ? var.name : element(local.cluster_name_parts_from_nodepool, length(local.cluster_name_parts_from_nodepool) - 3)
164+
cluster_name_computed = var.name
167165
cluster_network_tag = "gke-${var.name}"
168166
cluster_ca_certificate = local.cluster_master_auth_map["cluster_ca_certificate"]
169167
cluster_master_version = local.cluster_output_master_version

modules/gke-node-pool/metadata.display.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ spec:
6262
name:
6363
name: name
6464
title: Name
65-
level: 1
6665
regexValidation: ^[a-z]([a-z0-9-]{0,38}[a-z0-9])?$
6766
validation: Node pool name must start with a lowercase letter followed by up to 39 lowercase letters, numbers, or hyphens and cannot end with a hyphen.
67+
level: 1
6868
name_prefix:
6969
name: name_prefix
7070
title: Name Prefix

modules/private-cluster-update-variant/main.tf

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,7 @@ locals {
151151
cluster_region = var.regional ? var.region : join("-", slice(split("-", local.cluster_location), 0, 2))
152152
cluster_zones = sort(local.cluster_output_zones)
153153

154-
// node pool ID is in the form projects/<project-id>/locations/<location>/clusters/<cluster-name>/nodePools/<nodepool-name>
155-
cluster_name_parts_from_nodepool = length(var.node_pools) == 0 ? [] : split("/", element(values(google_container_node_pool.pools)[*].id, 0))
156-
cluster_name_computed = length(var.node_pools) == 0 ? var.name : element(local.cluster_name_parts_from_nodepool, length(local.cluster_name_parts_from_nodepool) - 3)
154+
cluster_name_computed = var.name
157155
cluster_network_tag = "gke-${var.name}"
158156
cluster_ca_certificate = local.cluster_master_auth_map["cluster_ca_certificate"]
159157
cluster_master_version = local.cluster_output_master_version

modules/private-cluster/main.tf

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,7 @@ locals {
151151
cluster_region = var.regional ? var.region : join("-", slice(split("-", local.cluster_location), 0, 2))
152152
cluster_zones = sort(local.cluster_output_zones)
153153

154-
// node pool ID is in the form projects/<project-id>/locations/<location>/clusters/<cluster-name>/nodePools/<nodepool-name>
155-
cluster_name_parts_from_nodepool = length(var.node_pools) == 0 ? [] : split("/", element(values(google_container_node_pool.pools)[*].id, 0))
156-
cluster_name_computed = length(var.node_pools) == 0 ? var.name : element(local.cluster_name_parts_from_nodepool, length(local.cluster_name_parts_from_nodepool) - 3)
154+
cluster_name_computed = var.name
157155
cluster_network_tag = "gke-${var.name}"
158156
cluster_ca_certificate = local.cluster_master_auth_map["cluster_ca_certificate"]
159157
cluster_master_version = local.cluster_output_master_version

0 commit comments

Comments
 (0)