Add PutOptions.AttemptUnpackDockerCompatibility - #7010
Open
ajoshua2004 wants to merge 1 commit into
Open
Conversation
| f.Close() | ||
| return fmt.Errorf("copier: put: error reading unpacked archive %q: %w", path, err) | ||
| } | ||
| entryPath := filepath.Join(destDir, entry.Name) |
Contributor
There was a problem hiding this comment.
@nalind is this safe? Could it write outside of it's destination?
Detect if written files are possibly compressed archives during Put and extract them instead of copying them when the flag is set. Signed-off-by: Joshua Arrevillaga <2004jarrevillaga@gmail.com>
ajoshua2004
force-pushed
the
unpackDocker
branch
from
August 11, 2026 20:46
313bb36 to
b1b057c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
/kind api-change
What this PR does / why we need it:
Adds
AttemptUnpackDockerCompatibility(bool) tocopier.PutOptions. When enabled, the Put handler detects if a written regular file is a possibly-compressed archive (gzip/bzip2/xz/zstd) and extracts its contents in place instead of keeping the archive as-is.How to verify it
go test ./copier/ -run TestAttemptUnpackDockerCompatibilityNoChroot -vgo test ./copier/ -run TestAttemptUnpackDockerCompatibilityChroot -vWhich issue(s) this PR fixes:
Part of #6732
Special notes for your reviewer:
The detection reuses the existing isArchivePath() and compression.AutoDecompress() infrastructure already used on the Get side for ExpandArchives. The flag is not wired to any caller yet, it's available on PutOptions for callers to opt into when needed.
Does this PR introduce a user-facing change?