Skip to content

Commit

Permalink
containerservice - update sdk to 2024-05-01 (#27105)
Browse files Browse the repository at this point in the history
* `hashicorp/go-azure-sdk` - update to `v0.20240819.1075239`

* fix golint

* `containerservice` - update sdk to `2024-05-01`

* fix errors in the tests

* fix golint

* fix tests

* make terrafmt
  • Loading branch information
ms-henglu authored Aug 21, 2024
1 parent ca742ee commit 35298b7
Show file tree
Hide file tree
Showing 257 changed files with 357 additions and 1,784 deletions.
8 changes: 4 additions & 4 deletions internal/services/containers/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import (
containerregistry_v2023_06_01_preview "github.com/hashicorp/go-azure-sdk/resource-manager/containerregistry/2023-06-01-preview"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerregistry/2023-07-01/cacherules"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2019-08-01/containerservices"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/agentpools"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/managedclusters"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/snapshots"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2024-04-01/fleetupdatestrategies"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2024-04-01/updateruns"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2024-05-01/agentpools"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2024-05-01/maintenanceconfigurations"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2024-05-01/managedclusters"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2024-05-01/snapshots"
"github.com/hashicorp/go-azure-sdk/resource-manager/kubernetesconfiguration/2022-11-01/extensions"
"github.com/hashicorp/go-azure-sdk/resource-manager/kubernetesconfiguration/2022-11-01/fluxconfiguration"
"github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager"
Expand Down
2 changes: 1 addition & 1 deletion internal/services/containers/kubernetes_addons.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/hashicorp/go-azure-helpers/lang/pointer"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonids"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/managedclusters"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2024-05-01/managedclusters"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-11-01/applicationgateways"
"github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2020-08-01/workspaces"
"github.com/hashicorp/go-azure-sdk/sdk/environments"
Expand Down
49 changes: 7 additions & 42 deletions internal/services/containers/kubernetes_cluster_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/hashicorp/go-azure-helpers/resourcemanager/location"
"github.com/hashicorp/go-azure-helpers/resourcemanager/tags"
"github.com/hashicorp/go-azure-helpers/resourcemanager/zones"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/managedclusters"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2024-05-01/managedclusters"
"github.com/hashicorp/go-azure-sdk/resource-manager/operationalinsights/2020-08-01/workspaces"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/features"
Expand Down Expand Up @@ -868,13 +868,6 @@ func dataSourceKubernetesClusterRead(d *pluginsdk.ResourceData, meta interface{}
return fmt.Errorf("setting `key_management_service`: %+v", err)
}

if !features.FourPointOhBeta() {
customCaTrustCertList := flattenCustomCaTrustCerts(props.SecurityProfile)
if err := d.Set("custom_ca_trust_certificates_base64", customCaTrustCertList); err != nil {
return fmt.Errorf("setting `custom_ca_trust_certificates_base64`: %+v", err)
}
}

serviceMeshProfile := flattenKubernetesClusterAzureServiceMeshProfile(props.ServiceMeshProfile)
if err := d.Set("service_mesh_profile", serviceMeshProfile); err != nil {
return fmt.Errorf("setting `service_mesh_profile`: %+v", err)
Expand Down Expand Up @@ -1033,26 +1026,12 @@ func flattenKubernetesClusterDataSourceStorageProfile(input *managedclusters.Man
snapshotController = *input.SnapshotController.Enabled
}

if !features.FourPointOhBeta() {
diskVersion := ""
if input.DiskCSIDriver != nil && input.DiskCSIDriver.Version != nil {
diskVersion = *input.DiskCSIDriver.Version
}
storageProfile = append(storageProfile, map[string]interface{}{
"blob_driver_enabled": blobEnabled,
"disk_driver_enabled": diskEnabled,
"disk_driver_version": diskVersion,
"file_driver_enabled": fileEnabled,
"snapshot_controller_enabled": snapshotController,
})
} else {
storageProfile = append(storageProfile, map[string]interface{}{
"blob_driver_enabled": blobEnabled,
"disk_driver_enabled": diskEnabled,
"file_driver_enabled": fileEnabled,
"snapshot_controller_enabled": snapshotController,
})
}
storageProfile = append(storageProfile, map[string]interface{}{
"blob_driver_enabled": blobEnabled,
"disk_driver_enabled": diskEnabled,
"file_driver_enabled": fileEnabled,
"snapshot_controller_enabled": snapshotController,
})
}

return storageProfile
Expand Down Expand Up @@ -1582,17 +1561,3 @@ func flattenKubernetesClusterDataSourceUpgradeSettings(input *managedclusters.Ag

return []interface{}{values}
}

func flattenCustomCaTrustCerts(input *managedclusters.ManagedClusterSecurityProfile) []interface{} {
if input == nil || input.CustomCATrustCertificates == nil {
return make([]interface{}, 0)
}

customCaTrustCertInterface := make([]interface{}, len(*input.CustomCATrustCertificates))

for index, value := range *input.CustomCATrustCertificates {
customCaTrustCertInterface[index] = value
}

return customCaTrustCertInterface
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema"
"github.com/hashicorp/go-azure-helpers/resourcemanager/tags"
"github.com/hashicorp/go-azure-helpers/resourcemanager/zones"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/agentpools"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2024-05-01/agentpools"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/features"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/containers/validate"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package containers

import (
"context"
"encoding/base64"
"fmt"
"log"
"regexp"
Expand All @@ -20,9 +19,9 @@ import (
"github.com/hashicorp/go-azure-helpers/resourcemanager/zones"
"github.com/hashicorp/go-azure-sdk/resource-manager/compute/2022-03-01/capacityreservationgroups"
"github.com/hashicorp/go-azure-sdk/resource-manager/compute/2022-03-01/proximityplacementgroups"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/agentpools"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/managedclusters"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/snapshots"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2024-05-01/agentpools"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2024-05-01/managedclusters"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2024-05-01/snapshots"
"github.com/hashicorp/go-azure-sdk/resource-manager/network/2023-09-01/subnets"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
Expand Down Expand Up @@ -401,37 +400,6 @@ func resourceKubernetesClusterNodePoolSchema() map[string]*pluginsdk.Schema {
},
}

if !features.FourPointOhBeta() {
s["message_of_the_day"] = &pluginsdk.Schema{
Deprecated: "This property is not available in the stable API and will be removed in v4.0 of the Azure Provider. Please see https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/guides/4.0-upgrade-guide#aks-migration-to-stable-api for more details.",
Type: pluginsdk.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: validation.StringIsNotEmpty,
}

s["custom_ca_trust_enabled"] = &pluginsdk.Schema{
Deprecated: "This property is not available in the stable API and will be removed in v4.0 of the Azure Provider. Please see https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/guides/4.0-upgrade-guide#aks-migration-to-stable-api for more details.",
Type: pluginsdk.TypeBool,
Optional: true,
}

s["os_sku"].ValidateFunc = validation.StringInSlice([]string{
string(agentpools.OSSKUAzureLinux),
string(agentpools.OSSKUCBLMariner),
string(agentpools.OSSKUMariner),
string(agentpools.OSSKUUbuntu),
string(agentpools.OSSKUWindowsTwoZeroOneNine),
string(agentpools.OSSKUWindowsTwoZeroTwoTwo),
}, false)

s["workload_runtime"].ValidateFunc = validation.StringInSlice([]string{
string(agentpools.WorkloadRuntimeOCIContainer),
string(agentpools.WorkloadRuntimeWasmWasi),
string(agentpools.WorkloadRuntimeKataMshvVMIsolation),
}, false)
}

if !features.FourPointOh() {
s["enable_auto_scaling"] = &pluginsdk.Schema{
Type: pluginsdk.TypeBool,
Expand Down Expand Up @@ -570,10 +538,6 @@ func resourceKubernetesClusterNodePoolCreate(d *pluginsdk.ResourceData, meta int
Count: utils.Int64(int64(count)),
}

if !features.FourPointOhBeta() {
profile.EnableCustomCATrust = pointer.To(d.Get("custom_ca_trust_enabled").(bool))
}

if gpuInstanceProfile := d.Get("gpu_instance").(string); gpuInstanceProfile != "" {
profile.GpuInstanceProfile = pointer.To(agentpools.GPUInstanceProfile(gpuInstanceProfile))
}
Expand Down Expand Up @@ -635,16 +599,6 @@ func resourceKubernetesClusterNodePoolCreate(d *pluginsdk.ResourceData, meta int
profile.NodeTaints = nodeTaints
}

if !features.FourPointOhBeta() {
if v := d.Get("message_of_the_day").(string); v != "" {
if profile.OsType != nil && *profile.OsType == agentpools.OSTypeWindows {
return fmt.Errorf("`message_of_the_day` cannot be specified for Windows nodes and must be a static string (i.e. will be printed raw and not executed as a script)")
}
messageOfTheDayEncoded := base64.StdEncoding.EncodeToString([]byte(v))
profile.MessageOfTheDay = &messageOfTheDayEncoded
}
}

if osDiskSizeGB := d.Get("os_disk_size_gb").(int); osDiskSizeGB > 0 {
profile.OsDiskSizeGB = utils.Int64(int64(osDiskSizeGB))
}
Expand Down Expand Up @@ -822,12 +776,6 @@ func resourceKubernetesClusterNodePoolUpdate(d *pluginsdk.ResourceData, meta int
}
}

if !features.FourPointOhBeta() {
if d.HasChange("custom_ca_trust_enabled") {
props.EnableCustomCATrust = utils.Bool(d.Get("custom_ca_trust_enabled").(bool))
}
}

if d.HasChange("max_count") || enableAutoScaling {
props.MaxCount = utils.Int64(int64(d.Get("max_count").(int)))
}
Expand Down Expand Up @@ -994,10 +942,6 @@ func resourceKubernetesClusterNodePoolRead(d *pluginsdk.ResourceData, meta inter
d.Set("enable_node_public_ip", props.EnableNodePublicIP)
d.Set("enable_host_encryption", props.EnableEncryptionAtHost)
default:
d.Set("custom_ca_trust_enabled", props.EnableCustomCATrust)
d.Set("enable_auto_scaling", props.EnableAutoScaling)
d.Set("enable_node_public_ip", props.EnableNodePublicIP)
d.Set("enable_host_encryption", props.EnableEncryptionAtHost)
}
d.Set("fips_enabled", props.EnableFIPS)
d.Set("ultra_ssd_enabled", props.EnableUltraSSD)
Expand Down Expand Up @@ -1048,18 +992,6 @@ func resourceKubernetesClusterNodePoolRead(d *pluginsdk.ResourceData, meta inter
}
d.Set("max_count", maxCount)

if !features.FourPointOhBeta() {
messageOfTheDay := ""
if props.MessageOfTheDay != nil {
messageOfTheDayDecoded, err := base64.StdEncoding.DecodeString(*props.MessageOfTheDay)
if err != nil {
return fmt.Errorf("setting `message_of_the_day`: %+v", err)
}
messageOfTheDay = string(messageOfTheDayDecoded)
}
d.Set("message_of_the_day", messageOfTheDay)
}

maxPods := 0
if props.MaxPods != nil {
maxPods = int(*props.MaxPods)
Expand Down Expand Up @@ -1167,7 +1099,7 @@ func resourceKubernetesClusterNodePoolDelete(d *pluginsdk.ResourceData, meta int
return err
}

err = client.DeleteThenPoll(ctx, *id, agentpools.DefaultDeleteOperationOptions())
err = client.DeleteThenPoll(ctx, *id)
if err != nil {
return fmt.Errorf("deleting %s: %+v", *id, err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (

"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonids"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/agentpools"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/snapshots"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2024-05-01/agentpools"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2024-05-01/snapshots"
"github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
Expand Down Expand Up @@ -576,7 +576,7 @@ func TestAccKubernetesClusterNodePool_upgradeSettings(t *testing.T) {
},
data.ImportStep(),
{
Config: r.upgradeSettings(data, 1, 0),
Config: r.upgradeSettings(data, 5, 0),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"time"

"github.com/hashicorp/go-azure-helpers/resourcemanager/commonids"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/agentpools"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/snapshots"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2024-05-01/agentpools"
"github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2024-05-01/snapshots"
"github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check"
Expand Down Expand Up @@ -185,6 +185,9 @@ func TestAccKubernetesCluster_linuxProfile(t *testing.T) {
}

func TestAccKubernetesCluster_linuxProfileUpdateSshKey(t *testing.T) {
if features.FourPointOhBeta() {
t.Skip("Skipping this test in 4.0 beta as it is not supported after switching to stable API")
}
data := acceptance.BuildTestData(t, "azurerm_kubernetes_cluster", "test")
r := KubernetesClusterResource{}

Expand Down
Loading

0 comments on commit 35298b7

Please sign in to comment.