From 3a376d808d87a637eb4d8a498f394b3d184f6889 Mon Sep 17 00:00:00 2001 From: Steph Date: Thu, 5 Sep 2024 08:51:58 +0200 Subject: [PATCH] fix test configs for renamed properties --- ...ubernetes_cluster_network_resource_test.go | 30 +++---- .../kubernetes_cluster_other_resource_test.go | 72 ++++++++--------- .../kubernetes_cluster_resource_test.go | 10 +-- ...ubernetes_cluster_resource_upgrade_test.go | 10 +-- ...ubernetes_cluster_scaling_resource_test.go | 80 +++++++++---------- .../containers/kubernetes_nodepool.go | 12 +-- 6 files changed, 107 insertions(+), 107 deletions(-) diff --git a/internal/services/containers/kubernetes_cluster_network_resource_test.go b/internal/services/containers/kubernetes_cluster_network_resource_test.go index 2607ff697d10..92d4de0c8838 100644 --- a/internal/services/containers/kubernetes_cluster_network_resource_test.go +++ b/internal/services/containers/kubernetes_cluster_network_resource_test.go @@ -380,7 +380,7 @@ func TestAccKubernetesCluster_enableNodePublicIP(t *testing.T) { Config: r.enableNodePublicIPConfig(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("default_node_pool.0.enable_node_public_ip").HasValue("true"), + check.That(data.ResourceName).Key("default_node_pool.0.node_public_ip_enabled").HasValue("true"), ), }, data.ImportStep(), @@ -412,7 +412,7 @@ func TestAccKubernetesCluster_nodePublicIPPrefix(t *testing.T) { Config: r.nodePublicIPPrefixConfig(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("default_node_pool.0.enable_node_public_ip").HasValue("true"), + check.That(data.ResourceName).Key("default_node_pool.0.node_public_ip_enabled").HasValue("true"), check.That(data.ResourceName).Key("default_node_pool.0.node_public_ip_prefix_id").Exists(), ), }, @@ -1966,10 +1966,10 @@ resource "azurerm_kubernetes_cluster" "test" { dns_prefix = "acctestaks%d" default_node_pool { - name = "default" - node_count = 1 - vm_size = "Standard_DS2_v2" - enable_node_public_ip = true + name = "default" + node_count = 1 + vm_size = "Standard_DS2_v2" + node_public_ip_enabled = true upgrade_settings { max_surge = "10%%" } @@ -2067,7 +2067,7 @@ resource "azurerm_kubernetes_cluster" "test" { name = "default" node_count = 1 vm_size = "Standard_DS2_v2" - enable_node_public_ip = true + node_public_ip_enabled = true node_public_ip_prefix_id = azurerm_public_ip_prefix.test.id upgrade_settings { max_surge = "10%%" @@ -4384,10 +4384,10 @@ resource "azurerm_kubernetes_cluster" "test" { resource_group_name = azurerm_resource_group.test.name dns_prefix = "acctestaks%[2]d" default_node_pool { - name = "default" - node_count = 1 - vm_size = "Standard_DS2_v2" - enable_node_public_ip = true + name = "default" + node_count = 1 + vm_size = "Standard_DS2_v2" + node_public_ip_enabled = true node_network_profile { node_public_ip_tags = { RoutingPreference = "Internet" @@ -4427,10 +4427,10 @@ resource "azurerm_kubernetes_cluster" "test" { resource_group_name = azurerm_resource_group.test.name dns_prefix = "acctestaks%[2]d" default_node_pool { - name = "default" - node_count = 1 - vm_size = "Standard_DS2_v2" - enable_node_public_ip = true + name = "default" + node_count = 1 + vm_size = "Standard_DS2_v2" + node_public_ip_enabled = true node_network_profile { allowed_host_ports { port_start = 8001 diff --git a/internal/services/containers/kubernetes_cluster_other_resource_test.go b/internal/services/containers/kubernetes_cluster_other_resource_test.go index 22aede084aa5..b17a285b69d8 100644 --- a/internal/services/containers/kubernetes_cluster_other_resource_test.go +++ b/internal/services/containers/kubernetes_cluster_other_resource_test.go @@ -1349,12 +1349,12 @@ resource "azurerm_kubernetes_cluster" "test" { dns_prefix = "acctestaks%d" default_node_pool { - name = "default" - node_count = 1 - enable_auto_scaling = true - vm_size = "Standard_DS2_v2" - min_count = 1 - max_count = 1 + name = "default" + node_count = 1 + auto_scaling_enabled = true + vm_size = "Standard_DS2_v2" + min_count = 1 + max_count = 1 upgrade_settings { max_surge = "10%%" } @@ -1385,12 +1385,12 @@ resource "azurerm_kubernetes_cluster" "test" { dns_prefix = "acctestaks%d" default_node_pool { - name = "default" - node_count = 2 - vm_size = "Standard_DS2_v2" - enable_auto_scaling = true - max_count = 10 - min_count = 1 + name = "default" + node_count = 2 + vm_size = "Standard_DS2_v2" + auto_scaling_enabled = true + max_count = 10 + min_count = 1 upgrade_settings { max_surge = "10%%" } @@ -1421,12 +1421,12 @@ resource "azurerm_kubernetes_cluster" "test" { dns_prefix = "acctestaks%d" default_node_pool { - name = "default" - node_count = 1 - vm_size = "Standard_DS2_v2" - enable_auto_scaling = true - max_count = 10 - min_count = 1 + name = "default" + node_count = 1 + vm_size = "Standard_DS2_v2" + auto_scaling_enabled = true + max_count = 10 + min_count = 1 upgrade_settings { max_surge = "10%%" } @@ -1457,12 +1457,12 @@ resource "azurerm_kubernetes_cluster" "test" { dns_prefix = "acctestaks%d" default_node_pool { - name = "default" - node_count = 11 - vm_size = "Standard_DS2_v2" - enable_auto_scaling = true - max_count = 10 - min_count = 1 + name = "default" + node_count = 11 + vm_size = "Standard_DS2_v2" + auto_scaling_enabled = true + max_count = 10 + min_count = 1 upgrade_settings { max_surge = "10%%" } @@ -1493,12 +1493,12 @@ resource "azurerm_kubernetes_cluster" "test" { dns_prefix = "acctestAKS%d" default_node_pool { - name = "default" - vm_size = "Standard_DS2_v2" - enable_auto_scaling = true - min_count = 1 - max_count = 399 - node_count = 1 + name = "default" + vm_size = "Standard_DS2_v2" + auto_scaling_enabled = true + min_count = 1 + max_count = 399 + node_count = 1 upgrade_settings { max_surge = "10%%" } @@ -1529,12 +1529,12 @@ resource "azurerm_kubernetes_cluster" "test" { dns_prefix = "acctestaks%d" default_node_pool { - name = "default" - node_count = 1 - vm_size = "Standard_DS2_v2" - enable_auto_scaling = true - max_count = 10 - min_count = 2 + name = "default" + node_count = 1 + vm_size = "Standard_DS2_v2" + auto_scaling_enabled = true + max_count = 10 + min_count = 2 upgrade_settings { max_surge = "10%%" } diff --git a/internal/services/containers/kubernetes_cluster_resource_test.go b/internal/services/containers/kubernetes_cluster_resource_test.go index 490423a6f738..123957b70143 100644 --- a/internal/services/containers/kubernetes_cluster_resource_test.go +++ b/internal/services/containers/kubernetes_cluster_resource_test.go @@ -38,7 +38,7 @@ func TestAccKubernetesCluster_hostEncryption(t *testing.T) { Config: r.hostEncryption(data, currentKubernetesVersion), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("default_node_pool.0.enable_host_encryption").HasValue("true"), + check.That(data.ResourceName).Key("default_node_pool.0.host_encryption_enabled").HasValue("true"), ), }, }) @@ -319,10 +319,10 @@ resource "azurerm_kubernetes_cluster" "test" { kubernetes_version = %q default_node_pool { - name = "default" - node_count = 1 - vm_size = "Standard_DS2_v2" - enable_host_encryption = true + name = "default" + node_count = 1 + vm_size = "Standard_DS2_v2" + host_encryption_enabled = true upgrade_settings { max_surge = "10%%" } diff --git a/internal/services/containers/kubernetes_cluster_resource_upgrade_test.go b/internal/services/containers/kubernetes_cluster_resource_upgrade_test.go index f6960d158ded..0c53d77abb9d 100644 --- a/internal/services/containers/kubernetes_cluster_resource_upgrade_test.go +++ b/internal/services/containers/kubernetes_cluster_resource_upgrade_test.go @@ -455,11 +455,11 @@ resource "azurerm_kubernetes_cluster" "test" { kubernetes_version = %q default_node_pool { - name = "default" - vm_size = "Standard_DS2_v2" - enable_auto_scaling = true - min_count = %d - max_count = %d + name = "default" + vm_size = "Standard_DS2_v2" + auto_scaling_enabled = true + min_count = %d + max_count = %d upgrade_settings { max_surge = "10%%" } diff --git a/internal/services/containers/kubernetes_cluster_scaling_resource_test.go b/internal/services/containers/kubernetes_cluster_scaling_resource_test.go index e2171db88a7a..b71006154fd0 100644 --- a/internal/services/containers/kubernetes_cluster_scaling_resource_test.go +++ b/internal/services/containers/kubernetes_cluster_scaling_resource_test.go @@ -304,7 +304,7 @@ func TestAccKubernetesCluster_autoScalingError(t *testing.T) { Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), - ExpectError: regexp.MustCompile("cannot change `node_count` when `enable_auto_scaling` is set to `true`"), + ExpectError: regexp.MustCompile("cannot change `node_count` when `auto_scaling_enabled` is set to `true`"), }, }) } @@ -319,7 +319,7 @@ func TestAccKubernetesCluster_autoScalingErrorMax(t *testing.T) { Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), - ExpectError: regexp.MustCompile("`node_count`\\(11\\) must be equal to or less than `max_count`\\(10\\) when `enable_auto_scaling` is set to `true`"), + ExpectError: regexp.MustCompile("`node_count`\\(11\\) must be equal to or less than `max_count`\\(10\\) when `auto_scaling_enabled` is set to `true`"), }, }) } @@ -349,7 +349,7 @@ func TestAccKubernetesCluster_autoScalingErrorMin(t *testing.T) { Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), ), - ExpectError: regexp.MustCompile("`node_count`\\(1\\) must be equal to or greater than `min_count`\\(2\\) when `enable_auto_scaling` is set to `true`"), + ExpectError: regexp.MustCompile("`node_count`\\(1\\) must be equal to or greater than `min_count`\\(2\\) when `auto_scaling_enabled` is set to `true`"), }, }) } @@ -365,7 +365,7 @@ func TestAccKubernetesCluster_autoScalingNodeCountUnset(t *testing.T) { check.That(data.ResourceName).ExistsInAzure(r), check.That(data.ResourceName).Key("default_node_pool.0.min_count").HasValue("2"), check.That(data.ResourceName).Key("default_node_pool.0.max_count").HasValue("4"), - check.That(data.ResourceName).Key("default_node_pool.0.enable_auto_scaling").HasValue("true"), + check.That(data.ResourceName).Key("default_node_pool.0.auto_scaling_enabled").HasValue("true"), check.That(data.ResourceName).Key("auto_scaler_profile.0.max_graceful_termination_sec").HasValue("600"), check.That(data.ResourceName).Key("auto_scaler_profile.0.new_pod_scale_up_delay").HasValue("0s"), check.That(data.ResourceName).Key("auto_scaler_profile.0.scale_down_delay_after_add").HasValue("10m"), @@ -393,7 +393,7 @@ func TestAccKubernetesCluster_autoScalingNoAvailabilityZones(t *testing.T) { check.That(data.ResourceName).Key("default_node_pool.0.type").HasValue("VirtualMachineScaleSets"), check.That(data.ResourceName).Key("default_node_pool.0.min_count").HasValue("1"), check.That(data.ResourceName).Key("default_node_pool.0.max_count").HasValue("2"), - check.That(data.ResourceName).Key("default_node_pool.0.enable_auto_scaling").HasValue("true"), + check.That(data.ResourceName).Key("default_node_pool.0.auto_scaling_enabled").HasValue("true"), ), }, data.ImportStep(), @@ -424,7 +424,7 @@ func TestAccKubernetesCluster_autoScalingProfile(t *testing.T) { Config: r.autoScalingProfileConfigMinimal(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("default_node_pool.0.enable_auto_scaling").HasValue("true"), + check.That(data.ResourceName).Key("default_node_pool.0.auto_scaling_enabled").HasValue("true"), check.That(data.ResourceName).Key("auto_scaler_profile.0.expander").HasValue("random"), ), }, @@ -433,7 +433,7 @@ func TestAccKubernetesCluster_autoScalingProfile(t *testing.T) { Config: r.autoScalingProfileConfigComplete(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("default_node_pool.0.enable_auto_scaling").HasValue("true"), + check.That(data.ResourceName).Key("default_node_pool.0.auto_scaling_enabled").HasValue("true"), check.That(data.ResourceName).Key("auto_scaler_profile.0.expander").HasValue("least-waste"), check.That(data.ResourceName).Key("auto_scaler_profile.0.max_graceful_termination_sec").HasValue("15"), check.That(data.ResourceName).Key("auto_scaler_profile.0.max_node_provisioning_time").HasValue("10m"), @@ -512,10 +512,10 @@ resource "azurerm_kubernetes_cluster" "test" { dns_prefix = "acctestaks%d" default_node_pool { - name = "default" - node_count = 1 - vm_size = "Standard_DS2_v2" - enable_host_encryption = true + name = "default" + node_count = 1 + vm_size = "Standard_DS2_v2" + host_encryption_enabled = true upgrade_settings { max_surge = "10%%" } @@ -632,7 +632,7 @@ resource "azurerm_kubernetes_cluster" "test" { temporary_name_for_rotation = "temp" node_count = 1 vm_size = "%s" - enable_host_encryption = false + host_encryption_enabled = false upgrade_settings { max_surge = "10%%" } @@ -673,7 +673,7 @@ resource "azurerm_kubernetes_cluster" "test" { node_count = 1 vm_size = "%s" zones = %s - enable_node_public_ip = true + node_public_ip_enabled = true max_pods = 60 only_critical_addons_enabled = true @@ -725,7 +725,7 @@ resource "azurerm_kubernetes_cluster" "test" { temporary_name_for_rotation = "temp" node_count = 1 vm_size = "Standard_D2ads_v5" - enable_node_public_ip = true + node_public_ip_enabled = true max_pods = 60 only_critical_addons_enabled = true @@ -974,11 +974,11 @@ resource "azurerm_kubernetes_cluster" "test" { dns_prefix = "acctestaks%d" default_node_pool { - name = "default" - enable_auto_scaling = true - min_count = 2 - max_count = 4 - vm_size = "Standard_DS2_v2" + name = "default" + auto_scaling_enabled = true + min_count = 2 + max_count = 4 + vm_size = "Standard_DS2_v2" upgrade_settings { max_surge = "10%%" } @@ -1009,11 +1009,11 @@ resource "azurerm_kubernetes_cluster" "test" { dns_prefix = "acctestaks%d" default_node_pool { - name = "pool1" - min_count = 1 - max_count = 2 - enable_auto_scaling = true - vm_size = "Standard_DS2_v2" + name = "pool1" + min_count = 1 + max_count = 2 + auto_scaling_enabled = true + vm_size = "Standard_DS2_v2" upgrade_settings { max_surge = "10%%" } @@ -1045,12 +1045,12 @@ resource "azurerm_kubernetes_cluster" "test" { kubernetes_version = "%s" default_node_pool { - name = "pool1" - min_count = 1 - max_count = 2 - enable_auto_scaling = true - vm_size = "Standard_DS2_v2" - zones = ["1", "2"] + name = "pool1" + min_count = 1 + max_count = 2 + auto_scaling_enabled = true + vm_size = "Standard_DS2_v2" + zones = ["1", "2"] upgrade_settings { max_surge = "10%%" } @@ -1086,11 +1086,11 @@ resource "azurerm_kubernetes_cluster" "test" { kubernetes_version = "%s" default_node_pool { - name = "default" - enable_auto_scaling = true - min_count = 2 - max_count = 4 - vm_size = "Standard_DS2_v2" + name = "default" + auto_scaling_enabled = true + min_count = 2 + max_count = 4 + vm_size = "Standard_DS2_v2" upgrade_settings { max_surge = "10%%" } @@ -1126,11 +1126,11 @@ resource "azurerm_kubernetes_cluster" "test" { kubernetes_version = "%s" default_node_pool { - name = "default" - enable_auto_scaling = true - min_count = 2 - max_count = 4 - vm_size = "Standard_DS2_v2" + name = "default" + auto_scaling_enabled = true + min_count = 2 + max_count = 4 + vm_size = "Standard_DS2_v2" upgrade_settings { max_surge = "10%%" } diff --git a/internal/services/containers/kubernetes_nodepool.go b/internal/services/containers/kubernetes_nodepool.go index f757cdc6693d..7235759e332c 100644 --- a/internal/services/containers/kubernetes_nodepool.go +++ b/internal/services/containers/kubernetes_nodepool.go @@ -1337,34 +1337,34 @@ func ExpandDefaultNodePool(d *pluginsdk.ResourceData) (*[]managedclusters.Manage // Count must be set for the initial creation when using AutoScaling but cannot be updated if d.HasChange("default_node_pool.0.node_count") && !d.IsNewResource() { - return nil, fmt.Errorf("cannot change `node_count` when `enable_auto_scaling` is set to `true`") + return nil, fmt.Errorf("cannot change `node_count` when `auto_scaling_enabled` is set to `true`") } if maxCount > 0 { profile.MaxCount = utils.Int64(int64(maxCount)) if maxCount < count && d.IsNewResource() { - return nil, fmt.Errorf("`node_count`(%d) must be equal to or less than `max_count`(%d) when `enable_auto_scaling` is set to `true`", count, maxCount) + return nil, fmt.Errorf("`node_count`(%d) must be equal to or less than `max_count`(%d) when `auto_scaling_enabled` is set to `true`", count, maxCount) } } else { - return nil, fmt.Errorf("`max_count` must be configured when `enable_auto_scaling` is set to `true`") + return nil, fmt.Errorf("`max_count` must be configured when `auto_scaling_enabled` is set to `true`") } if minCount > 0 { profile.MinCount = utils.Int64(int64(minCount)) if minCount > count && d.IsNewResource() { - return nil, fmt.Errorf("`node_count`(%d) must be equal to or greater than `min_count`(%d) when `enable_auto_scaling` is set to `true`", count, minCount) + return nil, fmt.Errorf("`node_count`(%d) must be equal to or greater than `min_count`(%d) when `auto_scaling_enabled` is set to `true`", count, minCount) } } else { - return nil, fmt.Errorf("`min_count` must be configured when `enable_auto_scaling` is set to `true`") + return nil, fmt.Errorf("`min_count` must be configured when `auto_scaling_enabled` is set to `true`") } if minCount > maxCount { return nil, fmt.Errorf("`max_count` must be >= `min_count`") } } else if minCount > 0 || maxCount > 0 { - return nil, fmt.Errorf("`max_count`(%d) and `min_count`(%d) must be set to `null` when `enable_auto_scaling` is set to `false`", maxCount, minCount) + return nil, fmt.Errorf("`max_count`(%d) and `min_count`(%d) must be set to `null` when `auto_scaling_enabled` is set to `false`", maxCount, minCount) } if kubeletConfig := raw["kubelet_config"].([]interface{}); len(kubeletConfig) > 0 {