Skip to content

Commit 1ed77f5

Browse files
authored
Alerting: Add details field to pagerduty contact point (#912)
* Add details field to pagerduty contact point * Format and regenerate
1 parent ef7fa57 commit 1ed77f5

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

docs/resources/contact_point.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ Optional:
212212

213213
- `class` (String) The class or type of event, for example `ping failure`.
214214
- `component` (String) The component being affected by the event.
215+
- `details` (Map of String) A set of arbitrary key/value pairs that provide further detail about the incident.
215216
- `disable_resolve_message` (Boolean) Whether to disable sending resolve messages. Defaults to `false`.
216217
- `group` (String) The group to which the provided component belongs to.
217218
- `settings` (Map of String, Sensitive) Additional custom properties to attach to the notifier. Defaults to `map[]`.

examples/resources/grafana_contact_point/_acc_receiver_types.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ resource "grafana_contact_point" "receiver_types" {
5656
component = "mysql"
5757
group = "my service"
5858
summary = "message"
59+
details = {
60+
"one" = "two"
61+
"three" = "four"
62+
}
5963
}
6064

6165
pushover {

internal/resources/grafana/resource_alerting_contact_point_notifiers.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,15 @@ func (n pagerDutyNotifier) schema() *schema.Resource {
633633
Optional: true,
634634
Description: "The templated summary message of the event.",
635635
}
636+
r.Schema["details"] = &schema.Schema{
637+
Type: schema.TypeMap,
638+
Optional: true,
639+
Default: nil,
640+
Description: "A set of arbitrary key/value pairs that provide further detail about the incident.",
641+
Elem: &schema.Schema{
642+
Type: schema.TypeString,
643+
},
644+
}
636645
return r
637646
}
638647

@@ -662,6 +671,10 @@ func (n pagerDutyNotifier) pack(p gapi.ContactPoint, data *schema.ResourceData)
662671
notifier["summary"] = v.(string)
663672
delete(p.Settings, "summary")
664673
}
674+
if v, ok := p.Settings["details"]; ok && v != nil {
675+
notifier["details"] = unpackMap(v)
676+
delete(p.Settings, "details")
677+
}
665678

666679
packSecureFields(notifier, getNotifierConfigFromStateWithUID(data, n, p.UID), n.meta().secureFields)
667680

@@ -689,6 +702,9 @@ func (n pagerDutyNotifier) unpack(raw interface{}, name string) gapi.ContactPoin
689702
if v, ok := json["summary"]; ok && v != nil {
690703
settings["summary"] = v.(string)
691704
}
705+
if v, ok := json["details"]; ok && v != nil {
706+
settings["details"] = unpackMap(v)
707+
}
692708
return gapi.ContactPoint{
693709
UID: uid,
694710
Name: name,

internal/resources/grafana/resource_alerting_contact_point_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ func TestAccContactPoint_notifiers(t *testing.T) {
201201
resource.TestCheckResourceAttr("grafana_contact_point.receiver_types", "pagerduty.0.component", "mysql"),
202202
resource.TestCheckResourceAttr("grafana_contact_point.receiver_types", "pagerduty.0.group", "my service"),
203203
resource.TestCheckResourceAttr("grafana_contact_point.receiver_types", "pagerduty.0.summary", "message"),
204+
resource.TestCheckResourceAttr("grafana_contact_point.receiver_types", "pagerduty.0.details.one", "two"),
205+
resource.TestCheckResourceAttr("grafana_contact_point.receiver_types", "pagerduty.0.details.three", "four"),
204206
// pushover
205207
resource.TestCheckResourceAttr("grafana_contact_point.receiver_types", "pushover.#", "1"),
206208
resource.TestCheckResourceAttr("grafana_contact_point.receiver_types", "pushover.0.user_key", "userkey"),

0 commit comments

Comments
 (0)