@@ -1,6 +1,7 @@
|
||||
use validated_project::Project;
|
||||
|
||||
use crate::{
|
||||
actions::Actions,
|
||||
plan::{self, ClonedPlan, PlanPathExt},
|
||||
project::{self, ProjectPlan},
|
||||
schema_validator::SchemaValidator,
|
||||
@@ -42,6 +43,7 @@ impl State {
|
||||
Ok(ValidatedState {
|
||||
project: Some(project),
|
||||
plan: None,
|
||||
actions: LocalActions::default(),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -55,6 +57,51 @@ pub struct RawState {
|
||||
pub struct ValidatedState {
|
||||
pub project: Option<Project>,
|
||||
pub plan: Option<Plan>,
|
||||
|
||||
pub actions: LocalActions,
|
||||
}
|
||||
|
||||
impl ValidatedState {
|
||||
pub(crate) async fn build_actions(&mut self) -> anyhow::Result<&mut Self> {
|
||||
tracing::debug!("building actions");
|
||||
|
||||
if let Some(project) = &self.project {
|
||||
if let Some(actions) = Actions::new(&project.root, &project.value).await? {
|
||||
self.actions.add(actions);
|
||||
}
|
||||
}
|
||||
|
||||
self.actions.build().await?;
|
||||
|
||||
Ok(self)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Plan {}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct LocalActions(Vec<Actions>);
|
||||
|
||||
impl LocalActions {
|
||||
pub fn add(&mut self, actions: Actions) -> &mut Self {
|
||||
self.0.push(actions);
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub async fn build(&mut self) -> anyhow::Result<&mut Self> {
|
||||
for actions in &mut self.0 {
|
||||
actions.build().await?;
|
||||
}
|
||||
|
||||
Ok(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Deref for LocalActions {
|
||||
type Target = Vec<Actions>;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user