Back to Dagger

SDK Architecture

skills/dagger-codegen/references/sdk-architecture.md

0.20.72.1 KB
Original Source

SDK Architecture

Load when: You need to understand SDK interfaces, add a new SDK, or figure out why Go SDK is different from others.

Built-in SDKs

Defined in core/sdk/consts.go:

SDKCodegenNotes
Gocmd/codegen/generator/go/Hardcoded in engine, NOT a module
Pythonsdk/python/codegen/Native Python, ~870 lines
TypeScriptcmd/codegen/generator/typescript/Shares cmd/codegen binary
Javasdk/java/dagger-codegen-maven-plugin/Maven plugin
PHPsdk/php/src/Codegen/PHP classes
Elixirsdk/elixir/dagger_codegen/Elixir mix

Experimental SDK

SDKCodegenNotes
.NETsdk/dotnet/sdk/Dagger.SDK.SourceGenerator/C# Source Generator; not in consts.go

Interfaces

All at core/sdk.go:

InterfaceLinePurposeImplementers
ClientGenerator20Generate standalone clientsGo, TypeScript
CodeGenerator93Generate in-module bindingsAll 6 built-in
Runtime145Provide execution containerAll 6 built-in
ModuleTypes179Extract user type definitionsAll 6 built-in

Why Go is Special

Go SDK is not a module. It's hardcoded in the engine.

Implementation: core/sdk/go_sdk.go

How it works:

  1. cmd/codegen binary is built
  2. Packaged into container, tarball'd
  3. Embedded in engine image
  4. Engine calls it directly (no module invocation)

All other SDKs are modules that expose interfaces via GraphQL fields. The engine loads them dynamically.

Consequence: Code paths differ between Go and module-based SDKs. Look at both when debugging.

Key Files

FilePurpose
core/sdk/consts.goBuilt-in SDK list
core/sdk.goInterface definitions
core/sdk/go_sdk.goGo SDK (hardcoded)
core/sdk/module.goModule-based SDK wrapper
core/sdk/module_code_generator.goCodeGenerator for module SDKs
core/sdk/module_client_generator.goClientGenerator for module SDKs