Exec executes a command inside the container. executil.ExitError is returned if the command returns non-zero exit code.
(ctx context.Context, containerID string, cmd []string, stdin io.Reader, stdout, stderr io.WriteCloser, tty bool, resize <-chan remotecommand.TerminalSize)
| 40 | // Exec executes a command inside the container. executil.ExitError is returned if the command |
| 41 | // returns non-zero exit code. |
| 42 | func (s *streamRuntime) Exec(ctx context.Context, containerID string, cmd []string, stdin io.Reader, stdout, stderr io.WriteCloser, |
| 43 | tty bool, resize <-chan remotecommand.TerminalSize) error { |
| 44 | exitCode, err := s.c.execInContainer(ctrdutil.WithNamespace(ctx), containerID, execOptions{ |
| 45 | cmd: cmd, |
| 46 | stdin: stdin, |
| 47 | stdout: stdout, |
| 48 | stderr: stderr, |
| 49 | tty: tty, |
| 50 | resize: resize, |
| 51 | }) |
| 52 | if err != nil { |
| 53 | return fmt.Errorf("failed to exec in container: %w", err) |
| 54 | } |
| 55 | if *exitCode == 0 { |
| 56 | return nil |
| 57 | } |
| 58 | return &executil.CodeExitError{ |
| 59 | Err: fmt.Errorf("error executing command %v, exit code %d", cmd, *exitCode), |
| 60 | Code: int(*exitCode), |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | func (s *streamRuntime) Attach(ctx context.Context, containerID string, in io.Reader, out, err io.WriteCloser, tty bool, |
| 65 | resize <-chan remotecommand.TerminalSize) error { |
nothing calls this directly
no test coverage detected