From 85440accadf3d6a825cd2b30031a3af4b617cadb Mon Sep 17 00:00:00 2001 From: Nell Shamrell Date: Mon, 6 Apr 2020 13:50:23 -0700 Subject: [PATCH 1/4] adds command to rollback a release of an app Signed-off-by: Nell Shamrell --- src/commands/heroku.rs | 32 ++++++++++++++++++++++++++++++++ src/lib.rs | 3 ++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/commands/heroku.rs b/src/commands/heroku.rs index 4fed568..743f4f0 100644 --- a/src/commands/heroku.rs +++ b/src/commands/heroku.rs @@ -169,6 +169,38 @@ pub fn get_app_releases(ctx: &mut Context, msg: &Message, mut args: Args) -> Com Ok(()) } +#[command] +#[num_args(2)] +pub fn rollback_app(ctx: &mut Context, msg: &Message, mut args: Args) -> CommandResult { + let app_name = args + .single::() + .expect("You must include an app name"); + + let version_to_rollback_to = args + .single::() + .expect("You must include the version to roll back to"); + + let response = heroku_client(ctx).request(&releases::ReleaseRollback { + app_id: app_name.clone(), + params: releases::ReleaseRollbackParams { + release: version_to_rollback_to.clone(), + }, + }); + + msg.reply( + ctx, + match response { + Ok(_response) => format!( + "App {} was successfully rolled back to the code at {}", + app_name, version_to_rollback_to + ), + Err(e) => format!("An error occured when trying to rollback your app:\n{}", e), + }, + )?; + + Ok(()) +} + #[command] pub fn get_apps(ctx: &mut Context, msg: &Message, _args: Args) -> CommandResult { let response = heroku_client(ctx).request(&apps::AppList {}); diff --git a/src/lib.rs b/src/lib.rs index 0ee2ecb..1bb92ff 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -29,7 +29,8 @@ use crate::authorizations::users::*; restart_app, scale_app, update_app_config, - get_app_releases + get_app_releases, + rollback_app )] struct General; From b6cb8be0cf91983866e04fffe6688bee7b3a69ec Mon Sep 17 00:00:00 2001 From: Nell Shamrell Date: Mon, 6 Apr 2020 13:54:57 -0700 Subject: [PATCH 2/4] add documentation of rollback_app command Signed-off-by: Nell Shamrell --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 95d5598..2264b03 100644 --- a/README.md +++ b/README.md @@ -177,6 +177,19 @@ Version: 3 Status: succeeded ``` +**~rollback_app** + +If you would like to rollback your app to the code associated with a previous release of your app, you can do so with the ~rollback_app command. + +``` +you: ~get_app_releases testing-nell-bot version-to-rollback-to +``` + +``` +you: ~get_app_releases testing-nell-bot v5 +crates-io-bot: @you App testing-nell-bot was successfully rolled back to the code at v5 +``` + **~scale_app** You can scale formations of dynos within your application through the ~scale_app command. From c1d85b9aef862ed5189c33594d2ae7faecfed46d Mon Sep 17 00:00:00 2001 From: Nell Shamrell Date: Tue, 7 Apr 2020 11:47:04 -0700 Subject: [PATCH 3/4] corrects typos for rollback command Signed-off-by: Nell Shamrell --- README.md | 14 ++++++++++++-- src/commands/heroku.rs | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2264b03..66913d0 100644 --- a/README.md +++ b/README.md @@ -182,14 +182,24 @@ Status: succeeded If you would like to rollback your app to the code associated with a previous release of your app, you can do so with the ~rollback_app command. ``` -you: ~get_app_releases testing-nell-bot version-to-rollback-to +you: ~rollback_app testing-nell-bot version-to-rollback-to ``` ``` -you: ~get_app_releases testing-nell-bot v5 +you: ~rollback_app testing-nell-bot v5 + crates-io-bot: @you App testing-nell-bot was successfully rolled back to the code at v5 ``` +You can either specify the version with a "v" before the version number or with just the number. This command will also work. + +``` +you: ~rollback_app testing-nell-bot 5 + +crates-io-bot: @you App testing-nell-bot was successfully rolled back to the code at 5 +``` + + **~scale_app** You can scale formations of dynos within your application through the ~scale_app command. diff --git a/src/commands/heroku.rs b/src/commands/heroku.rs index 743f4f0..26ce77b 100644 --- a/src/commands/heroku.rs +++ b/src/commands/heroku.rs @@ -194,7 +194,7 @@ pub fn rollback_app(ctx: &mut Context, msg: &Message, mut args: Args) -> Command "App {} was successfully rolled back to the code at {}", app_name, version_to_rollback_to ), - Err(e) => format!("An error occured when trying to rollback your app:\n{}", e), + Err(e) => format!("An error occured when trying to roll back your app:\n{}", e), }, )?; From a0727adf4e8efb2314983023d08101f7c45410b4 Mon Sep 17 00:00:00 2001 From: Nell Shamrell Date: Tue, 7 Apr 2020 11:49:14 -0700 Subject: [PATCH 4/4] removes extra space Signed-off-by: Nell Shamrell --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 66913d0..91d3b4c 100644 --- a/README.md +++ b/README.md @@ -199,7 +199,6 @@ you: ~rollback_app testing-nell-bot 5 crates-io-bot: @you App testing-nell-bot was successfully rolled back to the code at 5 ``` - **~scale_app** You can scale formations of dynos within your application through the ~scale_app command.