Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
lukewarmtemp committed Sep 25, 2023
1 parent 19d740a commit ed4baf6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ pub(crate) enum ContainerImageOpts {

/// Source image reference, e.g. ostree-remote-image:someremote:registry:quay.io/exampleos/exampleos@sha256:abcd...
/// This conflicts with `--image`.
/// This conflicts with `--image`. Supports `registry:`, `docker://`, `oci:`, `oci-archive:`, `containers-storage:`, and `dir:`
#[clap(long, required_unless_present = "image")]
imgref: Option<String>,

Expand Down
10 changes: 10 additions & 0 deletions lib/src/container/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ pub enum Transport {
OciArchive,
/// Local container storage (`containers-storage:`)
ContainerStorage,
/// Local directory (`dir:`)
Dir,
}

/// Combination of a remote image reference and transport.
Expand Down Expand Up @@ -104,6 +106,7 @@ impl TryFrom<&str> for Transport {
Self::OCI_STR => Self::OciDir,
Self::OCI_ARCHIVE_STR => Self::OciArchive,
Self::CONTAINERS_STORAGE_STR => Self::ContainerStorage,
Self::LOCAL_DIRECTORY_STR => Self::Dir,
o => return Err(anyhow!("Unknown transport '{}'", o)),
})
}
Expand All @@ -113,6 +116,7 @@ impl Transport {
const OCI_STR: &str = "oci";
const OCI_ARCHIVE_STR: &str = "oci-archive";
const CONTAINERS_STORAGE_STR: &str = "containers-storage";
const LOCAL_DIRECTORY_STR: &str = "dir";
const REGISTRY_STR: &str = "registry";

/// Retrieve an identifier that can then be re-parsed from [`Transport::try_from::<&str>`].
Expand All @@ -122,6 +126,7 @@ impl Transport {
Transport::OciDir => Self::OCI_STR,
Transport::OciArchive => Self::OCI_ARCHIVE_STR,
Transport::ContainerStorage => Self::CONTAINERS_STORAGE_STR,
Transport::Dir => Self::LOCAL_DIRECTORY_STR,
}
}
}
Expand Down Expand Up @@ -242,6 +247,7 @@ impl std::fmt::Display for Transport {
Self::OciArchive => "oci-archive:",
Self::OciDir => "oci:",
Self::ContainerStorage => "containers-storage:",
Self::Dir => "dir:",
};
f.write_str(s)
}
Expand Down Expand Up @@ -514,6 +520,10 @@ mod tests {
let ir: ImageReference = "oci:somedir".try_into().unwrap();
assert_eq!(ir.transport, Transport::OciDir);
assert_eq!(ir.name, "somedir");

let ir: ImageReference = "dir:/some/dir/blah".try_into().unwrap();
assert_eq!(ir.transport, Transport::Dir);
assert_eq!(ir.name, "some/dir/blah");
}

#[test]
Expand Down

0 comments on commit ed4baf6

Please sign in to comment.