fix(foomo/squadron): slack notification log

This commit is contained in:
Kevin Franklin Kim 2025-03-21 15:57:12 +01:00
parent 6865c901f1
commit 80cfdcfb42
No known key found for this signature in database
2 changed files with 24 additions and 8 deletions

View File

@ -580,10 +580,8 @@ func (c *Command) notify(ctx context.Context, cmd, cluster, fleet, squadron, tag
switch {
case c.slackWebhookID != "":
c.l.Info("💌 sending slack notification")
return c.slack.SendWebhook(ctx, c.slackWebhookID, blocks)
case c.slackChannelID != "":
c.l.Info("💌 sending slack notification")
return c.slack.Send(
ctx,
c.slack.Channel(c.slackChannelID),

View File

@ -132,10 +132,16 @@ func (s *Slack) SendETCDUpdateMessage(ctx context.Context, cluster string) error
)
fallbackOpt := slack.MsgOptionText(fmt.Sprintf("ETCD config update on %s", cluster), false)
return s.Send(ctx,
if err := s.Send(ctx,
s.cfg.Channels["releases"],
slack.MsgOptionCompose(fallbackOpt, blockOpt),
)
); err != nil {
return err
}
s.l.Info("💌 sent slack notification")
return nil
}
func (s *Slack) Send(ctx context.Context, channel string, opts ...slack.MsgOption) error {
@ -145,8 +151,13 @@ func (s *Slack) Send(ctx context.Context, channel string, opts ...slack.MsgOptio
if err != nil {
return err
}
_, _, _, err = client.SendMessageContext(ctx, channel, opts...)
return err
if _, _, _, err = client.SendMessageContext(ctx, channel, opts...); err != nil {
return err
}
s.l.Info("💌 sent slack notification")
return nil
}
func (s *Slack) SendWebhook(ctx context.Context, webhook string, blocks []slack.Block) error {
@ -156,11 +167,18 @@ func (s *Slack) SendWebhook(ctx context.Context, webhook string, blocks []slack.
}
ctx, cancel := context.WithTimeout(ctx, time.Second)
defer cancel()
return slack.PostWebhookContext(ctx, url, &slack.WebhookMessage{
if err := slack.PostWebhookContext(ctx, url, &slack.WebhookMessage{
Blocks: &slack.Blocks{
BlockSet: blocks,
},
})
}); err != nil {
return err
}
s.l.Info("💌 sent slack notification")
return nil
}
func (s *Slack) MarkdownSection(text string) *slack.SectionBlock {