From b0720a755a5ad73c8ddd9df70ce3acbc500da472 Mon Sep 17 00:00:00 2001 From: KGSN Date: Fri, 25 Feb 2022 15:25:02 +0800 Subject: [PATCH] fix: datasource redis_zone_config - replace mem_size with shard_memories --- .../data_source_tc_redis_zone_config.go | 17 +++++++++++++++++ .../data_source_tc_redis_zone_config_test.go | 2 ++ tencentcloud/resource_tc_redis_instance.go | 2 +- website/docs/d/redis_zone_config.html.markdown | 3 ++- website/docs/r/redis_instance.html.markdown | 2 +- 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/tencentcloud/data_source_tc_redis_zone_config.go b/tencentcloud/data_source_tc_redis_zone_config.go index 702898a07e..363b252ced 100644 --- a/tencentcloud/data_source_tc_redis_zone_config.go +++ b/tencentcloud/data_source_tc_redis_zone_config.go @@ -74,8 +74,15 @@ func dataSourceTencentRedisZoneConfig() *schema.Resource { Type: schema.TypeList, Elem: &schema.Schema{Type: schema.TypeInt}, Computed: true, + Deprecated: "It has been deprecated from version 1.26.0. Use `shard_memories` instead.", Description: "The memory volume of an available instance(in MB).", }, + "shard_memories": { + Type: schema.TypeList, + Description: "The memory volume list of an available instance shard(in MB).", + Computed: true, + Elem: &schema.Schema{Type: schema.TypeInt}, + }, "redis_shard_nums": { Type: schema.TypeList, Computed: true, @@ -160,7 +167,17 @@ func dataSourceTencentRedisZoneConfigRead(d *schema.ResourceData, meta interface memSizes = append(memSizes, temp*1024) } + shardMemories := make([]int64, 0, len(products.ShardSize)) + for _, size := range products.ShardSize { + temp, err := strconv.ParseInt(*size, 10, 64) + if err != nil { + continue + } + shardMemories = append(shardMemories, temp*1024) + } + zoneConfigures["mem_sizes"] = memSizes + zoneConfigures["shard_memories"] = shardMemories zoneConfigures["type"] = REDIS_NAMES[*products.Type] var redisShardNums []int64 diff --git a/tencentcloud/data_source_tc_redis_zone_config_test.go b/tencentcloud/data_source_tc_redis_zone_config_test.go index 66d587e363..373626ea79 100644 --- a/tencentcloud/data_source_tc_redis_zone_config_test.go +++ b/tencentcloud/data_source_tc_redis_zone_config_test.go @@ -22,6 +22,7 @@ func TestAccDataSourceRedisZoneConfig_basic(t *testing.T) { resource.TestCheckResourceAttrSet("data.tencentcloud_redis_zone_config.test", "list.0.type"), resource.TestCheckResourceAttrSet("data.tencentcloud_redis_zone_config.test", "list.0.version"), resource.TestCheckResourceAttrSet("data.tencentcloud_redis_zone_config.test", "list.0.mem_sizes.#"), + resource.TestCheckResourceAttrSet("data.tencentcloud_redis_zone_config.test", "list.0.shard_memories.#"), ), }, { @@ -33,6 +34,7 @@ func TestAccDataSourceRedisZoneConfig_basic(t *testing.T) { resource.TestCheckResourceAttrSet("data.tencentcloud_redis_zone_config.testWithRegion", "list.0.type_id"), resource.TestCheckResourceAttrSet("data.tencentcloud_redis_zone_config.testWithRegion", "list.0.version"), resource.TestCheckResourceAttrSet("data.tencentcloud_redis_zone_config.testWithRegion", "list.0.mem_sizes.#"), + resource.TestCheckResourceAttrSet("data.tencentcloud_redis_zone_config.testWithRegion", "list.0.shard_memories.#"), resource.TestCheckResourceAttrSet("data.tencentcloud_redis_zone_config.testWithRegion", "list.0.redis_shard_nums.#"), resource.TestCheckResourceAttrSet("data.tencentcloud_redis_zone_config.testWithRegion", "list.0.redis_replicas_nums.#"), ), diff --git a/tencentcloud/resource_tc_redis_instance.go b/tencentcloud/resource_tc_redis_instance.go index 1cc4de69de..7585b6d28b 100644 --- a/tencentcloud/resource_tc_redis_instance.go +++ b/tencentcloud/resource_tc_redis_instance.go @@ -168,7 +168,7 @@ func resourceTencentCloudRedisInstance() *schema.Resource { "mem_size": { Type: schema.TypeInt, Required: true, - Description: "The memory volume of an available instance(in MB), please refer to `tencentcloud_redis_zone_config.list[zone].mem_sizes`. When redis is standard type, it represents total memory size of the instance; when Redis is cluster type, it represents memory size of per sharding.", + Description: "The memory volume of an available instance(in MB), please refer to `tencentcloud_redis_zone_config.list[zone].shard_memories`. When redis is standard type, it represents total memory size of the instance; when Redis is cluster type, it represents memory size of per sharding.", }, "vpc_id": { Type: schema.TypeString, diff --git a/website/docs/d/redis_zone_config.html.markdown b/website/docs/d/redis_zone_config.html.markdown index d7e52d2a56..ee435d6f5b 100644 --- a/website/docs/d/redis_zone_config.html.markdown +++ b/website/docs/d/redis_zone_config.html.markdown @@ -33,9 +33,10 @@ The following arguments are supported: In addition to all arguments above, the following attributes are exported: * `list` - A list of zone. Each element contains the following attributes: - * `mem_sizes` - The memory volume of an available instance(in MB). + * `mem_sizes` - (**Deprecated**) It has been deprecated from version 1.26.0. Use `shard_memories` instead. The memory volume of an available instance(in MB). * `redis_replicas_nums` - The support numbers of instance copies. * `redis_shard_nums` - The support numbers of instance shard. + * `shard_memories` - The memory volume list of an available instance shard(in MB). * `type_id` - Instance type. Which redis type supports in this zone. * `type` - (**Deprecated**) It has been deprecated from version 1.33.1. Please use 'type_id' instead. Instance type. Available values: `master_slave_redis`, `master_slave_ckv`, `cluster_ckv`, `cluster_redis` and `standalone_redis`. * `version` - Version description of an available instance. Possible values: `Redis 3.2`, `Redis 4.0`. diff --git a/website/docs/r/redis_instance.html.markdown b/website/docs/r/redis_instance.html.markdown index ef1ec6396e..09191a9ce6 100644 --- a/website/docs/r/redis_instance.html.markdown +++ b/website/docs/r/redis_instance.html.markdown @@ -68,7 +68,7 @@ resource "tencentcloud_redis_instance" "red1" { The following arguments are supported: * `availability_zone` - (Required, ForceNew) The available zone ID of an instance to be created, please refer to `tencentcloud_redis_zone_config.list`. -* `mem_size` - (Required) The memory volume of an available instance(in MB), please refer to `tencentcloud_redis_zone_config.list[zone].mem_sizes`. When redis is standard type, it represents total memory size of the instance; when Redis is cluster type, it represents memory size of per sharding. +* `mem_size` - (Required) The memory volume of an available instance(in MB), please refer to `tencentcloud_redis_zone_config.list[zone].shard_memories`. When redis is standard type, it represents total memory size of the instance; when Redis is cluster type, it represents memory size of per sharding. * `auto_renew_flag` - (Optional, ForceNew) Auto-renew flag. 0 - default state (manual renewal); 1 - automatic renewal; 2 - explicit no automatic renewal. * `charge_type` - (Optional, ForceNew) The charge type of instance. Valid values: `PREPAID` and `POSTPAID`. Default value is `POSTPAID`. Note: TencentCloud International only supports `POSTPAID`. Caution that update operation on this field will delete old instances and create new with new charge type. * `force_delete` - (Optional) Indicate whether to delete Redis instance directly or not. Default is false. If set true, the instance will be deleted instead of staying recycle bin. Note: only works for `PREPAID` instance.