MCPcopy
hub / github.com/dagger/dagger / entrypointCall

Method entrypointCall

cmd/dagger/shell_exec.go:341–378  ·  view source on GitHub ↗

entrypointCall is executed when it's the first command in a pipeline

(ctx context.Context, cmd string, args []string)

Source from the content-addressed store, hash-verified

339
340// entrypointCall is executed when it's the first command in a pipeline
341func (h *shellCallHandler) entrypointCall(ctx context.Context, cmd string, args []string) (*ShellState, error) {
342 if cmd, _ := h.BuiltinCommand(cmd); cmd != nil {
343 return nil, cmd.Execute(ctx, h, args, nil)
344 }
345
346 st, err := h.StateLookup(ctx, cmd)
347 if err != nil {
348 return nil, err
349 }
350 if h.Debug() {
351 shellDebug(ctx, "Entrypoint", cmd, args, st)
352 }
353
354 def := h.GetDef(st)
355
356 // Command is a function in current context (module or core)
357 if h.isCurrentContextFunction(cmd) {
358 // When MainObject is Query (entrypoint proxy or core-only),
359 // functions are already on Query - no constructor needed.
360 if def.MainObject.AsObject != nil && def.MainObject.AsObject.Name == "Query" {
361 newSt := h.NewState()
362 return h.functionCall(ctx, &newSt, cmd, args)
363 }
364 // We need to assume a constructor call without arguments
365 st, err := h.constructorCall(ctx, def, st, nil)
366 if err != nil {
367 return nil, err
368 }
369 return h.functionCall(ctx, st, cmd, args)
370 }
371
372 // Command is a module ref — invoke its named constructor on Query.
373 if def.HasModule() && st.IsEmpty() && def.ModuleConstructor() != nil {
374 return h.constructorCall(ctx, def, st, args)
375 }
376
377 return st, nil
378}
379
380func (h *shellCallHandler) isCurrentContextFunction(name string) bool {
381 def := h.GetDef(nil)

Callers 1

cmdMethod · 0.95

Calls 13

BuiltinCommandMethod · 0.95
StateLookupMethod · 0.95
DebugMethod · 0.95
GetDefMethod · 0.95
NewStateMethod · 0.95
functionCallMethod · 0.95
constructorCallMethod · 0.95
shellDebugFunction · 0.85
HasModuleMethod · 0.80
ModuleConstructorMethod · 0.80
ExecuteMethod · 0.45

Tested by

no test coverage detected