Skip to content

Commit

Permalink
Refactor data to settings (specificity)
Browse files Browse the repository at this point in the history
  • Loading branch information
blaggacao committed Aug 26, 2021
1 parent 1885447 commit 86607fb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
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

0 comments on commit 86607fb

Please sign in to comment.