Skip to content

Commit

Permalink
Able to set key in extra-properties field of condition for service in…
Browse files Browse the repository at this point in the history
…cident rule (#205)

authored-by: ilteriş tabak <[email protected]>
  • Loading branch information
ilteristabak authored Dec 10, 2020
1 parent d3d5c10 commit 0fce2c7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 12 additions & 0 deletions opsgenie/resource_opsgenie_service_incident_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -298,6 +303,10 @@ func expandOpsGenieServiceIncidentRuleConditions(input []interface{}) []og.Condi
condition.Operation = og.ConditionOperation(config["operation"].(string))
condition.IsNot = &not_value
condition.ExpectedValue = config["expected_value"].(string)
key := config["key"].(string)
if key != "" {
condition.Key = config["key"].(string)
}
conditions = append(conditions, condition)
}

Expand Down Expand Up @@ -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
}
Expand Down
7 changes: 7 additions & 0 deletions opsgenie/resource_opsgenie_service_incident_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 0fce2c7

Please sign in to comment.