Anatomy of a Call
cmd/dagger/functions
initializeDefaultModule
modSrc = dag.ModuleSource(modRef)
modSrc.AsModule().Serve() -> moduleSourceSchema.moduleSourceAsModule
- create a new
core.Module mod instance
loadDependencyModules
- for each dependent module as a
ModuleSource object
mod.Deps = dependencies
runModuleDefInSDK
- get types exposed by the module
- (if self calls)
modSrc.SDKImpl.AsTypeDefs().TypeDefs(dependent modules) -> core.Module
deps.SchemaIntrospectionJSONFile
- get all the core types (except
host) and the types exposed by the dependencies and registered in the engine
- dependencies have already been loaded above inside
loadDependencyModules, calling depModSrc.AsModule()
mod.sdk.moduleTypeDefs(modSrc, introspectionJSON)
- function defined inside the SDK and returning a
core.Module with the types exposed by the module itself
- (if no self calls)
mod.Runtime = modSrc.SDKImpl.AsRuntime()
mod.Runtime -> call module function "" -> get result as a core.Module
- add exposed types to the module
mod = mod.WithObject()....WithInterface()....WithEnum()....Patch()
- (if self calls)
mod.Deps = mod.Deps.Append(mod) => TODO: fix duplicate?
- (if self calls)
- initialize module runtime that has not been used to get the types (due to Go private modules and SSH socket closed after) => TODO: fix duplicate?
mod.Runtime = modSrc.SDKImpl.AsRuntime().Sync()
- (if self calls)
- add module as its own dependency
mod.Deps = mod.Deps.Append(mod) => TODO: fix duplicate?
- preload the module Runtime => TODO: fix duplicate?
mod.Runtime = modSrc.SDKImpl.AsRuntime()
def = inspectModule(modSrc) query engine for module source info, using the module source ID
def.loadTypeDefs query engine for types exposed by the module
loadCommand
RunE
Anatomy of a Develop
cmd/dagger/module - moduleDevelopCmd
- get SDK
modSrc.SDK().Source()
- set SDK if a specific is defined at develop time:
modSrc = modSrc.SourceSubpath()
- get source path
modSrc.GeneratedContextDirectory() -> moduleSourceSchema.moduleSourceGeneratedContextDirectory
- in:
core.ModuleSource
out: core.Directory
runCodegen
loadDependencyModules
- for each dependent module as a
ModuleSource object
deps = deps.append(depModSrc.AsModule())
- (if self calls)
modSrc.AsModule() => TODO: why not just modSrc.SDKImpl.AsTypeDefs().TypeDefs(dependent modules)?
deps = mod.Deps.Append(mod) // TODO: shouldn't it be something like deps = deps.Append(mod) instead?
modSrc.SDKImpl.AsCodeGenerator().Codegen(deps, modSrc)
deps.SchemaIntrospectionJSONFile
- get all the core types (except
host) and the types exposed by the dependencies and registered in the engine
- dependencies have already been loaded above inside
loadDependencyModules, calling depModSrc.AsModule()
mod.sdk.codegen(modSrc, introspectionJSON)
- function defined inside the SDK and returning a
core.GeneratedCode object
- update
.gitattributes, .gitignore
- return the directory
runClientGenerator (-> not yet detailed)
- write
dagger.json
- return the
diff between what has been generated and the original context directory
.Export(modSrc.LocalContextDirectoryPath())
- apply the
diff to the local directory