-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
skopeo: add a helper method for inspecting a container image
This is basically the same thing as in podman.rs, just for skopeo (and without escaping the mount namespace). Signed-off-by: Ondřej Budai <[email protected]>
- Loading branch information
1 parent
aa4b811
commit 8122dd5
Showing
2 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use std::process::Command; | ||
use anyhow::Result; | ||
use serde::Deserialize; | ||
|
||
#[derive(Deserialize)] | ||
#[serde(rename_all = "PascalCase")] | ||
pub(crate) struct Inspect { | ||
pub(crate) digest: String, | ||
} | ||
|
||
/// Given an image ID, return its manifest digest | ||
pub(crate) fn oci_archive_digest(imageref: &str) -> Result<String> { | ||
let o = Command::new("skopeo") | ||
.args(["inspect", imageref]) | ||
.output().expect("running skopeo"); | ||
let st = o.status; | ||
if !st.success() { | ||
anyhow::bail!("Failed to execute skopeo inspect: {st:?}"); | ||
} | ||
let i: Inspect = serde_json::from_slice(&o.stdout)?; | ||
Ok(i.digest) | ||
} |