@@ -105,11 +105,13 @@ func (d *Datasource) Execute() (cty.Value, error) {
105
105
}
106
106
107
107
func (d * Datasource ) ResolveImageByFilters () (* cvm.Image , error ) {
108
- client , _ , _ , err := d .config .Client ()
108
+ clientMap , err := d .config .Client ()
109
109
if err != nil {
110
110
return nil , err
111
111
}
112
112
113
+ cvmClient := clientMap ["cvm_client" ].(* cvm.Client )
114
+
113
115
req := cvm .NewDescribeImagesRequest ()
114
116
115
117
var filters []* cvm.Filter
@@ -127,7 +129,7 @@ func (d *Datasource) ResolveImageByFilters() (*cvm.Image, error) {
127
129
var resp * cvm.DescribeImagesResponse
128
130
err = buildCvm .Retry (ctx , func (ctx context.Context ) error {
129
131
var e error
130
- resp , e = client .DescribeImages (req )
132
+ resp , e = cvmClient .DescribeImages (req )
131
133
return e
132
134
})
133
135
if err != nil {
@@ -150,19 +152,21 @@ func (d *Datasource) ResolveImageByFilters() (*cvm.Image, error) {
150
152
}
151
153
152
154
func (d * Datasource ) ResolveImageByImageFamily () (* cvm.Image , error ) {
153
- client , _ , _ , err := d .config .Client ()
155
+ clientMap , err := d .config .Client ()
154
156
if err != nil {
155
157
return nil , err
156
158
}
157
159
160
+ cvmClient := clientMap ["cvm_client" ].(* cvm.Client )
161
+
158
162
var resp * cvm.DescribeImageFromFamilyResponse
159
163
req := cvm .NewDescribeImageFromFamilyRequest ()
160
164
req .ImageFamily = & d .config .ImageFamily
161
165
162
166
ctx := context .TODO ()
163
167
err = buildCvm .Retry (ctx , func (ctx context.Context ) error {
164
168
var e error
165
- resp , e = client .DescribeImageFromFamily (req )
169
+ resp , e = cvmClient .DescribeImageFromFamily (req )
166
170
return e
167
171
})
168
172
0 commit comments