MCPcopy Index your code
hub / github.com/devspace-sh/devspace / ExecBuffered

Method ExecBuffered

pkg/devspace/kubectl/exec.go:148–167  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

146
147// ExecBuffered executes a command for kubernetes and returns the output and error buffers
148func (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
170func (client *client) ExecBufferedCombined(ctx context.Context, pod *corev1.Pod, container string, command []string, stdin io.Reader) ([]byte, error) {

Callers 1

CopyFromReaderMethod · 0.95

Calls 1

ExecStreamMethod · 0.95

Tested by

no test coverage detected