Skip to content

Commit

Permalink
chore: remove refs to deprecated io/ioutil (openkruise#1404)
Browse files Browse the repository at this point in the history
* chore: remove refs to deprecated io/ioutil


* fix: gofmt checker.go


---------
  • Loading branch information
testwill authored Sep 7, 2023
1 parent 7955c64 commit 76809ef
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions pkg/webhook/util/health/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"crypto/tls"
"crypto/x509"
"fmt"
"io/ioutil"
"net/http"
"os"
"path"
"sync"

Expand All @@ -40,7 +40,7 @@ var (
)

func loadHTTPClientWithCACert() error {
caCert, err := ioutil.ReadFile(caCertFilePath)
caCert, err := os.ReadFile(caCertFilePath)
if err != nil {
return err
}
Expand Down
9 changes: 4 additions & 5 deletions pkg/webhook/util/writer/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package writer
import (
"errors"
"fmt"
"io/ioutil"
"os"
"path"

Expand Down Expand Up @@ -158,19 +157,19 @@ func (f *fsCertWriter) read() (*generator.Artifacts, error) {
if err := ensureExist(f.Path); err != nil {
return nil, err
}
caKeyBytes, err := ioutil.ReadFile(path.Join(f.Path, CAKeyName))
caKeyBytes, err := os.ReadFile(path.Join(f.Path, CAKeyName))
if err != nil {
return nil, err
}
caCertBytes, err := ioutil.ReadFile(path.Join(f.Path, CACertName))
caCertBytes, err := os.ReadFile(path.Join(f.Path, CACertName))
if err != nil {
return nil, err
}
certBytes, err := ioutil.ReadFile(path.Join(f.Path, ServerCertName))
certBytes, err := os.ReadFile(path.Join(f.Path, ServerCertName))
if err != nil {
return nil, err
}
keyBytes, err := ioutil.ReadFile(path.Join(f.Path, ServerKeyName))
keyBytes, err := os.ReadFile(path.Join(f.Path, ServerKeyName))
if err != nil {
return nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/framework/test_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package framework
import (
"flag"
"fmt"
"io/ioutil"
"os"
"time"

Expand Down Expand Up @@ -346,7 +345,7 @@ func AfterReadingAllFlags(t *TestContextType) {
if len(t.Host) == 0 && len(t.KubeConfig) == 0 {
// Check if we can use the in-cluster config
if clusterConfig, err := restclient.InClusterConfig(); err == nil {
if tempFile, err := ioutil.TempFile(os.TempDir(), "kubeconfig-"); err == nil {
if tempFile, err := os.CreateTemp(os.TempDir(), "kubeconfig-"); err == nil {
kubeConfig := createKubeConfig(clusterConfig)
clientcmd.WriteToFile(*kubeConfig, tempFile.Name())
t.KubeConfig = tempFile.Name()
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/framework/testfiles/testfiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"errors"
"fmt"
"io/fs"
"io/ioutil"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -123,7 +122,7 @@ func (r RootFileSource) ReadTestFile(filePath string) ([]byte, error) {
} else {
fullPath = filepath.Join(r.Root, filePath)
}
data, err := ioutil.ReadFile(fullPath)
data, err := os.ReadFile(fullPath)
if os.IsNotExist(err) {
// Not an error (yet), some other provider may have the file.
return nil, nil
Expand Down

0 comments on commit 76809ef

Please sign in to comment.