Skip to content

Commit 9ddcc0a

Browse files
committed
fix: Prioritize oci digest when tag is specified as well
Previously digest was removed and `latest` tag was added if missing. This leads to either failing to download the image (when `latest` is not present), or fetching the possibly wrong image and then failing on digest comparison. New behavior is consistent with `docker pull` - when digest is specified, the tag is disregarded.
1 parent f9d41cf commit 9ddcc0a

1 file changed

Lines changed: 4 additions & 14 deletions

File tree

src/oci.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,27 +53,17 @@ pub(crate) async fn pull_to_cache_dir(
5353
content_digest
5454
} else {
5555
info!("Fetching metadata for {image}");
56-
// Workaround for bug somewhere in `WasmClient::pull_manifest_and_config`
57-
// metadata digest must be removed from Reference, otherwise no matter
58-
// what the pulled image contains, we get the specified digest.
59-
let image_without_digest = Reference::with_tag(
60-
image.registry().to_string(),
61-
image.repository().to_string(),
62-
image.tag().unwrap_or("latest").to_string(),
63-
);
64-
let (_oci_config, wasm_config, metadata_digest) = client
65-
.pull_manifest_and_config(&image_without_digest, &auth)
66-
.instrument(info_span!("pull_manifest_and_config"))
67-
.await?;
56+
let (_oci_config, wasm_config, metadata_digest) =
57+
client.pull_manifest_and_config(image, &auth).await?;
6858
match image.digest() {
6959
None => warn!(
7060
"Consider adding metadata digest to component's `location.oci` configuration: {image}@{metadata_digest}"
7161
),
7262
Some(specified) => {
7363
debug!("Fetched metadata digest {metadata_digest}");
7464
if specified != metadata_digest {
75-
bail!(
76-
"metadata digest mismatch. Specified:\n{image_without_digest}@{specified}\nActually got:\n{image_without_digest}@{metadata_digest}"
65+
unreachable!(
66+
"metadata digest mismatch. Specified: {image}\nActual: {metadata_digest}"
7767
)
7868
}
7969
}

0 commit comments

Comments
 (0)