diff --git a/mmv1/third_party/tgc_next/pkg/services/container/node_config.go b/mmv1/third_party/tgc_next/pkg/services/container/node_config.go index 253ccf92b628..08424fe62793 100644 --- a/mmv1/third_party/tgc_next/pkg/services/container/node_config.go +++ b/mmv1/third_party/tgc_next/pkg/services/container/node_config.go @@ -2556,8 +2556,15 @@ func flattenEphemeralStorageLocalSsdConfig(v interface{}) []map[string]interface return nil } + // Default localSsdCount to 0 if missing. The field is required in the schema, + // but the API may not return it if the value is 0. + localSsdCount := c["localSsdCount"] + if localSsdCount == nil { + localSsdCount = 0 + } + transformed := map[string]interface{}{ - "local_ssd_count": c["localSsdCount"], + "local_ssd_count": localSsdCount, "data_cache_count": c["dataCacheCount"], } @@ -3300,8 +3307,15 @@ func flattenFastSocket(v interface{}) []map[string]interface{} { if !ok { return nil } + // Default enabled to false if missing. The field is required in the schema, + // but the API may not return it if the value is false. + enabled, ok := c["enabled"].(bool) + if !ok { + enabled = false + } + transformed := map[string]interface{}{ - "enabled": c["enabled"], + "enabled": enabled, } return []map[string]interface{}{transformed} diff --git a/mmv1/third_party/tgc_next/pkg/services/container/resource_node_pool_cai2hcl.go b/mmv1/third_party/tgc_next/pkg/services/container/resource_node_pool_cai2hcl.go index b3fd08614444..f04952e4254f 100644 --- a/mmv1/third_party/tgc_next/pkg/services/container/resource_node_pool_cai2hcl.go +++ b/mmv1/third_party/tgc_next/pkg/services/container/resource_node_pool_cai2hcl.go @@ -261,12 +261,17 @@ func flattenNodeNetworkConfig(c interface{}, d *schema.ResourceData, prefix stri // "create_pod_range": d.Get(prefix + "network_config.0.create_pod_range"), // API doesn't return this value so we set the old one. Field is ForceNew + Required "pod_ipv4_cidr_block": config["podIpv4CidrBlock"], "pod_range": config["podRange"], - "enable_private_nodes": config["enablePrivateNodes"], "pod_cidr_overprovision_config": flattenPodCidrOverprovisionConfig(config["podCidrOverprovisionConfig"]), "network_performance_config": flattenNodeNetworkPerformanceConfig(config["networkPerformanceConfig"]), "additional_node_network_configs": flattenAdditionalNodeNetworkConfig(config["additionalNodeNetworkConfigs"]), "additional_pod_network_configs": flattenAdditionalPodNetworkConfig(config["additionalPodNetworkConfigs"]), } + + // enable_private_nodes = false and the field not in HCL behaves the same, as this field is in ForceSendFields and the false value is included in the API request when it is not specified in config. + // Only convert the field enable_private_nodes when its value is true in CAI asset. + if v, ok := config["enablePrivateNodes"].(bool); ok && v { + transformed["enable_private_nodes"] = v + } return []map[string]interface{}{transformed} } return nil