Skip to content

Commit

Permalink
Move shims registry.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Oct 26, 2024
1 parent b1cfa6e commit 9c9ff09
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions crates/core/src/flow/link.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::shim_registry::{Shim, ShimRegistry, ShimsMap};
use crate::layout::{Shim, ShimRegistry, ShimsMap};
use crate::tool::Tool;
use miette::IntoDiagnostic;
use proto_pdk_api::*;
Expand Down Expand Up @@ -92,7 +92,7 @@ impl Tool {
);
}

ShimRegistry::update(&self.proto, registry)?;
ShimRegistry::update(&self.proto.store.shims_dir, registry)?;
}

Ok(())
Expand Down
2 changes: 2 additions & 0 deletions crates/core/src/layout/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
mod bin_manager;
mod inventory;
mod product;
mod shim_registry;
mod store;

pub use bin_manager::*;
pub use inventory::*;
pub use product::*;
pub use shim_registry::*;
pub use store::*;
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::helpers::{read_json_file_with_lock, write_json_file_with_lock};
use crate::proto::ProtoEnvironment;
use rustc_hash::FxHashMap;
use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
use std::path::Path;

#[derive(Default, Deserialize, PartialEq, Serialize)]
#[serde(default)]
Expand All @@ -28,12 +28,12 @@ pub type ShimsMap = BTreeMap<String, Shim>;
pub struct ShimRegistry;

impl ShimRegistry {
pub fn update<P: AsRef<ProtoEnvironment>>(proto: P, entries: ShimsMap) -> miette::Result<()> {
pub fn update(shims_dir: &Path, entries: ShimsMap) -> miette::Result<()> {
if entries.is_empty() {
return Ok(());
}

let file = proto.as_ref().store.shims_dir.join("registry.json");
let file = shims_dir.join("registry.json");

let mut config: ShimsMap = if file.exists() {
read_json_file_with_lock(&file)?
Expand Down
1 change: 0 additions & 1 deletion crates/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ pub mod layout;
mod proto;
mod proto_config;
pub mod registry;
mod shim_registry;
mod tool;
mod tool_loader;
mod tool_manifest;
Expand Down

0 comments on commit 9c9ff09

Please sign in to comment.