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 bazel-contrib#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 b757fb3
Showing 1 changed file with 1 addition and 1 deletion.
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 b757fb3

Please sign in to comment.