Skip to content

copier: add AddAndCopyOptions.DirCopyContents#6816

Merged
TomSweeneyRedHat merged 1 commit into
containers:mainfrom
akca:copier-dircopycontents
May 19, 2026
Merged

copier: add AddAndCopyOptions.DirCopyContents#6816
TomSweeneyRedHat merged 1 commit into
containers:mainfrom
akca:copier-dircopycontents

Conversation

@akca
Copy link
Copy Markdown
Contributor

@akca akca commented Apr 28, 2026

What type of PR is this?

/kind feature

What this PR does / why we need it:

Adds a new AddAndCopyOptions.DirCopyContents field (of type types.OptionalBool) that controls whether copying a source directory copies just its contents (default, true) or the directory itself with its contents nested below it.

This wires the existing GetOptions.KeepDirectoryNames setting through the AddAndCopyOptions API, aligning with BuildKit's FileAction_Copy.dirCopyContents logic.

How to verify it

Which issue(s) this PR fixes:

Fixes #6803

Special notes for your reviewer:

KeepDirectoryNames is the opposite of DirCopyContents: DirCopyContents == OptionalBoolFalse maps to KeepDirectoryNames = true. Both OptionalBoolUndefined and OptionalBoolTrue preserve existing default behavior (copy contents only). The added test covers this inversion logic only, since KeepDirectoryNames already has tests in copier/copier_test.go.

Does this PR introduce a user-facing change?

None

@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Apr 28, 2026
Comment thread add.go Outdated
Comment thread add.go Outdated
@akca akca requested a review from TomSweeneyRedHat April 29, 2026 09:47
Copy link
Copy Markdown
Member

@nalind nalind left a comment

Choose a reason for hiding this comment

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

I think the copier package has test coverage for the KeepDirectoryNames, so this LGTM.
Please squash (for example, with git rebase -i) and re-push in preparation for merging.
Thanks!

Signed-off-by: Fatih Akca <fatihakca5@gmail.com>
@akca akca force-pushed the copier-dircopycontents branch from ed2285d to c35c0af Compare May 8, 2026 15:35
@akca akca requested a review from nalind May 8, 2026 15:35
Copy link
Copy Markdown
Member

@nalind nalind left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

Copy link
Copy Markdown
Member

@TomSweeneyRedHat TomSweeneyRedHat left a comment

Choose a reason for hiding this comment

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

LGTM

@TomSweeneyRedHat
Copy link
Copy Markdown
Member

@akca Thanks!
/lgtm

@TomSweeneyRedHat TomSweeneyRedHat merged commit 594081f into containers:main May 19, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for Op_File.Actions.FileAction_Copy.DirCopyContents

3 participants