Skip to content

Commit

Permalink
Merge pull request #64 from cgwalters/bump
Browse files Browse the repository at this point in the history
Update oci-spec, drop once-cell and libc
  • Loading branch information
cgwalters authored Jun 3, 2024
2 parents 28155f4 + d71d9c0 commit 10e0fea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
6 changes: 2 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ license = "MIT OR Apache-2.0"
name = "containers-image-proxy"
readme = "README.md"
repository = "https://github.com/containers/containers-image-proxy-rs"
version = "0.5.8"
version = "0.5.9"
rust-version = "1.70.0"

[dependencies]
anyhow = "1.0"
fn-error-context = "0.2.0"
futures-util = "0.3.13"
oci-spec = "0.5.5"
once_cell = "1.9.0"
libc = "0.2"
oci-spec = "0.6.5"
rustix = { version = "0.38", features = ["process", "net"] }
serde = { features = ["derive"], version = "1.0.125" }
serde_json = "1.0.64"
Expand Down
22 changes: 13 additions & 9 deletions src/imageproxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use anyhow::{anyhow, Context, Result};
use cap_std_ext::prelude::CapStdExtCommandExt;
use cap_std_ext::{cap_std, cap_tempfile};
use futures_util::Future;
use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};
use std::fs::File;
use std::ops::Range;
Expand All @@ -17,7 +16,7 @@ use std::os::unix::prelude::CommandExt;
use std::path::PathBuf;
use std::pin::Pin;
use std::process::{Command, Stdio};
use std::sync::{Arc, Mutex};
use std::sync::{Arc, Mutex, OnceLock};
use tokio::io::{AsyncBufRead, AsyncReadExt};
use tokio::sync::Mutex as AsyncMutex;
use tokio::task::JoinError;
Expand All @@ -38,11 +37,16 @@ pub const RESERVED_FD_RANGE: Range<i32> = 100..200;
// Note that payload data (non-metadata) should go over a pipe file descriptor.
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());
fn base_proto_version() -> &'static semver::VersionReq {
// Introduced in https://github.com/containers/skopeo/pull/1523
static BASE_PROTO_VERSION: OnceLock<semver::VersionReq> = OnceLock::new();
BASE_PROTO_VERSION.get_or_init(|| semver::VersionReq::parse("0.2.3").unwrap())
}

fn layer_info_proto_version() -> &'static semver::VersionReq {
static LAYER_INFO_PROTO_VERSION: OnceLock<semver::VersionReq> = OnceLock::new();
LAYER_INFO_PROTO_VERSION.get_or_init(|| semver::VersionReq::parse("0.2.5").unwrap())
}

#[derive(Serialize)]
struct Request {
Expand Down Expand Up @@ -279,7 +283,7 @@ impl ImageProxy {
tracing::debug!("Remote protocol version: {protover}");
let protover = semver::Version::parse(protover.as_str())?;
// Previously we had a feature to opt-in to requiring newer versions using `if cfg!()`.
let supported = &*BASE_PROTO_VERSION;
let supported = base_proto_version();
if !supported.matches(&protover) {
return Err(anyhow!(
"Unsupported protocol version {} (compatible: {})",
Expand Down Expand Up @@ -500,7 +504,7 @@ impl ImageProxy {
img: &OpenedImage,
) -> Result<Option<Vec<ConvertedLayerInfo>>> {
tracing::debug!("Getting layer info");
if !LAYER_INFO_PROTO_VERSION.matches(&self.protover) {
if !layer_info_proto_version().matches(&self.protover) {
return Ok(None);
}
let reply = self.impl_request("GetLayerInfo", [img.0]).await?;
Expand Down

0 comments on commit 10e0fea

Please sign in to comment.