Skip to content

Commit

Permalink
Add new attach_resources recipe (#149)
Browse files Browse the repository at this point in the history
* Add new `attach_resources` recipe

* Fix deadlock in `create_input` when resources form a cycle

* Update `attach_resources` recipe to handle "external" resource references

* Update `attach_resources` using a graph to handle internal references

* Add more verbose error when detecting a cycle in `attach_resources`

* Simplify graph construction in `attach_resources`
  • Loading branch information
kylewlacy authored Dec 21, 2024
1 parent 38a8c06 commit 1369ba1
Show file tree
Hide file tree
Showing 8 changed files with 1,510 additions and 3 deletions.
13 changes: 12 additions & 1 deletion crates/brioche-core/src/bake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use super::{

pub use process::{process_rootfs_recipes, ProcessRootfsRecipes};

mod attach_resources;
mod collect_references;
mod download;
mod process;
Expand Down Expand Up @@ -248,7 +249,7 @@ async fn bake_inner(
let baked = run_bake(&brioche, recipe.value, &meta).await?;

// Send expensive recipes to optionally be synced to
// the registry right afer we baked it
// the registry right after we baked it
if let Some(input_recipe) = input_recipe {
brioche
.sync_tx
Expand Down Expand Up @@ -540,6 +541,16 @@ async fn run_bake(brioche: &Brioche, recipe: Recipe, meta: &Arc<Meta>) -> anyhow

Ok(Artifact::Directory(directory))
}
Recipe::AttachResources { recipe } => {
let artifact = bake(brioche, *recipe, &scope).await?;
let Artifact::Directory(mut directory) = artifact.value else {
anyhow::bail!("tried attaching resources for non-directory artifact");
};

attach_resources::attach_resources(brioche, &mut directory).await?;

Ok(Artifact::Directory(directory))
}
Recipe::Sync { recipe } => {
let result = bake(brioche, *recipe, &scope).await?;
Ok(result.value)
Expand Down
Loading

0 comments on commit 1369ba1

Please sign in to comment.