Multiple slack channels#68
Conversation
Codecov Report
@@ Coverage Diff @@
## master #68 +/- ##
==========================================
- Coverage 17.2% 5.83% -11.38%
==========================================
Files 3 5 +2
Lines 587 1732 +1145
==========================================
Hits 101 101
- Misses 472 1617 +1145
Partials 14 14
Continue to review full report at Codecov.
|
b859da8 to
73403d8
Compare
| if len(ctx.AnkhConfig.Slack.Channels) > 0 { | ||
| ctx.Logger.Debugf("Pinging %d slack channels %+v", len(ctx.AnkhConfig.Slack.Channels), ctx.AnkhConfig.Slack.Channels) | ||
| if ctx.Mode == ankh.Rollback { | ||
| ctx.SlackDeploymentVersion = "rollback" |
|
|
||
| if ctx.SlackChannel != "" { | ||
| if err := slack.PingSlackChannel(ctx); err != nil { | ||
| if len(ctx.AnkhConfig.Slack.Channels) > 0 { |
There was a problem hiding this comment.
This change requires the channel to be set in the ankh config? This doesn't allow the use-case where a different slack channel is used for different application deploys.
| ctx.Logger.Infof("--dry-run set so not sending message '%v' to slack channel %v", messageText, ctx.SlackChannel) | ||
| for name, id := range channels { | ||
| if !ctx.DryRun { | ||
| _, _, err = api.PostMessage(id, slack.MsgOptionAttachments(attachment), slack.MsgOptionPostMessageParameters(messageParams)) |
There was a problem hiding this comment.
This error is not checked inside the loop so only the last channel error will be returned/checked from this function.
There was a problem hiding this comment.
I'm not sure about go conventions for handling multiple possible errors and returning, but this will collect all the messages and return a single error.
There was a problem hiding this comment.
Per a request from Donald Johnson, added support to ankh for posting to multiple slack channels. Also added channels as an array to the slack section in ankh config
73403d8 to
e6836dd
Compare
Please comment and suggest improvements. The AppSec team would like to post to multiple Slack channels on release, this PR adds support for that use case.