@@ -13,9 +13,9 @@ import (
13
13
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
14
14
)
15
15
16
- func dataSourceAlicloudArmsPrometheis () * schema.Resource {
16
+ func dataSourceAliCloudArmsPrometheis () * schema.Resource {
17
17
return & schema.Resource {
18
- Read : dataSourceAlicloudArmsPrometheisRead ,
18
+ Read : dataSourceAliCloudArmsPrometheisRead ,
19
19
Schema : map [string ]* schema.Schema {
20
20
"ids" : {
21
21
Type : schema .TypeList ,
@@ -35,12 +35,12 @@ func dataSourceAlicloudArmsPrometheis() *schema.Resource {
35
35
Optional : true ,
36
36
ForceNew : true ,
37
37
},
38
+ "tags" : tagsSchemaForceNew (),
38
39
"enable_details" : {
39
40
Type : schema .TypeBool ,
40
41
Optional : true ,
41
42
Default : false ,
42
43
},
43
- "tags" : tagsSchemaForceNew (),
44
44
"output_file" : {
45
45
Type : schema .TypeString ,
46
46
Optional : true ,
@@ -91,6 +91,10 @@ func dataSourceAlicloudArmsPrometheis() *schema.Resource {
91
91
Type : schema .TypeString ,
92
92
Computed : true ,
93
93
},
94
+ "resource_group_id" : {
95
+ Type : schema .TypeString ,
96
+ Computed : true ,
97
+ },
94
98
"remote_read_intra_url" : {
95
99
Type : schema .TypeString ,
96
100
Computed : true ,
@@ -127,10 +131,6 @@ func dataSourceAlicloudArmsPrometheis() *schema.Resource {
127
131
Type : schema .TypeString ,
128
132
Computed : true ,
129
133
},
130
- "resource_group_id" : {
131
- Type : schema .TypeString ,
132
- Computed : true ,
133
- },
134
134
"tags" : {
135
135
Type : schema .TypeMap ,
136
136
Computed : true ,
@@ -142,7 +142,7 @@ func dataSourceAlicloudArmsPrometheis() *schema.Resource {
142
142
}
143
143
}
144
144
145
- func dataSourceAlicloudArmsPrometheisRead (d * schema.ResourceData , meta interface {}) error {
145
+ func dataSourceAliCloudArmsPrometheisRead (d * schema.ResourceData , meta interface {}) error {
146
146
client := meta .(* connectivity.AliyunClient )
147
147
148
148
action := "ListPrometheusInstanceByTagAndResourceGroupId"
@@ -195,7 +195,7 @@ func dataSourceAlicloudArmsPrometheisRead(d *schema.ResourceData, meta interface
195
195
addDebug (action , response , request )
196
196
197
197
if err != nil {
198
- return WrapErrorf (err , DataDefaultErrorMsg , "alicloud_arms_prometheis " , action , AlibabaCloudSdkGoERROR )
198
+ return WrapErrorf (err , DataDefaultErrorMsg , "alicloud_arms_prometheus " , action , AlibabaCloudSdkGoERROR )
199
199
}
200
200
201
201
resp , err := jsonpath .Get ("$.Data.PrometheusInstances" , response )
@@ -244,22 +244,25 @@ func dataSourceAlicloudArmsPrometheisRead(d *schema.ResourceData, meta interface
244
244
s = append (s , mapping )
245
245
continue
246
246
}
247
+
247
248
id := fmt .Sprint (fmt .Sprint (object ["ClusterId" ]))
248
- client := meta .(* connectivity.AliyunClient )
249
249
armsService := ArmsService {client }
250
- object , err := armsService .DescribeArmsPrometheus (id )
250
+
251
+ armsPrometheus , err := armsService .DescribeArmsPrometheus (id )
251
252
if err != nil {
252
253
return WrapError (err )
253
254
}
254
- mapping ["remote_read_intra_url" ] = object ["RemoteReadIntraUrl" ]
255
- mapping ["remote_read_inter_url" ] = object ["RemoteReadInterUrl" ]
256
- mapping ["remote_write_intra_url" ] = object ["RemoteWriteIntraUrl" ]
257
- mapping ["remote_write_inter_url" ] = object ["RemoteWriteInterUrl" ]
258
- mapping ["push_gate_way_intra_url" ] = object ["PushGateWayIntraUrl" ]
259
- mapping ["push_gate_way_inter_url" ] = object ["PushGateWayInterUrl" ]
260
- mapping ["http_api_intra_url" ] = object ["HttpApiIntraUrl" ]
261
- mapping ["http_api_inter_url" ] = object ["HttpApiInterUrl" ]
262
- mapping ["auth_token" ] = object ["AuthToken" ]
255
+
256
+ mapping ["remote_read_intra_url" ] = armsPrometheus ["RemoteReadIntraUrl" ]
257
+ mapping ["remote_read_inter_url" ] = armsPrometheus ["RemoteReadInterUrl" ]
258
+ mapping ["remote_write_intra_url" ] = armsPrometheus ["RemoteWriteIntraUrl" ]
259
+ mapping ["remote_write_inter_url" ] = armsPrometheus ["RemoteWriteInterUrl" ]
260
+ mapping ["push_gate_way_intra_url" ] = armsPrometheus ["PushGatewayIntraUrl" ]
261
+ mapping ["push_gate_way_inter_url" ] = armsPrometheus ["PushGatewayInterUrl" ]
262
+ mapping ["http_api_intra_url" ] = armsPrometheus ["HttpApiIntraUrl" ]
263
+ mapping ["http_api_inter_url" ] = armsPrometheus ["HttpApiInterUrl" ]
264
+ mapping ["auth_token" ] = armsPrometheus ["AuthToken" ]
265
+
263
266
s = append (s , mapping )
264
267
}
265
268
0 commit comments