Skip to content

Commit 397e224

Browse files
authored
Alerting: Adding color option to slack contact point (#2010)
* Adding color option to slack contact point * Generating docs
1 parent 70e344b commit 397e224

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

docs/resources/contact_point.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ Read-Only:
358358

359359
Optional:
360360

361+
- `color` (String) Templated color of the slack message.
361362
- `disable_resolve_message` (Boolean) Whether to disable sending resolve messages. Defaults to `false`.
362363
- `endpoint_url` (String) Use this to override the Slack API endpoint URL to send requests to.
363364
- `icon_emoji` (String) The name of a Slack workspace emoji to use as the bot icon.

examples/resources/grafana_contact_point/_acc_receiver_types.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ resource "grafana_contact_point" "receiver_types" {
118118
mention_channel = "here"
119119
mention_users = "user"
120120
mention_groups = "group"
121+
color = "color"
121122
}
122123

123124
teams {

internal/resources/grafana/resource_alerting_contact_point_notifiers.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,6 +1514,11 @@ func (s slackNotifier) schema() *schema.Resource {
15141514
Optional: true,
15151515
Description: "Comma-separated list of groups to mention in the message.",
15161516
}
1517+
r.Schema["color"] = &schema.Schema{
1518+
Type: schema.TypeString,
1519+
Optional: true,
1520+
Description: "Templated color of the slack message.",
1521+
}
15171522
return r
15181523
}
15191524

@@ -1533,6 +1538,7 @@ func (s slackNotifier) pack(p *models.EmbeddedContactPoint, data *schema.Resourc
15331538
packNotifierStringField(&settings, &notifier, "mentionChannel", "mention_channel")
15341539
packNotifierStringField(&settings, &notifier, "mentionUsers", "mention_users")
15351540
packNotifierStringField(&settings, &notifier, "mentionGroups", "mention_groups")
1541+
packNotifierStringField(&settings, &notifier, "color", "color")
15361542

15371543
packSecureFields(notifier, getNotifierConfigFromStateWithUID(data, s, p.UID), s.meta().secureFields)
15381544

@@ -1557,6 +1563,7 @@ func (s slackNotifier) unpack(raw interface{}, name string) *models.EmbeddedCont
15571563
unpackNotifierStringField(&json, &settings, "mention_channel", "mentionChannel")
15581564
unpackNotifierStringField(&json, &settings, "mention_users", "mentionUsers")
15591565
unpackNotifierStringField(&json, &settings, "mention_groups", "mentionGroups")
1566+
unpackNotifierStringField(&json, &settings, "color", "color")
15601567

15611568
return &models.EmbeddedContactPoint{
15621569
UID: uid,

internal/resources/grafana/resource_alerting_contact_point_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ func TestAccContactPoint_notifiers(t *testing.T) {
261261
resource.TestCheckResourceAttr("grafana_contact_point.receiver_types", "slack.0.mention_channel", "here"),
262262
resource.TestCheckResourceAttr("grafana_contact_point.receiver_types", "slack.0.mention_users", "user"),
263263
resource.TestCheckResourceAttr("grafana_contact_point.receiver_types", "slack.0.mention_groups", "group"),
264+
resource.TestCheckResourceAttr("grafana_contact_point.receiver_types", "slack.0.color", "color"),
264265
// teams
265266
resource.TestCheckResourceAttr("grafana_contact_point.receiver_types", "teams.#", "1"),
266267
resource.TestCheckResourceAttr("grafana_contact_point.receiver_types", "teams.0.url", "http://teams-webhook"),

0 commit comments

Comments
 (0)