From da8c0ca830ea0105b93bf489249a82d8af155a02 Mon Sep 17 00:00:00 2001 From: guoguangwu Date: Wed, 7 Jun 2023 18:02:33 +0800 Subject: [PATCH] chore: remove refs to deprecated io/ioutil --- cloudmock/gce/gcphttp/utils.go | 4 ++-- pkg/applylib/mocks/mockkubeapiserver/patchresource.go | 4 ++-- pkg/applylib/mocks/mockkubeapiserver/putresource.go | 4 ++-- upup/pkg/fi/cloudup/openstack/metadata.go | 5 ++--- util/pkg/vfs/gsfs.go | 3 +-- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/cloudmock/gce/gcphttp/utils.go b/cloudmock/gce/gcphttp/utils.go index b88c5ef90dc4d..6fe0233a87de4 100644 --- a/cloudmock/gce/gcphttp/utils.go +++ b/cloudmock/gce/gcphttp/utils.go @@ -20,7 +20,7 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" ) @@ -101,7 +101,7 @@ func buildJSONResponse(statusCode int, obj interface{}) (*http.Response, error) r.Header = make(http.Header) r.Header.Add("Content-Type", "application/json; charset=UTF-8") - r.Body = ioutil.NopCloser(bytes.NewReader(b)) + r.Body = io.NopCloser(bytes.NewReader(b)) return r, nil } diff --git a/pkg/applylib/mocks/mockkubeapiserver/patchresource.go b/pkg/applylib/mocks/mockkubeapiserver/patchresource.go index d005df93f0248..8d5559b5dc837 100644 --- a/pkg/applylib/mocks/mockkubeapiserver/patchresource.go +++ b/pkg/applylib/mocks/mockkubeapiserver/patchresource.go @@ -18,7 +18,7 @@ package mockkubeapiserver import ( "fmt" - "io/ioutil" + "io" "net/http" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" @@ -43,7 +43,7 @@ func (req *patchResource) Run(s *MockKubeAPIServer) error { existing = objects.Objects[id] } - bodyBytes, err := ioutil.ReadAll(req.r.Body) + bodyBytes, err := io.ReadAll(req.r.Body) if err != nil { return err } diff --git a/pkg/applylib/mocks/mockkubeapiserver/putresource.go b/pkg/applylib/mocks/mockkubeapiserver/putresource.go index df88e9c1fc809..5a0512f326fbd 100644 --- a/pkg/applylib/mocks/mockkubeapiserver/putresource.go +++ b/pkg/applylib/mocks/mockkubeapiserver/putresource.go @@ -18,7 +18,7 @@ package mockkubeapiserver import ( "fmt" - "io/ioutil" + "io" "net/http" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" @@ -48,7 +48,7 @@ func (req *putResource) Run(s *MockKubeAPIServer) error { return req.writeErrorResponse(http.StatusNotFound) } - bodyBytes, err := ioutil.ReadAll(req.r.Body) + bodyBytes, err := io.ReadAll(req.r.Body) if err != nil { return err } diff --git a/upup/pkg/fi/cloudup/openstack/metadata.go b/upup/pkg/fi/cloudup/openstack/metadata.go index 85fce1345b313..54fa7ea7de39b 100644 --- a/upup/pkg/fi/cloudup/openstack/metadata.go +++ b/upup/pkg/fi/cloudup/openstack/metadata.go @@ -20,7 +20,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "os" "path" @@ -86,7 +85,7 @@ func newMetadataService(serviceURL string, configDrivePath string, mounter *moun // GetLocalMetadata returns a local metadata for the server func GetLocalMetadata() (*InstanceMetadata, error) { - mountTarget, err := ioutil.TempDir("", "configdrive") + mountTarget, err := os.MkdirTemp("", "configdrive") if err != nil { return nil, err } @@ -153,7 +152,7 @@ func (mds MetadataService) getFromMetadataService() (*InstanceMetadata, error) { func (mds MetadataService) parseMetadata(r io.Reader) (*InstanceMetadata, error) { var meta InstanceMetadata - data, err := ioutil.ReadAll(r) + data, err := io.ReadAll(r) if err != nil { return nil, err } diff --git a/util/pkg/vfs/gsfs.go b/util/pkg/vfs/gsfs.go index 1da908f4413d9..60501e0878f55 100644 --- a/util/pkg/vfs/gsfs.go +++ b/util/pkg/vfs/gsfs.go @@ -22,7 +22,6 @@ import ( "encoding/base64" "fmt" "io" - "io/ioutil" "net/http" "os" "path" @@ -420,7 +419,7 @@ type terraformGSObjectAccessControl struct { } func (p *GSPath) RenderTerraform(w *terraformWriter.TerraformWriter, name string, data io.Reader, acl ACL) error { - bytes, err := ioutil.ReadAll(data) + bytes, err := io.ReadAll(data) if err != nil { return fmt.Errorf("reading data: %v", err) }