Repository navigation
add include/exclude support - #3583
Conversation
47176e8 to
40ea699
Compare
There was a problem hiding this comment.
@vito I'm wondering if we should allow setting AllowWildcard in llb.CopyInfo. Thoughts?
This should allow (dir *Directory) WithDirectory() to work the same as (host *Host) Directory()
There was a problem hiding this comment.
I wonder if we should just always set it to true. It looks like we did that before. 🤔 I'll make that change and @sipsma can tell me if it's a bad idea. :P
dagger/core/schema/filesystem.go
Line 132 in c9f7c11
There was a problem hiding this comment.
Wait, I'm not actually sure how this would be used, since the wildcard is applied to the source directory meaning you'd need to have a DirectoryID with a wildcard in it.
You would have to do something like this:
func TestDirectoryWithDirectoryWildcard(t *testing.T) {
t.Parallel()
c, ctx := connect(t)
defer c.Close()
dir := c.Directory().
WithNewFile("a.txt").
WithNewFile("b.txt").
WithNewFile("c.txt.rar").
WithNewFile("subdir/d.txt").
WithNewFile("subdir/e.txt").
WithNewFile("subdir/f.txt.rar")
dirID, err := dir.Directory("s*").ID(ctx)
require.NoError(t, err)
entries, err := c.Directory().WithDirectory(dirID, "").Entries(ctx)
require.NoError(t, err)
require.Equal(t, []string{"d.txt", "e.txt", "f.txt.rar"}, entries)
}The dir.Directory("s*") is what feels weird, because that gives you an object that presumes it's going to be used for copying in to somewhere.
There was a problem hiding this comment.
I'm good with that. The corner case is that it's technically possible for files and directories to have * in their name, but like... it's hard to think of a more obscure situation. We can have an optional field to disallow wildcards too to handle that if we want, but defaulting on is good with me.
EDIT: I loaded the page before the most recent comment, above was in response to whether it should default on
There was a problem hiding this comment.
@vito Ah... I think I was misunderstanding how AllowWildcard works. (Include|Exclude)Patterns already allows wildcards, I'm guessing?
I wish the docs for buildkit were... existent... sometimes.
There was a problem hiding this comment.
EDIT: I loaded the page before the most recent comment, above was in response to whether it should default on
😆 Well, I added it, we can decide whether we want to keep it. It feels a little weird to me since a wildcarded DirectoryID won't work for every directory API call, but maybe it'll be useful in actual code.
There was a problem hiding this comment.
@vito Ah... I think I was misunderstanding how
AllowWildcardworks.(Include|Exclude)Patternsalready allows wildcards, I'm guessing?
Yeah, they already support wildcards.
Sounds like this is redundant then, I'll just revert the commit. :)
There was a problem hiding this comment.
Technically I may need it to fully implement the 0.2 API. But that might be something we can just say we won't allow.
Pull it for now. ![]()
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
this is weird since it results in a DirectoryID that only makes sense for being used in WithDirectory. wildcards are already supported through include/exclude where the semantics are much more clear. This reverts commit b9226b4. Signed-off-by: Alex Suraci <[email protected]>
Adds
include/excludefilters to the following APIs: