Stop using deprecated ioutil functions

This commit is contained in:
Katrina Verey
2022-08-10 16:59:18 -04:00
parent 416eed97c4
commit f6b72077c8
70 changed files with 322 additions and 362 deletions

View File

@@ -11,7 +11,6 @@ import (
"compress/gzip"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
@@ -215,7 +214,7 @@ func RestoreAsset(dir, name string) error {
if err != nil {
return err
}
err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
err = os.WriteFile(_filePath(dir, name), data, info.Mode())
if err != nil {
return err
}

View File

@@ -6,7 +6,7 @@ package openapi
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"reflect"
"strings"
@@ -220,7 +220,7 @@ func definitionRefsFromRNode(object *yaml.RNode) ([]string, error) {
// parseOpenAPI reads openAPIPath yaml and converts it to RNode
func parseOpenAPI(openAPIPath string) (*yaml.RNode, error) {
b, err := ioutil.ReadFile(openAPIPath)
b, err := os.ReadFile(openAPIPath)
if err != nil {
return nil, err
}

View File

@@ -5,7 +5,7 @@ package openapi
import (
"fmt"
"io/ioutil"
"os"
"testing"
"github.com/google/go-cmp/cmp"
@@ -116,11 +116,11 @@ openAPI:
name: image-name
value: "nginx"
`
f, err := ioutil.TempFile("", "openapi-")
f, err := os.CreateTemp("", "openapi-")
if !assert.NoError(t, err) {
t.FailNow()
}
if !assert.NoError(t, ioutil.WriteFile(f.Name(), []byte(inputyaml), 0600)) {
if !assert.NoError(t, os.WriteFile(f.Name(), []byte(inputyaml), 0600)) {
t.FailNow()
}
@@ -168,11 +168,11 @@ openAPI:
ref: "#/definitions/io.k8s.cli.setters.image-tag"
`
f, err := ioutil.TempFile("", "openapi-")
f, err := os.CreateTemp("", "openapi-")
if !assert.NoError(t, err) {
t.FailNow()
}
if !assert.NoError(t, ioutil.WriteFile(f.Name(), []byte(inputyaml), 0600)) {
if !assert.NoError(t, os.WriteFile(f.Name(), []byte(inputyaml), 0600)) {
t.FailNow()
}
@@ -203,11 +203,11 @@ func TestAddSchemaFromFile_empty(t *testing.T) {
kind: Example
`
f, err := ioutil.TempFile("", "openapi-")
f, err := os.CreateTemp("", "openapi-")
if !assert.NoError(t, err) {
t.FailNow()
}
if !assert.NoError(t, ioutil.WriteFile(f.Name(), []byte(inputyaml), 0600)) {
if !assert.NoError(t, os.WriteFile(f.Name(), []byte(inputyaml), 0600)) {
t.FailNow()
}