Skip to content

Pass the image layers as a Vector #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
22 changes: 11 additions & 11 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ impl Client {
self.validate_layers(&manifest, accepted_media_types)
.await?;

let layers = stream::iter(&manifest.layers)
let layers = stream::iter(manifest.layers.clone())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a clone of the descriptors, not the actual layers.

.map(|layer| {
// This avoids moving `self` which is &mut Self
// into the async block. We only want to capture
Expand Down Expand Up @@ -322,7 +322,7 @@ impl Client {
pub async fn push(
&mut self,
image_ref: &Reference,
layers: &[ImageLayer],
layers: Vec<ImageLayer>,
config: Config,
auth: &RegistryAuth,
manifest: Option<OciImageManifest>,
Expand All @@ -335,7 +335,7 @@ impl Client {

let manifest: OciImageManifest = match manifest {
Some(m) => m,
None => OciImageManifest::build(layers, &config, None),
None => OciImageManifest::build(layers.as_ref(), &config, None),
};

// Upload layers
Expand Down Expand Up @@ -2331,9 +2331,12 @@ mod test {
.await
.expect("authenticated");

let layers_len = image_data.layers.len();
let layer_1_data_len = image_data.layers[0].data.len();
let layer_1_data = image_data.layers[0].data.clone();
c.push(
&push_image,
&image_data.layers,
image_data.layers,
image_data.config.clone(),
registry_auth,
Some(manifest.clone()),
Expand All @@ -2355,13 +2358,10 @@ mod test {
.await
.expect("failed to pull pushed image manifest");

assert!(image_data.layers.len() == 1);
assert!(layers_len == 1);
assert!(pulled_image_data.layers.len() == 1);
assert_eq!(
image_data.layers[0].data.len(),
pulled_image_data.layers[0].data.len()
);
assert_eq!(image_data.layers[0].data, pulled_image_data.layers[0].data);
assert_eq!(layer_1_data_len, pulled_image_data.layers[0].data.len());
assert_eq!(layer_1_data, pulled_image_data.layers[0].data);

assert_eq!(manifest.media_type, pulled_manifest.media_type);
assert_eq!(manifest.schema_version, pulled_manifest.schema_version);
Expand Down Expand Up @@ -2440,7 +2440,7 @@ mod test {
} = image;
c.push(
&dest_image,
&layers,
layers,
config,
&RegistryAuth::Anonymous,
manifest,
Expand Down