MCPcopy
hub / github.com/kubernetes/client-go / watchErrorStream

Function watchErrorStream

tools/remotecommand/errorstream.go:36–55  ·  view source on GitHub ↗

watchErrorStream watches the errorStream for remote command error data, decodes it with the given errorStreamDecoder, sends the decoded error (or nil if the remote command exited successfully) to the returned error channel, and closes it. This function returns immediately.

(errorStream io.Reader, d errorStreamDecoder)

Source from the content-addressed store, hash-verified

34// command exited successfully) to the returned error channel, and closes it.
35// This function returns immediately.
36func watchErrorStream(errorStream io.Reader, d errorStreamDecoder) chan error {
37 errorChan := make(chan error)
38
39 go func() {
40 defer runtime.HandleCrash()
41
42 message, err := ioutil.ReadAll(errorStream)
43 switch {
44 case err != nil && err != io.EOF:
45 errorChan <- fmt.Errorf("error reading from error stream: %s", err)
46 case len(message) > 0:
47 errorChan <- d.decode(message)
48 default:
49 errorChan <- nil
50 }
51 close(errorChan)
52 }()
53
54 return errorChan
55}

Callers 4

streamMethod · 0.85
streamMethod · 0.85
streamMethod · 0.85
TestV2ErrorStreamReadingFunction · 0.85

Calls 2

ErrorfMethod · 0.65
decodeMethod · 0.65

Tested by 1

TestV2ErrorStreamReadingFunction · 0.68