Skip to content

Commit c613b3c

Browse files
authored
Replace bytes.NewReader with strings.NewReader (#3619)
1 parent f1e132b commit c613b3c

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

‎cmd/experimental/kjobctl/pkg/cmd/describe/describe_test.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ limitations under the License.
1717
package describe
1818

1919
import (
20-
"bytes"
2120
"io"
2221
"net/http"
22+
"strings"
2323
"testing"
2424
"time"
2525

@@ -716,7 +716,7 @@ Worker Groups:
716716
NegotiatedSerializer: resource.UnstructuredPlusDefaultContentConfig().NegotiatedSerializer,
717717
Resp: &http.Response{
718718
StatusCode: http.StatusOK,
719-
Body: io.NopCloser(bytes.NewReader([]byte(runtime.EncodeOrDie(codec, tc.objs[0])))),
719+
Body: io.NopCloser(strings.NewReader(runtime.EncodeOrDie(codec, tc.objs[0]))),
720720
},
721721
})
722722
}

‎cmd/experimental/kjobctl/pkg/parser/slurm.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package parser
1818

1919
import (
2020
"bufio"
21-
"bytes"
2221
"errors"
2322
"fmt"
2423
"regexp"
@@ -57,7 +56,7 @@ type ParsedSlurmFlags struct {
5756
func SlurmFlags(script string, ignoreUnknown bool) (ParsedSlurmFlags, error) {
5857
var flags ParsedSlurmFlags
5958

60-
scanner := bufio.NewScanner(bytes.NewReader([]byte(script)))
59+
scanner := bufio.NewScanner(strings.NewReader(script))
6160

6261
for scanner.Scan() {
6362
line := strings.TrimSpace(scanner.Text())

‎cmd/kueuectl/app/list/list_pods_test.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ func mockRESTClient(codec runtime.Codec, tc podTestCase) (*restfake.RESTClient,
833833
return &http.Response{
834834
StatusCode: http.StatusOK,
835835
Header: getDefaultHeader(),
836-
Body: io.NopCloser(bytes.NewReader([]byte(runtime.EncodeOrDie(codec, tc.job)))),
836+
Body: io.NopCloser(strings.NewReader(runtime.EncodeOrDie(codec, tc.job))),
837837
}, nil
838838
case fmt.Sprintf("%s/pods", reqPathPrefix):
839839
return &http.Response{
@@ -900,5 +900,5 @@ func emptyTableObjBody(codec runtime.Codec) io.ReadCloser {
900900
table := &metav1.Table{
901901
ColumnDefinitions: podColumns,
902902
}
903-
return io.NopCloser(bytes.NewReader([]byte(runtime.EncodeOrDie(codec, table))))
903+
return io.NopCloser(strings.NewReader(runtime.EncodeOrDie(codec, table)))
904904
}

‎cmd/kueuectl/app/list/list_workload_test.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ limitations under the License.
1717
package list
1818

1919
import (
20-
"bytes"
2120
"fmt"
2221
"io"
2322
"net/http"
23+
"strings"
2424
"testing"
2525
"time"
2626

@@ -911,7 +911,7 @@ wl2 j2 lq2 cq2 PENDING 22
911911
NegotiatedSerializer: resource.UnstructuredPlusDefaultContentConfig().NegotiatedSerializer,
912912
Resp: &http.Response{
913913
StatusCode: http.StatusOK,
914-
Body: io.NopCloser(bytes.NewReader([]byte(runtime.EncodeOrDie(codec, tc.job[0])))),
914+
Body: io.NopCloser(strings.NewReader(runtime.EncodeOrDie(codec, tc.job[0]))),
915915
},
916916
})
917917
}

0 commit comments

Comments
 (0)