MCPcopy
hub / github.com/dagger/dagger / ModuleConstructor

Method ModuleConstructor

cmd/dagger/module_inspect.go:571–582  ·  view source on GitHub ↗

ModuleConstructor returns the constructor function for the module's named main object. This is the module-specific constructor (e.g. Query.myMod()), as opposed to MainObject.AsObject.Constructor which is Query's synthetic "with" or no-op constructor. Returns nil if no named constructor is available.

()

Source from the content-addressed store, hash-verified

569// is Query's synthetic "with" or no-op constructor.
570// Returns nil if no named constructor is available.
571func (m *moduleDef) ModuleConstructor() *modFunction {
572 if obj := m.GetObject(m.Name); obj != nil && obj.Constructor != nil && obj.Constructor.Name != "" {
573 return obj.Constructor
574 }
575 // Only fall back to MainObject's constructor if it's a real one
576 // or the Query-side shell constructor path. The object typedef constructor
577 // can be metadata-only with an empty name.
578 if c := m.MainObject.AsObject.Constructor; c != nil {
579 return c
580 }
581 return nil
582}
583
584func (m *moduleDef) HasMainFunction(name string) bool {
585 return m.GetMainFunction(name) != nil

Callers 3

entrypointCallMethod · 0.80
constructorCallMethod · 0.80
StateResultMethod · 0.80

Calls 1

GetObjectMethod · 0.95

Tested by

no test coverage detected