MCPcopy Create free account
hub / github.com/dagger/dagger / DynamicInputsForCall

Method DynamicInputsForCall

core/modfunc.go:627–787  ·  view source on GitHub ↗

nolint:gocyclo // intrinsically long state machine; refactoring would hurt clarity

(
	ctx context.Context,
	parent dagql.AnyResult,
	args map[string]dagql.Input,
	view call.View,
	req *dagql.CallRequest,
)

Source from the content-addressed store, hash-verified

625
626//nolint:gocyclo // intrinsically long state machine; refactoring would hurt clarity
627func (fn *ModuleFunction) DynamicInputsForCall(
628 ctx context.Context,
629 parent dagql.AnyResult,
630 args map[string]dagql.Input,
631 view call.View,
632 req *dagql.CallRequest,
633) error {
634 var ctxArgs []*FunctionArg
635 var workspaceArgs []*FunctionArg
636 var userDefaults []*UserDefault
637
638 // The decoded args map includes schema defaults, but the call ID only
639 // contains arguments the caller explicitly provided. Use the call ID so
640 // .env user defaults can still override schema defaults like Python "= None".
641 explicitArgs := map[string]bool{}
642 for _, idArg := range req.Args {
643 explicitArgs[idArg.Name] = true
644 }
645
646 for _, argMetadataRes := range fn.metadata.Args {
647 argMetadata := argMetadataRes.Self()
648 if explicitArgs[argMetadata.Name] {
649 // was explicitly set by the user, skip
650 continue
651 }
652 if argMetadata.TypeDef.Self().Kind != TypeDefKindObject &&
653 (argMetadata.TypeDef.Self().Kind != TypeDefKindList ||
654 !argMetadata.TypeDef.Self().AsList.Valid ||
655 argMetadata.TypeDef.Self().AsList.Value.Self() == nil ||
656 argMetadata.TypeDef.Self().AsList.Value.Self().ElementTypeDef.Self() == nil ||
657 argMetadata.TypeDef.Self().AsList.Value.Self().ElementTypeDef.Self().Kind != TypeDefKindObject) {
658 // Only default objects need processing at this time.
659 // Primitive default values were already processes earlier
660 // in the flow.
661 // This applies to both types of object defaults:
662 // 1) "contextual args" from `defaultPath` annotations
663 // 2) "user defaults" from user-defined .env
664 // 3) "workspace args" that are automatically injected
665 continue
666 }
667 // Check for Workspace arguments first - they're always injected
668 if argMetadata.IsWorkspace() {
669 workspaceArgs = append(workspaceArgs, argMetadata)
670 continue
671 }
672 userDefault, hasUserDefault, err := fn.UserDefault(ctx, argMetadata.Name)
673 if err != nil {
674 return fmt.Errorf("%s.%s(%s=): load user default: %w",
675 fn.mod.Self().Name(),
676 fn.metadata.Name,
677 argMetadata.Name,
678 err,
679 )
680 }
681 if hasUserDefault {
682 userDefaults = append(userDefaults, userDefault)
683 } else if argMetadata.isContextual() {
684 ctxArgs = append(ctxArgs, argMetadata)

Callers

nothing calls this directly

Calls 13

UserDefaultMethod · 0.95
loadContextualArgMethod · 0.95
loadWorkspaceArgMethod · 0.95
CurrentDagqlServerFunction · 0.92
OptFunction · 0.92
SelfMethod · 0.80
IsWorkspaceMethod · 0.80
isContextualMethod · 0.80
DagqlIDMethod · 0.80
SetArgInputMethod · 0.80
NameMethod · 0.65
WaitMethod · 0.65

Tested by

no test coverage detected