Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP]nydus-image: enhance unpack command to support extracting files to dir #1480

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

adamqqqplay
Copy link
Member

@adamqqqplay adamqqqplay commented Nov 10, 2023

Relevant Issue (if applicable)

N/A

Details

When --output is specified as a directory, the nydus-image unpack command will return an error, which is not convenient for users.

This patch enhances this command in the following 3 aspects:

  1. Allow --output to be passed as a directory. In this case, the tar file will be output to this subdirectory.
  2. Added --untar flag to support decompressing this tar file into the directory specified by --output.
  3. When --output is not specified, the default output is to /dev/stdout

Types of changes

What types of changes does your PullRequest introduce? Put an x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation Update (if none of the other choices apply)

Checklist

Go over all the following points, and put an x in all the boxes that apply.

  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.

@adamqqqplay adamqqqplay requested a review from a team as a code owner November 10, 2023 08:13
@adamqqqplay adamqqqplay requested review from liubogithub and removed request for a team November 10, 2023 08:13
Copy link

codecov bot commented Nov 10, 2023

Codecov Report

Merging #1480 (3d62276) into master (c9fbce8) will increase coverage by 0.03%.
Report is 1 commits behind head on master.
The diff coverage is 59.45%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1480      +/-   ##
==========================================
+ Coverage   62.50%   62.54%   +0.03%     
==========================================
  Files         123      123              
  Lines       43148    43216      +68     
  Branches    43148    43216      +68     
==========================================
+ Hits        26971    27030      +59     
- Misses      14870    14877       +7     
- Partials     1307     1309       +2     
Files Coverage Δ
src/bin/nydus-image/main.rs 0.76% <0.00%> (-0.01%) ⬇️
src/bin/nydus-image/unpack/mod.rs 34.59% <73.33%> (+34.59%) ⬆️

... and 2 files with indirect coverage changes

@adamqqqplay
Copy link
Member Author

I will add unit tests in this PR later. Please wait a moment.

When --output is specified as a directory, the nydus-image unpack
command will return an error, which is not convenient for users.

This patch enhances this command in the following 3 aspects:
1. Allow --output to be passed as a directory. In this case, the tar
 file will be output to this subdirectory.
2. Added --untar flag to support decompressing this tar file into the
 directory specified by --output.
3. When --output is not specified, the default output is to /dev/stdout

Signed-off-by: Qinqi Qu <[email protected]>
.unpack(config)
.with_context(|| "fail to unpack")
.with_context(|| format!("failed to unpack image to: {}", output))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unpack blob.

@@ -32,11 +32,12 @@ pub trait Unpacker {
fn unpack(&self, config: Arc<ConfigV2>) -> Result<()>;
}

/// A unpacker with the ability to convert bootstrap file and blob file to tar
/// A unpacker with the ability to convert bootstrap file and blob file to tar or dir.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or untar to a directory.

})
}

fn load_rafs(&self, config: Arc<ConfigV2>) -> Result<RafsSuper> {
let (rs, _) = RafsSuper::load_from_file(self.bootstrap.as_path(), config, false)?;
Ok(rs)
}

fn get_unpack_path(&self) -> Result<PathBuf> {
// If output ends with path separator, then it is a dir.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd better not make the assumption.

.required(false),
)
.arg(
Arg::new("untar")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A smoke test is required for new option.
Besides update doc please.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ccx1024cc Unit testing is complete and now changed to WIP.

@adamqqqplay adamqqqplay changed the title nydus-image: enhance unpack command to support extracting files to dir [WIP]nydus-image: enhance unpack command to support extracting files to dir Dec 13, 2023
@adamqqqplay adamqqqplay marked this pull request as draft December 13, 2023 11:27
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.

3 participants