Skip to content

Commit 10e0fea

Browse files
authored
Merge pull request #64 from cgwalters/bump
Update oci-spec, drop once-cell and libc
2 parents 28155f4 + d71d9c0 commit 10e0fea

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@ license = "MIT OR Apache-2.0"
55
name = "containers-image-proxy"
66
readme = "README.md"
77
repository = "https://github.com/containers/containers-image-proxy-rs"
8-
version = "0.5.8"
8+
version = "0.5.9"
99
rust-version = "1.70.0"
1010

1111
[dependencies]
1212
anyhow = "1.0"
1313
fn-error-context = "0.2.0"
1414
futures-util = "0.3.13"
15-
oci-spec = "0.5.5"
16-
once_cell = "1.9.0"
17-
libc = "0.2"
15+
oci-spec = "0.6.5"
1816
rustix = { version = "0.38", features = ["process", "net"] }
1917
serde = { features = ["derive"], version = "1.0.125" }
2018
serde_json = "1.0.64"

src/imageproxy.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use anyhow::{anyhow, Context, Result};
88
use cap_std_ext::prelude::CapStdExtCommandExt;
99
use cap_std_ext::{cap_std, cap_tempfile};
1010
use futures_util::Future;
11-
use once_cell::sync::Lazy;
1211
use serde::{Deserialize, Serialize};
1312
use std::fs::File;
1413
use std::ops::Range;
@@ -17,7 +16,7 @@ use std::os::unix::prelude::CommandExt;
1716
use std::path::PathBuf;
1817
use std::pin::Pin;
1918
use std::process::{Command, Stdio};
20-
use std::sync::{Arc, Mutex};
19+
use std::sync::{Arc, Mutex, OnceLock};
2120
use tokio::io::{AsyncBufRead, AsyncReadExt};
2221
use tokio::sync::Mutex as AsyncMutex;
2322
use tokio::task::JoinError;
@@ -38,11 +37,16 @@ pub const RESERVED_FD_RANGE: Range<i32> = 100..200;
3837
// Note that payload data (non-metadata) should go over a pipe file descriptor.
3938
const MAX_MSG_SIZE: usize = 32 * 1024;
4039

41-
// Introduced in https://github.com/containers/skopeo/pull/1523
42-
static BASE_PROTO_VERSION: Lazy<semver::VersionReq> =
43-
Lazy::new(|| semver::VersionReq::parse("0.2.3").unwrap());
44-
static LAYER_INFO_PROTO_VERSION: Lazy<semver::VersionReq> =
45-
Lazy::new(|| semver::VersionReq::parse("0.2.5").unwrap());
40+
fn base_proto_version() -> &'static semver::VersionReq {
41+
// Introduced in https://github.com/containers/skopeo/pull/1523
42+
static BASE_PROTO_VERSION: OnceLock<semver::VersionReq> = OnceLock::new();
43+
BASE_PROTO_VERSION.get_or_init(|| semver::VersionReq::parse("0.2.3").unwrap())
44+
}
45+
46+
fn layer_info_proto_version() -> &'static semver::VersionReq {
47+
static LAYER_INFO_PROTO_VERSION: OnceLock<semver::VersionReq> = OnceLock::new();
48+
LAYER_INFO_PROTO_VERSION.get_or_init(|| semver::VersionReq::parse("0.2.5").unwrap())
49+
}
4650

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

0 commit comments

Comments
 (0)