#![deny(unsafe_code)]
#![allow(missing_docs)]
#![allow(
clippy::needless_pass_by_value,
clippy::module_name_repetitions,
clippy::collapsible_if,
clippy::collapsible_match
)]
pub mod file;
pub mod hf;
pub mod image_ref;
pub mod ipfs;
pub mod oci;
pub mod registry;
pub mod s3;
pub mod sign;
pub use file::FileRegistry;
pub use hf::HfRegistry;
pub use image_ref::{ImageRef, ImageRefError};
pub use ipfs::IpfsRegistry;
pub use oci::OciRegistry;
pub use registry::{LayerSet, Registry, RegistryError};
pub use s3::S3Registry;
pub use sign::{ManifestSignature, sign_manifest, verify_manifest};
pub fn open(
image_ref: &ImageRef,
auth: &std::collections::BTreeMap<String, String>,
) -> Result<Box<dyn Registry>, RegistryError> {
match image_ref {
ImageRef::File { .. } => Ok(Box::new(FileRegistry::new())),
ImageRef::Hf { .. } => Ok(Box::new(HfRegistry::new(auth.get("HF_TOKEN").cloned()))),
ImageRef::S3 { .. } => Ok(Box::new(S3Registry::new(auth.clone()))),
ImageRef::Ipfs { .. } => Ok(Box::new(IpfsRegistry::new(
auth.get("IPFS_API")
.cloned()
.unwrap_or_else(|| "http://127.0.0.1:5001".into()),
))),
ImageRef::Oci { .. } => Ok(Box::new(OciRegistry::new(auth.clone()))),
}
}