From 20ce9eb2d253c8195a1326a13dccf49407231ed1 Mon Sep 17 00:00:00 2001 From: Danil Valov Date: Wed, 24 Apr 2024 00:38:05 +0300 Subject: [PATCH] CodeBuild Events support - add option to Settings to enable/disable CodeBuild support --- plugin.json | 8 ++++++++ server/configuration.go | 7 ++++--- server/plugin.go | 6 +++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/plugin.json b/plugin.json index 16bf974..ee81356 100644 --- a/plugin.json +++ b/plugin.json @@ -43,6 +43,14 @@ "help_text": "Generated token to validate incoming requests from AWS SNS.", "placeholder": "", "default": null + }, + { + "key": "EnableCodeBuildNotifications", + "display_name": "Enable CodeBuild notifications support:", + "type": "bool", + "help_text": "Enable to add support for handling CodeBuild SNS notifications.", + "placeholder": "", + "default": false } ] } diff --git a/server/configuration.go b/server/configuration.go index a967c43..a52b6e0 100644 --- a/server/configuration.go +++ b/server/configuration.go @@ -18,9 +18,10 @@ import ( // If you add non-reference types to your configuration struct, be sure to rewrite Clone as a deep // copy appropriate for your types. type configuration struct { - TeamChannel string - AllowedUserIds string - Token string + TeamChannel string + AllowedUserIds string + Token string + EnableCodeBuildNotifications bool } // Clone shallow copies the configuration. Your implementation may require a deep copy if diff --git a/server/plugin.go b/server/plugin.go index f335a42..ff62cb4 100644 --- a/server/plugin.go +++ b/server/plugin.go @@ -265,7 +265,11 @@ func (p *Plugin) handleNotification(body io.Reader, channel *TeamChannel) { if isCodeBuild, messageNotification := p.isCodeBuildEvent(notification.Message); isCodeBuild { p.API.LogDebug("Processing CodeBuild Event") - p.sendPostNotification(p.createSNSCodeBuildEventNotificationAttachment(notification.Subject, messageNotification), channel) + + if p.configuration.EnableCodeBuildNotifications { + p.sendPostNotification(p.createSNSCodeBuildEventNotificationAttachment(notification.Subject, messageNotification), channel) + } + return }