Skip to content

Commit

Permalink
add null support for operation_type (#13)
Browse files Browse the repository at this point in the history
* add null support for operation_type

* fix operation_type validation
  • Loading branch information
duzitong authored Sep 26, 2024
1 parent 4fb0368 commit b8b27c7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
18 changes: 16 additions & 2 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,22 @@ locals {
}
}
deployment_data_omit_null = { for k, v in local.deployment_data : k => v if v != null }
key_vault = var.create_key_vault ? azurerm_key_vault.deployment_keyvault[0] : data.azurerm_key_vault.key_vault[0]
owned_user_storages = [for storage in local.decoded_user_storages : storage if lower(storage.extendedLocation.name) == lower(data.azapi_resource.customlocation.id)]
deployment_setting_properties = {
arcNodeResourceIds = flatten([for server in data.azurerm_arc_machine.arcservers : server.id])
deploymentMode = var.is_exported ? "Deploy" : "Validate"
operationType = var.operation_type
deploymentConfiguration = {
version = "10.0.0.0"
scaleUnits = [
{
deploymentData = local.deployment_data_omit_null
}
]
}
}
deployment_setting_properties_omit_null = { for k, v in local.deployment_setting_properties : k => v if v != null }
key_vault = var.create_key_vault ? azurerm_key_vault.deployment_keyvault[0] : data.azurerm_key_vault.key_vault[0]
owned_user_storages = [for storage in local.decoded_user_storages : storage if lower(storage.extendedLocation.name) == lower(data.azapi_resource.customlocation.id)]
rdma_adapter_properties = {
jumboPacket = "9014"
networkDirect = "Enabled"
Expand Down
14 changes: 1 addition & 13 deletions validate.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,7 @@ data "azurerm_arc_machine" "arcservers" {
resource "azapi_resource" "validatedeploymentsetting" {
type = "Microsoft.AzureStackHCI/clusters/deploymentSettings@2024-04-01"
body = {
properties = {
arcNodeResourceIds = flatten([for server in data.azurerm_arc_machine.arcservers : server.id])
deploymentMode = var.is_exported ? "Deploy" : "Validate"
operationType = var.operation_type
deploymentConfiguration = {
version = "10.0.0.0"
scaleUnits = [
{
deploymentData = local.deployment_data_omit_null
}
]
}
}
properties = local.deployment_setting_properties_omit_null
}
name = "default"
parent_id = azapi_resource.cluster.id
Expand Down
2 changes: 1 addition & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ variable "operation_type" {
description = "The intended operation for a cluster."

validation {
condition = contains(["ClusterProvisioning", "ClusterUpgrade"], var.operation_type)
condition = var.operation_type == null || contains(["ClusterProvisioning", "ClusterUpgrade"], var.operation_type)
error_message = "operation_type must be either 'ClusterProvisioning' or 'ClusterUpgrade'."
}
}
Expand Down

0 comments on commit b8b27c7

Please sign in to comment.