Move step running into enum for dynamic ordering (#1188)
Co-authored-by: Stuart Reilly <sreilly@scottlogic.com>
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#![allow(dead_code)]
|
||||
use crate::executor::RunType;
|
||||
#[cfg(target_os = "linux")]
|
||||
use crate::steps::linux::Distribution;
|
||||
use crate::sudo::Sudo;
|
||||
use crate::utils::{get_require_sudo_string, require_option};
|
||||
use crate::{config::Config, executor::Executor};
|
||||
@@ -18,10 +20,17 @@ pub struct ExecutionContext<'a> {
|
||||
tmux_session: Mutex<Option<String>>,
|
||||
/// True if topgrade is running under ssh.
|
||||
under_ssh: bool,
|
||||
#[cfg(target_os = "linux")]
|
||||
distribution: &'a Result<Distribution>,
|
||||
}
|
||||
|
||||
impl<'a> ExecutionContext<'a> {
|
||||
pub fn new(run_type: RunType, sudo: Option<Sudo>, config: &'a Config) -> Self {
|
||||
pub fn new(
|
||||
run_type: RunType,
|
||||
sudo: Option<Sudo>,
|
||||
config: &'a Config,
|
||||
#[cfg(target_os = "linux")] distribution: &'a Result<Distribution>,
|
||||
) -> Self {
|
||||
let under_ssh = var("SSH_CLIENT").is_ok() || var("SSH_TTY").is_ok();
|
||||
Self {
|
||||
run_type,
|
||||
@@ -29,6 +38,8 @@ impl<'a> ExecutionContext<'a> {
|
||||
config,
|
||||
tmux_session: Mutex::new(None),
|
||||
under_ssh,
|
||||
#[cfg(target_os = "linux")]
|
||||
distribution,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,4 +71,9 @@ impl<'a> ExecutionContext<'a> {
|
||||
pub fn get_tmux_session(&self) -> Option<String> {
|
||||
self.tmux_session.lock().unwrap().clone()
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub fn distribution(&self) -> &Result<Distribution> {
|
||||
self.distribution
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user