Merge pull request #18209 from mtrmac/no-NewBuffer

Don't use bytes.NewBuffer to read data
This commit is contained in:
OpenShift Merge Robot 2023-04-17 03:19:35 -04:00 • committed by GitHub
commit 5c70641e4f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -257,7 +257,7 @@ func (r *ConmonOCIRuntime) UpdateContainerStatus(ctr *Container) error {
if err != nil {
return fmt.Errorf("reading stdout: %s: %w", ctr.ID(), err)
}
if err := json.NewDecoder(bytes.NewBuffer(out)).Decode(state); err != nil {
if err := json.NewDecoder(bytes.NewReader(out)).Decode(state); err != nil {
return fmt.Errorf("decoding container status for container %s: %w", ctr.ID(), err)
}
ctr.state.PID = state.Pid

View file

@ -99,7 +99,7 @@ binaryData:
for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) {
buf := bytes.NewBufferString(test.configMapContent)
buf := bytes.NewReader([]byte(test.configMapContent))
cm, err := readConfigMapFromFile(buf)
if test.expectError {