my ($slack_webhook, $hive_pipeline, $is_error, $is_exit, $beekeeper_message, $loop_until) = @_;
my @attachments;
my $error_fallback = "this beekeeper has detected an error condition";
my $exit_fallback = "this beekeeper has stopped";
$beekeeper_message =~ s/###,/###\n/g;
if ($loop_until) {
$beekeeper_message .= "\nBeekeeper's loop_until set to '$loop_until'";
}
if ($is_error) {
push @attachments, {
'color' => 'danger',
'fallback' => $error_fallback,
'title' => 'Beekeeper encountered an error',
'text' => $beekeeper_message,
}
} elsif ($is_exit) {
push @attachments, {
'color' => 'warning',
'fallback' => $exit_fallback,
'title' => 'Beekeeper has exited',
'text' => $beekeeper_message,
}
} else {
# FIXME: this can never happen because $is_exit is always set to 1
push @attachments, {
'color' => 'good',
'fallback' => 'beekeeper sent a non-error, non-exit message',
'title' => 'Beekeeper message',
'text' => $beekeeper_message,
}
}
my $dbc = $hive_pipeline->hive_dba()->dbc();
my $payload = {
'text' => sprintf('Message from %s@%s:%s', $hive_pipeline->hive_pipeline_name, $dbc->host, $dbc->port),
'attachments' => \@attachments,
};
}