MCPcopy Index your code
hub / github.com/coder/coder / run

Function run

agent/agentcontainers/containers_dockercli.go:220–229  ·  view source on GitHub ↗

Helper function to run a command and return its stdout and stderr. We want to differentiate stdout and stderr instead of using CombinedOutput. We also want to differentiate between a command running successfully with output to stderr and a non-zero exit code.

(ctx context.Context, execer agentexec.Execer, cmd string, args ...string)

Source from the content-addressed store, hash-verified

218// We also want to differentiate between a command running successfully with
219// output to stderr and a non-zero exit code.
220func run(ctx context.Context, execer agentexec.Execer, cmd string, args ...string) (stdout, stderr string, err error) {
221 var stdoutBuf, stderrBuf strings.Builder
222 execCmd := execer.CommandContext(ctx, cmd, args...)
223 execCmd.Stdout = &stdoutBuf
224 execCmd.Stderr = &stderrBuf
225 err = execCmd.Run()
226 stdout = strings.TrimSpace(stdoutBuf.String())
227 stderr = strings.TrimSpace(stderrBuf.String())
228 return stdout, stderr, err
229}
230
231// dockerCLI is an implementation for Docker CLI that lists containers.
232type dockerCLI struct {

Callers 1

EnvInfoFunction · 0.70

Calls 3

CommandContextMethod · 0.65
RunMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected