Add a key for running remote topgrades
This commit is contained in:
@@ -154,3 +154,8 @@ The configuration should be placed in the following paths depending by the opera
|
||||
* **macOS** - `~/Library/Preferences/topgrade.toml`
|
||||
* **Windows** - `%APPDATA%/topgrade.toml`
|
||||
* **Other Unix systems** - `~/.config/topgrade.toml`
|
||||
|
||||
## Remote execution
|
||||
You can specify a key called `remote_topgrades` in the configuration file. This key should contain a
|
||||
list of hostnames that have topgrade installed on them. Topgrade will execute Topgrades on these
|
||||
remote hosts.
|
||||
|
||||
@@ -69,6 +69,7 @@ pub struct ConfigFile {
|
||||
commands: Option<Commands>,
|
||||
git_repos: Option<Vec<String>>,
|
||||
disable: Option<Vec<Step>>,
|
||||
remote_topgrades: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
impl ConfigFile {
|
||||
@@ -198,4 +199,9 @@ impl Config {
|
||||
pub fn verbose(&self) -> bool {
|
||||
self.opt.verbose
|
||||
}
|
||||
|
||||
/// List of remote hosts to run Topgrade in
|
||||
pub fn remote_topgrades(&self) -> &Option<Vec<String>> {
|
||||
&self.config_file.remote_topgrades
|
||||
}
|
||||
}
|
||||
|
||||
12
src/main.rs
12
src/main.rs
@@ -1,5 +1,4 @@
|
||||
#![allow(clippy::cognitive_complexity)]
|
||||
|
||||
mod config;
|
||||
mod ctrlc;
|
||||
mod error;
|
||||
@@ -132,6 +131,17 @@ fn run() -> Result<(), Error> {
|
||||
#[cfg(windows)]
|
||||
execute(&mut report, "WSL", || windows::run_wsl_topgrade(run_type), true)?;
|
||||
|
||||
if let Some(topgrades) = config.remote_topgrades() {
|
||||
for remote_topgrade in topgrades {
|
||||
execute(
|
||||
&mut report,
|
||||
remote_topgrade,
|
||||
|| generic::run_remote_topgrade(run_type, remote_topgrade),
|
||||
config.no_retry(),
|
||||
)?;
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
let distribution = linux::Distribution::detect();
|
||||
|
||||
|
||||
@@ -136,3 +136,18 @@ pub fn run_composer_update(base_dirs: &BaseDirs, run_type: RunType) -> Result<()
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn run_remote_topgrade(run_type: RunType, hostname: &str) -> Result<(), Error> {
|
||||
let ssh = utils::require("ssh")?;
|
||||
|
||||
run_type
|
||||
.execute(&ssh)
|
||||
.args(&[
|
||||
"-t",
|
||||
hostname,
|
||||
"env",
|
||||
&format!("TOPGRADE_PREFIX={}", hostname),
|
||||
"topgrade",
|
||||
])
|
||||
.check_run()
|
||||
}
|
||||
|
||||
@@ -89,8 +89,6 @@ pub fn run_wsl_topgrade(run_type: RunType) -> Result<(), Error> {
|
||||
.check_output()
|
||||
.map_err(|_| ErrorKind::SkipStep)?;
|
||||
|
||||
print_separator("WSL");
|
||||
|
||||
run_type
|
||||
.execute(&wsl)
|
||||
.args(&["bash", "-c"])
|
||||
|
||||
Reference in New Issue
Block a user