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

copier: handle globbing with "**" path components #5688

Merged
merged 1 commit into from
Sep 3, 2024

Conversation

nalind
Copy link
Member

@nalind nalind commented Aug 15, 2024

What type of PR is this?

/kind feature

What this PR does / why we need it:

Handle glob patterns with "**" path components by expanding "**" to the set of subdirectories and calling filepath.Glob() on the results.

How to verify it

New unit test!
New conformance tests!

Which issue(s) this PR fixes:

None

Special notes for your reviewer:

Does this PR introduce a user-facing change?

`buildah build` now expands "**" path components in source locations in ADD and COPY instructions as referring to any subdirectory.

@openshift-ci openshift-ci bot added kind/feature Categorizes issue or PR as related to a new feature. approved labels Aug 15, 2024
@nalind nalind force-pushed the copyglob branch 10 times, most recently from 5634cf4 to b46edf0 Compare August 21, 2024 14:45
@nalind nalind force-pushed the copyglob branch 3 times, most recently from 4b4af3f to a2db852 Compare August 28, 2024 18:43
Copy link
Collaborator

@flouthoc flouthoc left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

openshift-ci bot commented Sep 1, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: flouthoc, nalind

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

// will be concatenated.
func extendedGlob(pattern string) (matches []string, err error) {
subdirectories := func(dir string) []string {
var subdirectories []string
Copy link
Member

Choose a reason for hiding this comment

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

This is difficult to read, since the function and the variable have the same name. Would have been better if they were different.

copier/copier.go Outdated
if len(expanded) > 1 {
patterns = append(append(patterns[:i], expanded...), patterns[i+1:]...)
} else {
i++
Copy link
Member

Choose a reason for hiding this comment

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

Why not use break?

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't know that patterns[i+1] (if we're not at the end of the slice) doesn't need to be expanded.

Handle glob patterns with "**" path components by expanding "**" to the
set of subdirectories and calling filepath.Glob() on the results.

Signed-off-by: Nalin Dahyabhai <[email protected]>
@rhatdan
Copy link
Member

rhatdan commented Sep 3, 2024

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Sep 3, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit fb40f69 into containers:main Sep 3, 2024
38 of 39 checks passed
@nalind nalind deleted the copyglob branch September 3, 2024 17:43
@stale-locking-app stale-locking-app bot locked as resolved and limited conversation to collaborators Dec 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved kind/feature Categorizes issue or PR as related to a new feature. lgtm locked - please file new issue/PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants