Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/imageproxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const MAX_MSG_SIZE: usize = 32 * 1024;
// Introduced in https://github.com/containers/skopeo/pull/1523
static BASE_PROTO_VERSION: Lazy<semver::VersionReq> =
Lazy::new(|| semver::VersionReq::parse("0.2.3").unwrap());
static LAYER_INFO_PROTO_VERSION: Lazy<semver::VersionReq> =
Lazy::new(|| semver::VersionReq::parse("0.2.5").unwrap());

#[derive(Serialize)]
struct Request {
Expand Down Expand Up @@ -192,6 +194,20 @@ impl TryFrom<ImageProxyConfig> for Command {
}
}

/// BlobInfo collects known information about a blob
#[derive(Debug, serde::Deserialize)]
pub struct ConvertedLayerInfo {
/// Uncompressed digest of a layer; for more information, see
/// https://github.com/opencontainers/image-spec/blob/main/config.md#layer-diffid
pub digest: String,

/// Size of blob
pub size: i64,

/// Mediatype of blob
pub media_type: oci_spec::image::MediaType,
}

impl ImageProxy {
/// Create an image proxy that fetches the target image, using default configuration.
pub async fn new() -> Result<Self> {
Expand Down Expand Up @@ -430,6 +446,18 @@ impl ImageProxy {
Ok((fd, finish))
}

///Returns data that can be used to find the "diffid" corresponding to a particular layer.
#[instrument]
pub async fn get_layer_info(&self, img: &OpenedImage) -> Result<Option<Vec<ConvertedLayerInfo>>> {
tracing::debug!("Getting layer info");
if !LAYER_INFO_PROTO_VERSION.matches(&self.protover) {
return Ok(None);
}
let reply = self.impl_request("GetLayerInfo", [img.0]).await?;
let layers: Vec<ConvertedLayerInfo> = reply.0;
Ok(Some(layers))
}

/// Close the connection and wait for the child process to exit successfully.
#[instrument]
pub async fn finalize(self) -> Result<()> {
Expand Down