Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ jobs:
- name: Checkout ostree-rs-ext
uses: actions/checkout@v3
with:
repository: ostreedev/ostree-rs-ext
# repository: ostreedev/ostree-rs-ext
# Temporary fork until https://github.com/ostreedev/ostree-rs-ext/pull/663
# is published in a release
repository: jeckersb/ostree-rs-ext
ref: ocidir-0.3
path: ostree-rs-ext
fetch-depth: 20
- name: Test ostree-rs-ext
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn-error-context = "0.2.0"
futures-util = "0.3.13"
# NOTE when bumping this in a semver-incompatible way, because we re-export it you
# must also bump the semver of this project.
oci-spec = "0.6.5"
oci-spec = "0.7.0"
rustix = { version = "0.38", features = ["process", "net"] }
serde = { features = ["derive"], version = "1.0.125" }
serde_json = "1.0.64"
Expand Down
8 changes: 4 additions & 4 deletions ci/test-ostree-rs-ext.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
set -xeuo pipefail
cd ostree-rs-ext
./ci/installdeps.sh
cat >> Cargo.toml <<'EOF'
[patch.crates-io]
containers-image-proxy = { path = ".." }
EOF
#cat >> Cargo.toml <<'EOF'
#[patch.crates-io]
#containers-image-proxy = { path = ".." }
#EOF
cargo test
4 changes: 2 additions & 2 deletions examples/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::io::Write;

use anyhow::Result;
use clap::Parser;
use oci_spec::image::ImageManifest;
use oci_spec::image::{Digest, ImageManifest};
use tokio::io::AsyncReadExt;

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

/// The digest of the target blob to fetch
digest: String,
digest: Digest,

/// The size of the blob to fetch
size: u64,
Expand Down
21 changes: 18 additions & 3 deletions src/imageproxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use anyhow::{anyhow, Context, Result};
use cap_std_ext::prelude::CapStdExtCommandExt;
use cap_std_ext::{cap_std, cap_tempfile};
use futures_util::Future;
use oci_spec::image::{Descriptor, Digest};
use serde::{Deserialize, Serialize};
use std::fs::File;
use std::ops::Range;
Expand Down Expand Up @@ -234,10 +235,10 @@ impl TryFrom<ImageProxyConfig> for Command {
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,
pub digest: Digest,

/// Size of blob
pub size: i64,
pub size: u64,

/// Mediatype of blob
pub media_type: oci_spec::image::MediaType,
Expand Down Expand Up @@ -474,7 +475,7 @@ impl ImageProxy {
pub async fn get_blob(
&self,
img: &OpenedImage,
digest: &str,
digest: &Digest,
size: u64,
) -> Result<(
impl AsyncBufRead + Send + Unpin,
Expand All @@ -493,6 +494,20 @@ impl ImageProxy {
Ok((fd, finish))
}

/// Fetch a descriptor. The requested size and digest are verified (by the proxy process).
#[instrument]
pub async fn get_descriptor(
&self,
img: &OpenedImage,
descriptor: &Descriptor,
) -> Result<(
impl AsyncBufRead + Send + Unpin,
impl Future<Output = Result<()>> + Unpin + '_,
)> {
self.get_blob(img, descriptor.digest(), descriptor.size())
.await
}

///Returns data that can be used to find the "diffid" corresponding to a particular layer.
#[instrument]
pub async fn get_layer_info(
Expand Down