diff --git a/CHANGELOG.md b/CHANGELOG.md index 438bef7f..89f90a4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.5.4 (December 10, 2020) +BUGFIX: +* Able to set key in extra-properties field of condition for service incident rule (#204) + + ## 0.5.3 (December 4, 2020) BUGFIX: * GO SDK v2 version synced to support none & escalation in schedule rotations diff --git a/opsgenie/resource_opsgenie_service_incident_rule.go b/opsgenie/resource_opsgenie_service_incident_rule.go index 547c6bd5..f104acd8 100644 --- a/opsgenie/resource_opsgenie_service_incident_rule.go +++ b/opsgenie/resource_opsgenie_service_incident_rule.go @@ -71,6 +71,11 @@ func resourceOpsGenieServiceIncidentRule() *schema.Resource { "contains-value", "greater-than", "less-than", "is-empty", "equals-ignore-whitespace", }, false), }, + "key": { + Type: schema.TypeString, + Optional: true, + Description: "If 'field' is set as 'extra-properties', key could be used for key-value pair", + }, "not": { Type: schema.TypeBool, Optional: true, @@ -298,6 +303,10 @@ func expandOpsGenieServiceIncidentRuleConditions(input []interface{}) []og.Condi condition.Operation = og.ConditionOperation(config["operation"].(string)) condition.IsNot = ¬_value condition.ExpectedValue = config["expected_value"].(string) + key := config["key"].(string) + if key != "" { + condition.Key = config["key"].(string) + } conditions = append(conditions, condition) } @@ -377,6 +386,9 @@ func flattenOpsGenieServiceIncidentRuleConditions(input og.Condition) map[string condition["operation"] = input.Operation condition["not"] = &input.IsNot condition["expected_value"] = input.ExpectedValue + if input.Key != "" { + condition["key"] = input.Key + } return condition } diff --git a/opsgenie/resource_opsgenie_service_incident_rule_test.go b/opsgenie/resource_opsgenie_service_incident_rule_test.go index eafc387e..c3e1b1e8 100644 --- a/opsgenie/resource_opsgenie_service_incident_rule_test.go +++ b/opsgenie/resource_opsgenie_service_incident_rule_test.go @@ -206,6 +206,13 @@ resource "opsgenie_service_incident_rule" "test2" { operation = "contains" expected_value = "expected2" } + conditions { + field = "extra-properties" + not = false + operation = "equals" + expected_value = "expected2" + key = "asd" + } incident_properties { message = "This is a test message" priority = "P3"