Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor data to settings (specificity) I/V #117

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# SPDX-License-Identifier: MPL-2.0

.direnv
/target
result*
/examples/system/bare-system.qcow2
16 changes: 8 additions & 8 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -170,7 +170,7 @@ async fn get_deployment_data(
supports_flakes: bool,
flakes: &[deploy::DeployFlake<'_>],
extra_build_args: &[String],
) -> Result<Vec<deploy::data::Data>, GetDeploymentDataError> {
) -> Result<Vec<settings::Root>, GetDeploymentDataError> {
futures_util::stream::iter(flakes).then(|flake| async move {

info!("Evaluating flake in {}", flake.repo);
Expand Down Expand Up @@ -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<deploy::DeployFlake<'_>>,
data: Vec<deploy::data::Data>,
data: Vec<settings::Root>,
supports_flakes: bool,
check_sigs: bool,
interactive: bool,
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down
14 changes: 7 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ pub fn init_logger(
Ok(())
}

pub mod data;
pub mod settings;
pub mod deploy;
pub mod push;
pub mod cli;
Expand Down Expand Up @@ -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>,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/data.rs → src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Node>,
Expand Down