feat: add oras restore command#1792
Conversation
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1792 +/- ##
==========================================
- Coverage 85.28% 85.25% -0.04%
==========================================
Files 141 143 +2
Lines 6429 6739 +310
==========================================
+ Hits 5483 5745 +262
- Misses 671 706 +35
- Partials 275 288 +13 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new oras restore command that complements the existing oras backup command, allowing users to restore artifacts from OCI image layouts back to registries. The command supports both directory and tar archive inputs, dry-run mode, referrer handling, and various distribution specifications.
- Implements the
oras restorecommand with comprehensive CLI options and error handling - Adds extensive E2E test coverage for restore functionality including edge cases
- Integrates display handlers for both status and metadata output
Reviewed Changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
cmd/oras/root/restore.go |
Main implementation of the restore command with options parsing and execution logic |
test/e2e/suite/command/restore.go |
Comprehensive E2E test suite covering restore scenarios and error cases |
cmd/oras/internal/display/status/tty.go |
TTY-based status display handler for restore operations |
cmd/oras/internal/display/status/text.go |
Text-based status display handler for restore operations |
cmd/oras/internal/display/metadata/text/restore.go |
Text metadata handler for restore command output |
cmd/oras/root/cmd.go |
Integration of restore command into the main CLI |
test/e2e/suite/command/backup.go |
Updates to backup tests for consistency with restore command |
cmd/oras/root/backup.go |
Minor documentation and error message improvements |
Comments suppressed due to low confidence (7)
test/e2e/suite/command/restore.go:142
- The function
strings.SplitSeqdoes not exist in the Go standard library. This should likely bestrings.Splitinstead.
for referrerDgst := range strings.SplitSeq(strings.TrimSpace(string(referrers)), "\n") {
test/e2e/suite/command/restore.go:198
- The function
strings.SplitSeqdoes not exist in the Go standard library. This should likely bestrings.Splitinstead.
for referrerDgst := range strings.SplitSeq(strings.TrimSpace(string(referrers)), "\n") {
test/e2e/suite/command/restore.go:316
- The function
strings.SplitSeqdoes not exist in the Go standard library. This should likely bestrings.Splitinstead.
for referrerDgst := range strings.SplitSeq(strings.TrimSpace(string(referrers)), "\n") {
test/e2e/suite/command/restore.go:415
- The function
strings.SplitSeqdoes not exist in the Go standard library. This should likely bestrings.Splitinstead.
for referrerDgst := range strings.SplitSeq(strings.TrimSpace(string(referrers)), "\n") {
test/e2e/suite/command/restore.go:504
- The function
strings.SplitSeqdoes not exist in the Go standard library. This should likely bestrings.Splitinstead.
for referrerDgst := range strings.SplitSeq(strings.TrimSpace(string(referrers)), "\n") {
test/e2e/suite/command/restore.go:606
- The function
strings.SplitSeqdoes not exist in the Go standard library. This should likely bestrings.Splitinstead.
for referrerDgst := range strings.SplitSeq(strings.TrimSpace(string(referrers)), "\n") {
test/e2e/suite/command/restore.go:631
- The function
strings.SplitSeqdoes not exist in the Go standard library. This should likely bestrings.Splitinstead.
for referrerDgst := range strings.SplitSeq(strings.TrimSpace(string(referrers)), "\n") {
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
What this PR does / why we need it:
Add a new command
oras restoreand the corresponding tests.Spec: https://github.com/oras-project/oras/blob/main/docs/proposals/backup-restore.md
The command looks like this:

oras -h:oras restore -h:oras restore --input backup localhost:5000/restore-oras-250804:oras restore --input backup localhost:5000/restore-oras-250804 --dry-run: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 #1366
Please check the following list: