2024-04-15 10:24:14 -07:00
|
|
|
use std::path::PathBuf;
|
|
|
|
|
2024-04-16 01:53:44 -07:00
|
|
|
use crate::schema::OciSchema;
|
|
|
|
|
2024-04-15 10:24:14 -07:00
|
|
|
use self::backend::OciPackerBackendType;
|
|
|
|
use oci_spec::image::{ImageConfiguration, ImageManifest};
|
|
|
|
|
|
|
|
pub mod backend;
|
|
|
|
pub mod cache;
|
|
|
|
pub mod service;
|
|
|
|
|
2024-04-16 01:53:44 -07:00
|
|
|
#[derive(Debug, Default, Clone, Copy, Eq, PartialEq, Hash)]
|
2024-04-15 10:24:14 -07:00
|
|
|
pub enum OciPackedFormat {
|
|
|
|
#[default]
|
|
|
|
Squashfs,
|
|
|
|
Erofs,
|
2024-04-16 01:53:44 -07:00
|
|
|
Tar,
|
2024-04-15 10:24:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
impl OciPackedFormat {
|
|
|
|
pub fn extension(&self) -> &str {
|
|
|
|
match self {
|
|
|
|
OciPackedFormat::Squashfs => "squashfs",
|
|
|
|
OciPackedFormat::Erofs => "erofs",
|
2024-04-16 01:53:44 -07:00
|
|
|
OciPackedFormat::Tar => "tar",
|
2024-04-15 10:24:14 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn backend(&self) -> OciPackerBackendType {
|
|
|
|
match self {
|
|
|
|
OciPackedFormat::Squashfs => OciPackerBackendType::MkSquashfs,
|
|
|
|
OciPackedFormat::Erofs => OciPackerBackendType::MkfsErofs,
|
2024-04-16 01:53:44 -07:00
|
|
|
OciPackedFormat::Tar => OciPackerBackendType::Tar,
|
2024-04-15 10:24:14 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone)]
|
2024-04-16 01:53:44 -07:00
|
|
|
pub struct OciPackedImage {
|
2024-04-15 10:24:14 -07:00
|
|
|
pub digest: String,
|
|
|
|
pub path: PathBuf,
|
|
|
|
pub format: OciPackedFormat,
|
2024-04-16 01:53:44 -07:00
|
|
|
pub config: OciSchema<ImageConfiguration>,
|
|
|
|
pub manifest: OciSchema<ImageManifest>,
|
2024-04-15 10:24:14 -07:00
|
|
|
}
|
|
|
|
|
2024-04-16 01:53:44 -07:00
|
|
|
impl OciPackedImage {
|
2024-04-15 10:24:14 -07:00
|
|
|
pub fn new(
|
|
|
|
digest: String,
|
|
|
|
path: PathBuf,
|
|
|
|
format: OciPackedFormat,
|
2024-04-16 01:53:44 -07:00
|
|
|
config: OciSchema<ImageConfiguration>,
|
|
|
|
manifest: OciSchema<ImageManifest>,
|
|
|
|
) -> OciPackedImage {
|
|
|
|
OciPackedImage {
|
2024-04-15 10:24:14 -07:00
|
|
|
digest,
|
|
|
|
path,
|
|
|
|
format,
|
|
|
|
config,
|
|
|
|
manifest,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|