Skip to content

add/copy: support AllowWildcard and AllowEmptyWildcard#6843

Open
akca wants to merge 1 commit into
containers:mainfrom
akca:opfile-copy-wildcard
Open

add/copy: support AllowWildcard and AllowEmptyWildcard#6843
akca wants to merge 1 commit into
containers:mainfrom
akca:opfile-copy-wildcard

Conversation

@akca
Copy link
Copy Markdown
Contributor

@akca akca commented May 11, 2026

What type of PR is this?

/kind feature

What this PR does / why we need it:

Adds AllowWildcard and AllowEmptyWildcard to the copier's stat/get operations and exposes them as --allow-wildcard / --allow-empty-wildcard on buildah add and buildah copy, aligning with BuildKit's FileActionCopy flags (ref).

AllowWildcard controls whether glob patterns are allowed in source paths. When false, wildcards are rejected. buildah add/buildah copy sets this to true by default and preserves current behaviour.

AllowEmptyWildcard controls what happens when a wildcard source matches no files. By default (false), the operation fails if every source comes up empty. With --allow-empty-wildcard=true, an empty result is silently accepted. Docker/BuildKit defaults to true (ref), so COPY nonexistent* /dest/ silently succeeds in Docker but errors in buildah. If there's interest in matching Docker's default, that could be a follow-up PR since it would touch many more places.

How to verify it

go test ./copier -run Wildcard -v

Which issue(s) this PR fixes:

Fixes #6828
Fixes #6829

Special notes for your reviewer:

  • copier uses plain bool for these fields (no value provided = doesn't allow globs). Existing callers in buildah and podman all pass resolved paths without wildcard characters, so they should be unaffected. image.go is the only exception (exclusion patterns may contain wildcards), so it now explicitly sets AllowWildcard: true. Let me know if there are callers I missed.
  • Literal missing paths produce ENOENT. Non-matching globs produce "matched nothing" (not ENOENT, since no specific file was looked up).
  • Conformance tests copy-multiple-some-missing-glob and copy-multiple-missing-file-with-nomatch-on-glob verify the multi-source behaviour matches Docker.

Does this PR introduce a user-facing change?

Add `--allow-wildcard` and `--allow-empty-wildcard` flags to `buildah add` and `buildah copy`

@akca akca force-pushed the opfile-copy-wildcard branch 14 times, most recently from f8c12a8 to 96971cf Compare May 13, 2026 11:45
@packit-as-a-service
Copy link
Copy Markdown

Ephemeral COPR build failed. @containers/packit-build please check.

@akca akca force-pushed the opfile-copy-wildcard branch 4 times, most recently from bca54ee to f5656b9 Compare May 13, 2026 16:10
@akca akca marked this pull request as ready for review May 13, 2026 16:41
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label May 13, 2026
@akca akca force-pushed the opfile-copy-wildcard branch from f5656b9 to 80e1b5b Compare May 18, 2026 15:27
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.

Very good overall. A question about the default for the allow-wildcard setting in the options structs in the copier package, and a couple of smaller questions around the tests.

Comment thread tests/add.bats Outdated
Comment thread tests/add.bats Outdated
Comment thread tests/copy.bats Outdated
Comment thread tests/copy.bats Outdated
Comment thread copier/copier.go Outdated
Comment thread copier/copier.go Outdated
Comment thread copier/copier_test.go Outdated
@akca akca force-pushed the opfile-copy-wildcard branch from 80e1b5b to f96056e Compare May 19, 2026 15:51
Expose --allow-wildcard and --allow-empty-wildcard on buildah add/copy,
aligning with BuildKit's FileActionCopy flags.

--allow-wildcard (default true) controls whether source paths may
contain glob characters. When false, wildcards are rejected.

--allow-empty-wildcard (default false) controls whether zero glob matches
is an error. Individual empty wildcards are silently skipped,
operation only fails when every source matches nothing.

Signed-off-by: Fatih Akca <fatihakca5@gmail.com>
@akca akca force-pushed the opfile-copy-wildcard branch from f96056e to c3f527f Compare May 19, 2026 16:10
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!

@nalind
Copy link
Copy Markdown
Member

nalind commented May 19, 2026

@containers/buildah-maintainers PTAL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 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.AllowEmptyWildcard Add support for Op_File.Actions.FileAction_Copy.AllowWildcard

2 participants