diff --git a/pkg/cache/ondisk.go b/pkg/cache/ondisk.go index 5d7e41b..9186879 100644 --- a/pkg/cache/ondisk.go +++ b/pkg/cache/ondisk.go @@ -4,7 +4,7 @@ import ( "crypto/sha256" "encoding/hex" "fmt" - "io/ioutil" + "io" "os" "path" "sync" @@ -37,12 +37,12 @@ func (c *onDisk) Get(resourceKind, resourceAPIVersion, k8sVersion string) (inter return nil, err } - return ioutil.ReadAll(f) + return io.ReadAll(f) } // Set adds a JSON schema to the schema cache func (c *onDisk) Set(resourceKind, resourceAPIVersion, k8sVersion string, schema interface{}) error { c.Lock() defer c.Unlock() - return ioutil.WriteFile(cachePath(c.folder, resourceKind, resourceAPIVersion, k8sVersion), schema.([]byte), 0644) + return os.WriteFile(cachePath(c.folder, resourceKind, resourceAPIVersion, k8sVersion), schema.([]byte), 0644) } diff --git a/pkg/registry/http.go b/pkg/registry/http.go index 2af0c6c..9d342d2 100644 --- a/pkg/registry/http.go +++ b/pkg/registry/http.go @@ -4,7 +4,7 @@ import ( "crypto/tls" "errors" "fmt" - "io/ioutil" + "io" "log" "net/http" "os" @@ -99,7 +99,7 @@ func (r SchemaRegistry) DownloadSchema(resourceKind, resourceAPIVersion, k8sVers return url, nil, fmt.Errorf(msg) } - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { msg := fmt.Sprintf("failed parsing schema from %s: %s", url, err) if r.debug { diff --git a/pkg/registry/http_test.go b/pkg/registry/http_test.go index 1ab4791..53962c9 100644 --- a/pkg/registry/http_test.go +++ b/pkg/registry/http_test.go @@ -3,7 +3,7 @@ package registry import ( "bytes" "fmt" - "io/ioutil" + "io" "net/http" "strings" "testing" @@ -50,7 +50,7 @@ func TestDownloadSchema(t *testing.T) { newMockHTTPGetter(func(url string) (resp *http.Response, err error) { return &http.Response{ StatusCode: http.StatusNotFound, - Body: ioutil.NopCloser(strings.NewReader("http response mock body")), + Body: io.NopCloser(strings.NewReader("http response mock body")), }, nil }), "http://kubernetesjson.dev", @@ -66,7 +66,7 @@ func TestDownloadSchema(t *testing.T) { newMockHTTPGetter(func(url string) (resp *http.Response, err error) { return &http.Response{ StatusCode: http.StatusServiceUnavailable, - Body: ioutil.NopCloser(strings.NewReader("http response mock body")), + Body: io.NopCloser(strings.NewReader("http response mock body")), }, nil }), "http://kubernetesjson.dev", @@ -82,7 +82,7 @@ func TestDownloadSchema(t *testing.T) { newMockHTTPGetter(func(url string) (resp *http.Response, err error) { return &http.Response{ StatusCode: http.StatusOK, - Body: ioutil.NopCloser(strings.NewReader("http response mock body")), + Body: io.NopCloser(strings.NewReader("http response mock body")), }, nil }), "http://kubernetesjson.dev", diff --git a/pkg/registry/local.go b/pkg/registry/local.go index ec9e047..7501290 100644 --- a/pkg/registry/local.go +++ b/pkg/registry/local.go @@ -3,7 +3,7 @@ package registry import ( "errors" "fmt" - "io/ioutil" + "io" "log" "os" ) @@ -47,7 +47,7 @@ func (r LocalRegistry) DownloadSchema(resourceKind, resourceAPIVersion, k8sVersi } defer f.Close() - content, err := ioutil.ReadAll(f) + content, err := io.ReadAll(f) if err != nil { msg := fmt.Sprintf("failed to read schema at %s: %s", schemaFile, err) if r.debug {