Skip to content

Commit

Permalink
feat(crons): Allow specifying checkin environment
Browse files Browse the repository at this point in the history
  • Loading branch information
evanpurkhiser committed May 2, 2023
1 parent 204977c commit 9ff503c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2490,11 +2490,13 @@ pub struct MonitorCheckIn {
pub id: Uuid,
pub status: Option<MonitorCheckinStatus>,
pub duration: Option<u64>,
pub environment: Option<String>,
}

#[derive(Debug, Serialize)]
pub struct CreateMonitorCheckIn {
pub status: MonitorCheckinStatus,
pub environment: String,
}

#[derive(Debug, Serialize, Default)]
Expand All @@ -2503,6 +2505,8 @@ pub struct UpdateMonitorCheckIn {
pub status: Option<MonitorCheckinStatus>,
#[serde(skip_serializing_if = "Option::is_none")]
pub duration: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub environment: Option<String>,
}

#[derive(Deserialize, Debug)]
Expand Down
9 changes: 9 additions & 0 deletions src/commands/monitors/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ pub fn make_command(command: Command) -> Command {
.help("The monitor slug.")
.required(true),
)
.arg(
Arg::new("environment")
.short('e')
.default_value("production")
.help("Specify the environment of the monitor."),
)
.arg(
Arg::new("allow_failure")
.short('f')
Expand Down Expand Up @@ -47,6 +53,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
}

let monitor_slug = matches.get_one::<String>("monitor_slug").unwrap();
let environment = matches.get_one::<String>("environment").unwrap();

let allow_failure = matches.get_flag("allow_failure");
let args: Vec<_> = matches.get_many::<String>("args").unwrap().collect();
Expand All @@ -56,6 +63,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
monitor_slug,
&CreateMonitorCheckIn {
status: MonitorCheckinStatus::InProgress,
environment: environment.to_string(),
},
);

Expand Down Expand Up @@ -93,6 +101,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
let elapsed = started.elapsed();
elapsed.as_secs() * 1000 + u64::from(elapsed.subsec_millis())
}),
environment: Some(environment.to_string()),
},
)
.ok();
Expand Down

0 comments on commit 9ff503c

Please sign in to comment.