Skip to content

Commit ce70ccf

Browse files
committed
fix(cmd): sync needed action definitions for chosen pipeline w/ project
1 parent 2d6a231 commit ce70ccf

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

TODO.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
1. [x] For Pipelines
3131
2. [x] For containered builds & runs
3232
3. [x] For Ansible runs
33-
- [ ] Fix issue which causes not to adding actions definitions when using a pipeline from the registry, to the project config
33+
- [x] Fix issue which causes not to adding actions definitions when using a pipeline from the registry, to the project config
3434
- [x] Add `info` field to requirements to inform users about commands or links to install them
3535
- [x] Unify `edit`, `cat` & `rm` commands behavior
3636
- [x] Add possibility to setup variables inside each pipeline independently

src/pipelines.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,16 @@ impl DescribedPipeline {
437437

438438
Ok(cmds)
439439
}
440+
441+
/// Collect needed actions (only those which are found) for running this pipeline.
442+
pub fn collect_actions(&self, definitions: &BTreeSet<DefinedAction>) -> BTreeSet<DefinedAction> {
443+
self
444+
.actions
445+
.iter()
446+
.filter_map(|action| action.definition(definitions).ok())
447+
.cloned()
448+
.collect::<BTreeSet<_>>()
449+
}
440450
}
441451

442452
/// Lists all available Pipelines.
@@ -591,7 +601,7 @@ pub fn cat_project(config: &DeployerProjectOptions, args: CatProjectArgs) -> any
591601
Ok(())
592602
}
593603

594-
/// Tries to assign and setup the Pipeline from Registry.
604+
/// Tries to assign and setup the pipeline from Registry.
595605
///
596606
/// While setup, Deployer checks programming languages, target specs and
597607
/// deploy toolkit to make sure that Pipeline is compatible with your project.
@@ -645,6 +655,9 @@ pub fn assign_pipeline_to_project(
645655
DescribedPipeline::new_from_prompt(globals, &mut config.actions)?
646656
};
647657

658+
let needed_actions = pipeline.collect_actions(&globals.actions_registry);
659+
config.actions = config.actions.union(&needed_actions).cloned().collect();
660+
648661
if config.variables.is_empty() {
649662
println!("Please, specify variables for project first!");
650663
let mut needed = vec![];

0 commit comments

Comments
 (0)