MCPcopy Index your code
hub / github.com/dagger/dagger / RunE

Method RunE

cmd/dagger/functions.go:733–762  ·  view source on GitHub ↗

RunE is the final command in the function chain, where the API request is made.

(ctx context.Context, fn *modFunction)

Source from the content-addressed store, hash-verified

731
732// RunE is the final command in the function chain, where the API request is made.
733func (fc *FuncCommand) RunE(ctx context.Context, fn *modFunction) func(*cobra.Command, []string) error {
734 return func(cmd *cobra.Command, args []string) error {
735 q := handleObjectLeaf(fc.q, fn.ReturnType)
736
737 // Silence usage from this point on as errors don't likely come
738 // from wrong CLI usage.
739 fc.showUsage = false
740
741 o := cmd.OutOrStdout()
742 e := cmd.ErrOrStderr()
743
744 // It's possible that a chain ending in an object doesn't have anything
745 // else to sub-select. In that case `q` will be nil to signal that we
746 // just want to return the object's name, without making an API request.
747 if q == nil {
748 if fn.ReturnType.Name() == "Query" {
749 return printEncodedID(o, "")
750 }
751 return handleResponse(ctx, fc.c.Dagger(), fn.ReturnType, nil, o, e, autoApply)
752 }
753
754 var response any
755
756 if err := makeRequest(ctx, q, &response); err != nil {
757 return err
758 }
759
760 return handleResponse(ctx, fc.c.Dagger(), fn.ReturnType, response, o, e, autoApply)
761 }
762}
763
764func handleObjectLeaf(q *querybuilder.Selection, typeDef *modTypeDef) *querybuilder.Selection {
765 obj := typeDef.AsFunctionProvider()

Callers 2

executeMethod · 0.95
makeSubCmdMethod · 0.95

Calls 6

handleObjectLeafFunction · 0.85
printEncodedIDFunction · 0.85
handleResponseFunction · 0.85
makeRequestFunction · 0.85
DaggerMethod · 0.80
NameMethod · 0.65

Tested by

no test coverage detected