MCPcopy
hub / github.com/dagger/dagger / StateLookup

Method StateLookup

cmd/dagger/shell_exec.go:385–419  ·  view source on GitHub ↗
(ctx context.Context, name string)

Source from the content-addressed store, hash-verified

383}
384
385func (h *shellCallHandler) StateLookup(ctx context.Context, name string) (*ShellState, error) {
386 if h.Debug() {
387 shellDebug(ctx, "StateLookup", name)
388 }
389
390 def := h.GetDef(nil)
391
392 // 1. Function in current context (module or core)
393 if def.HasMainFunction(name) {
394 st := h.NewState()
395 return &st, nil
396 }
397
398 // Module-specific lookups
399 if def.HasModule() {
400 // 2. Is it the current module's name (or ".")?
401 // Treat as the module's named constructor function on Query.
402 if def.Name == name || name == "." {
403 st := h.NewState()
404 return &st, nil
405 }
406 }
407
408 // 4. Path to local or remote module source
409 def, _, err := h.maybeLoadModule(ctx, name)
410 if err != nil {
411 return nil, err
412 }
413 if def != nil {
414 st := h.newModState(def.SourceDigest)
415 return &st, nil
416 }
417
418 return nil, fmt.Errorf("function or module %q not found", name)
419}
420
421func (h *shellCallHandler) constructorCall(ctx context.Context, md *moduleDef, st *ShellState, args []string) (*ShellState, error) {
422 fn := md.ModuleConstructor()

Callers 2

entrypointCallMethod · 0.95
registerCommandsMethod · 0.95

Calls 8

DebugMethod · 0.95
GetDefMethod · 0.95
NewStateMethod · 0.95
maybeLoadModuleMethod · 0.95
newModStateMethod · 0.95
shellDebugFunction · 0.85
HasMainFunctionMethod · 0.80
HasModuleMethod · 0.80

Tested by

no test coverage detected