use serde::{Deserialize, Serialize};
pub const MEDIA_TYPE_MANIFEST_V2: &str = "application/vnd.docker.distribution.manifest.v2+json";
pub const MEDIA_TYPE_MANIFEST_LIST: &str =
"application/vnd.docker.distribution.manifest.list.v2+json";
pub const MEDIA_TYPE_OCI_MANIFEST: &str = "application/vnd.oci.image.manifest.v1+json";
pub const MEDIA_TYPE_OCI_INDEX: &str = "application/vnd.oci.image.index.v1+json";
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ImageManifest {
pub schema_version: u32,
#[serde(default)]
pub media_type: String,
pub config: Descriptor,
pub layers: Vec<Descriptor>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ManifestList {
pub schema_version: u32,
pub media_type: String,
pub manifests: Vec<PlatformManifest>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PlatformManifest {
pub media_type: String,
pub digest: String,
pub size: u64,
pub platform: Platform,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Platform {
pub architecture: String,
pub os: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub variant: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Descriptor {
pub media_type: String,
pub digest: String,
pub size: u64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ImageConfig {
pub architecture: String,
pub os: String,
pub config: ContainerConfigSpec,
pub rootfs: RootFs,
pub history: Vec<History>,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
pub struct ContainerConfigSpec {
pub user: Option<String>,
pub exposed_ports: Option<std::collections::HashMap<String, serde_json::Value>>,
pub env: Option<Vec<String>>,
pub entrypoint: Option<Vec<String>>,
pub cmd: Option<Vec<String>>,
pub volumes: Option<std::collections::HashMap<String, serde_json::Value>>,
pub working_dir: Option<String>,
pub labels: Option<std::collections::HashMap<String, String>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RootFs {
#[serde(rename = "type")]
pub fs_type: String,
pub diff_ids: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct History {
pub created: Option<String>,
pub created_by: Option<String>,
pub empty_layer: Option<bool>,
pub comment: Option<String>,
}