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

fix(compress): allow passing in compressor options #509

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rchincha
Copy link
Contributor

Goals of this PR:

  1. Allow passing in options to individual compressor
  2. Do not change default behavior

@rchincha
Copy link
Contributor Author

An alternative approach to: #508

@rchincha
Copy link
Contributor Author

https://github.com/project-stacker/stacker/blob/main/pkg/overlay/pack.go#L411C4-L411C4
becomes:

GzipCompressor.WithOpt(GzipBlockLen(256<<12))

Goals of this PR:
1. Allow passing in options to individual compressor
2. Do not change default behavior

Signed-off-by: Ramkumar Chinchani <[email protected]>
@codecov-commenter
Copy link

codecov-commenter commented Oct 13, 2023

Codecov Report

Merging #509 (029f15e) into main (312b2db) will decrease coverage by 0.04%.
The diff coverage is 50.00%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #509      +/-   ##
==========================================
- Coverage   73.48%   73.45%   -0.04%     
==========================================
  Files          60       60              
  Lines        4884     4893       +9     
==========================================
+ Hits         3589     3594       +5     
- Misses        935      939       +4     
  Partials      360      360              
Files Coverage Δ
mutate/compress.go 44.92% <50.00%> (+1.59%) ⬆️

@hallyn
Copy link
Contributor

hallyn commented Oct 13, 2023

Looks nice

@rchincha
Copy link
Contributor Author

@rchincha
Copy link
Contributor Author

@cyphar thoughts on this PR? Hoping to avoid a umoci fork.

@cyphar
Copy link
Member

cyphar commented Oct 21, 2023

A fork definitely won't be necessary, I'll review this on Monday. Sorry, I was a bit busy last week.

@@ -76,6 +91,15 @@ func (gz gzipCompressor) MediaTypeSuffix() string {
return "gzip"
}

func (gz gzipCompressor) WithOpt(opt CompressorOpt) Compressor {
switch val := opt.(type) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I like that we ignore invalid arguments here. If we make this act on *gzipCompressor we could make it return a bool (or error) and then the caller can decide if they care about whether WithOpt actually did anything.

Alternatively, it feels like it should be possible to reimplement all of this compressor stuff with a closure that is passed by the caller (that creates the writer and configures it). But that would require more work...

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we could add a CustomCompressor just for cases where you need to configure the compression? Idk...

@rchincha
Copy link
Contributor Author

Another place of relevance in umoci code wrt compressor options :(

https://github.com/opencontainers/umoci/blob/main/pkg/system/copy.go#L32

@rchincha
Copy link
Contributor Author

fyi, filed this against image-spec opencontainers/image-spec#1145

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.

4 participants