Skip to content

Conversation

Wwwsylvia
Copy link
Member

@Wwwsylvia Wwwsylvia commented Jul 23, 2025

What this PR does / why we need it:
Add a new command oras backup 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 backup -h:
image

oras backup mcr.microsoft.com/oss/v2/oras-project/oras:v1.2.3 -o backup.tar:

image

./oras backup mcr.microsoft.com/oss/v2/oras-project/oras --include-referrers -o backup:
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):
Spec: #1767
Resolves part of #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 Wwwsylvia force-pushed the feat_backup branch 2 times, most recently from f7b4dee to 2e443c4 Compare July 23, 2025 06:48
Copy link

codecov bot commented Jul 23, 2025

Codecov Report

❌ Patch coverage is 82.33996% with 80 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.28%. Comparing base (2a3c65a) to head (76d6eba).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cmd/oras/root/backup.go 77.31% 46 Missing and 20 partials ⚠️
cmd/oras/internal/display/status/text.go 76.92% 4 Missing and 2 partials ⚠️
cmd/oras/root/cp.go 77.27% 3 Missing and 2 partials ⚠️
cmd/oras/internal/display/status/tty.go 92.30% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1790      +/-   ##
==========================================
- Coverage   85.54%   85.28%   -0.27%     
==========================================
  Files         137      141       +4     
  Lines        6006     6429     +423     
==========================================
+ Hits         5138     5483     +345     
- Misses        617      671      +54     
- Partials      251      275      +24     

☔ 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.

@Wwwsylvia Wwwsylvia requested a review from Copilot July 23, 2025 09:26
Copilot

This comment was marked as outdated.

@Wwwsylvia Wwwsylvia requested a review from Copilot July 23, 2025 10:43
Copilot

This comment was marked as outdated.

@Wwwsylvia Wwwsylvia requested a review from Copilot July 26, 2025 02:45
Copilot

This comment was marked as outdated.

@Wwwsylvia Wwwsylvia marked this pull request as ready for review July 26, 2025 02:47
Wwwsylvia added 15 commits July 28, 2025 10:42
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>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Signed-off-by: Lixia (Sylvia) Lei <lixlei@microsoft.com>
Copilot

This comment was marked as outdated.

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 July 30, 2025 13:56
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 implements a new oras backup command that allows users to back up artifacts from a registry into an OCI image layout. The backup can be saved either as a directory or a tar archive, and supports backing up artifacts with their referrers.

Key changes include:

  • New backup command with support for directory and tar output formats
  • Backup functionality with optional referrer inclusion
  • Extended graph operations for recursive referrer discovery

Reviewed Changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
cmd/oras/root/backup.go Main backup command implementation with artifact resolution and output handling
cmd/oras/root/backup_test.go Comprehensive unit tests for backup command functionality
test/e2e/suite/command/backup.go End-to-end tests covering various backup scenarios
internal/graph/graph.go Enhanced graph operations with recursive referrer finding functionality
internal/io/tar_utils.go Utility functions for creating tar archives from directories
cmd/oras/internal/display/ Status and metadata handlers for backup progress display
Comments suppressed due to low confidence (1)

internal/graph/graph.go:108

  • The function name FindPredecessors is misleading as it returns referrers, not predecessors. Consider renaming to FindReferrers to better reflect its actual functionality.
func FindPredecessors(ctx context.Context, src oras.ReadOnlyGraphTarget, descs []ocispec.Descriptor, opts oras.ExtendedCopyGraphOptions) ([]ocispec.Descriptor, error) {

@Wwwsylvia Wwwsylvia requested a review from shizhMSFT July 30, 2025 14:00
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.

2 participants