From 26a78b0d3bfe90653aceb0d788b8586fca7f530e Mon Sep 17 00:00:00 2001 From: Kagashino Date: Wed, 12 Oct 2022 00:43:48 +0800 Subject: [PATCH] fix: vpc - distinguish assistant cidr type --- tencentcloud/resource_tc_vpc.go | 11 +++++++++- tencentcloud/service_tencentcloud_vpc.go | 26 +++++++++++++++--------- website/docs/r/vpc.html.markdown | 3 ++- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/tencentcloud/resource_tc_vpc.go b/tencentcloud/resource_tc_vpc.go index cde6c34baa..dc7d279ccb 100644 --- a/tencentcloud/resource_tc_vpc.go +++ b/tencentcloud/resource_tc_vpc.go @@ -98,7 +98,15 @@ func resourceTencentCloudVpcInstance() *schema.Resource { "assistant_cidrs": { Type: schema.TypeList, Optional: true, - Description: "List of Assistant CIDR.", + Description: "List of Assistant CIDR, NOTE: Only `NORMAL` typed CIDRs included, check the Docker CIDR by readonly `assistant_docker_cidrs`.", + Computed: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "docker_assistant_cidrs": { + Type: schema.TypeList, + Description: "List of Docker Assistant CIDR.", Computed: true, Elem: &schema.Schema{ Type: schema.TypeString, @@ -256,6 +264,7 @@ func resourceTencentCloudVpcInstanceRead(d *schema.ResourceData, meta interface{ _ = d.Set("create_time", info.createTime) _ = d.Set("is_default", info.isDefault) _ = d.Set("assistant_cidrs", info.assistantCidrs) + _ = d.Set("docker_assistant_cidrs", info.dockerAssistantCidrs) _ = d.Set("tags", tags) return nil diff --git a/tencentcloud/service_tencentcloud_vpc.go b/tencentcloud/service_tencentcloud_vpc.go index 3231529b74..c3fa940728 100644 --- a/tencentcloud/service_tencentcloud_vpc.go +++ b/tencentcloud/service_tencentcloud_vpc.go @@ -27,15 +27,16 @@ var eipUnattachLocker = &sync.Mutex{} // VPC basic information type VpcBasicInfo struct { - vpcId string - name string - cidr string - isMulticast bool - isDefault bool - dnsServers []string - createTime string - tags []*vpc.Tag - assistantCidrs []string + vpcId string + name string + cidr string + isMulticast bool + isDefault bool + dnsServers []string + createTime string + tags []*vpc.Tag + assistantCidrs []string + dockerAssistantCidrs []string } // subnet basic information @@ -353,8 +354,13 @@ getMoreData: if len(item.AssistantCidrSet) > 0 { for i := range item.AssistantCidrSet { + kind := item.AssistantCidrSet[i].AssistantType cidr := item.AssistantCidrSet[i].CidrBlock - basicInfo.assistantCidrs = append(basicInfo.assistantCidrs, *cidr) + if kind != nil && *kind == 0 { + basicInfo.assistantCidrs = append(basicInfo.assistantCidrs, *cidr) + } else { + basicInfo.dockerAssistantCidrs = append(basicInfo.dockerAssistantCidrs, *cidr) + } } } diff --git a/website/docs/r/vpc.html.markdown b/website/docs/r/vpc.html.markdown index bad0135338..c7017a524f 100644 --- a/website/docs/r/vpc.html.markdown +++ b/website/docs/r/vpc.html.markdown @@ -47,7 +47,7 @@ The following arguments are supported: * `cidr_block` - (Required, String, ForceNew) A network address block which should be a subnet of the three internal network segments (10.0.0.0/16, 172.16.0.0/12 and 192.168.0.0/16). * `name` - (Required, String) The name of the VPC. -* `assistant_cidrs` - (Optional, List: [`String`]) List of Assistant CIDR. +* `assistant_cidrs` - (Optional, List: [`String`]) List of Assistant CIDR, NOTE: Only `NORMAL` typed CIDRs included, check the Docker CIDR by readonly `assistant_docker_cidrs`. * `dns_servers` - (Optional, Set: [`String`]) The DNS server list of the VPC. And you can specify 0 to 5 servers to this list. * `is_multicast` - (Optional, Bool) Indicates whether VPC multicast is enabled. The default value is 'true'. * `tags` - (Optional, Map) Tags of the VPC. @@ -59,6 +59,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - ID of the resource. * `create_time` - Creation time of VPC. * `default_route_table_id` - Default route table id, which created automatically after VPC create. +* `docker_assistant_cidrs` - List of Docker Assistant CIDR. * `is_default` - Indicates whether it is the default VPC for this region.