Skip to content

Commit 86607fb

Browse files
committedAug 26, 2021
Refactor data to settings (specificity)
1 parent 1885447 commit 86607fb

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed
 

‎src/cli.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use clap::{ArgMatches, Clap, FromArgMatches};
1010

1111
use crate as deploy;
1212

13-
use self::deploy::{DeployFlake, ParseFlakeError};
13+
use self::deploy::{DeployFlake, ParseFlakeError, settings};
1414
use futures_util::stream::{StreamExt, TryStreamExt};
1515
use log::{debug, error, info, warn};
1616
use serde::Serialize;
@@ -170,7 +170,7 @@ async fn get_deployment_data(
170170
supports_flakes: bool,
171171
flakes: &[deploy::DeployFlake<'_>],
172172
extra_build_args: &[String],
173-
) -> Result<Vec<deploy::data::Data>, GetDeploymentDataError> {
173+
) -> Result<Vec<settings::Root>, GetDeploymentDataError> {
174174
futures_util::stream::iter(flakes).then(|flake| async move {
175175

176176
info!("Evaluating flake in {}", flake.repo);
@@ -389,14 +389,14 @@ pub enum RunDeployError {
389389

390390
type ToDeploy<'a> = Vec<(
391391
&'a deploy::DeployFlake<'a>,
392-
&'a deploy::data::Data,
393-
(&'a str, &'a deploy::data::Node),
394-
(&'a str, &'a deploy::data::Profile),
392+
&'a settings::Root,
393+
(&'a str, &'a settings::Node),
394+
(&'a str, &'a settings::Profile),
395395
)>;
396396

397397
async fn run_deploy(
398398
deploy_flakes: Vec<deploy::DeployFlake<'_>>,
399-
data: Vec<deploy::data::Data>,
399+
data: Vec<settings::Root>,
400400
supports_flakes: bool,
401401
check_sigs: bool,
402402
interactive: bool,
@@ -437,7 +437,7 @@ async fn run_deploy(
437437
None => return Err(RunDeployError::NodeNotFound(node_name.clone())),
438438
};
439439

440-
let mut profiles_list: Vec<(&str, &deploy::data::Profile)> = Vec::new();
440+
let mut profiles_list: Vec<(&str, &settings::Profile)> = Vec::new();
441441

442442
for profile_name in [
443443
node.node_settings.profiles_order.iter().collect(),
@@ -466,7 +466,7 @@ async fn run_deploy(
466466
let mut l = Vec::new();
467467

468468
for (node_name, node) in &data.nodes {
469-
let mut profiles_list: Vec<(&str, &deploy::data::Profile)> = Vec::new();
469+
let mut profiles_list: Vec<(&str, &settings::Profile)> = Vec::new();
470470

471471
for profile_name in [
472472
node.node_settings.profiles_order.iter().collect(),

‎src/lib.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ pub fn init_logger(
145145
Ok(())
146146
}
147147

148-
pub mod data;
148+
pub mod settings;
149149
pub mod deploy;
150150
pub mod push;
151151
pub mod cli;
@@ -312,13 +312,13 @@ fn test_parse_flake() {
312312
#[derive(Debug, Clone)]
313313
pub struct DeployData<'a> {
314314
pub node_name: &'a str,
315-
pub node: &'a data::Node,
315+
pub node: &'a settings::Node,
316316
pub profile_name: &'a str,
317-
pub profile: &'a data::Profile,
317+
pub profile: &'a settings::Profile,
318318

319319
pub cmd_overrides: &'a CmdOverrides,
320320

321-
pub merged_settings: data::GenericSettings,
321+
pub merged_settings: settings::GenericSettings,
322322

323323
pub debug_logs: bool,
324324
pub log_dir: Option<&'a str>,
@@ -395,10 +395,10 @@ impl<'a> DeployData<'a> {
395395
}
396396

397397
pub fn make_deploy_data<'a, 's>(
398-
top_settings: &'s data::GenericSettings,
399-
node: &'a data::Node,
398+
top_settings: &'s settings::GenericSettings,
399+
node: &'a settings::Node,
400400
node_name: &'a str,
401-
profile: &'a data::Profile,
401+
profile: &'a settings::Profile,
402402
profile_name: &'a str,
403403
cmd_overrides: &'a CmdOverrides,
404404
debug_logs: bool,

‎src/data.rs ‎src/settings.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pub struct Node {
6666
}
6767

6868
#[derive(Deserialize, Debug, Clone)]
69-
pub struct Data {
69+
pub struct Root {
7070
#[serde(flatten)]
7171
pub generic_settings: GenericSettings,
7272
pub nodes: HashMap<String, Node>,

0 commit comments

Comments
 (0)