Skip to content

Commit

Permalink
add: write detail to thread
Browse files Browse the repository at this point in the history
  • Loading branch information
na-ga committed Jul 1, 2022
1 parent 1279c8e commit db50892
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions report/slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,28 @@ func (s *slackReporter) Report(result *Result) error {
}

//
fields = s.appendField(fields, "Active node pools", activeNodePoolNameLinks)
fields = s.appendField(fields, "Active nodes", activeNodeNameLinks)
fields = s.appendField(fields, "Refresh target preemptible node", targetPreemptibleNode)
fields = s.appendField(fields, "Refresh target ondemand auto scale node", targetOndemandAutoscaleNode)
detailFields := make([]slack.AttachmentField, len(fields))
copy(detailFields, fields)

//
detailFields = s.appendField(detailFields, "Active node pools", activeNodePoolNameLinks)
detailFields = s.appendField(detailFields, "Active nodes", activeNodeNameLinks)
detailFields = s.appendField(detailFields, "Refresh target preemptible node", targetPreemptibleNode)
detailFields = s.appendField(detailFields, "Refresh target ondemand auto scale node", targetOndemandAutoscaleNode)

//
if message != "" {
fields = append(fields, slack.AttachmentField{
Title: "Message",
Value: s.WrapTextInCodeBlock(message),
})
detailFields = append(detailFields, slack.AttachmentField{
Title: "Message",
Value: s.WrapTextInCodeBlock(message),
})
}

//
// write summary
opts := []slack.MsgOption{
slack.MsgOptionAsUser(true),
slack.MsgOptionDisableLinkUnfurl(),
Expand All @@ -144,7 +152,23 @@ func (s *slackReporter) Report(result *Result) error {
Color: color,
}),
}
_, _, err := s.cli.PostMessage(s.channelID, opts...)
_, ts, err := s.cli.PostMessage(s.channelID, opts...)
if err != nil {
return err
}

// write detail to thread
opts = []slack.MsgOption{
slack.MsgOptionAsUser(true),
slack.MsgOptionDisableLinkUnfurl(),
slack.MsgOptionText(fmt.Sprintf("%s (detail)", title), false),
slack.MsgOptionTS(ts),
slack.MsgOptionAttachments(slack.Attachment{
Fields: detailFields,
Color: color,
}),
}
_, _, err = s.cli.PostMessage(s.channelID, opts...)
return err
}

Expand Down

0 comments on commit db50892

Please sign in to comment.