MCPcopy
hub / github.com/dagger/dagger / loadInput

Method loadInput

cmd/dagger/shell_exec.go:286–313  ·  view source on GitHub ↗
(ctx context.Context, args []string)

Source from the content-addressed store, hash-verified

284}
285
286func (h *shellCallHandler) loadInput(ctx context.Context, args []string) (*ShellState, error) {
287 stdin := interp.HandlerCtx(ctx).Stdin
288
289 // First command in pipeline: e.g., `cmd1 | cmd2 | cmd3`
290 if stdin == nil {
291 return nil, nil
292 }
293
294 b, err := io.ReadAll(stdin)
295 if err != nil {
296 return nil, err
297 }
298 s := string(b)
299
300 // Stdin expects a single state
301 st, err := h.state.Load(GetStateKey(s))
302 if st == nil && err == nil {
303 if h.Debug() {
304 // Need `.debug` to check what was actually passed. Just write
305 // to stderr instead of logger.
306 shellDebug(ctx, "unexpected stdin", args, s)
307 }
308 return nil, fmt.Errorf("unexpected input for command %q", args[0])
309 }
310
311 // Should pass state even if err != nil, for cleanup.
312 return st, err
313}
314
315// cmd is the main logic for executing simple commands
316func (h *shellCallHandler) cmd(ctx context.Context, args []string, st *ShellState) (*ShellState, error) {

Callers 1

ExecMethod · 0.95

Calls 4

DebugMethod · 0.95
GetStateKeyFunction · 0.85
shellDebugFunction · 0.85
LoadMethod · 0.65

Tested by

no test coverage detected