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

Implement partial.UncompressedSize #655

Merged
merged 6 commits into from
Jan 15, 2020

Conversation

jonjohnsonjr
Copy link
Collaborator

@jonjohnsonjr jonjohnsonjr commented Jan 14, 2020

This allows access to an optional method that v1.Layers can implement to
cheaply get the size of the uncompressed contents of a layer. This is
useful in situations where you need to know the size of the contents
before writing them (e.g. pkg/legacy/tarball.Write).

I dropped the ReadAll call in the "slow path". This means that the Uncompressed bytes aren't buffered (yay), but if using a streaming layer, we might accidentally consume it. The only known uses of the legacy package don't use streaming layers, so we can cross that bridge when we get to it.

@codecov-io
Copy link

codecov-io commented Jan 14, 2020

Codecov Report

Merging #655 into master will increase coverage by 0.22%.
The diff coverage is 83.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #655      +/-   ##
==========================================
+ Coverage   78.14%   78.37%   +0.22%     
==========================================
  Files         102      102              
  Lines        4503     4517      +14     
==========================================
+ Hits         3519     3540      +21     
+ Misses        567      562       -5     
+ Partials      417      415       -2
Impacted Files Coverage Δ
pkg/legacy/tarball/write.go 72.72% <75%> (ø) ⬆️
pkg/v1/partial/with.go 70.12% <85.71%> (+7.98%) ⬆️

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 556f30d...723a68c. Read the comment docs.

This allows access to an optional method that v1.Layers can implement to
cheaply get the size of the uncompressed contents of a layer. This is
useful in situations where you need to know the size of the contents
before writing them (e.g. pkg/legacy/tarball.Write).
@jonjohnsonjr jonjohnsonjr marked this pull request as ready for review January 15, 2020 21:07
pkg/v1/partial/with.go Outdated Show resolved Hide resolved
@jonjohnsonjr jonjohnsonjr merged commit 379933c into google:master Jan 15, 2020
@jonjohnsonjr jonjohnsonjr deleted the uncompressed-size branch January 15, 2020 21:43
smukherj1 added a commit to smukherj1/rules_docker that referenced this pull request Jan 15, 2020
Take advantage of
google/go-containerregistry#655 and avoid
loading an uncompressed layer into memory when writing out an image
tarball.
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