feat: implement basic workspace
This commit is contained in:
parent
f98b48667c
commit
bd927840d6
2
.env
2
.env
@ -3,3 +3,5 @@ FOREST_S3_BUCKET=forest
|
|||||||
FOREST_S3_REGION=eu-west-1
|
FOREST_S3_REGION=eu-west-1
|
||||||
FOREST_S3_USER=forestadmin
|
FOREST_S3_USER=forestadmin
|
||||||
FOREST_S3_PASSWORD=forestadmin
|
FOREST_S3_PASSWORD=forestadmin
|
||||||
|
|
||||||
|
FOREST_LOG_LEVEL=forest=trace
|
||||||
|
@ -6,7 +6,7 @@ use kdl::KdlDocument;
|
|||||||
use rusty_s3::{Bucket, Credentials, S3Action};
|
use rusty_s3::{Bucket, Credentials, S3Action};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
model::{Context, Plan, Project},
|
model::{Context, ForestFile, Plan},
|
||||||
plan_reconciler::PlanReconciler,
|
plan_reconciler::PlanReconciler,
|
||||||
state::SharedState,
|
state::SharedState,
|
||||||
};
|
};
|
||||||
@ -80,7 +80,13 @@ pub async fn execute() -> anyhow::Result<()> {
|
|||||||
let project_file = tokio::fs::read_to_string(&project_file_path).await?;
|
let project_file = tokio::fs::read_to_string(&project_file_path).await?;
|
||||||
let project_doc: KdlDocument = project_file.parse()?;
|
let project_doc: KdlDocument = project_file.parse()?;
|
||||||
|
|
||||||
let project: Project = project_doc.try_into()?;
|
let project: ForestFile = project_doc.try_into()?;
|
||||||
|
|
||||||
|
match project {
|
||||||
|
ForestFile::Workspace(workspace) => {
|
||||||
|
tracing::trace!("running as workspace")
|
||||||
|
}
|
||||||
|
ForestFile::Project(project) => {
|
||||||
tracing::trace!("found a project name: {}", project.name);
|
tracing::trace!("found a project name: {}", project.name);
|
||||||
|
|
||||||
let plan = if let Some(plan_file_path) = PlanReconciler::new()
|
let plan = if let Some(plan_file_path) = PlanReconciler::new()
|
||||||
@ -159,6 +165,8 @@ pub async fn execute() -> anyhow::Result<()> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use std::{collections::BTreeMap, path::Path};
|
use std::path::Path;
|
||||||
|
|
||||||
use crate::{model::Context, script::ScriptExecutor};
|
use crate::{model::Context, script::ScriptExecutor};
|
||||||
|
|
||||||
|
@ -372,3 +372,40 @@ impl TryFrom<KdlDocument> for Project {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize)]
|
||||||
|
pub struct Workspace {}
|
||||||
|
|
||||||
|
impl TryFrom<KdlDocument> for Workspace {
|
||||||
|
type Error = anyhow::Error;
|
||||||
|
|
||||||
|
fn try_from(value: KdlDocument) -> Result<Self, Self::Error> {
|
||||||
|
Ok(Self {})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize)]
|
||||||
|
pub enum ForestFile {
|
||||||
|
Workspace(Workspace),
|
||||||
|
Project(Project),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TryFrom<KdlDocument> for ForestFile {
|
||||||
|
type Error = anyhow::Error;
|
||||||
|
|
||||||
|
fn try_from(value: KdlDocument) -> Result<Self, Self::Error> {
|
||||||
|
if value.get("workspace").is_some() && value.get("project").is_some() {
|
||||||
|
anyhow::bail!("a forest.kdl file cannot contain both a workspace and project")
|
||||||
|
}
|
||||||
|
|
||||||
|
if value.get("project").is_some() {
|
||||||
|
return Ok(Self::Project(value.try_into()?));
|
||||||
|
}
|
||||||
|
|
||||||
|
if value.get("workspace").is_some() {
|
||||||
|
return Ok(Self::Workspace(value.try_into()?));
|
||||||
|
}
|
||||||
|
|
||||||
|
anyhow::bail!("a forest.kdl file must be either a project, workspace or plan")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2,7 +2,7 @@ use std::path::{Path, PathBuf};
|
|||||||
|
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
|
|
||||||
use crate::model::Project;
|
use crate::model::{ForestFile, Project};
|
||||||
|
|
||||||
pub mod git;
|
pub mod git;
|
||||||
pub mod local;
|
pub mod local;
|
||||||
|
9
examples/workspace/forest.kdl
Normal file
9
examples/workspace/forest.kdl
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
workspace {
|
||||||
|
members {
|
||||||
|
member "./projects/a"
|
||||||
|
member "./projects/b"
|
||||||
|
member "./plan/a"
|
||||||
|
member "./plan/b"
|
||||||
|
member "./components/*"
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user