Skip to content

Commit 234b720

Browse files
Removing deprecated exists calls (#582)
The plugin has marked `Exists` functionality deprecated due to it being a copy of Read
1 parent fdd8d0a commit 234b720

31 files changed

+7
-270
lines changed

signalfx/integration.go

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,12 @@ package signalfx
66
import (
77
"encoding/json"
88
"fmt"
9-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
109
"log"
1110
"reflect"
1211
"strings"
13-
)
1412

15-
func handleIntegrationExists(err error) (bool, error) {
16-
if err != nil {
17-
if strings.Contains(err.Error(), "404") {
18-
return false, nil
19-
}
20-
return false, err
21-
}
22-
return true, nil
23-
}
13+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
14+
)
2415

2516
func handleIntegrationRead(err error, d *schema.ResourceData) bool {
2617
if err != nil {

signalfx/resource_signalfx_alert_muting_rule.go

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ import (
88
"encoding/json"
99
"errors"
1010
"fmt"
11-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
1211
"log"
1312
"strings"
1413
"time"
1514

15+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
16+
1617
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1718
"github.com/signalfx/signalfx-go/alertmuting"
1819
)
@@ -106,7 +107,6 @@ func alertMutingRuleResource() *schema.Resource {
106107
Read: alertMutingRuleRead,
107108
Update: alertMutingRuleUpdate,
108109
Delete: alertMutingRuleDelete,
109-
Exists: alertMutingRuleExists,
110110
Importer: &schema.ResourceImporter{
111111
State: schema.ImportStatePassthrough,
112112
},
@@ -183,18 +183,6 @@ func alertMutingRuleCreate(d *schema.ResourceData, meta interface{}) error {
183183
return alertMutingRuleAPIToTF(d, amr)
184184
}
185185

186-
func alertMutingRuleExists(d *schema.ResourceData, meta interface{}) (bool, error) {
187-
config := meta.(*signalfxConfig)
188-
_, err := config.Client.GetAlertMutingRule(context.TODO(), d.Id())
189-
if err != nil {
190-
if strings.Contains(err.Error(), "404") {
191-
return false, nil
192-
}
193-
return false, err
194-
}
195-
return true, nil
196-
}
197-
198186
func alertMutingRuleRead(d *schema.ResourceData, meta interface{}) error {
199187
config := meta.(*signalfxConfig)
200188
amr, err := config.Client.GetAlertMutingRule(context.TODO(), d.Id())

signalfx/resource_signalfx_aws_external_integration.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,5 @@ func integrationAWSExternalResource() *schema.Resource {
3636
},
3737
Read: IntegrationAWSRead,
3838
Delete: noop, // delete is handled in the resource_signalfx_aws_integration.go
39-
Exists: IntegrationAWSExists,
4039
}
4140
}

signalfx/resource_signalfx_aws_integration.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -263,22 +263,9 @@ func integrationAWSResource() *schema.Resource {
263263
Read: integrationAWSRead,
264264
Update: integrationAWSUpdate,
265265
Delete: integrationAWSDelete,
266-
Exists: integrationAWSExists,
267266
}
268267
}
269268

270-
func integrationAWSExists(d *schema.ResourceData, meta any) (bool, error) {
271-
config := meta.(*signalfxConfig)
272-
_, err := config.Client.GetAWSCloudWatchIntegration(context.TODO(), d.Get("integration_id").(string))
273-
if err != nil {
274-
if strings.Contains(err.Error(), "404") {
275-
return false, nil
276-
}
277-
return false, err
278-
}
279-
return true, nil
280-
}
281-
282269
func integrationAWSRead(d *schema.ResourceData, meta any) error {
283270
config := meta.(*signalfxConfig)
284271

signalfx/resource_signalfx_aws_integration_ops.go

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,12 @@ import (
77
"context"
88
"encoding/json"
99
"fmt"
10-
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
11-
"github.com/signalfx/signalfx-go/integration"
1210
"log"
1311
"strings"
14-
)
1512

16-
func IntegrationAWSExists(d *schema.ResourceData, meta interface{}) (bool, error) {
17-
config := meta.(*signalfxConfig)
18-
_, err := config.Client.GetAWSCloudWatchIntegration(context.TODO(), d.Id())
19-
if err != nil {
20-
if strings.Contains(err.Error(), "404") {
21-
return false, nil
22-
}
23-
return false, err
24-
}
25-
return true, nil
26-
}
13+
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
14+
"github.com/signalfx/signalfx-go/integration"
15+
)
2716

2817
func IntegrationAWSRead(d *schema.ResourceData, meta interface{}) error {
2918
config := meta.(*signalfxConfig)

signalfx/resource_signalfx_aws_token_integration.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,5 @@ func integrationAWSTokenResource() *schema.Resource {
3636
},
3737
Read: IntegrationAWSRead,
3838
Delete: noop, // delete is handled in the resource_signalfx_aws_integration.go
39-
Exists: IntegrationAWSExists,
4039
}
4140
}

