Skip to content

feat: add OCI base image annotations to manifest#4496

Open
dyna-stadt wants to merge 3 commits intoGoogleContainerTools:masterfrom
dyna-stadt:feat/oci-base-image-annotations
Open

feat: add OCI base image annotations to manifest#4496
dyna-stadt wants to merge 3 commits intoGoogleContainerTools:masterfrom
dyna-stadt:feat/oci-base-image-annotations

Conversation

@dyna-stadt
Copy link

Adds support for the OCI pre-defined annotation keys for base images:

  • org.opencontainers.image.base.name
  • org.opencontainers.image.base.digest

These manifest-level annotations are automatically populated when building OCI format images from a non-scratch base image.

Fixes #4218 🛠️

Adds support for the OCI pre-defined annotation keys for base images:
- org.opencontainers.image.base.name
- org.opencontainers.image.base.digest

These manifest-level annotations are automatically populated when
building OCI format images from a non-scratch base image.

Fixes GoogleContainerTools#4218

Refs: ASDY-12887
@google-cla
Copy link

google-cla bot commented Mar 9, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant enhancement to Jib's OCI image building capabilities by automatically embedding base image metadata directly into the image manifest. This feature ensures that OCI-compliant images built with Jib will include standardized annotations for the base image's name and digest, improving traceability, provenance, and adherence to OCI specifications. This change is crucial for users who require detailed and standardized metadata within their container images.

Highlights

  • OCI Base Image Annotations: Implemented support for OCI pre-defined annotations org.opencontainers.image.base.name and org.opencontainers.image.base.digest to track the base image used for building.
  • Automatic Population: These annotations are now automatically populated in the manifest when building OCI format images from a non-scratch base image.
  • Image Metadata Enhancement: Extended the Image class to store base image name and digest, and updated image building and pulling steps to capture this information.
  • OCI Manifest Template Updates: Modified OciManifestTemplate to include an annotations map and methods for adding and retrieving annotations.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • jib-core/src/main/java/com/google/cloud/tools/jib/builder/steps/BuildImageStep.java
    • Added logic to set the base image name and digest on the image builder when the base image is not scratch.
  • jib-core/src/main/java/com/google/cloud/tools/jib/builder/steps/PullBaseImageStep.java
    • Modified image pulling methods to capture and set the base image digest on the Image object for various manifest types (V21, BuildableManifestTemplate, ManifestListTemplate).
  • jib-core/src/main/java/com/google/cloud/tools/jib/image/Image.java
    • Added baseImageName and baseImageDigest fields to store base image information.
    • Introduced setBaseImageName and setBaseImageDigest builder methods.
    • Updated the Image constructor to accept and initialize the new base image fields.
    • Provided getter methods for baseImageName and baseImageDigest.
    • Added a mutable setter setBaseImageDigest for post-construction updates.
  • jib-core/src/main/java/com/google/cloud/tools/jib/image/json/ImageToJsonTranslator.java
    • Implemented logic to add OCI base image annotations (org.opencontainers.image.base.name and org.opencontainers.image.base.digest) to the OciManifestTemplate if the target image format is OCI and base image information is available.
  • jib-core/src/main/java/com/google/cloud/tools/jib/image/json/OciManifestTemplate.java
    • Introduced a Map to store manifest-level annotations.
    • Added addAnnotation method to allow adding key-value pairs to the annotations.
    • Provided getAnnotations method to retrieve an immutable copy of the annotations map.
  • jib-core/src/test/java/com/google/cloud/tools/jib/image/ImageTest.java
    • Added unit tests to verify the correct behavior of baseImageName and baseImageDigest setters and getters, including default values and the mutable setter.
  • jib-core/src/test/java/com/google/cloud/tools/jib/image/json/ImageToJsonTranslatorTest.java
    • Added tests to confirm that OCI base image annotations are correctly applied to OciManifestTemplate but not to V22ManifestTemplate.
    • Included a test case to ensure no annotations are added when base image information is absent.
  • jib-core/src/test/java/com/google/cloud/tools/jib/image/json/OciManifestTemplateTest.java
    • Added tests for the addAnnotation and getAnnotations methods, covering functionality, serialization/deserialization, and the immutability of the returned annotations map.
Activity
  • No specific review comments or activity have been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for OCI base image annotations, which is a valuable feature. The implementation is solid and includes good test coverage. I have a couple of minor suggestions to improve code clarity and maintainability.

dyna-stadt and others added 2 commits March 9, 2026 16:22
…mageToJsonTranslator.java


apply suggestions

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.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.

Automatically add standard oci annotations for base images

1 participant