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

feat(alert_muting_rule): Add action_on_muting_rule_window_ended attribute in newrelic_alert_muting_rule Terraform Resource #2783

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newrelic/resource_newrelic_alert_muting_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ func resourceNewRelicAlertMutingRule() *schema.Resource {
"action_on_muting_rule_window_ended": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "The action when the muting rule window is ended or disabled.",
ValidateFunc: validation.StringInSlice(
[]string{
Expand Down
5 changes: 1 addition & 4 deletions newrelic/structures_newrelic_alert_muting_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,7 @@ func flattenMutingRule(mutingRule *alerts.MutingRule, d *schema.ResourceData) er
configuredCondition := x.([]interface{})

_ = d.Set("enabled", mutingRule.Enabled)

if _, ok := d.GetOk("action_on_muting_rule_window_ended"); ok {
_ = d.Set("action_on_muting_rule_window_ended", mutingRule.ActionOnMutingRuleWindowEnded)
}
_ = d.Set("action_on_muting_rule_window_ended", mutingRule.ActionOnMutingRuleWindowEnded)
Copy link
Member

Choose a reason for hiding this comment

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

@vagrawal-newrelic @Aashirwadjain this is nice, but the attribute doesn't need to be Computed for this to happen since the read function is anyway being called in create; you can just have this condition.

The only thing to double check is that since this is coming from an enum in client go, if there is no value returned from the API for this attribute, is an empty string effectively being sent to Terraform from the Go Client via this attribute and saved as "" to the state; if this is the case, we should be okay; and if not, a condition might need to be added accordingly. I don't think this should be the case though.

Please test these changes (for all cases we ideated previously) and let me know if you discover something unusual


err := d.Set("condition", flattenMutingRuleConditionGroup(mutingRule.Condition, configuredCondition))
if err != nil {
Expand Down
Loading