Skip to content

Commit

Permalink
fix: accumulate image manifests in oci_image_index
Browse files Browse the repository at this point in the history
In the recent #386, when we replaced use of the "yq" tool with the
"jq" tool, we translated the "oci_image_index" rule's accumulation of
image manifests incorrectly, such that we lose all but the last index
that we add to the index.

In "jq", the "update-assignment" operator (|=) does not append to an
array supplied as its left-hand context value automatically. Instead,
one must use a "complex assignment", mentioning the context value
explicitly together with the addition operator.
  • Loading branch information
seh committed Jun 20, 2024
1 parent 464858a commit d96429a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/multi_architecture_image/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ genrule(
assert_contains(
name = "check_digest",
actual = ":hash",
expected = "sha256:9163db354e086c5ef0170ce0ec318312dde887f660552c4a438926863d473d3c",
expected = "sha256:9cc41e3583d5385aa6adc686c15f4e4625ec46fceabde54146add048aa95e716",
)
2 changes: 1 addition & 1 deletion oci/private/image_index.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function add_image() {
local platform=$("${JQ}" -c '{"os": .os, "architecture": .architecture, "variant": .variant, "os.version": .["os.version"], "os.features": .["os.features"]} | with_entries(select( .value != null ))' "${image_path}/blobs/${config_blob_path}")
"${JQ}" --argjson platform "${platform}" \
--argjson manifest "${manifest}" \
'.manifests |= [$manifest + {"platform": $platform}]'\
'.manifests |= . + [$manifest + {"platform": $platform}]'\
"${output_path}/manifest_list.json" > "${output_path}/manifest_list.new.json"
"${COREUTILS}" cp --no-preserve=mode "${output_path}/manifest_list.new.json" "${output_path}/manifest_list.json"
done
Expand Down

0 comments on commit d96429a

Please sign in to comment.