From c0bf86b4ab04f1dfc6d41ae148fe97f2d91f7a20 Mon Sep 17 00:00:00 2001 From: SevenEarth <391613297@qq.com> Date: Tue, 27 Aug 2024 16:17:23 +0800 Subject: [PATCH 1/3] add --- .../tke/resource_tc_kubernetes_node_pool.go | 6 ++++ ...ource_tc_kubernetes_node_pool_extension.go | 36 ++++++++++++++----- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/tencentcloud/services/tke/resource_tc_kubernetes_node_pool.go b/tencentcloud/services/tke/resource_tc_kubernetes_node_pool.go index 40dc24e91e..2d87c2d827 100644 --- a/tencentcloud/services/tke/resource_tc_kubernetes_node_pool.go +++ b/tencentcloud/services/tke/resource_tc_kubernetes_node_pool.go @@ -457,6 +457,12 @@ func ResourceTencentCloudKubernetesNodePool() *schema.Resource { Computed: true, Description: "Instance name, no more than 60 characters. For usage, refer to `InstanceNameSettings` in https://www.tencentcloud.com/document/product/377/31001.", }, + "instance_name_style": { + Type: schema.TypeString, + Optional: true, + Computed: true, + Description: "Type of CVM instance name. Valid values: `ORIGINAL` and `UNIQUE`. Default value: `ORIGINAL`. For usage, refer to `InstanceNameSettings` in https://www.tencentcloud.com/document/product/377/31001.", + }, "host_name": { Type: schema.TypeString, Optional: true, diff --git a/tencentcloud/services/tke/resource_tc_kubernetes_node_pool_extension.go b/tencentcloud/services/tke/resource_tc_kubernetes_node_pool_extension.go index dd5f0fa614..fed9b7504e 100644 --- a/tencentcloud/services/tke/resource_tc_kubernetes_node_pool_extension.go +++ b/tencentcloud/services/tke/resource_tc_kubernetes_node_pool_extension.go @@ -307,8 +307,14 @@ func resourceTencentCloudKubernetesNodePoolReadPostHandleResponse1(ctx context.C if _, ok := d.GetOk("cam_role_name"); ok || launchCfg.CamRoleName != nil { launchConfig["cam_role_name"] = launchCfg.CamRoleName } - if launchCfg.InstanceNameSettings != nil && launchCfg.InstanceNameSettings.InstanceName != nil { - launchConfig["instance_name"] = launchCfg.InstanceNameSettings.InstanceName + if launchCfg.InstanceNameSettings != nil { + if launchCfg.InstanceNameSettings.InstanceName != nil { + launchConfig["instance_name"] = launchCfg.InstanceNameSettings.InstanceName + } + + if launchCfg.InstanceNameSettings.InstanceNameStyle != nil { + launchConfig["instance_name_style"] = launchCfg.InstanceNameSettings.InstanceNameStyle + } } if launchCfg.HostNameSettings != nil && launchCfg.HostNameSettings.HostName != nil { launchConfig["host_name"] = launchCfg.HostNameSettings.HostName @@ -1015,10 +1021,17 @@ func composedKubernetesAsScalingConfigParaSerial(dMap map[string]interface{}, me request.CamRoleName = helper.String(v.(string)) } + tmpInstanceNameSettings := &as.InstanceNameSettings{} if v, ok := dMap["instance_name"]; ok && v != "" { - request.InstanceNameSettings = &as.InstanceNameSettings{ - InstanceName: helper.String(v.(string)), - } + tmpInstanceNameSettings.InstanceName = helper.String(v.(string)) + } + + if v, ok := dMap["instance_name_style"]; ok && v != "" { + tmpInstanceNameSettings.InstanceNameStyle = helper.String(v.(string)) + } + + if tmpInstanceNameSettings.InstanceName != nil || tmpInstanceNameSettings.InstanceNameStyle != nil { + request.InstanceNameSettings = tmpInstanceNameSettings } if v, ok := dMap["host_name"]; ok && v != "" { @@ -1169,10 +1182,17 @@ func composeAsLaunchConfigModifyRequest(d *schema.ResourceData, launchConfigId s } } + tmpInstanceNameSettings := &as.InstanceNameSettings{} if v, ok := dMap["instance_name"]; ok && v != "" { - request.InstanceNameSettings = &as.InstanceNameSettings{ - InstanceName: helper.String(v.(string)), - } + tmpInstanceNameSettings.InstanceName = helper.String(v.(string)) + } + + if v, ok := dMap["instance_name_style"]; ok && v != "" { + tmpInstanceNameSettings.InstanceNameStyle = helper.String(v.(string)) + } + + if tmpInstanceNameSettings.InstanceName != nil || tmpInstanceNameSettings.InstanceNameStyle != nil { + request.InstanceNameSettings = tmpInstanceNameSettings } if v, ok := dMap["host_name"]; ok && v != "" { From 312dc248b4ded335991204344a6e740dd3e12795 Mon Sep 17 00:00:00 2001 From: SevenEarth <391613297@qq.com> Date: Tue, 27 Aug 2024 16:19:01 +0800 Subject: [PATCH 2/3] add --- .changelog/2791.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/2791.txt diff --git a/.changelog/2791.txt b/.changelog/2791.txt new file mode 100644 index 0000000000..4ab31ac4ab --- /dev/null +++ b/.changelog/2791.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/tencentcloud_kubernetes_node_pool: support `instance_name_style` param +``` From 40e1af93f135432ee80d949cd2cee45ad0e4e9f5 Mon Sep 17 00:00:00 2001 From: SevenEarth <391613297@qq.com> Date: Tue, 27 Aug 2024 16:20:57 +0800 Subject: [PATCH 3/3] add --- website/docs/r/kubernetes_node_pool.html.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/website/docs/r/kubernetes_node_pool.html.markdown b/website/docs/r/kubernetes_node_pool.html.markdown index 1e4c1c1710..0e7c45e7d3 100644 --- a/website/docs/r/kubernetes_node_pool.html.markdown +++ b/website/docs/r/kubernetes_node_pool.html.markdown @@ -198,6 +198,7 @@ The `auto_scaling_config` object supports the following: * `instance_charge_type_prepaid_period` - (Optional, Int) The tenancy (in month) of the prepaid instance, NOTE: it only works when instance_charge_type is set to `PREPAID`. Valid values are `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `9`, `10`, `11`, `12`, `24`, `36`. * `instance_charge_type_prepaid_renew_flag` - (Optional, String) Auto renewal flag. Valid values: `NOTIFY_AND_AUTO_RENEW`: notify upon expiration and renew automatically, `NOTIFY_AND_MANUAL_RENEW`: notify upon expiration but do not renew automatically, `DISABLE_NOTIFY_AND_MANUAL_RENEW`: neither notify upon expiration nor renew automatically. Default value: `NOTIFY_AND_MANUAL_RENEW`. If this parameter is specified as `NOTIFY_AND_AUTO_RENEW`, the instance will be automatically renewed on a monthly basis if the account balance is sufficient. NOTE: it only works when instance_charge_type is set to `PREPAID`. * `instance_charge_type` - (Optional, String) Charge type of instance. Valid values are `PREPAID`, `POSTPAID_BY_HOUR`, `SPOTPAID`. The default is `POSTPAID_BY_HOUR`. NOTE: `SPOTPAID` instance must set `spot_instance_type` and `spot_max_price` at the same time. +* `instance_name_style` - (Optional, String) Type of CVM instance name. Valid values: `ORIGINAL` and `UNIQUE`. Default value: `ORIGINAL`. For usage, refer to `InstanceNameSettings` in https://www.tencentcloud.com/document/product/377/31001. * `instance_name` - (Optional, String) Instance name, no more than 60 characters. For usage, refer to `InstanceNameSettings` in https://www.tencentcloud.com/document/product/377/31001. * `internet_charge_type` - (Optional, String) Charge types for network traffic. Valid value: `BANDWIDTH_PREPAID`, `TRAFFIC_POSTPAID_BY_HOUR` and `BANDWIDTH_PACKAGE`. * `internet_max_bandwidth_out` - (Optional, Int) Max bandwidth of Internet access in Mbps. Default is `0`.