From 8e547915fcd7eb13515436244e57b1cb2dd07eb4 Mon Sep 17 00:00:00 2001 From: Moritz Sanft <58110325+msanft@users.noreply.github.com> Date: Thu, 14 Dec 2023 15:53:06 +0100 Subject: [PATCH] cli: make `location` field optional --- cli/internal/cloudcmd/tfvars.go | 2 +- cli/internal/terraform/variables.go | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cli/internal/cloudcmd/tfvars.go b/cli/internal/cloudcmd/tfvars.go index 2d55342da2..4b78f7df85 100644 --- a/cli/internal/cloudcmd/tfvars.go +++ b/cli/internal/cloudcmd/tfvars.go @@ -65,7 +65,7 @@ func TerraformIAMUpgradeVars(conf *config.Config, fileHandler file.Handler) (ter return nil, fmt.Errorf("parsing existing IAM workspace: %w", err) } - // Migration from the "region" to the "location" field name. + // Migration from the "region" to the "location" field na. // TODO(msanft): Remove after v2.14.0 is released. if oldVars.Region != nil && *oldVars.Region != "" && oldVars.Location == "" { oldVars.Location = *oldVars.Region diff --git a/cli/internal/terraform/variables.go b/cli/internal/terraform/variables.go index 210fa71bab..6c800e124a 100644 --- a/cli/internal/terraform/variables.go +++ b/cli/internal/terraform/variables.go @@ -38,8 +38,9 @@ func VariablesFromBytes[T any](b []byte, vars *T) error { return fmt.Errorf("parsing variables: %w", err) } - if err := gohcl.DecodeBody(file.Body, nil, vars); err != nil { - return fmt.Errorf("decoding variables: %w", err) + diags := gohcl.DecodeBody(file.Body, nil, vars) + if diags.HasErrors() { + return fmt.Errorf("decoding variables: %w", diags) } return nil } @@ -246,9 +247,9 @@ type AzureNodeGroup struct { type AzureIAMVariables struct { // Region is the Azure location to use. (e.g. westus). // THIS FIELD IS DEPRECATED AND ONLY KEPT FOR MIGRATION PURPOSES. DO NOT USE. - Region *string `hcl:"region" cty:"region"` + Region *string `hcl:"region" cty:"region"` // TODO(msanft): Remove this field once v2.14.0 is released. // Location is the Azure location to use. (e.g. westus) - Location string `hcl:"location" cty:"location"` + Location string `hcl:"location,optional" cty:"location"` // TODO(msanft): Make this required once v2.14.0 is released. // ServicePrincipal is the name of the service principal to use. ServicePrincipal string `hcl:"service_principal_name" cty:"service_principal_name"` // ResourceGroup is the name of the resource group to use.