Skip to content

Commit 23037d9

Browse files
committed
fix: Add null handling for bastion, operator image locals
Signed-off-by: Devon Crouse <devon.crouse@oracle.com>
1 parent d537b48 commit 23037d9

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

module-bastion.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ data "oci_core_images" "bastion" {
1919
}
2020

2121
locals {
22-
bastion_public_ip = (var.create_bastion
23-
? one(module.bastion[*].public_ip)
22+
bastion_public_ip = (var.create_bastion && length(module.bastion) > 0
23+
? lookup(element(module.bastion, 0), "public_ip", var.bastion_public_ip)
2424
: var.bastion_public_ip
2525
)
2626

27-
bastion_images = one(data.oci_core_images.bastion[*].images) # Data source result or null
28-
bastion_image_ids = local.bastion_images[*].id # Image OCIDs from data source
27+
bastion_images = try(data.oci_core_images.bastion[0].images, tolist([])) # Data source result or empty
28+
bastion_image_ids = local.bastion_images[*].id # Image OCIDs from data source
2929
bastion_image_id = (var.bastion_image_type == "custom"
3030
? var.bastion_image_id : element(coalescelist(local.bastion_image_ids, ["none"]), 0)
3131
)

module-operator.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ data "oci_core_images" "operator" {
2020

2121
locals {
2222
// The private IP of the operator instance, whether created in this TF state or existing provided by ID
23-
operator_private_ip = (local.cluster_enabled && var.create_operator
24-
? one(module.operator[*].private_ip)
23+
operator_private_ip = (local.cluster_enabled && var.create_operator && length(module.operator) > 0
24+
? lookup(element(module.operator, 0), "private_ip", var.operator_private_ip)
2525
: var.operator_private_ip
2626
)
2727

@@ -32,8 +32,8 @@ locals {
3232
])
3333

3434
// The resolved image ID for the created operator instance
35-
operator_images = one(data.oci_core_images.operator[*].images) # Data source result or null
36-
operator_image_ids = local.operator_images[*].id # Image OCIDs from data source
35+
operator_images = try(data.oci_core_images.operator[0].images, tolist([])) # Data source result or empty
36+
operator_image_ids = local.operator_images[*].id # Image OCIDs from data source
3737
operator_image_id = (var.operator_image_type == "custom"
3838
? var.operator_image_id : element(coalescelist(local.operator_image_ids, ["none"]), 0)
3939
)

modules/operator/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ variable "install_kubectx" { type = bool }
2020
variable "kubeconfig" { type = string }
2121
variable "kubernetes_version" { type = string }
2222
variable "nsg_ids" { type = list(string) }
23-
variable "operator_image_os_version" { type = string}
23+
variable "operator_image_os_version" { type = string }
2424
variable "pv_transit_encryption" { type = bool }
2525
variable "shape" { type = map(any) }
2626
variable "ssh_private_key" {

modules/workers/locals.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,11 @@ locals {
168168
for k, v in local.enabled_worker_pools : tobool(v.drain) ? lookup(v, "size", var.worker_pool_size) : 0
169169
])
170170

171-
# Number of work pools in the worker pools with autoscale enabled
171+
# Number of work pools in the worker pools with autoscale enabled
172172
expected_autoscale_worker_pools = length(local.enabled_worker_pools) == 0 ? 0 : sum([
173173
for k, v in local.enabled_worker_pools : tobool(v.autoscale) ? 1 : 0
174174
])
175-
175+
176176
# Enabled worker_pool map entries for node pools
177177
enabled_node_pools = {
178178
for k, v in local.enabled_worker_pools : k => v

variables-cluster.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ variable "create_cluster" {
88
}
99

1010
variable "cluster_name" {
11-
default = null
11+
default = "oke"
1212
description = "The name of oke cluster."
1313
type = string
1414
}

0 commit comments

Comments
 (0)