Skip to content

fix: force config media type when setting platform#1519

Merged
TerryHowe merged 5 commits into
oras-project:mainfrom
qweeah:push-platform
Nov 3, 2024
Merged

fix: force config media type when setting platform#1519
TerryHowe merged 5 commits into
oras-project:mainfrom
qweeah:push-platform

Conversation

@qweeah

@qweeah qweeah commented Oct 29, 2024

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

When selecting a platform, oras-go only allows config type to be application/vnd.oci.image.config.v1+json. See https://github.com/oras-project/oras-go/blob/v2.5.0/internal/platform/platform.go#L110.

This PR enforces above design with 2 changes:

  1. config.mediaType is set to application/vnd.oci.image.config.v1+json when baking platform into the config blob;
  2. The usage of oras push --artifact-type xxx -artifact-platform xxx --image-spec v1.0 ... is banned.

Without this PR, oras push might generate artifacts that cannot be consumed by oras pull --platform, see #1517 (comment)

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #1517

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?

Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
@codecov

codecov Bot commented Oct 29, 2024

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.87%. Comparing base (9a83394) to head (7ac6dad).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1519   +/-   ##
=======================================
  Coverage   83.86%   83.87%           
=======================================
  Files         118      118           
  Lines        5164     5166    +2     
=======================================
+ Hits         4331     4333    +2     
  Misses        592      592           
  Partials      241      241           

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

Comment thread cmd/oras/root/push.go Outdated

@TerryHowe TerryHowe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm

@TerryHowe TerryHowe merged commit 8f0f0cd into oras-project:main Nov 3, 2024
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.

oras push --artifact-platform is not compatible with oras pull --platform and similar commands

3 participants