From 01953d156b544c0cbed72db437bcdd44bfdacd7a Mon Sep 17 00:00:00 2001 From: guoguangwu Date: Mon, 4 Sep 2023 15:05:29 +0800 Subject: [PATCH] chore: remove refs to deprecated io/ioutil --- internal/pkg/auth/gcr.go | 3 +-- internal/pkg/relays/docker/docker.go | 3 +-- internal/pkg/relays/skopeo/skopeo.go | 3 +-- internal/pkg/sync/config.go | 4 ++-- internal/pkg/test/registries/gcp.go | 3 +-- 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/internal/pkg/auth/gcr.go b/internal/pkg/auth/gcr.go index d829760..6ad0c37 100644 --- a/internal/pkg/auth/gcr.go +++ b/internal/pkg/auth/gcr.go @@ -19,7 +19,6 @@ package auth import ( "encoding/json" "fmt" - "io/ioutil" "net/http" "os" "time" @@ -104,7 +103,7 @@ func hasGoogleMetadataServer() bool { // func gcpTokenFromCreds() (string, time.Time, error) { - b, err := ioutil.ReadFile(os.Getenv("GOOGLE_APPLICATION_CREDENTIALS")) + b, err := os.ReadFile(os.Getenv("GOOGLE_APPLICATION_CREDENTIALS")) if err != nil { return "", time.Time{}, err } diff --git a/internal/pkg/relays/docker/docker.go b/internal/pkg/relays/docker/docker.go index 8e3da57..33ca945 100644 --- a/internal/pkg/relays/docker/docker.go +++ b/internal/pkg/relays/docker/docker.go @@ -20,7 +20,6 @@ import ( "context" "fmt" "io" - "io/ioutil" "os" "time" @@ -248,7 +247,7 @@ func (dc *dockerClient) handleLog(rc io.ReadCloser, err error, verbose bool) err defer rc.Close() out := dc.wrOut if !verbose { - out = ioutil.Discard + out = io.Discard } terminalFd := os.Stdout.Fd() isTerminal := dc.wrOut == os.Stdout && terminal.IsTerminal(int(terminalFd)) diff --git a/internal/pkg/relays/skopeo/skopeo.go b/internal/pkg/relays/skopeo/skopeo.go index 7cb1de8..3a0c721 100644 --- a/internal/pkg/relays/skopeo/skopeo.go +++ b/internal/pkg/relays/skopeo/skopeo.go @@ -21,7 +21,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "os/exec" "strings" @@ -144,7 +143,7 @@ func chooseOutStream(out io.Writer, verbose, isErrorStream bool) io.Writer { } return log.StandardLogger().WriterLevel(log.InfoLevel) } - return ioutil.Discard + return io.Discard } // diff --git a/internal/pkg/sync/config.go b/internal/pkg/sync/config.go index 25dd097..7df828c 100644 --- a/internal/pkg/sync/config.go +++ b/internal/pkg/sync/config.go @@ -18,8 +18,8 @@ package sync import ( "fmt" - "io/ioutil" "path/filepath" + "os" "time" "gopkg.in/yaml.v2" @@ -241,7 +241,7 @@ func (c *SyncConfig) isChanged(evt fsnotify.Event) bool { // func LoadConfig(file string) (*SyncConfig, error) { - data, err := ioutil.ReadFile(file) + data, err := os.ReadFile(file) if err != nil { return nil, fmt.Errorf("error loading config file '%s': %v", file, err) diff --git a/internal/pkg/test/registries/gcp.go b/internal/pkg/test/registries/gcp.go index 42e53bb..747af43 100644 --- a/internal/pkg/test/registries/gcp.go +++ b/internal/pkg/test/registries/gcp.go @@ -18,7 +18,6 @@ package registries import ( "fmt" - "io/ioutil" "os" "sort" "testing" @@ -90,7 +89,7 @@ func EmptyGARRepo(t *testing.T, p *test.Params) { // TODO: find out how to remove the repo func emptyGCPRepo(t *testing.T, repo gcrname.Repository) { - b, err := ioutil.ReadFile(os.Getenv(test.EnvGCPCreds)) + b, err := os.ReadFile(os.Getenv(test.EnvGCPCreds)) if err != nil { t.Fatal(err) }