diff --git a/internal/provider/cluster.go b/internal/provider/cluster.go index 9bc8ae0..91ee52b 100644 --- a/internal/provider/cluster.go +++ b/internal/provider/cluster.go @@ -268,13 +268,13 @@ func resourceClusterRead(ctx context.Context, d *schema.ResourceData, meta inter } reqs, err := c.ListClusterRequest(ctx, clusterID, "CREATE_CLUSTER") - if scylla.IsDeletedErr(err) { + switch { + case scylla.IsDeletedErr(err): _ = d.Set("status", "DELETED") return nil - } else if err != nil { + case err != nil: return diag.Errorf("error reading cluster request: %s", err) - } - if len(reqs) != 1 { + case len(reqs) != 1: return diag.Errorf("unexpected number of cluster requests, expected 1, got: %+v", reqs) } _ = d.Set("request_id", reqs[0].ID) diff --git a/internal/provider/serverless_cluster.go b/internal/provider/serverless_cluster.go index ebf232f..117f644 100644 --- a/internal/provider/serverless_cluster.go +++ b/internal/provider/serverless_cluster.go @@ -115,12 +115,16 @@ func resourceServerlessClusterRead(ctx context.Context, d *schema.ResourceData, } reqs, err := c.ListClusterRequest(ctx, clusterID, "CREATE_CLUSTER") - if err != nil { + switch { + case scylla.IsDeletedErr(err): + _ = d.Set("status", "DELETED") + return nil + case err != nil: return diag.Errorf("error reading serverless cluster request: %s", err) - } - if len(reqs) != 1 { + case len(reqs) != 1: return diag.Errorf("unexpected number of serverless cluster requests, expected 1, got: %+v", reqs) } + _ = d.Set("request_id", reqs[0].ID) if reqs[0].Status != "COMPLETED" { if err := waitForCluster(ctx, c, reqs[0].ID); err != nil {