Skip to content

Commit c916d99

Browse files
committed
fix: modify get client
1 parent bd056e0 commit c916d99

File tree

1 file changed

+8
-4
lines changed
  • datasource/tencentcloud/image

1 file changed

+8
-4
lines changed

datasource/tencentcloud/image/data.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,13 @@ func (d *Datasource) Execute() (cty.Value, error) {
105105
}
106106

107107
func (d *Datasource) ResolveImageByFilters() (*cvm.Image, error) {
108-
client, _, _, err := d.config.Client()
108+
clientMap, err := d.config.Client()
109109
if err != nil {
110110
return nil, err
111111
}
112112

113+
cvmClient := clientMap["cvm_client"].(*cvm.Client)
114+
113115
req := cvm.NewDescribeImagesRequest()
114116

115117
var filters []*cvm.Filter
@@ -127,7 +129,7 @@ func (d *Datasource) ResolveImageByFilters() (*cvm.Image, error) {
127129
var resp *cvm.DescribeImagesResponse
128130
err = buildCvm.Retry(ctx, func(ctx context.Context) error {
129131
var e error
130-
resp, e = client.DescribeImages(req)
132+
resp, e = cvmClient.DescribeImages(req)
131133
return e
132134
})
133135
if err != nil {
@@ -150,19 +152,21 @@ func (d *Datasource) ResolveImageByFilters() (*cvm.Image, error) {
150152
}
151153

152154
func (d *Datasource) ResolveImageByImageFamily() (*cvm.Image, error) {
153-
client, _, _, err := d.config.Client()
155+
clientMap, err := d.config.Client()
154156
if err != nil {
155157
return nil, err
156158
}
157159

160+
cvmClient := clientMap["cvm_client"].(*cvm.Client)
161+
158162
var resp *cvm.DescribeImageFromFamilyResponse
159163
req := cvm.NewDescribeImageFromFamilyRequest()
160164
req.ImageFamily = &d.config.ImageFamily
161165

162166
ctx := context.TODO()
163167
err = buildCvm.Retry(ctx, func(ctx context.Context) error {
164168
var e error
165-
resp, e = client.DescribeImageFromFamily(req)
169+
resp, e = cvmClient.DescribeImageFromFamily(req)
166170
return e
167171
})
168172

0 commit comments

Comments
 (0)