-
Notifications
You must be signed in to change notification settings - Fork 16
Multiple slack channels #68
base: master
Are you sure you want to change the base?
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
ankh/main.go
Outdated
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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this used anywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes!
ankh/main.go
Outdated
@@ -431,8 +431,13 @@ func execute(ctx *ankh.ExecutionContext) { | |||
executeContext(ctx, &rootAnkhFile) | |||
} | |||
|
|||
if ctx.SlackChannel != "" { | |||
if err := slack.PingSlackChannel(ctx); err != nil { | |||
if len(ctx.AnkhConfig.Slack.Channels) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.