ExecBuffered executes a command for kubernetes and returns the output and error buffers
(ctx context.Context, pod *corev1.Pod, container string, command []string, stdin io.Reader)
| 146 | |
| 147 | // ExecBuffered executes a command for kubernetes and returns the output and error buffers |
| 148 | func (client *client) ExecBuffered(ctx context.Context, pod *corev1.Pod, container string, command []string, stdin io.Reader) ([]byte, []byte, error) { |
| 149 | stdoutBuffer := &bytes.Buffer{} |
| 150 | stderrBuffer := &bytes.Buffer{} |
| 151 | |
| 152 | kubeExecError := client.ExecStream(ctx, &ExecStreamOptions{ |
| 153 | Pod: pod, |
| 154 | Container: container, |
| 155 | Command: command, |
| 156 | Stdin: stdin, |
| 157 | Stdout: stdoutBuffer, |
| 158 | Stderr: stderrBuffer, |
| 159 | }) |
| 160 | if kubeExecError != nil { |
| 161 | if _, ok := kubeExecError.(kubectlExec.CodeExitError); !ok { |
| 162 | return nil, nil, kubeExecError |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | return stdoutBuffer.Bytes(), stderrBuffer.Bytes(), kubeExecError |
| 167 | } |
| 168 | |
| 169 | // ExecBufferedCombined starts a new exec request, waits for it to finish and returns the output to the caller |
| 170 | func (client *client) ExecBufferedCombined(ctx context.Context, pod *corev1.Pod, container string, command []string, stdin io.Reader) ([]byte, error) { |
no test coverage detected