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

Add v1util.EstargzReadCloser utility. #870

Merged
merged 8 commits into from
Dec 17, 2020
Merged

Conversation

mattmoor
Copy link
Collaborator

@mattmoor mattmoor commented Dec 16, 2020

This adds the first utility function we will need to start producing estargz layers.

Related: #866

@codecov-io
Copy link

codecov-io commented Dec 16, 2020

Codecov Report

Merging #870 (3423f03) into master (481434c) will increase coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #870      +/-   ##
==========================================
+ Coverage   74.28%   74.34%   +0.05%     
==========================================
  Files         106      107       +1     
  Lines        4476     4486      +10     
==========================================
+ Hits         3325     3335      +10     
  Misses        656      656              
  Partials      495      495              
Impacted Files Coverage Δ
pkg/v1/internal/estargz/estargz.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 481434c...3423f03. Read the comment docs.

@mattmoor
Copy link
Collaborator Author

Now with 100% coverage 😛

@imjasonh
Copy link
Collaborator

Commented on Slack, but for visibility:

v1util is a smell, can we move this to its own package, pkg/internal/estargz while we add experimental support to e.g., remote?

Copy link
Collaborator

@jonjohnsonjr jonjohnsonjr left a comment

Choose a reason for hiding this comment

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

I am really tempted to fork their package and remove github.com/hashicorp/errwrap and github.com/hashicorp/go-multierror, but I understand that's asking a lot 😄

// returns an io.ReadCloser from which compressed data may be read.
// Refer to estargz for the options:
// https://pkg.go.dev/github.com/containerd/stargz-snapshotter@v0.2.0/estargz#Option
func EstargzReadCloser(r io.ReadCloser, opts ...estargz.Option) (io.ReadCloser, v1.Hash, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we put this under pkg/internal/estargz while we're experimenting and expose it later? I'm not sure that I want to commit to this interface quite yet, and v1util is depended on by basically every package in this module, so it can't get pruned if it's in here.

Also estargz.NewRead[Close?]er reads nicely 😛

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This should be done, and I blew up the rest of v1util in: #872 for consistency.

func EstargzReadCloser(r io.ReadCloser, opts ...estargz.Option) (io.ReadCloser, v1.Hash, error) {
defer r.Close()

bs, err := ioutil.ReadAll(r)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Assuming this is just for prototyping and we won't always buffer the whole thing for a final implementation? We should be teeing r into a hasher, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I don't love this implementation either, but I think the estargz stuff wants to be able to seek around to build the index and reorder things for the final estargz file. The v1.Hash is not the overall hash, but the hash of the table of contents. I owe a better function comment than this has, so let me take a crack at that now.

@jonjohnsonjr
Copy link
Collaborator

v1util is a smell, can we move this to its own package, pkg/internal/estargz while we add experimental support to e.g., remote?

Are you me??

@mattmoor
Copy link
Collaborator Author

I am really tempted to fork their package and remove github.com/hashicorp/errwrap and github.com/hashicorp/go-multierror, but I understand that's asking a lot

Why not patch upstream?

@jonjohnsonjr
Copy link
Collaborator

Why not patch upstream?

Very finite amounts of time.

@mattmoor
Copy link
Collaborator Author

Very finite amounts of time

So you want to maintain a fork of something... right... 🤣

@mattmoor mattmoor merged commit e87a6fc into google:master Dec 17, 2020
@mattmoor mattmoor deleted the estargz-utils branch December 17, 2020 18:29
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.

None yet

4 participants