MCPcopy
hub / github.com/dagger/dagger / Save

Method Save

cmd/dagger/shell_state.go:308–326  ·  view source on GitHub ↗

Save the shell state in the state store so it can be retrieved by the next call in the chain

(ctx context.Context, st ShellState)

Source from the content-addressed store, hash-verified

306// Save the shell state in the state store so it can be retrieved by the
307// next call in the chain
308func (h *shellCallHandler) Save(ctx context.Context, st ShellState) error {
309 if st.Key != "" {
310 // Replace instead of mutate otherwise it's harder to manage
311 // when it's saved in a var.
312 defer h.state.Delete(ctx, st.Key)
313 }
314 nkey := h.state.Store(st)
315 w := interp.HandlerCtx(ctx).Stdout
316
317 if debugFlag && h.Debug() {
318 slog := slog.SpanLogger(ctx, InstrumentationLibrary)
319 slog.Debug("saving state", spreadDebugArgs(&st, "newKey", nkey)...)
320 }
321
322 // Writing a state to the handler's stdout will resolve the state if it's
323 // the last one in the chain, so this could return an API error, for example.
324 _, err := w.Write([]byte(newStateToken(nkey)))
325 return err
326}
327
328// Function returns the last function in the chain, if not empty
329func (st ShellState) Function() FunctionCall {

Callers 1

ExecMethod · 0.95

Calls 8

DebugMethod · 0.95
SpanLoggerFunction · 0.92
DebugFunction · 0.92
spreadDebugArgsFunction · 0.85
newStateTokenFunction · 0.85
WriteMethod · 0.65
DeleteMethod · 0.45
StoreMethod · 0.45

Tested by

no test coverage detected