Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ semver = { version = "1", features = ["serde"] }
uuid = { version = "1", features = ["serde", "v4"] }
chrono = { version = "0.4", features = ["serde"] }
thiserror = "2"
derive_more = { version = "1", default-features = false, features = ["deref", "from", "display"] }
tokio = { version = "1", features = ["full"] }
tokio-util = { version = "0.7", features = ["rt"] }
extism = "1"
Expand Down
2 changes: 1 addition & 1 deletion crates/hm-plugin-docker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ fn run_step(input: ExecutorInput) -> Result<StepResult, PluginError> {
}
})
.collect();
hm_plugin_protocol::SnapshotRef(format!(
hm_plugin_protocol::SnapshotRef::from(format!(
"harmont-local-ephemeral/{safe}:run-{}",
input.step_id.simple()
))
Expand Down
1 change: 1 addition & 0 deletions crates/hm-plugin-protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ semver = { workspace = true }
uuid = { workspace = true }
chrono = { workspace = true }
thiserror = { workspace = true }
derive_more = { workspace = true }

[dev-dependencies]
insta = { version = "1", features = ["json"] }
Expand Down
10 changes: 8 additions & 2 deletions crates/hm-plugin-protocol/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@ use crate::ir::CommandStep;

/// Opaque archive handle. The plugin streams bytes via
/// `hm_archive_read(id, offset, max)`.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, DeriveJsonSchema)]
#[derive(
Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, DeriveJsonSchema,
derive_more::From, derive_more::Deref, derive_more::Display,
)]
#[serde(transparent)]
pub struct ArchiveId(pub Uuid);

/// Opaque snapshot reference. For the docker plugin this is an image
/// tag; other plugins are free to encode their own format. The host
/// never inspects the contents.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, DeriveJsonSchema)]
#[derive(
Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, DeriveJsonSchema,
derive_more::From, derive_more::Deref, derive_more::Display,
)]
#[serde(transparent)]
pub struct SnapshotRef(pub String);

Expand Down
10 changes: 8 additions & 2 deletions crates/hm-plugin-protocol/src/host_abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,19 @@ pub enum KvScope {

/// Opaque socket handle returned by `hm_unix_socket_connect`. Bound
/// to the plugin instance that opened it.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, DeriveJsonSchema)]
#[derive(
Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, DeriveJsonSchema,
derive_more::From, derive_more::Deref, derive_more::Display,
)]
#[serde(transparent)]
pub struct SocketHandle(pub u64);

/// Opaque handle returned by `hm_spawn_loopback`. Bound to the plugin
/// instance.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, DeriveJsonSchema)]
#[derive(
Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, DeriveJsonSchema,
derive_more::From, derive_more::Deref, derive_more::Display,
)]
#[serde(transparent)]
pub struct LoopbackHandle(pub u64);

Expand Down
2 changes: 1 addition & 1 deletion crates/hm/src/orchestrator/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl ArchiveStore {

/// Register a new archive. Returns the freshly-minted ID.
pub fn register(&self, bytes: Vec<u8>) -> ArchiveId {
let id = ArchiveId(Uuid::new_v4());
let id = ArchiveId::from(Uuid::new_v4());
let _ = self.archives.lock().map(|mut m| m.insert(id, bytes));
id
}
Expand Down
4 changes: 2 additions & 2 deletions crates/hm/src/orchestrator/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ pub async fn decide(docker: &DockerClient, step: &CommandStep) -> Result<CacheDe
};
if docker.image_exists(&tag).await? {
Ok(CacheDecision::Hit {
tag: SnapshotRef(tag),
tag: SnapshotRef::from(tag),
})
} else {
Ok(CacheDecision::MissBuildAs {
tag: SnapshotRef(tag),
tag: SnapshotRef::from(tag),
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/hm/src/orchestrator/docker_host_fns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub(crate) async fn extract_workspace_impl(args: DockerExtractArgs) -> Result<()
let s = current().context("no orchestrator state")?;
let archive = s.archives.read(args.archive_id, 0, u64::MAX);
if archive.is_empty() {
anyhow::bail!("archive {} is empty or unknown", args.archive_id.0);
anyhow::bail!("archive {} is empty or unknown", args.archive_id);
}
let cancel = s.cancel.clone();
let docker = s.docker.clone();
Expand Down
Loading