Skip to content

Add support for gzip-compressed CPIO output#2253

Open
lavishpal wants to merge 4 commits into
chainguard-dev:mainfrom
lavishpal:build-cpio-gzip-support
Open

Add support for gzip-compressed CPIO output#2253
lavishpal wants to merge 4 commits into
chainguard-dev:mainfrom
lavishpal:build-cpio-gzip-support

Conversation

@lavishpal

Copy link
Copy Markdown

This PR implement support for gzip-compressed CPIO archives when the output filename ends with .gz
Detect .gz output filenames and wrap the destination writer with a gzip writer
Ran the relevant go tests

@lavishpal lavishpal force-pushed the build-cpio-gzip-support branch from f692bf1 to 282b5a3 Compare June 1, 2026 23:28
@lavishpal

Copy link
Copy Markdown
Author

cc: @imjasonh

Signed-off-by: Lavish Pal <lvishpal408@gmail.com>
@lavishpal lavishpal force-pushed the build-cpio-gzip-support branch from 282b5a3 to 15aa0c7 Compare June 4, 2026 14:09

@codysoyland codysoyland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for your contribution!

Is this needed if you can just run the output to gzip?

Can you include tests?

Comment thread internal/cli/build-cpio.go Outdated
@lavishpal

Copy link
Copy Markdown
Author

implemented based on an existing TODO comment in the codebase "// TODO(mattmoor): Consider wrapping in a gzip writer if the filename ends in .gz"

Happy to add tests and fix the gzw.Close() error handling.

@lavishpal

Copy link
Copy Markdown
Author

also to add some context on the running two separate commands means the full uncompressed output hits disk before being compressed even piping avoids that but still requires gzip to present as a binary which may be not guaranteed on windows or in minimal/distroless build env

Signed-off-by: Lavish Pal <lvishpal408@gmail.com>
@lavishpal

Copy link
Copy Markdown
Author

@codysoyland , i fixed gzw.Close() to return its error explicitly instead of using defer and also added tests covering both the .gz and non-.gz output paths.

@lavishpal lavishpal requested a review from codysoyland June 24, 2026 03:30

@codysoyland codysoyland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for adding tests! I made a few small suggestions.

Comment thread internal/cli/build_cpio.go
Comment thread internal/cli/build_cpio_test.go Outdated
Comment thread internal/cli/build_cpio_test.go Outdated
Signed-off-by: Lavish Pal <lvishpal408@gmail.com>
Signed-off-by: Lavish Pal <lvishpal408@gmail.com>
@lavishpal lavishpal requested a review from codysoyland June 27, 2026 03:14
@lavishpal

Copy link
Copy Markdown
Author

I address all the changes you have suggested. Can you PTAL?

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