oras-project / oras

OCI registry client - managing content like artifacts, images, packages
https://oras.land
Apache License 2.0
1.52k stars 181 forks source link

fix: force config media type when setting platform #1519

Closed qweeah closed 1 month ago

qweeah commented 1 month ago

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 https://github.com/oras-project/oras/issues/1517#issuecomment-2443360381

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:

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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

Additional details and impacted files ```diff @@ 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 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.