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

feat: update existing index (index update) #1476

Closed wangxiaoxuan273 closed 2 months ago

wangxiaoxuan273 commented 3 months ago

What this PR does / why we need it:

oras manifest index update

Current status output:

root# oras manifest index update 
wxxdevreg.azurecr.io/test@sha256:2b8bab8c7d73d178fa66c391458e5a441e09ab47bb85c3b4936bd94ac07c9132 --add s390x --add sha256:89fa64341cccaf9b1ede4d06abf5217c785adb6cbb40827f7488db5d97f3d3c8 --remove sha256:a1f5af96aa0a2d2e77bb6f18174353d7fa96700a5fac76a9f460a44f6999330c --merge temp02 --tag temp03 --tag temp04
Fetching  sha256:2b8bab8c7d73d178fa66c391458e5a441e09ab47bb85c3b4936bd94ac07c9132
Fetched   sha256:2b8bab8c7d73d178fa66c391458e5a441e09ab47bb85c3b4936bd94ac07c9132
Fetching  s390x
Fetched   sha256:fd0201b8b0d7cdde2b9e8bcf5278b49668f1dd377a01ec1e2ef0e57382c25a0d s390x
Added     sha256:fd0201b8b0d7cdde2b9e8bcf5278b49668f1dd377a01ec1e2ef0e57382c25a0d s390x
Fetching  sha256:89fa64341cccaf9b1ede4d06abf5217c785adb6cbb40827f7488db5d97f3d3c8
Fetched   sha256:89fa64341cccaf9b1ede4d06abf5217c785adb6cbb40827f7488db5d97f3d3c8
Added     sha256:89fa64341cccaf9b1ede4d06abf5217c785adb6cbb40827f7488db5d97f3d3c8
Fetching  temp02
Fetched   sha256:a4c7b57cea489149bc30e7ecce464ea16ac44ea7dcf734ccfeadd4f6846b175c temp02
Merged    sha256:a4c7b57cea489149bc30e7ecce464ea16ac44ea7dcf734ccfeadd4f6846b175c temp02
Removed   sha256:a1f5af96aa0a2d2e77bb6f18174353d7fa96700a5fac76a9f460a44f6999330c
Updated   sha256:79812a00bb50fc45e56e1744a5201a40364a417bfe444156f3209f3d451b7ecc
Pushed    [registry] wxxdevreg.azurecr.io/test
Tagged temp04
Tagged temp03
Digest: sha256:79812a00bb50fc45e56e1744a5201a40364a417bfe444156f3209f3d451b7ecc

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

This PR builds on #1475

Please check the following list:

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 91.78082% with 12 lines in your changes missing coverage. Please review.

Project coverage is 86.00%. Comparing base (2808ea1) to head (229d4c8). Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cmd/oras/root/manifest/index/update.go 92.42% 5 Missing and 5 partials :warning:
cmd/oras/root/manifest/index/create.go 81.81% 1 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1476 +/- ## ========================================== + Coverage 85.83% 86.00% +0.17% ========================================== Files 116 117 +1 Lines 4073 4210 +137 ========================================== + Hits 3496 3621 +125 - Misses 345 351 +6 - Partials 232 238 +6 ```

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

qweeah commented 2 months ago

Found two lines in the demo output very misleading:

...
Updated   sha256:79812a00bb50fc45e56e1744a5201a40364a417bfe444156f3209f3d451b7ecc
Pushed    [registry] wxxdevreg.azurecr.io/test@sha256:2b8bab8c7d73d178fa66c391458e5a441e09ab47bb85c3b4936bd94ac07c9132
...

Shouldn't sha256:79812a00bb50fc45e56e1744a5201a40364a417bfe444156f3209f3d451b7ecc be pushed?

wangxiaoxuan273 commented 2 months ago

Found two lines in the demo output very misleading:

...
Updated   sha256:79812a00bb50fc45e56e1744a5201a40364a417bfe444156f3209f3d451b7ecc
Pushed    [registry] wxxdevreg.azurecr.io/test@sha256:2b8bab8c7d73d178fa66c391458e5a441e09ab47bb85c3b4936bd94ac07c9132
...

Shouldn't sha256:79812a00bb50fc45e56e1744a5201a40364a417bfe444156f3209f3d451b7ecc be pushed?

Thanks for catching!

wangxiaoxuan273 commented 2 months ago

Found two lines in the demo output very misleading:

...
Updated   sha256:79812a00bb50fc45e56e1744a5201a40364a417bfe444156f3209f3d451b7ecc
Pushed    [registry] wxxdevreg.azurecr.io/test@sha256:2b8bab8c7d73d178fa66c391458e5a441e09ab47bb85c3b4936bd94ac07c9132
...

Shouldn't sha256:79812a00bb50fc45e56e1744a5201a40364a417bfe444156f3209f3d451b7ecc be pushed?

Fixed the push path output by adding and using a new function getPushPath.