use serde::Deserialize;
pub use crate::remote_image::{ImageReference, RemoteIndex, RemoteLocation};
pub const DEFAULT_IMAGE_BASE: &str = "https://image.arcboxcdn.com/darwin";
pub const IMAGE_BASE_ENV: &str = "ARCBOX_MACOS_IMAGE_BASE";
#[must_use]
pub fn image_base() -> RemoteLocation {
let base = std::env::var(IMAGE_BASE_ENV).unwrap_or_else(|_| DEFAULT_IMAGE_BASE.to_string());
RemoteLocation::parse(&base)
}
#[derive(Debug, Deserialize)]
pub struct ImageManifest {
pub schema_version: u32,
pub name: String,
pub version: String,
#[serde(default)]
#[allow(dead_code, reason = "published schema field; not yet surfaced locally")]
pub variant: String,
pub os: OsInfo,
#[serde(default)]
pub runner_version: Option<String>,
#[serde(default)]
#[allow(dead_code, reason = "published schema field; not yet surfaced locally")]
pub xcode: Vec<String>,
pub hardware_model: String,
pub machine_id: String,
pub minimum_cpu_count: u64,
pub minimum_memory_mib: u64,
pub disk: DiskManifest,
pub aux: RemoteFile,
}
#[derive(Debug, Deserialize)]
pub struct OsInfo {
pub product_version: String,
#[serde(default)]
pub build: String,
}
#[derive(Debug, Deserialize)]
pub struct RemoteFile {
pub path: String,
pub uncompressed_size: u64,
pub compressed_size: u64,
pub sha256: String,
}
#[derive(Debug, Deserialize)]
pub struct DiskManifest {
pub disk_format: String,
pub uncompressed_size: u64,
pub chunk_size: u64,
pub chunks: Vec<DiskChunk>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct DiskChunk {
pub path: String,
pub size: u64,
pub sha256: String,
}