diff --git a/internal/models/notification_recipients.go b/internal/models/notification_recipients.go index 3f5268d8..5ad9dd21 100644 --- a/internal/models/notification_recipients.go +++ b/internal/models/notification_recipients.go @@ -16,13 +16,13 @@ type NotificationRecipientDetailsModel struct { PDSeverity types.String `tfsdk:"pagerduty_severity"` } -var NotificationRecipientAttrTypes = map[string]attr.Type{ +var NotificationRecipientAttrType = map[string]attr.Type{ "id": types.StringType, "type": types.StringType, "target": types.StringType, - "notification_details": types.ListType{ElemType: types.ObjectType{AttrTypes: NotificationRecipientDetailsAttrTypes}}, + "notification_details": types.ListType{ElemType: types.ObjectType{AttrTypes: NotificationRecipientDetailsAttrType}}, } -var NotificationRecipientDetailsAttrTypes = map[string]attr.Type{ +var NotificationRecipientDetailsAttrType = map[string]attr.Type{ "pagerduty_severity": types.StringType, } diff --git a/internal/provider/burn_alert_resource.go b/internal/provider/burn_alert_resource.go index ff07f75c..5bfd4dae 100644 --- a/internal/provider/burn_alert_resource.go +++ b/internal/provider/burn_alert_resource.go @@ -210,7 +210,7 @@ func (r *burnAlertResource) ImportState(ctx context.Context, req resource.Import resp.Diagnostics.Append(resp.State.Set(ctx, &models.BurnAlertResourceModel{ ID: types.StringValue(id), Dataset: types.StringValue(dataset), - Recipients: types.SetUnknown(types.ObjectType{AttrTypes: models.NotificationRecipientAttrTypes}), + Recipients: types.SetUnknown(types.ObjectType{AttrTypes: models.NotificationRecipientAttrType}), })...) } diff --git a/internal/provider/notification_recipients.go b/internal/provider/notification_recipients.go index 329d9781..8a2cffed 100644 --- a/internal/provider/notification_recipients.go +++ b/internal/provider/notification_recipients.go @@ -121,7 +121,7 @@ func reconcileReadNotificationRecipientState(ctx context.Context, remote []clien var recipients []models.NotificationRecipientModel diags.Append(state.ElementsAs(ctx, &recipients, false)...) if diags.HasError() { - return types.SetNull(types.ObjectType{AttrTypes: models.NotificationRecipientAttrTypes}) + return types.SetNull(types.ObjectType{AttrTypes: models.NotificationRecipientAttrType}) } mappedRecips := mapNotificationRecipientToState(ctx, remote, recipients, diags) @@ -129,7 +129,7 @@ func reconcileReadNotificationRecipientState(ctx context.Context, remote []clien for _, r := range mappedRecips { values = append(values, notificationRecipientModelToObjectValue(ctx, r, diags)) } - result, d := types.SetValueFrom(ctx, types.ObjectType{AttrTypes: models.NotificationRecipientAttrTypes}, values) + result, d := types.SetValueFrom(ctx, types.ObjectType{AttrTypes: models.NotificationRecipientAttrType}, values) diags.Append(d...) return result @@ -167,14 +167,14 @@ func expandNotificationRecipients(ctx context.Context, set types.Set, diags *dia func flattenNotificationRecipients(ctx context.Context, n []client.NotificationRecipient, diags *diag.Diagnostics) types.Set { if len(n) == 0 { - return types.SetNull(types.ObjectType{AttrTypes: models.NotificationRecipientAttrTypes}) + return types.SetNull(types.ObjectType{AttrTypes: models.NotificationRecipientAttrType}) } var values []attr.Value for _, r := range n { values = append(values, notificationRecipientToObjectValue(ctx, r, diags)) } - result, d := types.SetValueFrom(ctx, types.ObjectType{AttrTypes: models.NotificationRecipientAttrTypes}, values) + result, d := types.SetValueFrom(ctx, types.ObjectType{AttrTypes: models.NotificationRecipientAttrType}, values) diags.Append(d...) return result @@ -187,7 +187,7 @@ func notificationRecipientToObjectValue(ctx context.Context, r client.Notificati "target": types.StringValue(r.Target), "notification_details": notificationRecipientDetailsToList(ctx, r.Details, diags), } - recipObjVal, d := types.ObjectValue(models.NotificationRecipientAttrTypes, recipObj) + recipObjVal, d := types.ObjectValue(models.NotificationRecipientAttrType, recipObj) diags.Append(d...) return recipObjVal @@ -207,16 +207,16 @@ func notificationRecipientModelToObjectValue(ctx context.Context, r models.Notif if diags.HasError() { return basetypes.ObjectValue{} } - detailsObjVal, d := types.ObjectValue(models.NotificationRecipientDetailsAttrTypes, map[string]attr.Value{"pagerduty_severity": details[0].PDSeverity}) + detailsObjVal, d := types.ObjectValue(models.NotificationRecipientDetailsAttrType, map[string]attr.Value{"pagerduty_severity": details[0].PDSeverity}) diags.Append(d...) - result, d = types.ListValueFrom(ctx, types.ObjectType{AttrTypes: models.NotificationRecipientDetailsAttrTypes}, []attr.Value{detailsObjVal}) + result, d = types.ListValueFrom(ctx, types.ObjectType{AttrTypes: models.NotificationRecipientDetailsAttrType}, []attr.Value{detailsObjVal}) diags.Append(d...) } else { - result = types.ListNull(types.ObjectType{AttrTypes: models.NotificationRecipientDetailsAttrTypes}) + result = types.ListNull(types.ObjectType{AttrTypes: models.NotificationRecipientDetailsAttrType}) } recipObj["notification_details"] = result - recipObjVal, d := types.ObjectValue(models.NotificationRecipientAttrTypes, recipObj) + recipObjVal, d := types.ObjectValue(models.NotificationRecipientAttrType, recipObj) diags.Append(d...) return recipObjVal @@ -237,13 +237,13 @@ func notificationRecipientDetailsToList(ctx context.Context, details *client.Not var result basetypes.ListValue if details != nil { detailsObj := map[string]attr.Value{"pagerduty_severity": types.StringValue(string(details.PDSeverity))} - objVal, d := types.ObjectValue(models.NotificationRecipientDetailsAttrTypes, detailsObj) + objVal, d := types.ObjectValue(models.NotificationRecipientDetailsAttrType, detailsObj) diags.Append(d...) - result, d = types.ListValueFrom(ctx, types.ObjectType{AttrTypes: models.NotificationRecipientDetailsAttrTypes}, []attr.Value{objVal}) + result, d = types.ListValueFrom(ctx, types.ObjectType{AttrTypes: models.NotificationRecipientDetailsAttrType}, []attr.Value{objVal}) diags.Append(d...) } else { - result = types.ListNull(types.ObjectType{AttrTypes: models.NotificationRecipientDetailsAttrTypes}) + result = types.ListNull(types.ObjectType{AttrTypes: models.NotificationRecipientDetailsAttrType}) } return result diff --git a/internal/provider/notification_recipients_test.go b/internal/provider/notification_recipients_test.go index db36f83c..d8b90fa9 100644 --- a/internal/provider/notification_recipients_test.go +++ b/internal/provider/notification_recipients_test.go @@ -14,7 +14,7 @@ import ( ) func Test_reconcileReadNotificationRecipientState(t *testing.T) { - elemType := types.ObjectType{AttrTypes: models.NotificationRecipientAttrTypes} + elemType := types.ObjectType{AttrTypes: models.NotificationRecipientAttrType} type args struct { remote []client.NotificationRecipient state types.Set @@ -96,7 +96,7 @@ func Test_reconcileReadNotificationRecipientState(t *testing.T) { ID: types.StringValue("ijkl13579"), Type: types.StringValue("pagerduty"), Target: types.StringValue("test-pagerduty"), - Details: types.ListValueMust(types.ObjectType{AttrTypes: models.NotificationRecipientDetailsAttrTypes}, severityStringToValue("warning")), + Details: types.ListValueMust(types.ObjectType{AttrTypes: models.NotificationRecipientDetailsAttrType}, severityStringToValue("warning")), }, }), }, @@ -109,7 +109,7 @@ func Test_reconcileReadNotificationRecipientState(t *testing.T) { state: notificationRecipientModelsToSet([]models.NotificationRecipientModel{ {ID: types.StringValue("abcd12345")}, {Type: types.StringValue("slack"), Target: types.StringValue("#test-foo")}, - {ID: types.StringValue("ijkl13579"), Details: types.ListValueMust(types.ObjectType{AttrTypes: models.NotificationRecipientDetailsAttrTypes}, severityStringToValue("warning"))}, + {ID: types.StringValue("ijkl13579"), Details: types.ListValueMust(types.ObjectType{AttrTypes: models.NotificationRecipientDetailsAttrType}, severityStringToValue("warning"))}, }), }, want: notificationRecipientModelsToSet([]models.NotificationRecipientModel{ @@ -125,7 +125,7 @@ func Test_reconcileReadNotificationRecipientState(t *testing.T) { state: notificationRecipientModelsToSet([]models.NotificationRecipientModel{ {ID: types.StringValue("abcd12345")}, {Type: types.StringValue("slack"), Target: types.StringValue("#test-channel")}, - {ID: types.StringValue("ijkl13579"), Details: types.ListValueMust(types.ObjectType{AttrTypes: models.NotificationRecipientDetailsAttrTypes}, severityStringToValue("warning"))}, + {ID: types.StringValue("ijkl13579"), Details: types.ListValueMust(types.ObjectType{AttrTypes: models.NotificationRecipientDetailsAttrType}, severityStringToValue("warning"))}, }), }, want: notificationRecipientModelsToSet([]models.NotificationRecipientModel{ @@ -146,10 +146,9 @@ func notificationRecipientModelsToSet(n []models.NotificationRecipientModel) typ for _, r := range n { values = append(values, notificationRecipientModelToObjectValue(context.Background(), r, &diag.Diagnostics{})) } - return types.SetValueMust(types.ObjectType{AttrTypes: models.NotificationRecipientAttrTypes}, values) + return types.SetValueMust(types.ObjectType{AttrTypes: models.NotificationRecipientAttrType}, values) } func severityStringToValue(s string) []attr.Value { - detailsObj := map[string]attr.Value{"pagerduty_severity": types.StringValue(s)} - return []attr.Value{types.ObjectValueMust(models.NotificationRecipientDetailsAttrTypes, detailsObj)} + return []attr.Value{types.ObjectValueMust(models.NotificationRecipientDetailsAttrType, map[string]attr.Value{"pagerduty_severity": types.StringValue(s)})} } diff --git a/internal/provider/trigger_resource.go b/internal/provider/trigger_resource.go index 40c4f496..5996fed6 100644 --- a/internal/provider/trigger_resource.go +++ b/internal/provider/trigger_resource.go @@ -385,7 +385,7 @@ func (r *triggerResource) ImportState(ctx context.Context, req resource.ImportSt resp.Diagnostics.Append(resp.State.Set(ctx, &models.TriggerResourceModel{ ID: types.StringValue(id), Dataset: types.StringValue(dataset), - Recipients: types.SetUnknown(types.ObjectType{AttrTypes: models.NotificationRecipientAttrTypes}), + Recipients: types.SetUnknown(types.ObjectType{AttrTypes: models.NotificationRecipientAttrType}), })...) }