Skip to content

Conversation

apparentlymart
Copy link
Contributor

What this PR does / why we need it:

This implements the new behavior proposed in #1696.

I am contributing this change on behalf of the OpenTofu project.

Which issue(s) this PR fixes:

Fixes #1670

Please check the following list:

  • Does the affected code have corresponding tests, e.g. unit test, E2E test?
  • Does this change require a documentation update?
  • Does this introduce breaking changes that would require an announcement or bumping the major version?
  • Do all new files have an appropriate license header? (no new files)

@apparentlymart
Copy link
Contributor Author

(I'm going to leave this as a draft for now because #1696 is not finalized yet.)

Copy link

codecov bot commented Apr 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.24%. Comparing base (b28a30b) to head (c2676f5).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1700      +/-   ##
==========================================
+ Coverage   85.20%   85.24%   +0.03%     
==========================================
  Files         129      129              
  Lines        5780     5815      +35     
==========================================
+ Hits         4925     4957      +32     
- Misses        609      611       +2     
- Partials      246      247       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Wwwsylvia Wwwsylvia changed the title oras manifest index: artifactType for index and child manifest descriptors feat: oras manifest index: artifactType for index and child manifest descriptors Jun 18, 2025
The "index create" and "index update" subcommands now accept
--artifact-type options to set or change the "artifactType" property of
the index manifest.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
For each manifest in the generated index manifest that is of a recognized
media type and has an artifactType value, we'll copy that value into the
associated descriptor so that software consuming the index can optionally
ignore or reject descriptors of the wrong artifactType without having to
retrieve the full manifest first.

The behavior does not change for manifests of any other media type or
those which do not have an artifactType property.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
@apparentlymart apparentlymart force-pushed the f-index-manifest-artifacttype branch from b84868b to a753d5f Compare June 18, 2025 18:40
Previously the --artifact-type option would accept any non-empty string and
copy it into the artifactType property of the index. Now we'll require that
it matches the regular expression pattern given in the OCI image spec,
so that we can avoid creating manifests with syntactically-invalid artifact
type values.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
Copy link
Member

@Wwwsylvia Wwwsylvia left a comment

Choose a reason for hiding this comment

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

LGTM

@shizhMSFT shizhMSFT requested a review from Copilot June 24, 2025 05:21
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds support for specifying and propagating artifactType in OCI index creation and updates, including validation and E2E/unit tests.

  • Introduce --artifact-type flag to oras manifest index create and update
  • Validate media type syntax and apply it to the created/updated index and child descriptors
  • Expand E2E and unit tests to cover artifactType behavior in both registry and OCI layout modes

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
test/e2e/suite/command/manifest_index.go Added E2E tests for artifactType propagation, creation, update, removal, and validation
cmd/oras/root/manifest/index/update.go Registered --artifact-type flag, added validation and update logic for index artifact type
cmd/oras/root/manifest/index/create_test.go New unit tests for enrichDescriptor and validateMediaType
cmd/oras/root/manifest/index/create.go Registered --artifact-type flag, added validation and initialization of index artifact type

Copy link
Contributor

@shizhMSFT shizhMSFT left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@wangxiaoxuan273 wangxiaoxuan273 left a comment

Choose a reason for hiding this comment

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

LGTM

@Wwwsylvia Wwwsylvia merged commit e201208 into oras-project:main Jun 24, 2025
8 checks passed
@apparentlymart apparentlymart deleted the f-index-manifest-artifacttype branch June 24, 2025 13:47
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.

artifactType in index manifest and in its "manifests" descriptors
5 participants