Skip to content

Commit

Permalink
Fix opsgenie_integration_action filter block (#250)
Browse files Browse the repository at this point in the history
See: #249

* Add code to check if filter block being added in
  expandOpsgenieIntegrationActions is empty.  If empty set filter
  value to nil instead of the empty filter block.
  • Loading branch information
RobertHorrox authored Oct 17, 2023
1 parent 914e371 commit 8549f09
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion opsgenie/resource_opsgenie_integration_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,14 @@ func expandOpsgenieIntegrationActions(input interface{}) []integration.Integrati
action.CustomPriority = customPriority.(string)
}
filters := expandOpsgenieFilter(inputMap["filter"].([]interface{}))
action.Filter = &filters

// If a filter is not included in the resource, this will still set an empty filter. `omitempty` will
// only leave out the key when marshaling the Json if its value is `nil`
if filters.ConditionMatchType == "" && len(filters.Conditions) == 0 {
action.Filter = nil
} else {
action.Filter = &filters
}

if action.Type == integration.Create {
action.Source = inputMap["source"].(string)
Expand Down

0 comments on commit 8549f09

Please sign in to comment.