feat(oci_image_index): support annotations attribute#897
Open
yeji-poolside wants to merge 1 commit into
Open
Conversation
Adds an `annotations` attribute to `oci_image_index`, mirroring the existing one on `oci_image`. The macro accepts annotations as either an inline dict or a label to a key=value file; the underlying rule takes a file (the macro converts a dict via `write_file`, same as `oci_image`). Annotations are merged into the index manifest's top-level `.annotations` field before its digest is computed, so the wrapper's descriptor still matches the blob. The merge reuses the same jq filter `oci_image` uses, so behavior is consistent across the two rules. Fixes bazel-contrib#798. Use case (from bazel-contrib#798): GitHub Container Registry, Akuity Kargo, and other consumers look for `org.opencontainers.image.source` and `org.opencontainers.image.revision` on the index of multi-arch images to surface commit/repository links in their UIs. Without this attribute, users have to post-process the index outside Bazel. Example: oci_image_index( name = "app", images = [":app_linux_amd64", ":app_linux_arm64"], annotations = { "org.opencontainers.image.source": "https://github.com/example/repo", "org.opencontainers.image.revision": "abc1234", }, ) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an
annotationsattribute tooci_image_index, mirroring the existing one onoci_image. The macro accepts annotations as either an inline dict or a label to a key=value file; the underlying rule takes a file (the macro converts a dict viawrite_file, same asoci_image). Annotations are merged into the index manifest's top-level.annotationsfield before its digest is computed, so the wrapper's descriptor still matches the blob. The merge reuses the same jq filteroci_imageuses, so behavior is consistent across the two rules.Fixes #798.
Use case (from #798): GitHub Container Registry, Akuity Kargo, and other consumers look for
org.opencontainers.image.sourceandorg.opencontainers.image.revisionon the index of multi-arch images to surface commit/repository links in their UIs. Without this attribute, users have to post-process the index outside Bazel.Example: