replace ioutil with io and os for pkg/api

This commit is contained in:
ahrtr 2021-10-30 14:49:09 +08:00
parent fc6890f902
commit e8a0289455
3 changed files with 9 additions and 9 deletions

View File

@ -17,8 +17,8 @@ limitations under the License.
package testing
import (
"io/ioutil"
"math/rand"
"os"
"testing"
"github.com/google/go-cmp/cmp"
@ -59,7 +59,7 @@ func BenchmarkPodConversion(b *testing.B) {
}
func BenchmarkNodeConversion(b *testing.B) {
data, err := ioutil.ReadFile("node_example.json")
data, err := os.ReadFile("node_example.json")
if err != nil {
b.Fatalf("Unexpected error while reading file: %v", err)
}
@ -89,7 +89,7 @@ func BenchmarkNodeConversion(b *testing.B) {
}
func BenchmarkReplicationControllerConversion(b *testing.B) {
data, err := ioutil.ReadFile("replication_controller_example.json")
data, err := os.ReadFile("replication_controller_example.json")
if err != nil {
b.Fatalf("Unexpected error while reading file: %v", err)
}

View File

@ -17,7 +17,7 @@ limitations under the License.
package testing
import (
"io/ioutil"
"os"
"testing"
"time"
@ -140,7 +140,7 @@ func BenchmarkPodCopy(b *testing.B) {
}
func BenchmarkNodeCopy(b *testing.B) {
data, err := ioutil.ReadFile("node_example.json")
data, err := os.ReadFile("node_example.json")
if err != nil {
b.Fatalf("Unexpected error while reading file: %v", err)
}
@ -159,7 +159,7 @@ func BenchmarkNodeCopy(b *testing.B) {
}
func BenchmarkReplicationControllerCopy(b *testing.B) {
data, err := ioutil.ReadFile("replication_controller_example.json")
data, err := os.ReadFile("replication_controller_example.json")
if err != nil {
b.Fatalf("Unexpected error while reading file: %v", err)
}

View File

@ -20,7 +20,7 @@ import (
"bytes"
"encoding/hex"
gojson "encoding/json"
"io/ioutil"
"io"
"math/rand"
"reflect"
"testing"
@ -363,7 +363,7 @@ func TestObjectWatchFraming(t *testing.T) {
if n, err := w.Write(obj.Bytes()); err != nil || n != len(obj.Bytes()) {
t.Fatal(err)
}
sr := streaming.NewDecoder(framer.NewFrameReader(ioutil.NopCloser(out)), s)
sr := streaming.NewDecoder(framer.NewFrameReader(io.NopCloser(out)), s)
resultSecret := &v1.Secret{}
res, _, err := sr.Decode(nil, resultSecret)
if err != nil {
@ -392,7 +392,7 @@ func TestObjectWatchFraming(t *testing.T) {
if n, err := w.Write(obj.Bytes()); err != nil || n != len(obj.Bytes()) {
t.Fatal(err)
}
sr = streaming.NewDecoder(framer.NewFrameReader(ioutil.NopCloser(out)), s)
sr = streaming.NewDecoder(framer.NewFrameReader(io.NopCloser(out)), s)
outEvent := &metav1.WatchEvent{}
_, _, err = sr.Decode(nil, outEvent)
if err != nil || outEvent.Type != string(watch.Added) {