Skip to main content

canic_host/release_set/
mod.rs

1//! Release-set discovery, manifest emission, and staging helpers.
2
3use std::time::{SystemTime, UNIX_EPOCH};
4
5mod config;
6mod manifest;
7mod paths;
8mod stage;
9
10pub use config::{
11    AttachedFleetRole, ConfiguredPoolExpectation, ConfiguredRoleLifecycle, DeclaredFleetRole,
12    LOCAL_ROOT_MIN_READY_CYCLES, RenamedFleetRole, attach_fleet_role, configured_bootstrap_roles,
13    configured_controllers, configured_deployable_roles, configured_fleet_name,
14    configured_install_targets, configured_local_root_create_cycles, configured_pool_expectations,
15    configured_release_roles, configured_role_auto_create, configured_role_capabilities,
16    configured_role_details, configured_role_kinds, configured_role_lifecycle,
17    configured_role_metrics_profiles, configured_role_topups, declare_fleet_role,
18    matching_fleet_config_paths, rename_fleet_role,
19};
20pub use manifest::{
21    ReleaseSetEntry, RootReleaseSetManifest, emit_root_release_set_manifest,
22    emit_root_release_set_manifest_if_ready, emit_root_release_set_manifest_with_config,
23    load_root_release_set_manifest,
24};
25pub use paths::{
26    canister_manifest_path, canisters_root, config_path, display_workspace_path, icp_root,
27    load_root_package_version, load_workspace_package_version, resolve_artifact_root,
28    root_manifest_path, root_release_set_manifest_path, workspace_manifest_path, workspace_root,
29};
30use stage::build_release_set_entry;
31pub(crate) use stage::icp_query_on_network;
32pub use stage::{resume_root_bootstrap, stage_root_release_set};
33
34#[cfg(test)]
35use stage::read_release_artifact;
36
37#[cfg(test)]
38use config::{
39    attach_fleet_role_source, configured_bootstrap_roles_from_source,
40    configured_controllers_from_source, configured_deployable_roles_from_source,
41    configured_fleet_name_from_source, configured_local_root_create_cycles_from_source,
42    configured_pool_expectations_from_source, configured_release_roles_from_source,
43    configured_role_auto_create_from_source, configured_role_capabilities_from_source,
44    configured_role_details_from_source, configured_role_kinds_from_source,
45    configured_role_lifecycle_from_source, configured_role_metrics_profiles_from_source,
46    configured_role_topups_from_source, declare_fleet_role_source, rename_fleet_role_source,
47};
48
49pub(super) const CANISTERS_ROOT_RELATIVE: &str = "fleets";
50pub(super) const ROOT_CONFIG_FILE: &str = "canic.toml";
51pub(super) const WORKSPACE_MANIFEST_RELATIVE: &str = "Cargo.toml";
52pub const ROOT_RELEASE_SET_MANIFEST_FILE: &str = "root.release-set.json";
53pub(super) const GZIP_MAGIC: [u8; 2] = [0x1f, 0x8b];
54pub(super) const WASM_MAGIC: [u8; 4] = [0x00, 0x61, 0x73, 0x6d];
55
56// Read the current host wall clock so staged manifests use a stable whole-second
57// timestamp without depending on an exported root time endpoint.
58pub(super) fn root_time_secs(root_canister: &str) -> Result<u64, Box<dyn std::error::Error>> {
59    let _ = root_canister;
60    let now = SystemTime::now()
61        .duration_since(UNIX_EPOCH)
62        .map_err(|err| format!("system clock before unix epoch: {err}"))?;
63    Ok(now.as_secs())
64}
65
66#[cfg(test)]
67mod tests;