From 188544797c50e840b46d7063ba4550a7e5231bec Mon Sep 17 00:00:00 2001 From: David Arnold Date: Thu, 26 Aug 2021 13:49:35 -0500 Subject: [PATCH 1/2] fix: ignore direnv files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 47e00459..8f96f1ab 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ # # SPDX-License-Identifier: MPL-2.0 +.direnv /target result* /examples/system/bare-system.qcow2 From 86607fb46584735a5c947542657c3bb692f01fce Mon Sep 17 00:00:00 2001 From: David Arnold Date: Sat, 7 Aug 2021 13:45:56 -0500 Subject: [PATCH 2/2] Refactor data to settings (specificity) --- src/cli.rs | 16 ++++++++-------- src/lib.rs | 14 +++++++------- src/{data.rs => settings.rs} | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) rename src/{data.rs => settings.rs} (99%) diff --git a/src/cli.rs b/src/cli.rs index 61890e43..68ac6c97 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -10,7 +10,7 @@ use clap::{ArgMatches, Clap, FromArgMatches}; use crate as deploy; -use self::deploy::{DeployFlake, ParseFlakeError}; +use self::deploy::{DeployFlake, ParseFlakeError, settings}; use futures_util::stream::{StreamExt, TryStreamExt}; use log::{debug, error, info, warn}; use serde::Serialize; @@ -170,7 +170,7 @@ async fn get_deployment_data( supports_flakes: bool, flakes: &[deploy::DeployFlake<'_>], extra_build_args: &[String], -) -> Result, GetDeploymentDataError> { +) -> Result, GetDeploymentDataError> { futures_util::stream::iter(flakes).then(|flake| async move { info!("Evaluating flake in {}", flake.repo); @@ -389,14 +389,14 @@ pub enum RunDeployError { type ToDeploy<'a> = Vec<( &'a deploy::DeployFlake<'a>, - &'a deploy::data::Data, - (&'a str, &'a deploy::data::Node), - (&'a str, &'a deploy::data::Profile), + &'a settings::Root, + (&'a str, &'a settings::Node), + (&'a str, &'a settings::Profile), )>; async fn run_deploy( deploy_flakes: Vec>, - data: Vec, + data: Vec, supports_flakes: bool, check_sigs: bool, interactive: bool, @@ -437,7 +437,7 @@ async fn run_deploy( None => return Err(RunDeployError::NodeNotFound(node_name.clone())), }; - let mut profiles_list: Vec<(&str, &deploy::data::Profile)> = Vec::new(); + let mut profiles_list: Vec<(&str, &settings::Profile)> = Vec::new(); for profile_name in [ node.node_settings.profiles_order.iter().collect(), @@ -466,7 +466,7 @@ async fn run_deploy( let mut l = Vec::new(); for (node_name, node) in &data.nodes { - let mut profiles_list: Vec<(&str, &deploy::data::Profile)> = Vec::new(); + let mut profiles_list: Vec<(&str, &settings::Profile)> = Vec::new(); for profile_name in [ node.node_settings.profiles_order.iter().collect(), diff --git a/src/lib.rs b/src/lib.rs index 981ec1ed..630df179 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -145,7 +145,7 @@ pub fn init_logger( Ok(()) } -pub mod data; +pub mod settings; pub mod deploy; pub mod push; pub mod cli; @@ -312,13 +312,13 @@ fn test_parse_flake() { #[derive(Debug, Clone)] pub struct DeployData<'a> { pub node_name: &'a str, - pub node: &'a data::Node, + pub node: &'a settings::Node, pub profile_name: &'a str, - pub profile: &'a data::Profile, + pub profile: &'a settings::Profile, pub cmd_overrides: &'a CmdOverrides, - pub merged_settings: data::GenericSettings, + pub merged_settings: settings::GenericSettings, pub debug_logs: bool, pub log_dir: Option<&'a str>, @@ -395,10 +395,10 @@ impl<'a> DeployData<'a> { } pub fn make_deploy_data<'a, 's>( - top_settings: &'s data::GenericSettings, - node: &'a data::Node, + top_settings: &'s settings::GenericSettings, + node: &'a settings::Node, node_name: &'a str, - profile: &'a data::Profile, + profile: &'a settings::Profile, profile_name: &'a str, cmd_overrides: &'a CmdOverrides, debug_logs: bool, diff --git a/src/data.rs b/src/settings.rs similarity index 99% rename from src/data.rs rename to src/settings.rs index 6fe7f75f..9ce50a0f 100644 --- a/src/data.rs +++ b/src/settings.rs @@ -66,7 +66,7 @@ pub struct Node { } #[derive(Deserialize, Debug, Clone)] -pub struct Data { +pub struct Root { #[serde(flatten)] pub generic_settings: GenericSettings, pub nodes: HashMap,