Skip to content

Conversation

Wwwsylvia
Copy link
Member

@Wwwsylvia Wwwsylvia commented Aug 1, 2025

What this PR does / why we need it:

Add a new command oras restore and the corresponding tests.
Spec: https://github.com/oras-project/oras/blob/main/docs/proposals/backup-restore.md

The command looks like this:
oras -h:
image

oras restore -h:
image

oras restore --input backup localhost:5000/restore-oras-250804:
image

oras restore --input backup localhost:5000/restore-oras-250804 --dry-run:
image

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:

  • 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?

Wwwsylvia added 14 commits July 28, 2025 14:38
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>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Copy link

codecov bot commented Aug 1, 2025

Codecov Report

❌ Patch coverage is 83.03571% with 57 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.25%. Comparing base (edace6e) to head (fc9c0db).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cmd/oras/root/restore.go 80.95% 22 Missing and 10 partials ⚠️
cmd/oras/internal/display/metadata/text/backup.go 53.84% 4 Missing and 2 partials ⚠️
cmd/oras/internal/display/metadata/text/restore.go 82.85% 4 Missing and 2 partials ⚠️
cmd/oras/internal/display/status/text.go 76.92% 4 Missing and 2 partials ⚠️
cmd/oras/internal/display/status/tty.go 92.30% 3 Missing ⚠️
cmd/oras/root/backup.go 89.65% 3 Missing ⚠️
internal/io/tar_utils.go 95.00% 1 Missing ⚠️
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.
📢 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.

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>
@Wwwsylvia Wwwsylvia requested a review from Copilot August 4, 2025 06:26
Copilot

This comment was marked as outdated.

Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
@Wwwsylvia Wwwsylvia requested a review from Copilot August 4, 2025 06:54
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

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 restore command 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.SplitSeq does not exist in the Go standard library. This should likely be strings.Split instead.
			for referrerDgst := range strings.SplitSeq(strings.TrimSpace(string(referrers)), "\n") {

test/e2e/suite/command/restore.go:198

  • The function strings.SplitSeq does not exist in the Go standard library. This should likely be strings.Split instead.
			for referrerDgst := range strings.SplitSeq(strings.TrimSpace(string(referrers)), "\n") {

test/e2e/suite/command/restore.go:316

  • The function strings.SplitSeq does not exist in the Go standard library. This should likely be strings.Split instead.
			for referrerDgst := range strings.SplitSeq(strings.TrimSpace(string(referrers)), "\n") {

test/e2e/suite/command/restore.go:415

  • The function strings.SplitSeq does not exist in the Go standard library. This should likely be strings.Split instead.
				for referrerDgst := range strings.SplitSeq(strings.TrimSpace(string(referrers)), "\n") {

test/e2e/suite/command/restore.go:504

  • The function strings.SplitSeq does not exist in the Go standard library. This should likely be strings.Split instead.
				for referrerDgst := range strings.SplitSeq(strings.TrimSpace(string(referrers)), "\n") {

test/e2e/suite/command/restore.go:606

  • The function strings.SplitSeq does not exist in the Go standard library. This should likely be strings.Split instead.
			for referrerDgst := range strings.SplitSeq(strings.TrimSpace(string(referrers)), "\n") {

test/e2e/suite/command/restore.go:631

  • The function strings.SplitSeq does not exist in the Go standard library. This should likely be strings.Split instead.
			for referrerDgst := range strings.SplitSeq(strings.TrimSpace(string(referrers)), "\n") {

@Wwwsylvia Wwwsylvia marked this pull request as ready for review August 4, 2025 07:16
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>
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

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.

Add new commands to support uploading and downloading images
3 participants