Skip to content

Expose mediaType on ContentDescriptorTemplate#4499

Open
Sboti03 wants to merge 2 commits intoGoogleContainerTools:masterfrom
Sboti03:refactor/content-descriptor-media-type-getter
Open

Expose mediaType on ContentDescriptorTemplate#4499
Sboti03 wants to merge 2 commits intoGoogleContainerTools:masterfrom
Sboti03:refactor/content-descriptor-media-type-getter

Conversation

@Sboti03
Copy link
Copy Markdown

@Sboti03 Sboti03 commented Apr 1, 2026

Motivation

ContentDescriptorTemplate stores mediaType but does not expose it,
while other descriptor fields (digest, size, urls, annotations) are accessible
via public getters.

This makes it difficult to work with OCI artifacts without using reflection.

Change

Adds a public getter:

@Nullable
public String getMediaType()

Use case

Needed to inspect layer descriptors and select artifacts based on media type,
for example Helm chart layers: application/vnd.cncf.helm.chart.content.v1.tar+gzip

Notes

  • No behavioral change
  • Only exposes already parsed data
  • Consistent with existing descriptor getters

Fixes #4498 🛠️

@google-cla
Copy link
Copy Markdown

google-cla bot commented Apr 1, 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.

Copy link
Copy Markdown
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 removes an unused suppression annotation and adds a public getter for the mediaType field within the ContentDescriptorTemplate class. The reviewer recommends adding unit test assertions in V22ManifestTemplateTest and OciManifestTemplateTest to ensure the new getter correctly returns the expected data.

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.

Expose mediaType in ContentDescriptorTemplate

1 participant