#Host.directory() include vs exclude - if they conflict which one wins?
1 messages · Page 1 of 1 (latest)
I don’t know the answer off hand, but in case it helps, it’s passed through to buildkit (llb local() call)
yeah, i'm actually looking at https://github.com/dagger/dagger/blob/59076f606a6ae4afe7a3f253ca656894ca0e8792/core/directory.go#L416
Chatgpt says exclude wins when i pump this code in and ask but not being a go or buildkit knuckle cracker myself it would nice to get confirmation
the protobuf that gets passed to LLB also hints that exclude wins is also the case, though I haven't yet found the source code in buildkit that resolves it:
just did a quick test and exclude wins over include.
It kind of makes sense also since the way I reason about it is that include * is always implicit when you use Host.directory.
logic seems to be in this util library's Walk function which is not straightforward to follow: https://github.com/moby/buildkit/blob/eddfcd5265c293b564c5331d3d92ebce1c160f9b/vendor/github.com/tonistiigi/fsutil/walker.go#L46
coming from here: https://github.com/moby/buildkit/blob/eddfcd5265c293b564c5331d3d92ebce1c160f9b/session/filesync/filesync.go#L116
thanks marcos, i spent a few minutes poking around the Copy function in buildkit and wasn't able to find that, going from how it goes from Copy to Walk was a little tough to understand
your second link makes it a lot clearer though!
sure! happy to help!
Slightly tangential to the original topic - I haven't found out whether it's buildkit or dagger that does this, but apparently either one of the two will silently refuse to stage a folder in your container when calling "with_directory" if it has the string "secrets" in the folder name
That was a fun thing to debug 😄
I think at the very least it should warn that the folder was skipped if this is controlled by Dagger team (I also think Buildkit should spit out a warning as well if it's a buildkit thing).
🤔 is this happening when the folder is in the host also? This seems to work:
output, err := client.Pipeline("test").
Container().
From("alpine").
WithDirectory("/src", client.Host().Directory(".")).
WithExec([]string{"ls", "-l", "/src"}).
having a local folder called secrets_foo
I am out tomorrow but I will get a minimal repro going for this when I’m back!
👍
https://play.dagger.cloud/playground/zfVbmN4G4oy
^ that also works 🤔
Welcome to Dagger API Playground
looking forward to the repo 🙌
I also can't repro easily, I've tried with setting the source and dest to include "secrets", and it doesn't seem to appear.
Our of curiosity, you wouldn't have an exclude pattern somewhere that matches the secrets folder?