diff --git a/wire/cli/src/apply.rs b/wire/cli/src/apply.rs index d3c9df5..0212880 100644 --- a/wire/cli/src/apply.rs +++ b/wire/cli/src/apply.rs @@ -57,10 +57,6 @@ pub async fn apply( let header_span = Span::current(); let location = Arc::new(location); - // Respect user's --always-build-local arg - // TODO - // hive.force_always_local(args.always_build_local)?; - let header_span_enter = header_span.enter(); let (tags, names) = args.on.iter().fold( @@ -95,7 +91,19 @@ pub async fn apply( }) .map(|(name, _)| (name, Hive::node_from_path(name, &location, modifiers))) .map(|(name, node)| { - node.and_then(async |mut node| { + node.map_ok(|mut node| { + // Respect user's --always-build-local arg + + let name = &name.0.to_string(); + if args.always_build_local.contains(name) { + info!("Forcing a local build for {name}"); + + node.build_remotely = false; + } + + node + }) + .and_then(async |mut node| { let name = name.clone(); info!("Resolved {:?} to include {}", args.on, name); diff --git a/wire/lib/src/hive/mod.rs b/wire/lib/src/hive/mod.rs index e0544e0..7b08360 100644 --- a/wire/lib/src/hive/mod.rs +++ b/wire/lib/src/hive/mod.rs @@ -14,7 +14,6 @@ use std::fmt::Display; use std::fs; use std::path::PathBuf; use std::str::FromStr; -use std::sync::Arc; use tracing::{info, instrument}; use crate::commands::common::evaluate_hive_attribute; @@ -101,24 +100,6 @@ impl Hive { Ok(names) } - - /// # Errors - /// - /// Returns an error if a node in nodes does not exist in the hive. - pub fn force_always_local(&mut self, nodes: Vec) -> Result<(), HiveLibError> { - for node in nodes { - info!("Forcing a local build for {node}"); - - self.nodes - .get_mut(&Name(Arc::from(node.clone()))) - .ok_or(HiveLibError::HiveInitializationError( - HiveInitializationError::NodeDoesNotExist(node.clone()), - ))? - .build_remotely = false; - } - - Ok(()) - } } impl Display for Hive { @@ -395,36 +376,4 @@ mod tests { if logs.contains("The option `deployment._keys' is read-only, but it's set multiple times.") ); } - - #[tokio::test] - async fn test_force_always_local() { - let mut location: PathBuf = env::var("WIRE_TEST_DIR").unwrap().into(); - location.push("non_trivial_hive"); - let location = location!(location); - - let mut hive = Hive::new_from_path(&location, SubCommandModifiers::default()) - .await - .unwrap(); - - assert_matches!( - hive.force_always_local(vec!["non-existant".to_string()]), - Err(HiveLibError::HiveInitializationError( - HiveInitializationError::NodeDoesNotExist(node) - )) if node == "non-existant" - ); - - for node in hive.nodes.values() { - assert!(node.build_remotely); - } - - assert_matches!(hive.force_always_local(vec!["node-a".to_string()]), Ok(())); - - assert!( - !hive - .nodes - .get(&Name("node-a".into())) - .unwrap() - .build_remotely - ); - } }