Skip to content

Commit

Permalink
Cleanup with rustfmt
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Anderson <mark@chef.io>
  • Loading branch information
markan committed Feb 26, 2019
1 parent 51377dc commit 4b1c0bf
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 18 deletions.
8 changes: 6 additions & 2 deletions src/delivery/cli/api.rs
Expand Up @@ -15,7 +15,7 @@
// limitations under the License.
//
use clap::{App, Arg, ArgMatches, SubCommand};
use cli::arguments::{api_port_arg, config_path_arg, u_e_s_o_args, a2_mode_arg, value_of};
use cli::arguments::{a2_mode_arg, api_port_arg, config_path_arg, u_e_s_o_args, value_of};
use cli::Options;
use config::Config;
use types::DeliveryResult;
Expand Down Expand Up @@ -58,7 +58,11 @@ impl<'n> ApiClapOptions<'n> {
api_port: value_of(&matches, "api-port"),
ent: value_of(&matches, "ent"),
user: value_of(&matches, "user"),
a2_mode: if matches.is_present("a2-mode") { Some(true) } else { None },
a2_mode: if matches.is_present("a2-mode") {
Some(true)
} else {
None
},
}
}
}
Expand Down
10 changes: 7 additions & 3 deletions src/delivery/cli/clone.rs
Expand Up @@ -15,7 +15,7 @@
// limitations under the License.
//
use clap::{App, ArgMatches, SubCommand};
use cli::arguments::{project_specific_args, u_e_s_o_args, a2_mode_arg, value_of};
use cli::arguments::{a2_mode_arg, project_specific_args, u_e_s_o_args, value_of};
use cli::Options;
use config::Config;
use fips;
Expand Down Expand Up @@ -66,7 +66,11 @@ impl<'n> CloneClapOptions<'n> {
fips: matches.is_present("fips"),
fips_git_port: value_of(&matches, "fips-git-port"),
fips_custom_cert_filename: value_of(&matches, "fips-custom-cert-filename"),
a2_mode: if matches.is_present("a2-mode") { Some(true) } else { None },
a2_mode: if matches.is_present("a2-mode") {
Some(true)
} else {
None
},
}
}
}
Expand All @@ -80,7 +84,7 @@ impl<'n> Options for CloneClapOptions<'n> {
.set_organization(&self.org)
.set_project(&self.project)
.set_a2_mode_if_def(self.a2_mode);

if new_config.project.is_none() {
new_config.project = project::project_from_cwd().ok();
}
Expand Down
10 changes: 7 additions & 3 deletions src/delivery/cli/init.rs
Expand Up @@ -16,8 +16,8 @@
//
use clap::{App, ArgMatches, SubCommand};
use cli::arguments::{
config_path_arg, config_project_arg, local_arg, no_open_arg, pipeline_arg, project_arg,
project_specific_args, scp_args, u_e_s_o_args, a2_mode_arg, value_of,
a2_mode_arg, config_path_arg, config_project_arg, local_arg, no_open_arg, pipeline_arg,
project_arg, project_specific_args, scp_args, u_e_s_o_args, value_of,
};
use cli::Options;
use config::Config;
Expand Down Expand Up @@ -97,7 +97,11 @@ impl<'n> InitClapOptions<'n> {
fips: matches.is_present("fips"),
fips_git_port: value_of(&matches, "fips-git-port"),
fips_custom_cert_filename: value_of(&matches, "fips-custom-cert-filename"),
a2_mode: if matches.is_present("a2-mode") { Some(true) } else { None },
a2_mode: if matches.is_present("a2-mode") {
Some(true)
} else {
None
},
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/delivery/cli/job.rs
Expand Up @@ -107,7 +107,11 @@ impl<'n> JobClapOptions<'n> {
fips: matches.is_present("fips"),
fips_git_port: value_of(&matches, "fips-git-port"),
fips_custom_cert_filename: value_of(&matches, "fips-custom-cert-filename"),
a2_mode: if matches.is_present("a2-mode") { Some(true) } else { None },
a2_mode: if matches.is_present("a2-mode") {
Some(true)
} else {
None
},
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/delivery/cli/setup.rs
Expand Up @@ -61,7 +61,11 @@ impl<'n> SetupClapOptions<'n> {
path: value_of(&matches, "config-path"),
pipeline: value_of(&matches, "pipeline"),
project: value_of(&matches, "project"),
a2_mode: if matches.is_present("a2-mode") { Some(true) } else { None },
a2_mode: if matches.is_present("a2-mode") {
Some(true)
} else {
None
},
}
}
}
Expand Down
14 changes: 6 additions & 8 deletions src/delivery/config/mod.rs
Expand Up @@ -74,12 +74,11 @@ impl Default for Config {
fips: None,
fips_git_port: None,
fips_custom_cert_filename: None,
a2_mode: None
a2_mode: None,
}
}
}


macro_rules! config_accessor_for {
($name:ident, $set_name:ident, $err_msg:expr) => {
impl Config {
Expand Down Expand Up @@ -128,7 +127,7 @@ macro_rules! config_bool_accessor_for {
self
}
}

paste::item! {
pub fn [<set_ $name>](mut self, $name: bool) -> Config {
self.$name = Some($name);
Expand All @@ -139,8 +138,6 @@ macro_rules! config_bool_accessor_for {
};
}



config_accessor_for!(
server,
set_server,
Expand Down Expand Up @@ -212,7 +209,6 @@ config_bool_accessor_for!(
"You did not set the a2_mode. Set this value in your cli.toml."
);


impl Config {
/// Return the host and port at which we can access the Delivery
/// API. By default, we assume the use of HTTPS on the standard
Expand Down Expand Up @@ -526,7 +522,6 @@ mod tests {
);
}


#[test]
fn test_api_base_resource_with_port_with_a2() {
let mut conf = Config::default();
Expand All @@ -545,7 +540,10 @@ mod tests {
conf.server = Some("127.0.0.1".to_string());
conf.a2_mode = Some(true);
assert!(conf.api_port.is_none());
assert_eq!("127.0.0.1/workflow".to_string(), conf.api_base_resource().unwrap());
assert_eq!(
"127.0.0.1/workflow".to_string(),
conf.api_base_resource().unwrap()
);
}

#[test]
Expand Down

0 comments on commit 4b1c0bf

Please sign in to comment.