Compare commits
No commits in common. "cd65ef7a25cdc75052fbd04b120aeb066c3881db" and "495fc56f6effc7e5e7e31f714dbf2924605e1271" have entirely different histories.
cd65ef7a25
...
495fc56f6e
9 changed files with 18 additions and 58 deletions
21
src/cli.rs
21
src/cli.rs
|
@ -278,11 +278,6 @@ pub async fn run() {
|
|||
set_color_pref(&opts.color);
|
||||
init_logging();
|
||||
|
||||
if let Command::GenCompletions { shell } = opts.command {
|
||||
print_completions(shell, &mut Opts::command());
|
||||
return;
|
||||
}
|
||||
|
||||
let hive = get_hive(&opts).await.expect("Failed to get flake or hive");
|
||||
|
||||
use crate::troubleshooter::run_wrapped as r;
|
||||
|
@ -301,6 +296,7 @@ pub async fn run() {
|
|||
let args = command::apply::Opts {
|
||||
deploy,
|
||||
goal: crate::nix::Goal::Build,
|
||||
node_filter: Default::default(),
|
||||
};
|
||||
r(command::apply::run(hive, args), opts.config).await
|
||||
}
|
||||
|
@ -308,20 +304,21 @@ pub async fn run() {
|
|||
let args = command::apply::Opts {
|
||||
deploy,
|
||||
goal: crate::nix::Goal::UploadKeys,
|
||||
node_filter: Default::default(),
|
||||
};
|
||||
r(command::apply::run(hive, args), opts.config).await
|
||||
}
|
||||
Command::GenCompletions { .. } => unreachable!(),
|
||||
Command::GenCompletions { shell } => print_completions(shell, &mut Opts::command()),
|
||||
}
|
||||
}
|
||||
|
||||
fn print_completions(shell: Shell, cmd: &mut clap::Command) {
|
||||
let bin_name = cmd
|
||||
.get_bin_name()
|
||||
.expect("Must have a bin_name")
|
||||
.to_string();
|
||||
|
||||
clap_complete::generate(shell, cmd, bin_name, &mut std::io::stdout());
|
||||
clap_complete::generate(
|
||||
shell,
|
||||
cmd,
|
||||
cmd.get_name().to_string(),
|
||||
&mut std::io::stdout(),
|
||||
);
|
||||
}
|
||||
|
||||
fn set_color_pref(when: &ColorWhen) {
|
||||
|
|
|
@ -113,8 +113,6 @@ will treat deployment.replaceUnknownProfiles as though it was set true and perfo
|
|||
This is an experimental feature."#
|
||||
)]
|
||||
evaluator: EvaluatorType,
|
||||
#[command(flatten)]
|
||||
node_filter: NodeFilterOpts,
|
||||
}
|
||||
|
||||
#[derive(Debug, Args)]
|
||||
|
@ -138,6 +136,8 @@ Same as the targets for switch-to-configuration, with the following extra pseudo
|
|||
pub goal: Goal,
|
||||
#[command(flatten)]
|
||||
pub deploy: DeployOpts,
|
||||
#[command(flatten)]
|
||||
pub node_filter: NodeFilterOpts,
|
||||
}
|
||||
|
||||
pub async fn run(hive: Hive, opts: Opts) -> Result<(), ColmenaError> {
|
||||
|
@ -159,8 +159,8 @@ pub async fn run(hive: Hive, opts: Opts) -> Result<(), ColmenaError> {
|
|||
no_build_on_target,
|
||||
force_replace_unknown_profiles,
|
||||
evaluator,
|
||||
node_filter,
|
||||
},
|
||||
node_filter,
|
||||
} = opts;
|
||||
|
||||
if node_filter.on.is_none() && goal != Goal::Build {
|
||||
|
|
|
@ -110,18 +110,9 @@ pub async fn run(
|
|||
}));
|
||||
}
|
||||
|
||||
let results: Vec<Result<(), ColmenaError>> = join_all(futures).await;
|
||||
join_all(futures).await;
|
||||
|
||||
let mut failed: usize = 0;
|
||||
|
||||
for x in results {
|
||||
match x {
|
||||
Err(_) => failed += 1,
|
||||
Ok(_) => (),
|
||||
}
|
||||
}
|
||||
|
||||
Ok(failed)
|
||||
Ok(())
|
||||
});
|
||||
|
||||
let (meta, monitor, output) = tokio::join!(
|
||||
|
@ -130,13 +121,9 @@ pub async fn run(
|
|||
output.run_until_completion(),
|
||||
);
|
||||
|
||||
let failed = meta?;
|
||||
meta?;
|
||||
monitor?;
|
||||
output?;
|
||||
|
||||
if failed > 0 {
|
||||
Err(ColmenaError::ExecError { n_hosts: failed })
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -75,9 +75,6 @@ pub enum ColmenaError {
|
|||
|
||||
#[snafu(display("Unknown error: {}", message))]
|
||||
Unknown { message: String },
|
||||
|
||||
#[snafu(display("Exec failed on {} hosts", n_hosts))]
|
||||
ExecError { n_hosts: usize },
|
||||
}
|
||||
|
||||
impl From<std::io::Error> for ColmenaError {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{ rawHive ? null # Colmena Hive attrset
|
||||
, rawFlake ? null # Nix Flake attrset with `outputs.colmena`
|
||||
, hermetic ? rawFlake != null # Whether we are allowed to use <nixpkgs>
|
||||
, colmenaOptions ? import ./options.nix
|
||||
, colmenaModules ? import ./modules.nix
|
||||
, colmenaOptions
|
||||
, colmenaModules
|
||||
}:
|
||||
with builtins;
|
||||
let
|
||||
|
|
|
@ -208,13 +208,6 @@ with builtins; rec {
|
|||
type = types.listOf types.str;
|
||||
default = [ "sudo" "-H" "--" ];
|
||||
};
|
||||
sshOptions = lib.mkOption {
|
||||
description = mdDoc ''
|
||||
Extra SSH options to pass to the SSH command.
|
||||
'';
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -33,9 +33,6 @@ pub struct Ssh {
|
|||
/// Command to elevate privileges with.
|
||||
privilege_escalation_command: Vec<String>,
|
||||
|
||||
/// extra SSH options
|
||||
extra_ssh_options: Vec<String>,
|
||||
|
||||
/// Whether to use the experimental `nix copy` command.
|
||||
use_nix3_copy: bool,
|
||||
|
||||
|
@ -192,7 +189,6 @@ impl Ssh {
|
|||
port: None,
|
||||
ssh_config: None,
|
||||
privilege_escalation_command: Vec::new(),
|
||||
extra_ssh_options: Vec::new(),
|
||||
use_nix3_copy: false,
|
||||
job: None,
|
||||
}
|
||||
|
@ -210,10 +206,6 @@ impl Ssh {
|
|||
self.privilege_escalation_command = command;
|
||||
}
|
||||
|
||||
pub fn set_extra_ssh_options(&mut self, options: Vec<String>) {
|
||||
self.extra_ssh_options = options;
|
||||
}
|
||||
|
||||
pub fn set_use_nix3_copy(&mut self, enable: bool) {
|
||||
self.use_nix3_copy = enable;
|
||||
}
|
||||
|
@ -354,7 +346,6 @@ impl Ssh {
|
|||
]
|
||||
.iter()
|
||||
.map(|s| s.to_string())
|
||||
.chain(self.extra_ssh_options.clone())
|
||||
.collect();
|
||||
|
||||
if let Some(port) = self.port {
|
||||
|
|
|
@ -78,9 +78,6 @@ pub struct NodeConfig {
|
|||
#[serde(rename = "privilegeEscalationCommand")]
|
||||
privilege_escalation_command: Vec<String>,
|
||||
|
||||
#[serde(rename = "sshOptions")]
|
||||
extra_ssh_options: Vec<String>,
|
||||
|
||||
#[validate(custom = "validate_keys")]
|
||||
keys: HashMap<String, Key>,
|
||||
}
|
||||
|
@ -184,7 +181,6 @@ impl NodeConfig {
|
|||
self.target_host.as_ref().map(|target_host| {
|
||||
let mut host = Ssh::new(self.target_user.clone(), target_host.clone());
|
||||
host.set_privilege_escalation_command(self.privilege_escalation_command.clone());
|
||||
host.set_extra_ssh_options(self.extra_ssh_options.clone());
|
||||
|
||||
if let Some(target_port) = self.target_port {
|
||||
host.set_port(target_port);
|
||||
|
|
|
@ -248,7 +248,6 @@ mod tests {
|
|||
build_on_target: false,
|
||||
replace_unknown_profiles: false,
|
||||
privilege_escalation_command: vec![],
|
||||
extra_ssh_options: vec![],
|
||||
keys: HashMap::new(),
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue