Skip to content

feat(oci_image_index): support annotations attribute#897

Open
yeji-poolside wants to merge 1 commit into
bazel-contrib:mainfrom
poolsideai:oci-image-index-annotations
Open

feat(oci_image_index): support annotations attribute#897
yeji-poolside wants to merge 1 commit into
bazel-contrib:mainfrom
poolsideai:oci-image-index-annotations

Conversation

@yeji-poolside

@yeji-poolside yeji-poolside commented May 21, 2026

Copy link
Copy Markdown

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 #798.

Use case (from #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",
      },
  )

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FR: support adding annotations to an image index

1 participant