Skip to content

Commit 2887e9e

Browse files
committed
remove unused code
1 parent 07f99b5 commit 2887e9e

File tree

2 files changed

+11
-26
lines changed

2 files changed

+11
-26
lines changed

tencentcloud/data_source_tc_images.go

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121

2222
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
2323
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
24-
cbs "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cbs/v20170312"
2524
cvm "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm/v20170312"
2625
"github.com/terraform-providers/terraform-provider-tencentcloud/tencentcloud/internal/helper"
2726
)
@@ -138,7 +137,7 @@ func dataSourceTencentCloudImages() *schema.Resource {
138137
Description: "Whether support cloud-init.",
139138
},
140139
"snapshots": {
141-
Type: schema.TypeSet,
140+
Type: schema.TypeList,
142141
Computed: true,
143142
Description: "List of snapshot details.",
144143
Elem: &schema.Resource{
@@ -311,41 +310,30 @@ func dataSourceTencentCloudImagesRead(d *schema.ResourceData, meta interface{})
311310
return nil
312311
}
313312

314-
func imagesReadSnapshotByIds(ctx context.Context, cbsService CbsService, image *cvm.Image) (snapshotResults []map[string]interface{}, errSnap error) {
313+
func imagesReadSnapshotByIds(ctx context.Context, cbsService CbsService, image *cvm.Image) (snapshotResults []map[string]interface{}, errRet error) {
315314
if len(image.SnapshotSet) == 0 {
316315
return
317316
}
318317

319-
snapshotSetMap := map[string]interface{}{}
320318
snapshotByIds := make([]*string, 0, len(image.SnapshotSet))
321319
for _, snapshot := range image.SnapshotSet {
322320
snapshotByIds = append(snapshotByIds, snapshot.SnapshotId)
323321
}
324322

325-
snapshots, errSnap := cbsService.DescribeSnapshotByIds(ctx, snapshotByIds)
326-
if errSnap != nil {
323+
snapshots, errRet := cbsService.DescribeSnapshotByIds(ctx, snapshotByIds)
324+
if errRet != nil {
327325
return
328326
}
329327

328+
snapshotResults = make([]map[string]interface{}, 0, len(snapshots))
330329
for _, snapshot := range snapshots {
331-
snapshotSetMap[*snapshot.SnapshotId] = snapshot
332-
}
333-
334-
snapshotSet := image.SnapshotSet
335-
snapshotResults = make([]map[string]interface{}, 0, len(snapshotSet))
336-
if len(snapshotSet) > 0 {
337-
for _, snapshot := range snapshotSet {
338-
snapshotMap := make(map[string]interface{}, 4)
339-
id := snapshot.SnapshotId
340-
snapshotMap["snapshot_id"] = *id
341-
snapshotMap["disk_usage"] = snapshot.DiskUsage
342-
snapshotMap["disk_size"] = snapshot.DiskSize
330+
snapshotMap := make(map[string]interface{}, 4)
331+
snapshotMap["snapshot_id"] = snapshot.SnapshotId
332+
snapshotMap["disk_usage"] = snapshot.DiskUsage
333+
snapshotMap["disk_size"] = snapshot.DiskSize
334+
snapshotMap["snapshot_name"] = snapshot.SnapshotName
343335

344-
if v, ok := snapshotSetMap[*id]; ok {
345-
snapshotMap["snapshot_name"] = v.(*cbs.Snapshot).SnapshotName
346-
}
347-
snapshotResults = append(snapshotResults, snapshotMap)
348-
}
336+
snapshotResults = append(snapshotResults, snapshotMap)
349337
}
350338

351339
return

tencentcloud/service_tencentcloud_cbs.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,6 @@ func (me *CbsService) DescribeSnapshotByIds(ctx context.Context, snapshotIdsPara
258258
errRet = err
259259
return
260260
}
261-
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n",
262-
logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())
263-
264261
if len(response.Response.SnapshotSet) < 1 {
265262
break
266263
}

0 commit comments

Comments
 (0)