Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ var (
spannerdb string
spannercanceltable string
preprocesshook string
skipNotif bool

verbose bool
)
Expand Down Expand Up @@ -970,6 +971,7 @@ func runCmd() *cobra.Command {
cmd.Flags().StringVar(&scenariopubsub, "scenario-pubsub", os.Getenv("SCENARIO_PUBSUB"), "pubsub subscription for scenario progress (e.g. oopsnext-scenarios)")
cmd.Flags().StringVar(&spannerdb, "spanner-db", os.Getenv("SPANNER_DB"), "Spanner DB path for cancel checks")
cmd.Flags().StringVar(&spannercanceltable, "spanner-cancel-table", os.Getenv("SPANNER_CANCEL_TABLE"), "Spanner table name for cancel checks")
cmd.Flags().BoolVar(&skipNotif, "skip-result-notif", false, "skip result Slack notification")
return cmd
}

Expand All @@ -991,6 +993,7 @@ func init() {
rootcmd.PersistentFlags().StringSliceVarP(&tags, "tags", "t", tags, "key=value labels in scenario files that are allowed to run, empty means all")
rootcmd.PersistentFlags().StringVar(&githubtoken, "github-token", "", "GitHub token for commit status updates")
rootcmd.PersistentFlags().StringVar(&preprocesshook, "pre-process-hook", preprocesshook, "executable to run before processing each scenario, with the scenario file path as argument")
rootcmd.PersistentFlags().BoolVar(&skipNotif, "skip-result-notif", false, "skip result Slack notification")
rootcmd.AddCommand(runCmd())
}

Expand Down
30 changes: 15 additions & 15 deletions scenario.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,23 +415,23 @@ func doScenario(in *doScenarioInput) error {
continue
}

if in.ReportSlack != "" && len(s.errs) > 0 {
payload := SlackMessage{
Attachments: []SlackAttachment{
{
Color: "danger",
Title: fmt.Sprintf("%v - failure", filepath.Base(f)),
Text: fmt.Sprintf("Maintainers: %v\n%v", strings.Join(s.Maintainers, ", "), s.errs),
Footer: "oops",
Timestamp: time.Now().Unix(),
MrkdwnIn: []string{"text"},
},
if in.ReportSlack != "" && !skipNotif && len(s.errs) > 0 {
payload := SlackMessage{
Attachments: []SlackAttachment{
{
Color: "danger",
Title: fmt.Sprintf("%v - failure", filepath.Base(f)),
Text: fmt.Sprintf("Maintainers: %v\n%v", strings.Join(s.Maintainers, ", "), s.errs),
Footer: "oops",
Timestamp: time.Now().Unix(),
MrkdwnIn: []string{"text"},
},
}
},
}

err = payload.Notify(in.ReportSlack)
if err != nil {
log.Printf("Notify (slack) failed: %v", err)
err = payload.Notify(in.ReportSlack)
if err != nil {
log.Printf("Notify (slack) failed: %v", err)
}
}

Expand Down