Skip to content

Commit

Permalink
option to specify proxy command
Browse files Browse the repository at this point in the history
  • Loading branch information
slivingston committed Sep 16, 2024
1 parent 29aad72 commit 1b7e17b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
31 changes: 31 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,34 @@ fn config_subcommand(matches: &clap::ArgMatches) -> Result<(), CliError> {

local_config.wdeployments[wd_index].image = Some(new_image.into());

return match mgmt::modify_local(&local_config) {
Err(err) => CliError::new_std(err, 1),
Ok(()) => Ok(()),
};
} else if let Some(new_command) = matches.value_of("cprovider_cmd") {
match local_config.wdeployments[wd_index].cprovider {
CProvider::Proxy => {
let parts: Vec<&str> = new_command.split(' ').collect();
match parts[0] {
"rrhttp" => {
if parts.len() != 2 {
return CliError::new("Usage: rrhttp TARGET", 1);
}
}
_ => return CliError::new("unknown proxy command", 1),
};
local_config.wdeployments[wd_index].cargs =
parts.iter().map(|x| x.to_string()).collect();
}
_ => {
let errmessage = format!(
"cannot --assign-proxy-command for cprovider `{}`",
local_config.wdeployments[wd_index].cprovider
);
return CliError::new(errmessage.as_str(), 1);
}
}

return match mgmt::modify_local(&local_config) {
Err(err) => CliError::new_std(err, 1),
Ok(()) => Ok(()),
Expand Down Expand Up @@ -1151,6 +1179,9 @@ pub fn main() -> Result<(), CliError> {
.long("assign-image")
.value_name("IMG")
.help("assign image for cprovider to use (advanced option)"))
.arg(Arg::with_name("cprovider_cmd")
.long("assign-proxy-command")
.value_name("CMD"))
.arg(Arg::with_name("raw_device_path")
.long("add-raw-device")
.value_name("PATH")
Expand Down
3 changes: 2 additions & 1 deletion tests/snapshots/cli__prints_help_config.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: tests/cli.rs
assertion_line: 59
assertion_line: 56
expression: "String::from_utf8(output.stdout).unwrap()"
---
hardshare-config
Expand All @@ -25,6 +25,7 @@ OPTIONS:
--cprovider <CPROVIDER>
select a container provider: lxd, docker, docker-rootless, podman,
proxy
--assign-proxy-command <CMD>
--assign-image <IMG>
assign image for cprovider to use (advanced option)

Expand Down

0 comments on commit 1b7e17b

Please sign in to comment.