Add an ssh_arguments configuration file field (#211)
Can be used to add SSH command-line arguments like `-o ConnectTimeout=2`
This commit is contained in:
committed by
Roey Darwish Dror
parent
6dac7a18b2
commit
bfbb486fba
@@ -87,6 +87,7 @@ pub struct ConfigFile {
|
||||
git_repos: Option<Vec<String>>,
|
||||
disable: Option<Vec<Step>>,
|
||||
remote_topgrades: Option<Vec<String>>,
|
||||
ssh_arguments: Option<String>,
|
||||
}
|
||||
|
||||
impl ConfigFile {
|
||||
@@ -270,6 +271,11 @@ impl Config {
|
||||
&self.config_file.remote_topgrades
|
||||
}
|
||||
|
||||
/// Extra SSH arguments
|
||||
pub fn ssh_arguments(&self) -> &Option<String> {
|
||||
&self.config_file.ssh_arguments
|
||||
}
|
||||
|
||||
/// Prompt for a key before exiting
|
||||
pub fn keep_at_end(&self) -> bool {
|
||||
self.opt.keep_at_end || env::var("TOPGRADE_KEEP_END").is_ok()
|
||||
|
||||
@@ -132,7 +132,14 @@ fn run() -> Result<(), Error> {
|
||||
execute(
|
||||
&mut report,
|
||||
remote_topgrade,
|
||||
|| generic::run_remote_topgrade(run_type, remote_topgrade, config.run_in_tmux()),
|
||||
|| {
|
||||
generic::run_remote_topgrade(
|
||||
run_type,
|
||||
remote_topgrade,
|
||||
config.ssh_arguments(),
|
||||
config.run_in_tmux(),
|
||||
)
|
||||
},
|
||||
config.no_retry(),
|
||||
)?;
|
||||
}
|
||||
|
||||
@@ -137,7 +137,12 @@ pub fn run_composer_update(base_dirs: &BaseDirs, run_type: RunType) -> Result<()
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn run_remote_topgrade(run_type: RunType, hostname: &str, run_in_tmux: bool) -> Result<(), Error> {
|
||||
pub fn run_remote_topgrade(
|
||||
run_type: RunType,
|
||||
hostname: &str,
|
||||
ssh_arguments: &Option<String>,
|
||||
run_in_tmux: bool,
|
||||
) -> Result<(), Error> {
|
||||
let ssh = utils::require("ssh")?;
|
||||
|
||||
if run_in_tmux && !run_type.dry() {
|
||||
@@ -149,15 +154,15 @@ pub fn run_remote_topgrade(run_type: RunType, hostname: &str, run_in_tmux: bool)
|
||||
|
||||
unreachable!("Tmux execution is only implemented in Unix");
|
||||
} else {
|
||||
run_type
|
||||
.execute(&ssh)
|
||||
.args(&[
|
||||
"-t",
|
||||
hostname,
|
||||
"env",
|
||||
&format!("TOPGRADE_PREFIX={}", hostname),
|
||||
"topgrade",
|
||||
])
|
||||
.check_run()
|
||||
let mut args = vec!["-t", hostname];
|
||||
|
||||
if let Some(ssh_arguments) = ssh_arguments {
|
||||
args.extend(ssh_arguments.split_whitespace());
|
||||
}
|
||||
|
||||
let env = format!("TOPGRADE_PREFIX={}", hostname);
|
||||
args.extend(&["env", &env, "topgrade"]);
|
||||
|
||||
run_type.execute(&ssh).args(&args).check_run()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user