Skip to content

Commit

Permalink
Remove Option from slack_webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
psibi committed Jul 25, 2024
1 parent 232be30 commit 0ea46af
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub(crate) struct Cli {
#[group(required = true, multiple = false)]
pub(crate) struct NotifyHook {
#[arg(long, value_parser(Url::from_str), env = "HEALTH_CHECK_SLACK_WEBHOOK")]
pub(crate) slack_webhook: Option<Url>,
pub(crate) slack_webhook: Url,
}

#[derive(Debug)]
Expand Down Expand Up @@ -191,23 +191,21 @@ impl Cli {
match res {
Ok(()) => Ok(()),
Err(e) => {
if let Some(slack_webhook) = self.notification_hook.slack_webhook {
let slack_app = SlackApp::new(
slack_webhook,
self.notification_context,
self.app_description,
self.app_version,
self.image_url,
);
let mut msg = String::new();
for line in &*recent_output.lock() {
msg.push_str(line);
msg.push('\n');
}
let result = slack_app.send_notification(&e, &msg);
if let Err(err) = result {
eprintln!("Slack notification failed: {err:?}");
}
let slack_app = SlackApp::new(
self.notification_hook.slack_webhook,
self.notification_context,
self.app_description,
self.app_version,
self.image_url,
);
let mut msg = String::new();
for line in &*recent_output.lock() {
msg.push_str(line);
msg.push('\n');
}
let result = slack_app.send_notification(&e, &msg);
if let Err(err) = result {
eprintln!("Slack notification failed: {err:?}");
}
Err(e)
}
Expand Down

0 comments on commit 0ea46af

Please sign in to comment.