Skip to content

Commit fc8fd00

Browse files
authored
Merge pull request #67 from cgwalters/bump-oci-spec
Port to oci-spec 0.7
2 parents e741c37 + 87aee3e commit fc8fd00

File tree

5 files changed

+30
-11
lines changed

5 files changed

+30
-11
lines changed

.github/workflows/ci.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ jobs:
4646
- name: Checkout ostree-rs-ext
4747
uses: actions/checkout@v3
4848
with:
49-
repository: ostreedev/ostree-rs-ext
49+
# repository: ostreedev/ostree-rs-ext
50+
# Temporary fork until https://github.com/ostreedev/ostree-rs-ext/pull/663
51+
# is published in a release
52+
repository: jeckersb/ostree-rs-ext
53+
ref: ocidir-0.3
5054
path: ostree-rs-ext
5155
fetch-depth: 20
5256
- name: Test ostree-rs-ext

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn-error-context = "0.2.0"
1414
futures-util = "0.3.13"
1515
# NOTE when bumping this in a semver-incompatible way, because we re-export it you
1616
# must also bump the semver of this project.
17-
oci-spec = "0.6.5"
17+
oci-spec = "0.7.0"
1818
rustix = { version = "0.38", features = ["process", "net"] }
1919
serde = { features = ["derive"], version = "1.0.125" }
2020
serde_json = "1.0.64"

ci/test-ostree-rs-ext.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
set -xeuo pipefail
33
cd ostree-rs-ext
44
./ci/installdeps.sh
5-
cat >> Cargo.toml <<'EOF'
6-
[patch.crates-io]
7-
containers-image-proxy = { path = ".." }
8-
EOF
5+
#cat >> Cargo.toml <<'EOF'
6+
#[patch.crates-io]
7+
#containers-image-proxy = { path = ".." }
8+
#EOF
99
cargo test

examples/client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::io::Write;
22

33
use anyhow::Result;
44
use clap::Parser;
5-
use oci_spec::image::ImageManifest;
5+
use oci_spec::image::{Digest, ImageManifest};
66
use tokio::io::AsyncReadExt;
77

88
#[derive(clap::Parser, Debug)]
@@ -17,7 +17,7 @@ struct GetBlobOpts {
1717
reference: String,
1818

1919
/// The digest of the target blob to fetch
20-
digest: String,
20+
digest: Digest,
2121

2222
/// The size of the blob to fetch
2323
size: u64,

src/imageproxy.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ 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 oci_spec::image::{Descriptor, Digest};
1112
use serde::{Deserialize, Serialize};
1213
use std::fs::File;
1314
use std::ops::Range;
@@ -234,10 +235,10 @@ impl TryFrom<ImageProxyConfig> for Command {
234235
pub struct ConvertedLayerInfo {
235236
/// Uncompressed digest of a layer; for more information, see
236237
/// https://github.com/opencontainers/image-spec/blob/main/config.md#layer-diffid
237-
pub digest: String,
238+
pub digest: Digest,
238239

239240
/// Size of blob
240-
pub size: i64,
241+
pub size: u64,
241242

242243
/// Mediatype of blob
243244
pub media_type: oci_spec::image::MediaType,
@@ -474,7 +475,7 @@ impl ImageProxy {
474475
pub async fn get_blob(
475476
&self,
476477
img: &OpenedImage,
477-
digest: &str,
478+
digest: &Digest,
478479
size: u64,
479480
) -> Result<(
480481
impl AsyncBufRead + Send + Unpin,
@@ -493,6 +494,20 @@ impl ImageProxy {
493494
Ok((fd, finish))
494495
}
495496

497+
/// Fetch a descriptor. The requested size and digest are verified (by the proxy process).
498+
#[instrument]
499+
pub async fn get_descriptor(
500+
&self,
501+
img: &OpenedImage,
502+
descriptor: &Descriptor,
503+
) -> Result<(
504+
impl AsyncBufRead + Send + Unpin,
505+
impl Future<Output = Result<()>> + Unpin + '_,
506+
)> {
507+
self.get_blob(img, descriptor.digest(), descriptor.size())
508+
.await
509+
}
510+
496511
///Returns data that can be used to find the "diffid" corresponding to a particular layer.
497512
#[instrument]
498513
pub async fn get_layer_info(

0 commit comments

Comments
 (0)