Repository navigation
support dagger in dagger - #3674
Conversation
There was a problem hiding this comment.
@vito Wasn't sure what to do here.
This test is using dagger.Connect(ctx, dagger.WithWorkspace(".")).
Locally, that's the sdk/go directory. However when executed in a container, it will use the "parent"'s workdir (which is the root repo).
I was trying to find another way to make this test work that could run from either directory (either this, or remove the // Output at the end.
There was a problem hiding this comment.
I think we should just make this example self-contained. It's probably too implicit as it is. Something like:
dir, err := os.MkdirTemp("", "example*")
if err != nil {
panic(err)
}
defer os.RemoveAll(dir)
err = os.WriteFile(filepath.Join(dir, "foo"), []byte("hello"), 0644)
if err != nil {
panic(err)
}
client, err := dagger.Connect(ctx, dagger.WithWorkdir(dir))
// ...It's more verbose but way more obvious what it'll do.
There was a problem hiding this comment.
client, err := dagger.Connect(ctx, dagger.WithWorkdir(dir))
The trick here is WithWorkdir() is a no op with dagger-in-dagger because it's only taken into account at engine.Start which already happened
There was a problem hiding this comment.
How about now? A bit hackish, but it's self contained
There was a problem hiding this comment.
Err -- I hit undo.
I was trying to write a "hello.txt" file and read it back -- however since there's no more "workdir write", os.WriteFile() and Workdir() didn't match
There was a problem hiding this comment.
OK with this for now, hopefully we can clean it up/make it clearer once we support remote engine.
There was a problem hiding this comment.
Hm we could put the examples behind a build flag and skip them in CI. As long as they still run by default when I run go test on my machine that should be OK. So CI sets flag, examples_test.go skips with flag present.
We should be able to remove it with #3671 but there's still work to do there.
5cb6f8a to
466c460
Compare
|
I was thinking about this this morning. I'm glad you already had a stab at it. |
dc163fb to
0197794
Compare
|
Added a bunch of include/exclude filters (thanks @vito!) -- cache is insanely better |
7884d80 to
f1c3eb1
Compare
Add the `ExperimentalPrivilegedNesting` flag to `Exec()` which sets a valid `DAGGER_HOST` inside the container, allowing to communicate back to the same engine instance. In short, this means that it's possible to run a program that uses the Go SDK within Dagger itself -- `dagger.Connect()` will automagically work out of the box. Signed-off-by: Andrea Luzzardi <[email protected]>
f1c3eb1 to
838ab9b
Compare
Add the
ExperimentalPrivilegedNestingflag toExec()which sets a validDAGGER_HOSTinside the container, allowing to communicate back to the same engine instance.In short, this means that it's possible to run a program that uses the Go SDK within Dagger itself --
dagger.Connect()will automagically work out of the box.This PR also enables to to run dagger tests using dagger in our own CI.
/cc @helderco