I have a minimal go project with this layout
├── app
│ ├── go.mod
│ ├── go.sum
│ └── main.go
└── ci
├── go.mod
├── go.sum
└── main.go
The actual pipeline is a separate go module inside the ci folder. Executing the pipeline via ...
cd ci && go run main.go
... works as expected when in ci/main.go the dagger client connects using the workdir (relatively set) set to the app folder like this
client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stdout), dagger.WithWorkdir(".."))
Is it possible to run this pipeline via dagger run? I tried several variations with dagger run --workdir but it didn't work.
Inside the ci folder dagger run go run ./main.go states
panic: cannot configure workdir for existing session (please use --workdir or host.directory with absolute paths instead)
Could someone explain how this session mechanism works? As far as I understand the dagger cli starts it's own session and the workdir could not be set via dagger.Connect(...)?
Is there a way to query via the sdk if there is already an existing session?
As another attempt I removed the dagger.WithWorkdir('..') argument from dagger.Connect(...) and tried setting the workdir via the --workdir flag only. E.g. in the project root folder
dagger --workdir ./app run go run ../ci/main.go fails with ./ci/main.go:9:2: no required module provides package dagger.io/dagger
It seems that the split into separate go modules might not be possible? Maybe i miss something very important here?
Thanks in advance for any help?