Skip to content

Commit

Permalink
Fix positional args, tweak err handling for promote/demote/delete
Browse files Browse the repository at this point in the history
Signed-off-by: Salim Alam <salam@chef.io>
  • Loading branch information
chefsalim committed Apr 5, 2019
1 parent dae3a82 commit 356312c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
4 changes: 2 additions & 2 deletions components/hab/src/cli.rs
Expand Up @@ -546,8 +546,8 @@ pub fn get() -> App<'static, 'static> {
environment variable if defined. (default: https://bldr.habitat.sh)")
(@arg PKG_IDENT: +required +takes_value {valid_fully_qualified_ident} "A fully qualified package identifier \
(ex: core/busybox-static/1.42.2/20170513215502)")
(arg: arg_target())
(@arg CHANNEL: +required +takes_value "Promote to the specified release channel")
(arg: arg_target())
(@arg AUTH_TOKEN: -z --auth +takes_value "Authentication token for Builder")
)
(@subcommand demote =>
Expand All @@ -558,8 +558,8 @@ pub fn get() -> App<'static, 'static> {
environment variable if defined. (default: https://bldr.habitat.sh)")
(@arg PKG_IDENT: +required +takes_value {valid_fully_qualified_ident} "A fully qualified package identifier \
(ex: core/busybox-static/1.42.2/20170513215502)")
(arg: arg_target())
(@arg CHANNEL: +required +takes_value "Demote from the specified release channel")
(arg: arg_target())
(@arg AUTH_TOKEN: -z --auth +takes_value "Authentication token for Builder")
)
(@subcommand channels =>
Expand Down
7 changes: 6 additions & 1 deletion components/hab/src/command/pkg/delete.rs
Expand Up @@ -12,7 +12,8 @@
//!
//! //! Note: This command does not remove the package from disk

use crate::{api_client::Client,
use crate::{api_client::{self,
Client},
common::ui::{Status,
UIWriter,
UI},
Expand All @@ -22,6 +23,7 @@ use crate::{api_client::Client,
PackageTarget},
PRODUCT,
VERSION};
use hyper::status::StatusCode;

/// Delete a package from Builder.
///
Expand All @@ -39,6 +41,9 @@ pub fn start(ui: &mut UI,

if let Err(err) = api_client.delete_package((ident, target), token) {
println!("Failed to delete '{}': {:?}", ident, err);
if let api_client::Error::APIError(StatusCode::NotFound, _) = err {
println!("Perhaps you may need to specify a platform target argument");
}
return Err(Error::from(err));
}

Expand Down
7 changes: 6 additions & 1 deletion components/hab/src/command/pkg/demote.rs
Expand Up @@ -25,13 +25,15 @@
//! The package should already have been uploaded to Builder.
//! If the specified channel does not exist, this will fail.

use crate::{api_client::Client,
use crate::{api_client::{self,
Client},
common::ui::{Status,
UIWriter,
UI},
hcore::{package::{PackageIdent,
PackageTarget},
ChannelIdent}};
use hyper::status::StatusCode;

use crate::{error::{Error,
Result},
Expand Down Expand Up @@ -63,6 +65,9 @@ pub fn start(ui: &mut UI,
Ok(_) => (),
Err(e) => {
println!("Failed to demote '{}': {:?}", ident, e);
if let api_client::Error::APIError(StatusCode::NotFound, _) = e {
println!("Perhaps you may need to specify a platform target argument");
}
return Err(Error::from(e));
}
}
Expand Down
3 changes: 3 additions & 0 deletions components/hab/src/command/pkg/promote.rs
Expand Up @@ -70,6 +70,9 @@ pub fn start(ui: &mut UI,
Ok(_) => (),
Err(e) => {
println!("Failed to promote '{}': {:?}", ident, e);
if let api_client::Error::APIError(StatusCode::NotFound, _) = e {
println!("Perhaps you may need to specify a platform target argument");
}
return Err(Error::from(e));
}
}
Expand Down

0 comments on commit 356312c

Please sign in to comment.