signalfx/resource_signalfx_azure_integration.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -144,25 +144,12 @@ func integrationAzureResource() *schema.Resource {
144144
Read: integrationAzureRead,
145145
Update: integrationAzureUpdate,
146146
Delete: integrationAzureDelete,
147-
Exists: integrationAzureExists,
148147
Importer: &schema.ResourceImporter{
149148
State: schema.ImportStatePassthrough,
150149
},
151150
}
152151
}
153152

154-
func integrationAzureExists(d *schema.ResourceData, meta interface{}) (bool, error) {
155-
config := meta.(*signalfxConfig)
156-
_, err := config.Client.GetAzureIntegration(context.TODO(), d.Id())
157-
if err != nil {
158-
if strings.Contains(err.Error(), "404") {
159-
return false, nil
160-
}
161-
return false, err
162-
}
163-
return true, nil
164-
}
165-
166153
func integrationAzureRead(d *schema.ResourceData, meta interface{}) error {
167154
config := meta.(*signalfxConfig)
168155
int, err := config.Client.GetAzureIntegration(context.TODO(), d.Id())

signalfx/resource_signalfx_dashboard.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,6 @@ func dashboardResource() *schema.Resource {
461461
Read: dashboardRead,
462462
Update: dashboardUpdate,
463463
Delete: dashboardDelete,
464-
Exists: dashboardExists,
465464
Importer: &schema.ResourceImporter{
466465
State: schema.ImportStatePassthrough,
467466
},
@@ -846,18 +845,6 @@ func dashboardCreate(d *schema.ResourceData, meta interface{}) error {
846845
return dashboardAPIToTF(d, dash)
847846
}
848847

849-
func dashboardExists(d *schema.ResourceData, meta interface{}) (bool, error) {
850-
config := meta.(*signalfxConfig)
851-
_, err := config.Client.GetDashboard(context.TODO(), d.Id())
852-
if err != nil {
853-
if strings.Contains(err.Error(), "404") {
854-
return false, nil
855-
}
856-
return false, err
857-
}
858-
return true, nil
859-
}
860-
861848
func dashboardRead(d *schema.ResourceData, meta interface{}) error {
862849
config := meta.(*signalfxConfig)
863850
dash, err := config.Client.GetDashboard(context.TODO(), d.Id())

signalfx/resource_signalfx_dashboard_group.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"encoding/json"
99
"fmt"
1010
"log"
11-
"strings"
1211

1312
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1413
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
@@ -203,25 +202,12 @@ func dashboardGroupResource() *schema.Resource {
203202
Read: dashboardgroupRead,
204203
Update: dashboardgroupUpdate,
205204
Delete: dashboardgroupDelete,
206-
Exists: dashboardgroupExists,
207205
Importer: &schema.ResourceImporter{
208206
State: schema.ImportStatePassthrough,
209207
},
210208
}
211209
}
212210

213-
func dashboardgroupExists(d *schema.ResourceData, meta interface{}) (bool, error) {
214-
config := meta.(*signalfxConfig)
215-
_, err := config.Client.GetDashboardGroup(context.TODO(), d.Id())
216-
if err != nil {
217-
if strings.Contains(err.Error(), "404") {
218-
return false, nil
219-
}
220-
return false, err
221-
}
222-
return true, nil
223-
}
224-
225211
/*
226212
Use Resource object to construct json payload in order to create a dasboard group
227213
*/

signalfx/resource_signalfx_data_link.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"fmt"
1010
"log"
1111
"regexp"
12-
"strings"
1312

1413
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1514
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
@@ -154,7 +153,6 @@ func dataLinkResource() *schema.Resource {
154153
Read: dataLinkRead,
155154
Update: dataLinkUpdate,
156155
Delete: dataLinkDelete,
157-
Exists: dataLinkExists,
158156
Importer: &schema.ResourceImporter{
159157
State: schema.ImportStatePassthrough,
160158
},
@@ -432,15 +430,3 @@ func dataLinkDelete(d *schema.ResourceData, meta interface{}) error {
432430

433431
return config.Client.DeleteDataLink(context.TODO(), d.Id())
434432
}
435-
436-
func dataLinkExists(d *schema.ResourceData, meta interface{}) (bool, error) {
437-
config := meta.(*signalfxConfig)
438-
_, err := config.Client.GetDataLink(context.TODO(), d.Id())
439-
if err != nil {
440-
if strings.Contains(err.Error(), "404") {
441-
return false, nil
442-
}
443-
return false, err
444-
}
445-
return true, nil
446-
}

signalfx/resource_signalfx_detector.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,6 @@ func detectorResource() *schema.Resource {
274274
Read: detectorRead,
275275
Update: detectorUpdate,
276276
Delete: detectorDelete,
277-
Exists: detectorExists,
278277
Importer: &schema.ResourceImporter{
279278
State: schema.ImportStatePassthrough,
280279
},
@@ -523,18 +522,6 @@ func detectorCreate(d *schema.ResourceData, meta interface{}) error {
523522
return detectorRead(d, meta)
524523
}
525524

526-
func detectorExists(d *schema.ResourceData, meta interface{}) (bool, error) {
527-
config := meta.(*signalfxConfig)
528-
_, err := config.Client.GetDetector(context.TODO(), d.Id())
529-
if err != nil {
530-
if strings.Contains(err.Error(), "404") {
531-
return false, nil
532-
}
533-
return false, err
534-
}
535-
return true, nil
536-
}
537-
538525
func detectorRead(d *schema.ResourceData, meta interface{}) error {
539526
config := meta.(*signalfxConfig)
540527
det, err := config.Client.GetDetector(context.TODO(), d.Id())

signalfx/resource_signalfx_event_feed_chart.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ func eventFeedChartResource() *schema.Resource {
6969
Read: eventFeedChartRead,
7070
Update: eventFeedChartUpdate,
7171
Delete: eventFeedChartDelete,
72-
Exists: chartExists,
7372
Importer: &schema.ResourceImporter{
7473
State: schema.ImportStatePassthrough,
7574
},

signalfx/resource_signalfx_gcp_integration.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -133,25 +133,12 @@ func integrationGCPResource() *schema.Resource {
133133
Read: integrationGCPRead,
134134
Update: integrationGCPUpdate,
135135
Delete: integrationGCPDelete,
136-
Exists: integrationGCPExists,
137136
Importer: &schema.ResourceImporter{
138137
State: schema.ImportStatePassthrough,
139138
},
140139
}
141140
}
142141

143-
func integrationGCPExists(d *schema.ResourceData, meta any) (bool, error) {
144-
config := meta.(*signalfxConfig)
145-
_, err := config.Client.GetGCPIntegration(context.TODO(), d.Id())
146-
if err != nil {
147-
if strings.Contains(err.Error(), "404") {
148-
return false, nil
149-
}
150-
return false, err
151-
}
152-
return true, nil
153-
}
154-
155142
func integrationGCPRead(d *schema.ResourceData, meta any) error {
156143
config := meta.(*signalfxConfig)
157144
int, err := config.Client.GetGCPIntegration(context.TODO(), d.Id())

signalfx/resource_signalfx_heatmap_chart.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ func heatmapChartResource() *schema.Resource {
184184
Read: heatmapchartRead,
185185
Update: heatmapchartUpdate,
186186
Delete: heatmapchartDelete,
187-
Exists: chartExists,
188187
Importer: &schema.ResourceImporter{
189188
State: schema.ImportStatePassthrough,
190189
},

signalfx/resource_signalfx_jira_integration.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,25 +94,12 @@ func integrationJiraResource() *schema.Resource {
9494
Read: integrationJiraRead,
9595
Update: integrationJiraUpdate,
9696
Delete: integrationJiraDelete,
97-
Exists: integrationJiraExists,
9897
Importer: &schema.ResourceImporter{
9998
State: schema.ImportStatePassthrough,
10099
},
101100
}
102101
}
103102

104-
func integrationJiraExists(d *schema.ResourceData, meta interface{}) (bool, error) {
105-
config := meta.(*signalfxConfig)
106-
_, err := config.Client.GetJiraIntegration(context.TODO(), d.Id())
107-
if err != nil {
108-
if strings.Contains(err.Error(), "404") {
109-
return false, nil
110-
}
111-
return false, err
112-
}
113-
return true, nil
114-
}
115-
116103
func integrationJiraRead(d *schema.ResourceData, meta interface{}) error {
117104
config := meta.(*signalfxConfig)
118105
int, err := config.Client.GetJiraIntegration(context.TODO(), d.Id())

signalfx/resource_signalfx_list_chart.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ func listChartResource() *schema.Resource {
246246
Read: listchartRead,
247247
Update: listchartUpdate,
248248
Delete: listchartDelete,
249-
Exists: chartExists,
250249
Importer: &schema.ResourceImporter{
251250
State: schema.ImportStatePassthrough,
252251
},

signalfx/resource_signalfx_log_timeline.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ func logTimelineResource() *schema.Resource {
7575
Read: logTimelineRead,
7676
Update: logTimelineUpdate,
7777
Delete: logTimelineDelete,
78-
Exists: chartExists,
7978
Importer: &schema.ResourceImporter{
8079
State: schema.ImportStatePassthrough,
8180
},

signalfx/resource_signalfx_log_view.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ func logViewResource() *schema.Resource {
109109
Read: logViewRead,
110110
Update: logViewUpdate,
111111
Delete: logViewDelete,
112-
Exists: chartExists,
113112
Importer: &schema.ResourceImporter{
114113
State: schema.ImportStatePassthrough,
115114
},

0 commit comments

Comments
 (0)