Skip to content

Commit 3014069

Browse files
authored
Merge pull request bootc-dev#620 from albertofaria/docker-archive
Add docker-archive transport
2 parents 62bac42 + 7ecda73 commit 3014069

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/src/container/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ pub enum Transport {
5858
OciDir,
5959
/// A local OCI archive tarball (`oci-archive:`)
6060
OciArchive,
61+
/// A local Docker archive tarball (`docker-archive:`)
62+
DockerArchive,
6163
/// Local container storage (`containers-storage:`)
6264
ContainerStorage,
6365
/// Local directory (`dir:`)
@@ -107,6 +109,7 @@ impl TryFrom<&str> for Transport {
107109
Self::REGISTRY_STR | "docker" => Self::Registry,
108110
Self::OCI_STR => Self::OciDir,
109111
Self::OCI_ARCHIVE_STR => Self::OciArchive,
112+
Self::DOCKER_ARCHIVE_STR => Self::DockerArchive,
110113
Self::CONTAINERS_STORAGE_STR => Self::ContainerStorage,
111114
Self::LOCAL_DIRECTORY_STR => Self::Dir,
112115
o => return Err(anyhow!("Unknown transport '{}'", o)),
@@ -117,6 +120,7 @@ impl TryFrom<&str> for Transport {
117120
impl Transport {
118121
const OCI_STR: &'static str = "oci";
119122
const OCI_ARCHIVE_STR: &'static str = "oci-archive";
123+
const DOCKER_ARCHIVE_STR: &'static str = "docker-archive";
120124
const CONTAINERS_STORAGE_STR: &'static str = "containers-storage";
121125
const LOCAL_DIRECTORY_STR: &'static str = "dir";
122126
const REGISTRY_STR: &'static str = "registry";
@@ -127,6 +131,7 @@ impl Transport {
127131
Transport::Registry => Self::REGISTRY_STR,
128132
Transport::OciDir => Self::OCI_STR,
129133
Transport::OciArchive => Self::OCI_ARCHIVE_STR,
134+
Transport::DockerArchive => Self::DOCKER_ARCHIVE_STR,
130135
Transport::ContainerStorage => Self::CONTAINERS_STORAGE_STR,
131136
Transport::Dir => Self::LOCAL_DIRECTORY_STR,
132137
}
@@ -247,6 +252,7 @@ impl std::fmt::Display for Transport {
247252
// TODO once skopeo supports this, canonicalize as registry:
248253
Self::Registry => "docker://",
249254
Self::OciArchive => "oci-archive:",
255+
Self::DockerArchive => "docker-archive:",
250256
Self::OciDir => "oci:",
251257
Self::ContainerStorage => "containers-storage:",
252258
Self::Dir => "dir:",
@@ -502,6 +508,7 @@ mod tests {
502508
Transport::Registry,
503509
Transport::ContainerStorage,
504510
Transport::OciArchive,
511+
Transport::DockerArchive,
505512
Transport::OciDir,
506513
] {
507514
assert_eq!(Transport::try_from(v.serializable_name()).unwrap(), v);
@@ -551,6 +558,11 @@ mod tests {
551558
transport: Transport::OciArchive,
552559
name: "/path/to/foo.ociarchive",
553560
},
561+
Case {
562+
s: "docker-archive:/path/to/foo.dockerarchive",
563+
transport: Transport::DockerArchive,
564+
name: "/path/to/foo.dockerarchive",
565+
},
554566
Case {
555567
s: "containers-storage:localhost/someimage:blah",
556568
transport: Transport::ContainerStorage,

lib/src/refescape.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,10 @@ mod test {
151151
"localhost:5000/foo:latest",
152152
"fedora/x86_64/coreos",
153153
"/foo/bar/foo.oci-archive",
154+
"/foo/bar/foo.docker-archive",
154155
"docker://quay.io/exampleos/blah:latest",
155156
"oci-archive:/path/to/foo.ociarchive",
157+
"docker-archive:/path/to/foo.dockerarchive",
156158
];
157159
const CORNERCASES: &[&str] = &["/", "blah/", "/foo/"];
158160

0 commit comments

Comments
 (0)