Skip to content

Commit 2267c99

Browse files
committed
Move on_call out of the main app
We don't want to require pagerduty for external registries. But making this code no-op if the environment variables are missing would mean we don't get informed if things are mis-configured or un-configured. We aren't expecting this to be called from most code, only a handful of binaries that are specifically intended to monitor the service. In order to prevent this code from accidentally getting used throughout the app (though hopefully nobody is calling a function documented as "wakes up whoever is on-call" willy nilly), we can move this into the `bin` directory. We're specifically using `on_call/mod.rs` instead of `on_call.rs` so Cargo doesn't think that this file is supposed to be its own binary.
1 parent 651c8fb commit 2267c99

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/on_call.rs renamed to src/bin/on_call/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
use reqwest::{self, header, StatusCode as Status};
1+
extern crate cargo_registry;
2+
extern crate reqwest;
3+
4+
use self::reqwest::{header, StatusCode as Status};
25
use std::env;
36

4-
use util::*;
7+
use self::cargo_registry::util::*;
58

69
#[derive(Serialize, Debug)]
710
#[serde(rename_all = "snake_case", tag = "event_type")]

src/bin/test-pagerduty.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
88
#![deny(warnings)]
99

10-
extern crate cargo_registry;
10+
#[macro_use]
11+
extern crate serde_derive;
1112

12-
use std::env::args;
13+
mod on_call;
1314

14-
use cargo_registry::on_call;
15+
use std::env::args;
1516

1617
fn main() {
1718
let args = args().collect::<Vec<_>>();

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ pub mod email;
6969
pub mod git;
7070
pub mod github;
7171
pub mod middleware;
72-
pub mod on_call;
7372
pub mod render;
7473
pub mod schema;
7574
pub mod uploaders;

0 commit comments

Comments
 (0)