Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use TypeSet for notifications so that a change in order won't cause an update #311

Merged
merged 2 commits into from
Apr 22, 2024

Conversation

fformica
Copy link
Contributor

We don't want Terraform updates that are just reordering the list; a bug upstream was partly fixed in November but null elements are still popping up when using TypeSet, so adding some safety check to exclude them.

@fformica fformica requested a review from pburrows-ns1 April 19, 2024 14:25
Comment on lines 69 to 71
index := 0
if rawNotifications := d.Get("notifications").(*schema.Set); rawNotifications.Len() > 0 {
ns := make([]*monitor.Notification, rawNotifications.Len())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if you set this to

ns := make([]*monitor.Notification, 0, rawNotifications.Len())

then you don't need to define the index separately from the for loop. Then change the additions to the slice to appends, e.g.

ns[index] = monitor.NewEmailNotification(email.(string))
// change to:
ns = append(ns, monitor.NewEmailNotification(email.(string)))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Going to test it next week

@fformica fformica requested a review from Zach-Johnson April 22, 2024 09:20
@fformica fformica merged commit b05b570 into master Apr 22, 2024
2 checks passed
@fformica fformica deleted the INBOX-2266/use-typeset-for-notifications branch April 22, 2024 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants