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

Method StateResult

cmd/dagger/shell_exec.go:914–941  ·  view source on GitHub ↗

StateResult resolves a state into a value, more commonly by making an API request.

(ctx context.Context, st *ShellState)

Source from the content-addressed store, hash-verified

912
913// StateResult resolves a state into a value, more commonly by making an API request.
914func (h *shellCallHandler) StateResult(ctx context.Context, st *ShellState) (*Result, error) {
915 if st == nil {
916 return nil, nil
917 }
918
919 def := h.GetDef(st)
920 var err error
921
922 // Example: `build` (i.e., omitted constructor)
923 // Call the module's named constructor on Query.
924 if def.HasModule() && st.IsEmpty() {
925 if fn := def.ModuleConstructor(); fn != nil {
926 newSt := st.WithCall(fn, nil)
927 st = &newSt
928 }
929 }
930
931 fn, err := st.Function().GetDef(def)
932 if err != nil {
933 return nil, err
934 }
935
936 r := &Result{typeDef: fn.ReturnType}
937 q := handleObjectLeaf(st.QueryBuilder(h.dag), fn.ReturnType)
938 err = makeRequest(ctx, q, &r.Value)
939
940 return r, err
941}
942
943func (h *shellCallHandler) getOrInitDef(ref string, fn func() (*moduleDef, error)) (*moduleDef, error) {
944 // Fast path

Callers 2

resolveStateMethod · 0.95
parseFlagValueMethod · 0.95

Calls 9

GetDefMethod · 0.95
handleObjectLeafFunction · 0.85
makeRequestFunction · 0.85
HasModuleMethod · 0.80
ModuleConstructorMethod · 0.80
WithCallMethod · 0.80
IsEmptyMethod · 0.45
FunctionMethod · 0.45
QueryBuilderMethod · 0.45

Tested by

no test coverage detected