MCPcopy
hub / github.com/kubernetes/node-problem-detector / readFromReader

Function readFromReader

pkg/custompluginmonitor/plugin/plugin.go:133–144  ·  view source on GitHub ↗

readFromReader reads the maxBytes from the reader and drains the rest.

(reader io.ReadCloser, maxBytes int64)

Source from the content-addressed store, hash-verified

131
132// readFromReader reads the maxBytes from the reader and drains the rest.
133func readFromReader(reader io.ReadCloser, maxBytes int64) ([]byte, error) {
134 limitReader := io.LimitReader(reader, maxBytes)
135 data, err := io.ReadAll(limitReader)
136 if err != nil {
137 return []byte{}, err
138 }
139 // Drain the reader
140 if _, err := io.Copy(io.Discard, reader); err != nil {
141 return []byte{}, err
142 }
143 return data, nil
144}
145
146func (p *Plugin) run(rule cpmtypes.CustomRule) (exitStatus cpmtypes.Status, output string) {
147 var ctx context.Context

Callers 1

runMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected