mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-12 06:29:23 +00:00
chore: removing deprecated ioutil package
This commit is contained in:
parent
b7d7b4d0dc
commit
fcfe30804a
4 changed files with 11 additions and 11 deletions
6
pkg/cache/ondisk.go
vendored
6
pkg/cache/ondisk.go
vendored
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue