#How do I start to make a module support

1 messages ยท Page 1 of 1 (latest)

stark cradle
#

You'll be on the cutting edge so definitely expect it to be a bit rough ๐Ÿ™‚ And any time you run into something that's especially difficult or seems like you'd prefer something simpler, please let us know! There's still lots of room to make this easier.

The best place to start is probably to look at how python does it: https://github.com/sipsma/dagger/blob/e1d69edbfd0f94c93489edac4d9d6050c36fc3b7/sdk/python/runtime/main.go

There's also an example of a third-party SDK from @indigo tapir here: https://github.com/ibuildthecloud/daggerverse/blob/214762c0b6c5b6510cfa70e35be22118840d254c/amlsdk/main.go

And an example of a module using that third-party SDK here https://github.com/ibuildthecloud/daggerverse/blob/214762c0b6c5b6510cfa70e35be22118840d254c/hello/dagger.json#L3

The basic idea is that SDKs are themselves just modules that implement two functions:

  • ModuleRuntime returns the container that the actual module code executes in
  • Codegen returns the directory containing source code that gives the module authors bindings to both the core API (pretty much same as our existing SDK codegen) plus bindings to the module's dependencies. You get the full introspection json that contains the graphql introspection result for all of that as an argument, so in theory it should mostly just be a matter of taking that and plugging it into the existing elixir codegen

The examples so far have all been written in Go, but in theory you could also write your SDK module in any of the other existing SDK langs too. And once the Elixir Module SDK exists anyone can use that one to write their own SDKs, etc.

#

It may also be useful to take a look at the codegen result of existing SDKs; i.e. if you take an existing go module, run dagger mod sync you can look at the main func at the bottom to see how Go approaches registering the module types and handling invocation

#

Let me know if that's helpful enough to start and any more questions that come up ๐Ÿ™‚