#signature of Exec does have ctx context
1 messages ยท Page 1 of 1 (latest)
Let's jump back into this, time to learn how you can use Go to create a build and deploy pipeline using the new dagger.io SDK.
Learn with me as I use the new Dagger SDK to build a simple Go microservice and deploy it to DigitalOcean. There may be some Terraform involved too.
Be sure to tune in next time when we are going to see how Dagger and ...
Also, though we use ctx in many calls, we don't use it in our Execs in the Getting Started, for example.
has ctx:
output, err := build.Directory(path).ID(ctx)
...
_, err = workdir.Write(ctx, output, dagger.HostDirectoryWriteOpts{Path: path})
vs
no ctx:
build = build.Exec(dagger.ContainerExecOpts{
Args: []string{"go", "build", "-o", path},
})
yeah sorry I should have been more clear with "it shouldn't" ๐ The Exec function doesn't take a context, are you seeing some documentation where it does?
ah, core != sdk, what you're looking for is this: https://github.com/dagger/dagger/blob/main/sdk/go/api.gen.go#L213
which lines up with https://pkg.go.dev/dagger.io/dagger#Container.Exec
ah, right! I'm wondering if he thought it took a context because he looked at wrong spot too ๐
or just cuz so many other things do
Maybe! Can we do a better job of emphasizing the pkg.go.dev docs?
Dunno, I think I did a search in our repo for Exec and didn't even look that it was core vs sdk, lol. I was like, nice! found it!
It also aligned with the confusion/issue he was having, so I was like, "aha!"
Yeah makes sense! If it helps at all, what you're importing is technically https://github.com/dagger/dagger-go-sdk, so if you prefer to search repos, thats the one to do it on
d'oh, of course it is. I still wonder about the ctx vs no -ctx items. I guess we're looking to make IDs not required, so that ctx goes away...trying to wrap my head around which Context a user should be in charge of when it comes to the Dagger pipeline bit, if any.
It can definitely be confusing when you're first putting things together, especially if you're not aware of the underlying graphql api. I think of it as anything that actually causes an execution needs a context and returns an error (although apparently that's not always true ๐ )
"anything that actually causes an execution" except an Exec? ๐คฃ
or you mean execution in the go program?
Haha well technically ๐ค exec doesn't cause an execution, it just adds a command to the statement you're preparing. I mean execution as in something actually gets sent to the dagger engine
that's where the confusion lies I think, between "pipeline building" vs "graphql query building"
Yeah here's some more conversation stemming from that https://discord.com/channels/707636530424053791/1036707188892246118
ah, nice, that's super valuable. Hadn't seen that thread yet.
it's striking when he "runs" the exec (actually just prepares it) and nothing happens
https://www.youtube.com/watch?v=w-3K8in9jb4&t=1361s
Yes, I did see that, this triggered https://github.com/dagger/dagger/issues/3617
Maybe it should be called Command rather than Exec ... /cc @elfin apex
but basically at that point you're still constructing the DAG, not actually executing anything