From: Anil Belur Date: Wed, 7 Jan 2026 12:52:05 +0000 (+1000) Subject: fix: Add cloud_network default and conditional networks X-Git-Tag: v0.18.1^0 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F49%2F74049%2F1;p=releng%2Fcommon-packer.git fix: Add cloud_network default and conditional networks Fix packer validation error when cloud_network variable is not set. Issue: - builder.pkr.hcl: cloud_network variable had no default value - Both templates: networks parameter required array, failed with null Changes: 1. Added 'default = null' to cloud_network variable in builder.pkr.hcl 2. Made networks parameter conditional in both templates: - If cloud_network is null: networks = null (uses OpenStack default) - If cloud_network is set: networks = [cloud_network] Error Fixed: Error: Unset variable "cloud_network" A used variable must be set or have a default value Validation: packer validate -syntax-only templates/builder.pkr.hcl packer validate -syntax-only templates/docker.pkr.hcl Both pass successfully Impact: - Allows validation without cloud_network set - Maintains backward compatibility when cloud_network is provided - No functional change to actual builds (cloud_network provided at runtime) Related: opendaylight/releng-builder validation failure Change-Id: I0da5fa2b8decb71444e4066d3a82f79435aa8130 Signed-off-by: Anil Belur Signed-off-by: Anil Belur --- diff --git a/templates/builder.pkr.hcl b/templates/builder.pkr.hcl index 34ca8a5..b960dea 100644 --- a/templates/builder.pkr.hcl +++ b/templates/builder.pkr.hcl @@ -56,7 +56,8 @@ variable "cloud_pass" { } variable "cloud_network" { - type = string + type = string + default = null } variable "cloud_region" { @@ -200,7 +201,7 @@ source "openstack" "builder" { metadata = { ci_managed = "yes" } - networks = ["${var.cloud_network}"] + networks = var.cloud_network != null ? ["${var.cloud_network}"] : null region = "${var.cloud_region}" source_image_name = "${var.base_image}" diff --git a/templates/docker.pkr.hcl b/templates/docker.pkr.hcl index b0c538d..bd65fb5 100644 --- a/templates/docker.pkr.hcl +++ b/templates/docker.pkr.hcl @@ -206,7 +206,7 @@ source "openstack" "docker" { metadata = { ci_managed = "yes" } - networks = ["${var.cloud_network}"] + networks = var.cloud_network != null ? ["${var.cloud_network}"] : null region = "${var.cloud_region}" source_image_name = "${var.base_image}"