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

Implement file action remove for wildcards #1233

Merged
merged 1 commit into from
Oct 30, 2019

Conversation

hinshun
Copy link
Collaborator

@hinshun hinshun commented Oct 29, 2019

Fixes #1232 .

Where should tests go? In client/llb/fileop_test.go?

@GordonTheTurtle
Copy link
Collaborator

Please sign your commits following these rules:
https://github.com/moby/moby/blob/master/CONTRIBUTING.md#sign-your-work
The easiest way to do this is to amend the last commit:

$ git clone -b "rm-wildcard" [email protected]:hinshun/buildkit.git somewhere
$ cd somewhere
$ git commit --amend -s --no-edit
$ git push -f

Amending updates the existing PR. You DO NOT need to open a new one.

@tonistiigi
Copy link
Member

Where should tests go? In client/llb/fileop_test.go?

client/client_test.go (or client/fileop_test.go if you want to smaller files). This should be an integration test, eg. similar would be https://github.com/moby/buildkit/blob/master/client/client_test.go#L979

}

for _, s := range m {
p, err := fs.RootPath(d, filepath.Join(filepath.Join("/", s)))
Copy link
Member

Choose a reason for hiding this comment

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

Maybe create an extra function for this to avoid repetition with non-wildcard path.

@tonistiigi
Copy link
Member

@hinshun Add a capability for this as well https://github.com/moby/buildkit/blob/master/solver/pb/caps.go so support for it can be detected. We could also error out if the capability does not exist like https://github.com/moby/buildkit/blob/master/client/llb/exec.go#L150 but probably not that important as this shouldn't be widely used atm.

@@ -204,6 +225,10 @@ func cleanPath(s string) string {
return s2
}

func rootPath(root, src string) (string, error) {
Copy link
Member

@tonistiigi tonistiigi Oct 30, 2019

Choose a reason for hiding this comment

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

I thought a function that also calls os.RemoveAll and does the action.AllowNotFound check.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When AllowWildcard is true and is removing each of the matched paths, I don't think AllowNotFound makes sense there?

Copy link
Member

Choose a reason for hiding this comment

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

It should be a no-op for that case, assuming that directory is immutable. If it is not behavior can be undefined.

Copy link
Member

Choose a reason for hiding this comment

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

If you want to keep the different AllowWildcard behavior, feel free to revert this as a single line helper function doesn't really improve this code, just makes is more complicated to read through.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I refactored it as suggested 👍

@hinshun
Copy link
Collaborator Author

hinshun commented Oct 30, 2019

Looking into the caps change.

@hinshun hinshun force-pushed the rm-wildcard branch 2 times, most recently from dc64d2a to b8829fd Compare October 30, 2019 21:10
@tonistiigi tonistiigi merged commit fdd2f9b into moby:master Oct 30, 2019
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.

FileAction Rm doesn't seem to respect AllowWildcard
3 participants