This commit is contained in:
committed by
GitHub
parent
43be5bd7da
commit
be631c663e
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -1838,6 +1838,7 @@ dependencies = [
|
|||||||
"notify-rust",
|
"notify-rust",
|
||||||
"openssl-probe",
|
"openssl-probe",
|
||||||
"pretty_env_logger",
|
"pretty_env_logger",
|
||||||
|
"regex",
|
||||||
"rust-ini",
|
"rust-ini",
|
||||||
"self_update",
|
"self_update",
|
||||||
"serde",
|
"serde",
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ tempfile = "3.1.0"
|
|||||||
cfg-if = "0.1.10"
|
cfg-if = "0.1.10"
|
||||||
tokio = { version = "0.2", features = ["rt-core", "process"] }
|
tokio = { version = "0.2", features = ["rt-core", "process"] }
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
|
regex = "1.3.9"
|
||||||
|
|
||||||
[target.'cfg(target_os = "macos")'.dependencies]
|
[target.'cfg(target_os = "macos")'.dependencies]
|
||||||
notify-rust = "4.0.0"
|
notify-rust = "4.0.0"
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ use anyhow::Result;
|
|||||||
use directories::BaseDirs;
|
use directories::BaseDirs;
|
||||||
use log::{debug, LevelFilter};
|
use log::{debug, LevelFilter};
|
||||||
use pretty_env_logger::formatted_timed_builder;
|
use pretty_env_logger::formatted_timed_builder;
|
||||||
|
use regex::Regex;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::fs::write;
|
use std::fs::write;
|
||||||
@@ -332,6 +333,10 @@ pub struct CommandLineArgs {
|
|||||||
/// Alternative configuration file
|
/// Alternative configuration file
|
||||||
#[structopt(long = "config")]
|
#[structopt(long = "config")]
|
||||||
config: Option<PathBuf>,
|
config: Option<PathBuf>,
|
||||||
|
|
||||||
|
/// A regular expression for restricting remote host execution
|
||||||
|
#[structopt(long = "remote-host-limit", parse(try_from_str))]
|
||||||
|
remote_host_limit: Option<Regex>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CommandLineArgs {
|
impl CommandLineArgs {
|
||||||
@@ -649,4 +654,12 @@ impl Config {
|
|||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
str_value!(linux, emerge_update_flags);
|
str_value!(linux, emerge_update_flags);
|
||||||
|
|
||||||
|
pub fn should_execute_remote(&self, remote: &str) -> bool {
|
||||||
|
self.opt
|
||||||
|
.remote_host_limit
|
||||||
|
.as_ref()
|
||||||
|
.map(|h| h.is_match(remote))
|
||||||
|
.unwrap_or(true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ fn run() -> Result<()> {
|
|||||||
runner.execute(Step::Wsl, "WSL", || windows::run_wsl_topgrade(run_type))?;
|
runner.execute(Step::Wsl, "WSL", || windows::run_wsl_topgrade(run_type))?;
|
||||||
|
|
||||||
if let Some(topgrades) = config.remote_topgrades() {
|
if let Some(topgrades) = config.remote_topgrades() {
|
||||||
for remote_topgrade in topgrades {
|
for remote_topgrade in topgrades.iter().filter(|t| config.should_execute_remote(t)) {
|
||||||
runner.execute(Step::Remotes, format!("Remote ({})", remote_topgrade), || {
|
runner.execute(Step::Remotes, format!("Remote ({})", remote_topgrade), || {
|
||||||
generic::run_remote_topgrade(&ctx, remote_topgrade)
|
generic::run_remote_topgrade(&ctx, remote_topgrade)
|
||||||
})?;
|
})?;
|
||||||
|
|||||||
Reference in New Issue
Block a user