From 6d8af3b2e16d7c0145903c61bbd8d8d12197e1a9 Mon Sep 17 00:00:00 2001 From: Tomas Basham Date: Sat, 10 Dec 2022 12:27:09 +0000 Subject: [PATCH] Set the ICMP block when importing an uptime check When an ICMP uptime check was being imported the code to set the ICMP block in the state was not being called. This commit ensures the state is correctly updated. --- internal/provider/resource_uptime_check.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/internal/provider/resource_uptime_check.go b/internal/provider/resource_uptime_check.go index f25bb65..500af9d 100644 --- a/internal/provider/resource_uptime_check.go +++ b/internal/provider/resource_uptime_check.go @@ -516,6 +516,10 @@ func resourceStatusCakeUptimeCheckRead(ctx context.Context, d *schema.ResourceDa return diag.Errorf("failed to read HTTP check: %s", err) } + if err := d.Set("icmp_check", flattenUptimeCheckICMPCheck(res.Data, d)); err != nil { + return diag.Errorf("failed to read ICMP check: %s", err) + } + if err := d.Set("monitored_resource", flattenUptimeCheckMonitoredResource(res.Data, d)); err != nil { return diag.Errorf("failed to read monitored resource: %s", err) } @@ -1005,7 +1009,16 @@ func expandUptimeCheckICMPCheck(v interface{}, d *schema.ResourceData) (interfac } func flattenUptimeCheckICMPCheck(v interface{}, d *schema.ResourceData) interface{} { - return []interface{}{} + data := v.(statuscake.UptimeTest) + if data.TestType != statuscake.UptimeTestTypePING { + return nil + } + + return []map[string]interface{}{ + map[string]interface{}{ + "enabled": true, + }, + } } func expandUptimeCheckIncludeHeaders(v interface{}, d *schema.ResourceData) (interface{}, error) {