mirror of
https://github.com/yannh/kubeconform.git
synced 2026-02-21 10:57:01 +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"
|
"crypto/sha256"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
@ -37,12 +37,12 @@ func (c *onDisk) Get(resourceKind, resourceAPIVersion, k8sVersion string) (inter
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return ioutil.ReadAll(f)
|
return io.ReadAll(f)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set adds a JSON schema to the schema cache
|
// Set adds a JSON schema to the schema cache
|
||||||
func (c *onDisk) Set(resourceKind, resourceAPIVersion, k8sVersion string, schema interface{}) error {
|
func (c *onDisk) Set(resourceKind, resourceAPIVersion, k8sVersion string, schema interface{}) error {
|
||||||
c.Lock()
|
c.Lock()
|
||||||
defer c.Unlock()
|
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"
|
"crypto/tls"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
|
@ -99,7 +99,7 @@ func (r SchemaRegistry) DownloadSchema(resourceKind, resourceAPIVersion, k8sVers
|
||||||
return url, nil, fmt.Errorf(msg)
|
return url, nil, fmt.Errorf(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
msg := fmt.Sprintf("failed parsing schema from %s: %s", url, err)
|
msg := fmt.Sprintf("failed parsing schema from %s: %s", url, err)
|
||||||
if r.debug {
|
if r.debug {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package registry
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
@ -50,7 +50,7 @@ func TestDownloadSchema(t *testing.T) {
|
||||||
newMockHTTPGetter(func(url string) (resp *http.Response, err error) {
|
newMockHTTPGetter(func(url string) (resp *http.Response, err error) {
|
||||||
return &http.Response{
|
return &http.Response{
|
||||||
StatusCode: http.StatusNotFound,
|
StatusCode: http.StatusNotFound,
|
||||||
Body: ioutil.NopCloser(strings.NewReader("http response mock body")),
|
Body: io.NopCloser(strings.NewReader("http response mock body")),
|
||||||
}, nil
|
}, nil
|
||||||
}),
|
}),
|
||||||
"http://kubernetesjson.dev",
|
"http://kubernetesjson.dev",
|
||||||
|
|
@ -66,7 +66,7 @@ func TestDownloadSchema(t *testing.T) {
|
||||||
newMockHTTPGetter(func(url string) (resp *http.Response, err error) {
|
newMockHTTPGetter(func(url string) (resp *http.Response, err error) {
|
||||||
return &http.Response{
|
return &http.Response{
|
||||||
StatusCode: http.StatusServiceUnavailable,
|
StatusCode: http.StatusServiceUnavailable,
|
||||||
Body: ioutil.NopCloser(strings.NewReader("http response mock body")),
|
Body: io.NopCloser(strings.NewReader("http response mock body")),
|
||||||
}, nil
|
}, nil
|
||||||
}),
|
}),
|
||||||
"http://kubernetesjson.dev",
|
"http://kubernetesjson.dev",
|
||||||
|
|
@ -82,7 +82,7 @@ func TestDownloadSchema(t *testing.T) {
|
||||||
newMockHTTPGetter(func(url string) (resp *http.Response, err error) {
|
newMockHTTPGetter(func(url string) (resp *http.Response, err error) {
|
||||||
return &http.Response{
|
return &http.Response{
|
||||||
StatusCode: http.StatusOK,
|
StatusCode: http.StatusOK,
|
||||||
Body: ioutil.NopCloser(strings.NewReader("http response mock body")),
|
Body: io.NopCloser(strings.NewReader("http response mock body")),
|
||||||
}, nil
|
}, nil
|
||||||
}),
|
}),
|
||||||
"http://kubernetesjson.dev",
|
"http://kubernetesjson.dev",
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package registry
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
@ -47,7 +47,7 @@ func (r LocalRegistry) DownloadSchema(resourceKind, resourceAPIVersion, k8sVersi
|
||||||
}
|
}
|
||||||
|
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
content, err := ioutil.ReadAll(f)
|
content, err := io.ReadAll(f)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
msg := fmt.Sprintf("failed to read schema at %s: %s", schemaFile, err)
|
msg := fmt.Sprintf("failed to read schema at %s: %s", schemaFile, err)
|
||||||
if r.debug {
|
if r.debug {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue