Skip to content

Commit c0765a1

Browse files
committed
Add support to Slack private channels
1 parent 8f2a0a4 commit c0765a1

9 files changed

+57
-0
lines changed

sysdig/data_source_sysdig_monitor_notification_channel_slack.go

+8
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ func dataSourceSysdigMonitorNotificationChannelSlack() *schema.Resource {
2929
Type: schema.TypeString,
3030
Computed: true,
3131
},
32+
"is_private_channel": {
33+
Type: schema.TypeBool,
34+
Required: false,
35+
},
36+
"private_channel_url": {
37+
Type: schema.TypeString,
38+
Required: false,
39+
},
3240
"show_section_runbook_links": {
3341
Type: schema.TypeBool,
3442
Computed: true,

sysdig/data_source_sysdig_secure_notification_channel_slack.go

+8
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ func dataSourceSysdigSecureNotificationChannelSlack() *schema.Resource {
2929
Type: schema.TypeString,
3030
Computed: true,
3131
},
32+
"is_private_channel": {
33+
Type: schema.TypeBool,
34+
Required: false,
35+
},
36+
"private_channel_url": {
37+
Type: schema.TypeString,
38+
Required: false,
39+
},
3240
"template_version": {
3341
Type: schema.TypeString,
3442
Computed: true,

sysdig/internal/client/v2/model.go

+2
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ type NotificationChannelOptions struct {
121121
RoutingKey string `json:"routingKey,omitempty"` // Type: VictorOps
122122
Url string `json:"url,omitempty"` // Type: OpsGenie, Webhook, Slack, google chat, prometheus alert manager, custom webhook, ms teams
123123
Channel string `json:"channel,omitempty"` // Type: Slack
124+
IsPrivateChannel *bool `json:"isPrivateChannel,omitEmpty"` // Type: Slack
125+
PrivateChannelUrl string `json:"privateChannelUrl,omitEmpty"` // Type: Slack (if channel is private)
124126
Account string `json:"account,omitempty"` // Type: PagerDuty
125127
ServiceKey string `json:"serviceKey,omitempty"` // Type: PagerDuty
126128
ServiceName string `json:"serviceName,omitempty"` // Type: PagerDuty

sysdig/resource_sysdig_monitor_notification_channel_slack.go

+12
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ func resourceSysdigMonitorNotificationChannelSlack() *schema.Resource {
4040
Type: schema.TypeString,
4141
Required: true,
4242
},
43+
"is_private_channel": {
44+
Type: schema.TypeBool,
45+
Required: false,
46+
},
47+
"private_channel_url": {
48+
Type: schema.TypeString,
49+
Required: false,
50+
},
4351
"show_section_runbook_links": {
4452
Type: schema.TypeBool,
4553
Optional: true,
@@ -193,6 +201,8 @@ func monitorNotificationChannelSlackFromResourceData(d *schema.ResourceData, tea
193201
nc.Type = NOTIFICATION_CHANNEL_TYPE_SLACK
194202
nc.Options.Url = d.Get("url").(string)
195203
nc.Options.Channel = d.Get("channel").(string)
204+
nc.Options.IsPrivateChannel = d.Get("is_private_channel").(bool)
205+
nc.Options.PrivateChannelUrl = d.Get("private_channel_url").(string)
196206
nc.Options.TemplateConfiguration = []v2.NotificationChannelTemplateConfiguration{
197207
{
198208
TemplateKey: "SLACK_MONITOR_ALERT_NOTIFICATION_TEMPLATE_METADATA_v1",
@@ -244,6 +254,8 @@ func monitorNotificationChannelSlackToResourceData(nc *v2.NotificationChannel, d
244254

245255
_ = d.Set("url", nc.Options.Url)
246256
_ = d.Set("channel", nc.Options.Channel)
257+
_ = d.Set("is_private_channel", nc.Options.IsPrivateChannel)
258+
_ = d.Set("private_channel_url", nc.Options.PrivateChannelUrl)
247259

248260
runbookLinks := true
249261
eventDetails := true

sysdig/resource_sysdig_secure_notification_channel_slack.go

+12
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ func resourceSysdigSecureNotificationChannelSlack() *schema.Resource {
4141
Type: schema.TypeString,
4242
Required: true,
4343
},
44+
"is_private_channel": {
45+
Type: schema.TypeBool,
46+
Required: false,
47+
},
48+
"private_channel_url": {
49+
Type: schema.TypeString,
50+
Required: false,
51+
},
4452
"template_version": {
4553
Type: schema.TypeString,
4654
Optional: true,
@@ -163,6 +171,8 @@ func secureNotificationChannelSlackFromResourceData(d *schema.ResourceData, team
163171
nc.Type = NOTIFICATION_CHANNEL_TYPE_SLACK
164172
nc.Options.Url = d.Get("url").(string)
165173
nc.Options.Channel = d.Get("channel").(string)
174+
nc.Options.IsPrivateChannel = d.Get("is_private_channel").(bool)
175+
nc.Options.PrivateChannelUrl = d.Get("private_channel_url").(string)
166176

167177
setNotificationChannelSlackTemplateConfig(&nc, d)
168178

@@ -208,6 +218,8 @@ func secureNotificationChannelSlackToResourceData(nc *v2.NotificationChannel, d
208218

209219
_ = d.Set("url", nc.Options.Url)
210220
_ = d.Set("channel", nc.Options.Channel)
221+
_ = d.Set("is_private_channel", nc.Options.IsPrivateChannel)
222+
_ = d.Set("private_channel_url", nc.Options.PrivateChannelUrl)
211223

212224
err = getTemplateVersionFromNotificationChannelSlack(nc, d)
213225

website/docs/d/monitor_notification_channel_slack.md

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ In addition to all arguments above, the following attributes are exported:
3232
* `name` - The Notification Channel Name.
3333
* `url` - URL of the Slack.
3434
* `channel` - Channel name from this Slack.
35+
* `is_private_channel` - Whether the Slack channel is private or not.
36+
* `private_channel_url` - The channel URL,
3537
* `show_section_runbook_links` - Whether to include the runbook links section in the Slack messages.
3638
* `show_section_event_details` - Whether to include the event details section in the Slack messages.
3739
* `show_section_user_defined_content` - Whether to include the user defined section in the Slack messages.

website/docs/d/secure_notification_channel_slack.md

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ In addition to all arguments above, the following attributes are exported:
3232
* `name` - The Notification Channel Name.
3333
* `url` - URL of the Slack.
3434
* `channel` - Channel name from this Slack.* `template_version` - The notification template version to use to create notifications.
35+
* `is_private_channel` - Whether the Slack channel is private or not.
36+
* `private_channel_url` - The channel URL,
3537
* `enabled` - Whether the Notification Channel is active or not.
3638
* `notify_when_ok` - Whether the Notification Channel sends a notification when the condition is no longer triggered.
3739
* `notify_when_resolved` - Whether the Notification Channel sends a notification if it's manually acknowledged by a

website/docs/r/monitor_notification_channel_slack.md

+6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ resource "sysdig_monitor_notification_channel_slack" "sample-slack" {
2020
enabled = true
2121
url = "https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX"
2222
channel = "#sysdig"
23+
is_private_channel = false
2324
notify_when_ok = false
2425
notify_when_resolved = false
2526
}
@@ -47,6 +48,11 @@ resource "sysdig_monitor_notification_channel_slack" "sample-slack" {
4748

4849
* `channel` - (Required) Channel name from this Slack.
4950

51+
* `is_private_channel` - (Optional) Whether the Slack channel is private or not.
52+
53+
* `private_channel_url` - (Optional) The channel URL, if channel is private.
54+
55+
5056
* `enabled` - (Optional) If false, the channel will not emit notifications. Default is true.
5157

5258
* `notify_when_ok` - (Optional) Send a new notification when the alert condition is

website/docs/r/secure_notification_channel_slack.md

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ resource "sysdig_secure_notification_channel_slack" "sample-slack" {
2020
enabled = true
2121
url = "https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX"
2222
channel = "#sysdig"
23+
is_private_channel = false
2324
notify_when_ok = false
2425
notify_when_resolved = false
2526
template_version = "v2"
@@ -34,6 +35,10 @@ resource "sysdig_secure_notification_channel_slack" "sample-slack" {
3435

3536
* `channel` - (Required) Channel name from this Slack.
3637

38+
* `is_private_channel` - (Optional) Whether the Slack channel is private or not.
39+
40+
* `private_channel_url` - (Optional) The channel URL, if channel is private.
41+
3742
* `enabled` - (Optional) If false, the channel will not emit notifications. Default is true.
3843

3944
* `notify_when_ok` - (Optional) Send a new notification when the alert condition is

0 commit comments

Comments
 (0)