Skip to content

Commit

Permalink
Merge pull request #620 from albertofaria/docker-archive
Browse files Browse the repository at this point in the history
Add docker-archive transport
  • Loading branch information
cgwalters committed Apr 28, 2024
2 parents 62bac42 + 7ecda73 commit 3014069
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/src/container/mod.rs
Expand Up @@ -58,6 +58,8 @@ pub enum Transport {
OciDir,
/// A local OCI archive tarball (`oci-archive:`)
OciArchive,
/// A local Docker archive tarball (`docker-archive:`)
DockerArchive,
/// Local container storage (`containers-storage:`)
ContainerStorage,
/// Local directory (`dir:`)
Expand Down Expand Up @@ -107,6 +109,7 @@ impl TryFrom<&str> for Transport {
Self::REGISTRY_STR | "docker" => Self::Registry,
Self::OCI_STR => Self::OciDir,
Self::OCI_ARCHIVE_STR => Self::OciArchive,
Self::DOCKER_ARCHIVE_STR => Self::DockerArchive,
Self::CONTAINERS_STORAGE_STR => Self::ContainerStorage,
Self::LOCAL_DIRECTORY_STR => Self::Dir,
o => return Err(anyhow!("Unknown transport '{}'", o)),
Expand All @@ -117,6 +120,7 @@ impl TryFrom<&str> for Transport {
impl Transport {
const OCI_STR: &'static str = "oci";
const OCI_ARCHIVE_STR: &'static str = "oci-archive";
const DOCKER_ARCHIVE_STR: &'static str = "docker-archive";
const CONTAINERS_STORAGE_STR: &'static str = "containers-storage";
const LOCAL_DIRECTORY_STR: &'static str = "dir";
const REGISTRY_STR: &'static str = "registry";
Expand All @@ -127,6 +131,7 @@ impl Transport {
Transport::Registry => Self::REGISTRY_STR,
Transport::OciDir => Self::OCI_STR,
Transport::OciArchive => Self::OCI_ARCHIVE_STR,
Transport::DockerArchive => Self::DOCKER_ARCHIVE_STR,
Transport::ContainerStorage => Self::CONTAINERS_STORAGE_STR,
Transport::Dir => Self::LOCAL_DIRECTORY_STR,
}
Expand Down Expand Up @@ -247,6 +252,7 @@ impl std::fmt::Display for Transport {
// TODO once skopeo supports this, canonicalize as registry:
Self::Registry => "docker://",
Self::OciArchive => "oci-archive:",
Self::DockerArchive => "docker-archive:",
Self::OciDir => "oci:",
Self::ContainerStorage => "containers-storage:",
Self::Dir => "dir:",
Expand Down Expand Up @@ -502,6 +508,7 @@ mod tests {
Transport::Registry,
Transport::ContainerStorage,
Transport::OciArchive,
Transport::DockerArchive,
Transport::OciDir,
] {
assert_eq!(Transport::try_from(v.serializable_name()).unwrap(), v);
Expand Down Expand Up @@ -551,6 +558,11 @@ mod tests {
transport: Transport::OciArchive,
name: "/path/to/foo.ociarchive",
},
Case {
s: "docker-archive:/path/to/foo.dockerarchive",
transport: Transport::DockerArchive,
name: "/path/to/foo.dockerarchive",
},
Case {
s: "containers-storage:localhost/someimage:blah",
transport: Transport::ContainerStorage,
Expand Down
2 changes: 2 additions & 0 deletions lib/src/refescape.rs
Expand Up @@ -151,8 +151,10 @@ mod test {
"localhost:5000/foo:latest",
"fedora/x86_64/coreos",
"/foo/bar/foo.oci-archive",
"/foo/bar/foo.docker-archive",
"docker://quay.io/exampleos/blah:latest",
"oci-archive:/path/to/foo.ociarchive",
"docker-archive:/path/to/foo.dockerarchive",
];
const CORNERCASES: &[&str] = &["/", "blah/", "/foo/"];

Expand Down

0 comments on commit 3014069

Please sign in to comment.