From fa950b75436a59b460a6fb11f38b99bc52b8d1df Mon Sep 17 00:00:00 2001 From: akahenry Date: Mon, 28 Apr 2025 16:22:48 -0300 Subject: [PATCH 1/3] Add support to Slack private channels --- ...urce_sysdig_monitor_notification_channel_slack.go | 8 ++++++++ ...ource_sysdig_secure_notification_channel_slack.go | 8 ++++++++ sysdig/internal/client/v2/model.go | 2 ++ ...urce_sysdig_monitor_notification_channel_slack.go | 12 ++++++++++++ ...ource_sysdig_secure_notification_channel_slack.go | 12 ++++++++++++ website/docs/d/monitor_notification_channel_slack.md | 2 ++ website/docs/d/secure_notification_channel_slack.md | 2 ++ website/docs/r/monitor_notification_channel_slack.md | 6 ++++++ website/docs/r/secure_notification_channel_slack.md | 5 +++++ 9 files changed, 57 insertions(+) diff --git a/sysdig/data_source_sysdig_monitor_notification_channel_slack.go b/sysdig/data_source_sysdig_monitor_notification_channel_slack.go index 748c01f02..6c6f083de 100644 --- a/sysdig/data_source_sysdig_monitor_notification_channel_slack.go +++ b/sysdig/data_source_sysdig_monitor_notification_channel_slack.go @@ -29,6 +29,14 @@ func dataSourceSysdigMonitorNotificationChannelSlack() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "is_private_channel": { + Type: schema.TypeBool, + Required: false, + }, + "private_channel_url": { + Type: schema.TypeString, + Required: false, + }, "show_section_runbook_links": { Type: schema.TypeBool, Computed: true, diff --git a/sysdig/data_source_sysdig_secure_notification_channel_slack.go b/sysdig/data_source_sysdig_secure_notification_channel_slack.go index d09f8ed49..d4e52e2ac 100644 --- a/sysdig/data_source_sysdig_secure_notification_channel_slack.go +++ b/sysdig/data_source_sysdig_secure_notification_channel_slack.go @@ -29,6 +29,14 @@ func dataSourceSysdigSecureNotificationChannelSlack() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "is_private_channel": { + Type: schema.TypeBool, + Required: false, + }, + "private_channel_url": { + Type: schema.TypeString, + Required: false, + }, "template_version": { Type: schema.TypeString, Computed: true, diff --git a/sysdig/internal/client/v2/model.go b/sysdig/internal/client/v2/model.go index 1f8f8cb82..4339e49e7 100644 --- a/sysdig/internal/client/v2/model.go +++ b/sysdig/internal/client/v2/model.go @@ -121,6 +121,8 @@ type NotificationChannelOptions struct { RoutingKey string `json:"routingKey,omitempty"` // Type: VictorOps Url string `json:"url,omitempty"` // Type: OpsGenie, Webhook, Slack, google chat, prometheus alert manager, custom webhook, ms teams Channel string `json:"channel,omitempty"` // Type: Slack + IsPrivateChannel *bool `json:"isPrivateChannel,omitEmpty"` // Type: Slack + PrivateChannelUrl string `json:"privateChannelUrl,omitEmpty"` // Type: Slack (if channel is private) Account string `json:"account,omitempty"` // Type: PagerDuty ServiceKey string `json:"serviceKey,omitempty"` // Type: PagerDuty ServiceName string `json:"serviceName,omitempty"` // Type: PagerDuty diff --git a/sysdig/resource_sysdig_monitor_notification_channel_slack.go b/sysdig/resource_sysdig_monitor_notification_channel_slack.go index 21723eb1e..5ab8ffa1a 100644 --- a/sysdig/resource_sysdig_monitor_notification_channel_slack.go +++ b/sysdig/resource_sysdig_monitor_notification_channel_slack.go @@ -40,6 +40,14 @@ func resourceSysdigMonitorNotificationChannelSlack() *schema.Resource { Type: schema.TypeString, Required: true, }, + "is_private_channel": { + Type: schema.TypeBool, + Required: false, + }, + "private_channel_url": { + Type: schema.TypeString, + Required: false, + }, "show_section_runbook_links": { Type: schema.TypeBool, Optional: true, @@ -193,6 +201,8 @@ func monitorNotificationChannelSlackFromResourceData(d *schema.ResourceData, tea nc.Type = NOTIFICATION_CHANNEL_TYPE_SLACK nc.Options.Url = d.Get("url").(string) nc.Options.Channel = d.Get("channel").(string) + nc.Options.IsPrivateChannel = d.Get("is_private_channel").(bool) + nc.Options.PrivateChannelUrl = d.Get("private_channel_url").(string) nc.Options.TemplateConfiguration = []v2.NotificationChannelTemplateConfiguration{ { TemplateKey: "SLACK_MONITOR_ALERT_NOTIFICATION_TEMPLATE_METADATA_v1", @@ -244,6 +254,8 @@ func monitorNotificationChannelSlackToResourceData(nc *v2.NotificationChannel, d _ = d.Set("url", nc.Options.Url) _ = d.Set("channel", nc.Options.Channel) + _ = d.Set("is_private_channel", nc.Options.IsPrivateChannel) + _ = d.Set("private_channel_url", nc.Options.PrivateChannelUrl) runbookLinks := true eventDetails := true diff --git a/sysdig/resource_sysdig_secure_notification_channel_slack.go b/sysdig/resource_sysdig_secure_notification_channel_slack.go index 93132213b..23f84e241 100644 --- a/sysdig/resource_sysdig_secure_notification_channel_slack.go +++ b/sysdig/resource_sysdig_secure_notification_channel_slack.go @@ -41,6 +41,14 @@ func resourceSysdigSecureNotificationChannelSlack() *schema.Resource { Type: schema.TypeString, Required: true, }, + "is_private_channel": { + Type: schema.TypeBool, + Required: false, + }, + "private_channel_url": { + Type: schema.TypeString, + Required: false, + }, "template_version": { Type: schema.TypeString, Optional: true, @@ -163,6 +171,8 @@ func secureNotificationChannelSlackFromResourceData(d *schema.ResourceData, team nc.Type = NOTIFICATION_CHANNEL_TYPE_SLACK nc.Options.Url = d.Get("url").(string) nc.Options.Channel = d.Get("channel").(string) + nc.Options.IsPrivateChannel = d.Get("is_private_channel").(bool) + nc.Options.PrivateChannelUrl = d.Get("private_channel_url").(string) setNotificationChannelSlackTemplateConfig(&nc, d) @@ -208,6 +218,8 @@ func secureNotificationChannelSlackToResourceData(nc *v2.NotificationChannel, d _ = d.Set("url", nc.Options.Url) _ = d.Set("channel", nc.Options.Channel) + _ = d.Set("is_private_channel", nc.Options.IsPrivateChannel) + _ = d.Set("private_channel_url", nc.Options.PrivateChannelUrl) err = getTemplateVersionFromNotificationChannelSlack(nc, d) diff --git a/website/docs/d/monitor_notification_channel_slack.md b/website/docs/d/monitor_notification_channel_slack.md index 69ca404a6..e7718d6a1 100644 --- a/website/docs/d/monitor_notification_channel_slack.md +++ b/website/docs/d/monitor_notification_channel_slack.md @@ -32,6 +32,8 @@ In addition to all arguments above, the following attributes are exported: * `name` - The Notification Channel Name. * `url` - URL of the Slack. * `channel` - Channel name from this Slack. +* `is_private_channel` - Whether the Slack channel is private or not. +* `private_channel_url` - The channel URL, * `show_section_runbook_links` - Whether to include the runbook links section in the Slack messages. * `show_section_event_details` - Whether to include the event details section in the Slack messages. * `show_section_user_defined_content` - Whether to include the user defined section in the Slack messages. diff --git a/website/docs/d/secure_notification_channel_slack.md b/website/docs/d/secure_notification_channel_slack.md index 86d2d4d8a..80445b591 100644 --- a/website/docs/d/secure_notification_channel_slack.md +++ b/website/docs/d/secure_notification_channel_slack.md @@ -32,6 +32,8 @@ In addition to all arguments above, the following attributes are exported: * `name` - The Notification Channel Name. * `url` - URL of the Slack. * `channel` - Channel name from this Slack.* `template_version` - The notification template version to use to create notifications. +* `is_private_channel` - Whether the Slack channel is private or not. +* `private_channel_url` - The channel URL, * `enabled` - Whether the Notification Channel is active or not. * `notify_when_ok` - Whether the Notification Channel sends a notification when the condition is no longer triggered. * `notify_when_resolved` - Whether the Notification Channel sends a notification if it's manually acknowledged by a diff --git a/website/docs/r/monitor_notification_channel_slack.md b/website/docs/r/monitor_notification_channel_slack.md index 95c279fde..25b4c44ab 100644 --- a/website/docs/r/monitor_notification_channel_slack.md +++ b/website/docs/r/monitor_notification_channel_slack.md @@ -20,6 +20,7 @@ resource "sysdig_monitor_notification_channel_slack" "sample-slack" { enabled = true url = "https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX" channel = "#sysdig" + is_private_channel = false notify_when_ok = false notify_when_resolved = false } @@ -47,6 +48,11 @@ resource "sysdig_monitor_notification_channel_slack" "sample-slack" { * `channel` - (Required) Channel name from this Slack. +* `is_private_channel` - (Optional) Whether the Slack channel is private or not. + +* `private_channel_url` - (Optional) The channel URL, if channel is private. + + * `enabled` - (Optional) If false, the channel will not emit notifications. Default is true. * `notify_when_ok` - (Optional) Send a new notification when the alert condition is diff --git a/website/docs/r/secure_notification_channel_slack.md b/website/docs/r/secure_notification_channel_slack.md index ae81b4775..418bda5a3 100644 --- a/website/docs/r/secure_notification_channel_slack.md +++ b/website/docs/r/secure_notification_channel_slack.md @@ -20,6 +20,7 @@ resource "sysdig_secure_notification_channel_slack" "sample-slack" { enabled = true url = "https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX" channel = "#sysdig" + is_private_channel = false notify_when_ok = false notify_when_resolved = false template_version = "v2" @@ -34,6 +35,10 @@ resource "sysdig_secure_notification_channel_slack" "sample-slack" { * `channel` - (Required) Channel name from this Slack. +* `is_private_channel` - (Optional) Whether the Slack channel is private or not. + +* `private_channel_url` - (Optional) The channel URL, if channel is private. + * `enabled` - (Optional) If false, the channel will not emit notifications. Default is true. * `notify_when_ok` - (Optional) Send a new notification when the alert condition is From a1c6a252018e710740968139c90edaf97c3efdc0 Mon Sep 17 00:00:00 2001 From: Diego Bonfigli Date: Tue, 29 Apr 2025 13:15:01 +0200 Subject: [PATCH 2/3] feat(slack notification channel) support slack private channel --- ...sdig_monitor_notification_channel_slack.go | 6 +++--- ...ysdig_secure_notification_channel_slack.go | 6 +++--- sysdig/internal/client/v2/model.go | 4 ++-- ...sdig_monitor_notification_channel_slack.go | 13 +++++++----- ...monitor_notification_channel_slack_test.go | 20 +++++++++++++++++++ ...ysdig_secure_notification_channel_slack.go | 13 +++++++----- ..._secure_notification_channel_slack_test.go | 20 +++++++++++++++++++ .../d/monitor_notification_channel_slack.md | 12 +++++------ .../d/secure_notification_channel_slack.md | 13 ++++++------ .../r/monitor_notification_channel_slack.md | 8 ++++++-- .../r/secure_notification_channel_slack.md | 8 ++++---- 11 files changed, 85 insertions(+), 38 deletions(-) diff --git a/sysdig/data_source_sysdig_monitor_notification_channel_slack.go b/sysdig/data_source_sysdig_monitor_notification_channel_slack.go index 6c6f083de..91f04d5a6 100644 --- a/sysdig/data_source_sysdig_monitor_notification_channel_slack.go +++ b/sysdig/data_source_sysdig_monitor_notification_channel_slack.go @@ -29,13 +29,13 @@ func dataSourceSysdigMonitorNotificationChannelSlack() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "is_private_channel": { + "private_channel": { Type: schema.TypeBool, - Required: false, + Computed: true, }, "private_channel_url": { Type: schema.TypeString, - Required: false, + Computed: true, }, "show_section_runbook_links": { Type: schema.TypeBool, diff --git a/sysdig/data_source_sysdig_secure_notification_channel_slack.go b/sysdig/data_source_sysdig_secure_notification_channel_slack.go index d4e52e2ac..703bcf71d 100644 --- a/sysdig/data_source_sysdig_secure_notification_channel_slack.go +++ b/sysdig/data_source_sysdig_secure_notification_channel_slack.go @@ -29,13 +29,13 @@ func dataSourceSysdigSecureNotificationChannelSlack() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "is_private_channel": { + "private_channel": { Type: schema.TypeBool, - Required: false, + Computed: true, }, "private_channel_url": { Type: schema.TypeString, - Required: false, + Computed: true, }, "template_version": { Type: schema.TypeString, diff --git a/sysdig/internal/client/v2/model.go b/sysdig/internal/client/v2/model.go index 4339e49e7..e5fb9973b 100644 --- a/sysdig/internal/client/v2/model.go +++ b/sysdig/internal/client/v2/model.go @@ -121,8 +121,8 @@ type NotificationChannelOptions struct { RoutingKey string `json:"routingKey,omitempty"` // Type: VictorOps Url string `json:"url,omitempty"` // Type: OpsGenie, Webhook, Slack, google chat, prometheus alert manager, custom webhook, ms teams Channel string `json:"channel,omitempty"` // Type: Slack - IsPrivateChannel *bool `json:"isPrivateChannel,omitEmpty"` // Type: Slack - PrivateChannelUrl string `json:"privateChannelUrl,omitEmpty"` // Type: Slack (if channel is private) + PrivateChannel bool `json:"privateChannel,omitempty"` // Type: Slack + PrivateChannelUrl string `json:"privateChannelUrl,omitempty"` // Type: Slack Account string `json:"account,omitempty"` // Type: PagerDuty ServiceKey string `json:"serviceKey,omitempty"` // Type: PagerDuty ServiceName string `json:"serviceName,omitempty"` // Type: PagerDuty diff --git a/sysdig/resource_sysdig_monitor_notification_channel_slack.go b/sysdig/resource_sysdig_monitor_notification_channel_slack.go index 5ab8ffa1a..87c8e1421 100644 --- a/sysdig/resource_sysdig_monitor_notification_channel_slack.go +++ b/sysdig/resource_sysdig_monitor_notification_channel_slack.go @@ -40,13 +40,16 @@ func resourceSysdigMonitorNotificationChannelSlack() *schema.Resource { Type: schema.TypeString, Required: true, }, - "is_private_channel": { + "private_channel": { Type: schema.TypeBool, - Required: false, + Optional: true, + Default: false, + ForceNew: true, }, "private_channel_url": { Type: schema.TypeString, - Required: false, + Optional: true, + ForceNew: true, }, "show_section_runbook_links": { Type: schema.TypeBool, @@ -201,7 +204,7 @@ func monitorNotificationChannelSlackFromResourceData(d *schema.ResourceData, tea nc.Type = NOTIFICATION_CHANNEL_TYPE_SLACK nc.Options.Url = d.Get("url").(string) nc.Options.Channel = d.Get("channel").(string) - nc.Options.IsPrivateChannel = d.Get("is_private_channel").(bool) + nc.Options.PrivateChannel = d.Get("private_channel").(bool) nc.Options.PrivateChannelUrl = d.Get("private_channel_url").(string) nc.Options.TemplateConfiguration = []v2.NotificationChannelTemplateConfiguration{ { @@ -254,7 +257,7 @@ func monitorNotificationChannelSlackToResourceData(nc *v2.NotificationChannel, d _ = d.Set("url", nc.Options.Url) _ = d.Set("channel", nc.Options.Channel) - _ = d.Set("is_private_channel", nc.Options.IsPrivateChannel) + _ = d.Set("private_channel", nc.Options.PrivateChannel) _ = d.Set("private_channel_url", nc.Options.PrivateChannelUrl) runbookLinks := true diff --git a/sysdig/resource_sysdig_monitor_notification_channel_slack_test.go b/sysdig/resource_sysdig_monitor_notification_channel_slack_test.go index 527f2120e..14ec6fa1a 100644 --- a/sysdig/resource_sysdig_monitor_notification_channel_slack_test.go +++ b/sysdig/resource_sysdig_monitor_notification_channel_slack_test.go @@ -43,6 +43,14 @@ func TestAccMonitorNotificationChannelSlack(t *testing.T) { ImportState: true, ImportStateVerify: true, }, + { + Config: monitorNotificationChannelSlackSharedWithPrivateChannel(rText()), + }, + { + ResourceName: "sysdig_monitor_notification_channel_slack.sample-slack-private", + ImportState: true, + ImportStateVerify: true, + }, }, }) } @@ -90,3 +98,15 @@ resource "sysdig_monitor_notification_channel_slack" "sample-slack" { show_section_capturing_information = false }`, name) } + +func monitorNotificationChannelSlackSharedWithPrivateChannel(name string) string { + return fmt.Sprintf(` +resource "sysdig_monitor_notification_channel_slack" "sample-slack-private" { + name = "Example Channel %s - Slack" + enabled = true + url = "https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX" + channel = "#sysdig" + private_channel = true + private_channel_url = "https://app.slack.com/client/XXXXXXXX/XXXXXXXX" +}`, name) +} diff --git a/sysdig/resource_sysdig_secure_notification_channel_slack.go b/sysdig/resource_sysdig_secure_notification_channel_slack.go index 23f84e241..3aa2f2f56 100644 --- a/sysdig/resource_sysdig_secure_notification_channel_slack.go +++ b/sysdig/resource_sysdig_secure_notification_channel_slack.go @@ -41,13 +41,16 @@ func resourceSysdigSecureNotificationChannelSlack() *schema.Resource { Type: schema.TypeString, Required: true, }, - "is_private_channel": { + "private_channel": { Type: schema.TypeBool, - Required: false, + Optional: true, + Default: false, + ForceNew: true, }, "private_channel_url": { Type: schema.TypeString, - Required: false, + Optional: true, + ForceNew: true, }, "template_version": { Type: schema.TypeString, @@ -171,7 +174,7 @@ func secureNotificationChannelSlackFromResourceData(d *schema.ResourceData, team nc.Type = NOTIFICATION_CHANNEL_TYPE_SLACK nc.Options.Url = d.Get("url").(string) nc.Options.Channel = d.Get("channel").(string) - nc.Options.IsPrivateChannel = d.Get("is_private_channel").(bool) + nc.Options.PrivateChannel = d.Get("private_channel").(bool) nc.Options.PrivateChannelUrl = d.Get("private_channel_url").(string) setNotificationChannelSlackTemplateConfig(&nc, d) @@ -218,7 +221,7 @@ func secureNotificationChannelSlackToResourceData(nc *v2.NotificationChannel, d _ = d.Set("url", nc.Options.Url) _ = d.Set("channel", nc.Options.Channel) - _ = d.Set("is_private_channel", nc.Options.IsPrivateChannel) + _ = d.Set("private_channel", nc.Options.PrivateChannel) _ = d.Set("private_channel_url", nc.Options.PrivateChannelUrl) err = getTemplateVersionFromNotificationChannelSlack(nc, d) diff --git a/sysdig/resource_sysdig_secure_notification_channel_slack_test.go b/sysdig/resource_sysdig_secure_notification_channel_slack_test.go index 8e52979fa..986ebbab6 100644 --- a/sysdig/resource_sysdig_secure_notification_channel_slack_test.go +++ b/sysdig/resource_sysdig_secure_notification_channel_slack_test.go @@ -48,6 +48,14 @@ func TestAccSecureNotificationChannelSlack(t *testing.T) { ImportState: true, ImportStateVerify: true, }, + { + Config: secureNotificationChannelSlackSharedWithPrivateChannel(rText()), + }, + { + ResourceName: "sysdig_secure_notification_channel_slack.sample-slack-private", + ImportState: true, + ImportStateVerify: true, + }, }, }) } @@ -89,3 +97,15 @@ resource "sysdig_secure_notification_channel_slack" "sample-slack" { template_version = "%s" }`, name, version) } + +func secureNotificationChannelSlackSharedWithPrivateChannel(name string) string { + return fmt.Sprintf(` +resource "sysdig_secure_notification_channel_slack" "sample-slack-private" { + name = "Example Channel %s - Slack" + enabled = true + url = "https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX" + channel = "#sysdig" + private_channel = true + private_channel_url = "https://app.slack.com/client/XXXXXXXX/XXXXXXXX" +}`, name) +} diff --git a/website/docs/d/monitor_notification_channel_slack.md b/website/docs/d/monitor_notification_channel_slack.md index e7718d6a1..3e6ce1885 100644 --- a/website/docs/d/monitor_notification_channel_slack.md +++ b/website/docs/d/monitor_notification_channel_slack.md @@ -29,11 +29,10 @@ data "sysdig_monitor_notification_channel_slack" "nc_slack" { In addition to all arguments above, the following attributes are exported: * `id` - The Notification Channel ID. -* `name` - The Notification Channel Name. -* `url` - URL of the Slack. -* `channel` - Channel name from this Slack. -* `is_private_channel` - Whether the Slack channel is private or not. -* `private_channel_url` - The channel URL, +* `url` - URL of the Slack webhook. +* `channel` - Name of the Slack channel. +* `private_channel` - Whether the Slack Channel has been marked as private or not. +* `private_channel_url` - The channel URL, i.e. the link that is referencing the channel (not to be confused with the webhook url), if the channel is private. * `show_section_runbook_links` - Whether to include the runbook links section in the Slack messages. * `show_section_event_details` - Whether to include the event details section in the Slack messages. * `show_section_user_defined_content` - Whether to include the user defined section in the Slack messages. @@ -43,7 +42,6 @@ In addition to all arguments above, the following attributes are exported: * `show_section_capturing_information` - Whether to include the capturing information section in the Slack messages. * `enabled` - Whether the Notification Channel is active or not. * `notify_when_ok` - Whether the Notification Channel sends a notification when the condition is no longer triggered. -* `notify_when_resolved` - Whether the Notification Channel sends a notification if it's manually acknowledged by a - user. +* `notify_when_resolved` - Whether the Notification Channel sends a notification if it's manually acknowledged by a user. * `version` - The version of the Notification Channel. * `send_test_notification` - Whether the Notification Channel has enabled the test notification. diff --git a/website/docs/d/secure_notification_channel_slack.md b/website/docs/d/secure_notification_channel_slack.md index 80445b591..6c7ad7662 100644 --- a/website/docs/d/secure_notification_channel_slack.md +++ b/website/docs/d/secure_notification_channel_slack.md @@ -29,14 +29,13 @@ data "sysdig_secure_notification_channel_slack" "nc_slack" { In addition to all arguments above, the following attributes are exported: * `id` - The Notification Channel ID. -* `name` - The Notification Channel Name. -* `url` - URL of the Slack. -* `channel` - Channel name from this Slack.* `template_version` - The notification template version to use to create notifications. -* `is_private_channel` - Whether the Slack channel is private or not. -* `private_channel_url` - The channel URL, +* `url` - URL of the Slack webhook. +* `channel` - Name of the Slack channel. +* `private_channel` - Whether the Slack Channel has been marked as private or not. +* `private_channel_url` - The channel URL, i.e. the link that is referencing the channel (not to be confused with the webhook url), if the channel is private. +* `template_version` - The notification template version to use to create notifications. * `enabled` - Whether the Notification Channel is active or not. * `notify_when_ok` - Whether the Notification Channel sends a notification when the condition is no longer triggered. -* `notify_when_resolved` - Whether the Notification Channel sends a notification if it's manually acknowledged by a - user. +* `notify_when_resolved` - Whether the Notification Channel sends a notification if it's manually acknowledged by a user. * `version` - The version of the Notification Channel. * `send_test_notification` - Whether the Notification Channel has enabled the test notification. diff --git a/website/docs/r/monitor_notification_channel_slack.md b/website/docs/r/monitor_notification_channel_slack.md index 25b4c44ab..114ed84a9 100644 --- a/website/docs/r/monitor_notification_channel_slack.md +++ b/website/docs/r/monitor_notification_channel_slack.md @@ -30,7 +30,7 @@ resource "sysdig_monitor_notification_channel_slack" "sample-slack" { * `name` - (Required) The name of the Notification Channel. Must be unique. -* `url` - (Required) URL of the Slack. +* `url` - (Required) URL of the Slack webhook. * `show_section_runbook_links` - (Optional) Whether to include the runbook links section in the Slack messages. Default: true. @@ -46,7 +46,11 @@ resource "sysdig_monitor_notification_channel_slack" "sample-slack" { * `show_section_capturing_information` - (Optional) Whether to include the capturing information section in the Slack messages. Default: true. -* `channel` - (Required) Channel name from this Slack. +* `channel` - (Required) Name of the Slack channel. **NOTE**: If the channel is private this field cannot be changed after creation. + +* `private_channel` - (Optional, Forces new resource) If true, the Slack channel name will be visible only to the user that created this notification channel. Default: false. + +* `private_channel_url` - (Optional, Forces new resource) The channel URL, i.e. the link that is referencing the channel (not to be confused with the webhook url). Can be set only if the channel is private. * `is_private_channel` - (Optional) Whether the Slack channel is private or not. diff --git a/website/docs/r/secure_notification_channel_slack.md b/website/docs/r/secure_notification_channel_slack.md index 418bda5a3..27ad2eb43 100644 --- a/website/docs/r/secure_notification_channel_slack.md +++ b/website/docs/r/secure_notification_channel_slack.md @@ -31,13 +31,13 @@ resource "sysdig_secure_notification_channel_slack" "sample-slack" { * `name` - (Required) The name of the Notification Channel. Must be unique. -* `url` - (Required) URL of the Slack. +* `url` - (Required) URL of the Slack webhook. -* `channel` - (Required) Channel name from this Slack. +* `channel` - (Required) Name of the Slack channel. **NOTE**: If the channel is private this field cannot be changed after creation. -* `is_private_channel` - (Optional) Whether the Slack channel is private or not. +* `private_channel` - (Optional, Forces new resource) If true, the Slack channel name will be visible only to the user that created this notification channel. Default: false. -* `private_channel_url` - (Optional) The channel URL, if channel is private. +* `private_channel_url` - (Optional, Forces new resource) The channel URL, i.e. the link that is referencing the channel (not to be confused with the webhook url). Can be set only if the channel is private. * `enabled` - (Optional) If false, the channel will not emit notifications. Default is true. From 8f0daa7a80428423e2588dfd9ddf96097685ac1e Mon Sep 17 00:00:00 2001 From: Diego Bonfigli Date: Tue, 29 Apr 2025 16:45:56 +0200 Subject: [PATCH 3/3] address comments --- ...ata_source_sysdig_monitor_notification_channel_slack.go | 2 +- ...data_source_sysdig_secure_notification_channel_slack.go | 2 +- .../resource_sysdig_monitor_notification_channel_slack.go | 6 +++--- ...ource_sysdig_monitor_notification_channel_slack_test.go | 2 +- .../resource_sysdig_secure_notification_channel_slack.go | 6 +++--- ...source_sysdig_secure_notification_channel_slack_test.go | 2 +- website/docs/d/monitor_notification_channel_slack.md | 2 +- website/docs/d/secure_notification_channel_slack.md | 2 +- website/docs/r/monitor_notification_channel_slack.md | 7 +------ website/docs/r/secure_notification_channel_slack.md | 2 +- 10 files changed, 14 insertions(+), 19 deletions(-) diff --git a/sysdig/data_source_sysdig_monitor_notification_channel_slack.go b/sysdig/data_source_sysdig_monitor_notification_channel_slack.go index 91f04d5a6..321d71760 100644 --- a/sysdig/data_source_sysdig_monitor_notification_channel_slack.go +++ b/sysdig/data_source_sysdig_monitor_notification_channel_slack.go @@ -29,7 +29,7 @@ func dataSourceSysdigMonitorNotificationChannelSlack() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "private_channel": { + "is_private_channel": { Type: schema.TypeBool, Computed: true, }, diff --git a/sysdig/data_source_sysdig_secure_notification_channel_slack.go b/sysdig/data_source_sysdig_secure_notification_channel_slack.go index 703bcf71d..48694398d 100644 --- a/sysdig/data_source_sysdig_secure_notification_channel_slack.go +++ b/sysdig/data_source_sysdig_secure_notification_channel_slack.go @@ -29,7 +29,7 @@ func dataSourceSysdigSecureNotificationChannelSlack() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "private_channel": { + "is_private_channel": { Type: schema.TypeBool, Computed: true, }, diff --git a/sysdig/resource_sysdig_monitor_notification_channel_slack.go b/sysdig/resource_sysdig_monitor_notification_channel_slack.go index 87c8e1421..0b2fbb9c3 100644 --- a/sysdig/resource_sysdig_monitor_notification_channel_slack.go +++ b/sysdig/resource_sysdig_monitor_notification_channel_slack.go @@ -40,7 +40,7 @@ func resourceSysdigMonitorNotificationChannelSlack() *schema.Resource { Type: schema.TypeString, Required: true, }, - "private_channel": { + "is_private_channel": { Type: schema.TypeBool, Optional: true, Default: false, @@ -204,7 +204,7 @@ func monitorNotificationChannelSlackFromResourceData(d *schema.ResourceData, tea nc.Type = NOTIFICATION_CHANNEL_TYPE_SLACK nc.Options.Url = d.Get("url").(string) nc.Options.Channel = d.Get("channel").(string) - nc.Options.PrivateChannel = d.Get("private_channel").(bool) + nc.Options.PrivateChannel = d.Get("is_private_channel").(bool) nc.Options.PrivateChannelUrl = d.Get("private_channel_url").(string) nc.Options.TemplateConfiguration = []v2.NotificationChannelTemplateConfiguration{ { @@ -257,7 +257,7 @@ func monitorNotificationChannelSlackToResourceData(nc *v2.NotificationChannel, d _ = d.Set("url", nc.Options.Url) _ = d.Set("channel", nc.Options.Channel) - _ = d.Set("private_channel", nc.Options.PrivateChannel) + _ = d.Set("is_private_channel", nc.Options.PrivateChannel) _ = d.Set("private_channel_url", nc.Options.PrivateChannelUrl) runbookLinks := true diff --git a/sysdig/resource_sysdig_monitor_notification_channel_slack_test.go b/sysdig/resource_sysdig_monitor_notification_channel_slack_test.go index 14ec6fa1a..75b1b0148 100644 --- a/sysdig/resource_sysdig_monitor_notification_channel_slack_test.go +++ b/sysdig/resource_sysdig_monitor_notification_channel_slack_test.go @@ -106,7 +106,7 @@ resource "sysdig_monitor_notification_channel_slack" "sample-slack-private" { enabled = true url = "https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX" channel = "#sysdig" - private_channel = true + is_private_channel = true private_channel_url = "https://app.slack.com/client/XXXXXXXX/XXXXXXXX" }`, name) } diff --git a/sysdig/resource_sysdig_secure_notification_channel_slack.go b/sysdig/resource_sysdig_secure_notification_channel_slack.go index 3aa2f2f56..23b8cb6b9 100644 --- a/sysdig/resource_sysdig_secure_notification_channel_slack.go +++ b/sysdig/resource_sysdig_secure_notification_channel_slack.go @@ -41,7 +41,7 @@ func resourceSysdigSecureNotificationChannelSlack() *schema.Resource { Type: schema.TypeString, Required: true, }, - "private_channel": { + "is_private_channel": { Type: schema.TypeBool, Optional: true, Default: false, @@ -174,7 +174,7 @@ func secureNotificationChannelSlackFromResourceData(d *schema.ResourceData, team nc.Type = NOTIFICATION_CHANNEL_TYPE_SLACK nc.Options.Url = d.Get("url").(string) nc.Options.Channel = d.Get("channel").(string) - nc.Options.PrivateChannel = d.Get("private_channel").(bool) + nc.Options.PrivateChannel = d.Get("is_private_channel").(bool) nc.Options.PrivateChannelUrl = d.Get("private_channel_url").(string) setNotificationChannelSlackTemplateConfig(&nc, d) @@ -221,7 +221,7 @@ func secureNotificationChannelSlackToResourceData(nc *v2.NotificationChannel, d _ = d.Set("url", nc.Options.Url) _ = d.Set("channel", nc.Options.Channel) - _ = d.Set("private_channel", nc.Options.PrivateChannel) + _ = d.Set("is_private_channel", nc.Options.PrivateChannel) _ = d.Set("private_channel_url", nc.Options.PrivateChannelUrl) err = getTemplateVersionFromNotificationChannelSlack(nc, d) diff --git a/sysdig/resource_sysdig_secure_notification_channel_slack_test.go b/sysdig/resource_sysdig_secure_notification_channel_slack_test.go index 986ebbab6..d4044c462 100644 --- a/sysdig/resource_sysdig_secure_notification_channel_slack_test.go +++ b/sysdig/resource_sysdig_secure_notification_channel_slack_test.go @@ -105,7 +105,7 @@ resource "sysdig_secure_notification_channel_slack" "sample-slack-private" { enabled = true url = "https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX" channel = "#sysdig" - private_channel = true + is_private_channel = true private_channel_url = "https://app.slack.com/client/XXXXXXXX/XXXXXXXX" }`, name) } diff --git a/website/docs/d/monitor_notification_channel_slack.md b/website/docs/d/monitor_notification_channel_slack.md index 3e6ce1885..9fb7f3116 100644 --- a/website/docs/d/monitor_notification_channel_slack.md +++ b/website/docs/d/monitor_notification_channel_slack.md @@ -31,7 +31,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The Notification Channel ID. * `url` - URL of the Slack webhook. * `channel` - Name of the Slack channel. -* `private_channel` - Whether the Slack Channel has been marked as private or not. +* `is_private_channel` - Whether the Slack Channel has been marked as private or not. * `private_channel_url` - The channel URL, i.e. the link that is referencing the channel (not to be confused with the webhook url), if the channel is private. * `show_section_runbook_links` - Whether to include the runbook links section in the Slack messages. * `show_section_event_details` - Whether to include the event details section in the Slack messages. diff --git a/website/docs/d/secure_notification_channel_slack.md b/website/docs/d/secure_notification_channel_slack.md index 6c7ad7662..1885f46ac 100644 --- a/website/docs/d/secure_notification_channel_slack.md +++ b/website/docs/d/secure_notification_channel_slack.md @@ -31,7 +31,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The Notification Channel ID. * `url` - URL of the Slack webhook. * `channel` - Name of the Slack channel. -* `private_channel` - Whether the Slack Channel has been marked as private or not. +* `is_private_channel` - Whether the Slack Channel has been marked as private or not. * `private_channel_url` - The channel URL, i.e. the link that is referencing the channel (not to be confused with the webhook url), if the channel is private. * `template_version` - The notification template version to use to create notifications. * `enabled` - Whether the Notification Channel is active or not. diff --git a/website/docs/r/monitor_notification_channel_slack.md b/website/docs/r/monitor_notification_channel_slack.md index 114ed84a9..0c569eb9f 100644 --- a/website/docs/r/monitor_notification_channel_slack.md +++ b/website/docs/r/monitor_notification_channel_slack.md @@ -48,15 +48,10 @@ resource "sysdig_monitor_notification_channel_slack" "sample-slack" { * `channel` - (Required) Name of the Slack channel. **NOTE**: If the channel is private this field cannot be changed after creation. -* `private_channel` - (Optional, Forces new resource) If true, the Slack channel name will be visible only to the user that created this notification channel. Default: false. +* `is_private_channel` - (Optional, Forces new resource) If true, the Slack channel name will be visible only to the user that created this notification channel. Default: false. * `private_channel_url` - (Optional, Forces new resource) The channel URL, i.e. the link that is referencing the channel (not to be confused with the webhook url). Can be set only if the channel is private. -* `is_private_channel` - (Optional) Whether the Slack channel is private or not. - -* `private_channel_url` - (Optional) The channel URL, if channel is private. - - * `enabled` - (Optional) If false, the channel will not emit notifications. Default is true. * `notify_when_ok` - (Optional) Send a new notification when the alert condition is diff --git a/website/docs/r/secure_notification_channel_slack.md b/website/docs/r/secure_notification_channel_slack.md index 27ad2eb43..ee726ee5d 100644 --- a/website/docs/r/secure_notification_channel_slack.md +++ b/website/docs/r/secure_notification_channel_slack.md @@ -35,7 +35,7 @@ resource "sysdig_secure_notification_channel_slack" "sample-slack" { * `channel` - (Required) Name of the Slack channel. **NOTE**: If the channel is private this field cannot be changed after creation. -* `private_channel` - (Optional, Forces new resource) If true, the Slack channel name will be visible only to the user that created this notification channel. Default: false. +* `is_private_channel` - (Optional, Forces new resource) If true, the Slack channel name will be visible only to the user that created this notification channel. Default: false. * `private_channel_url` - (Optional, Forces new resource) The channel URL, i.e. the link that is referencing the channel (not to be confused with the webhook url). Can be set only if the channel is private.