From 4f5b090f481ddcac85085a5be842489d8437172a Mon Sep 17 00:00:00 2001 From: Noam Gal Date: Thu, 17 Nov 2022 12:08:57 -0800 Subject: [PATCH] removed deprecated ioutil Signed-off-by: Noam Gal --- hack/cmd-docs/main.go | 5 ++--- pkg/application/application.go | 5 ++--- pkg/application/application_test.go | 6 +++--- pkg/fs/fs.go | 4 ++-- pkg/git/provider_bitbucket-server.go | 4 ++-- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/hack/cmd-docs/main.go b/hack/cmd-docs/main.go index d1fe35c0..214745cb 100644 --- a/hack/cmd-docs/main.go +++ b/hack/cmd-docs/main.go @@ -2,14 +2,13 @@ package main import ( "io/fs" - "io/ioutil" "log" "os" "path/filepath" "strings" "github.com/argoproj-labs/argocd-autopilot/cmd/commands" - + "github.com/spf13/cobra/doc" ) @@ -55,7 +54,7 @@ func replaceHome() error { log.Printf("replaced home at: %s", fname) - err = ioutil.WriteFile(fname, []byte(newstr), 0422) + err = os.WriteFile(fname, []byte(newstr), 0422) if err != nil { return err } diff --git a/pkg/application/application.go b/pkg/application/application.go index 698e00c8..1c52de33 100644 --- a/pkg/application/application.go +++ b/pkg/application/application.go @@ -3,7 +3,6 @@ package application import ( "errors" "fmt" - "io/ioutil" "os" "path/filepath" "reflect" @@ -512,7 +511,7 @@ func fixResourcesPaths(k *kusttypes.Kustomization, newKustDir string) error { } var generateManifests = func(k *kusttypes.Kustomization) ([]byte, error) { - td, err := ioutil.TempDir(".", "auto-pilot") + td, err := os.MkdirTemp(".", "auto-pilot") if err != nil { return nil, fmt.Errorf("failed creating temp dir: %w", err) } @@ -533,7 +532,7 @@ var generateManifests = func(k *kusttypes.Kustomization) ([]byte, error) { } kustomizationPath := filepath.Join(td, "kustomization.yaml") - if err = ioutil.WriteFile(kustomizationPath, kyaml, 0400); err != nil { + if err = os.WriteFile(kustomizationPath, kyaml, 0400); err != nil { return nil, fmt.Errorf("failed writing file to \"%s\": %w", kustomizationPath, err) } diff --git a/pkg/application/application_test.go b/pkg/application/application_test.go index 82bf6b29..674550b8 100644 --- a/pkg/application/application_test.go +++ b/pkg/application/application_test.go @@ -2,7 +2,7 @@ package application import ( "errors" - "io/ioutil" + "io" "path/filepath" "reflect" "testing" @@ -206,7 +206,7 @@ func Test_writeFile(t *testing.T) { f, err := repofs.Open("/foo/bar") assert.NoError(t, err) - d, err := ioutil.ReadAll(f) + d, err := io.ReadAll(f) assert.NoError(t, err) assert.Equal(t, d, []byte("data")) @@ -226,7 +226,7 @@ func Test_writeFile(t *testing.T) { assert.Equal(t, "/someroot", repofs.Root()) f, err := repofs.Open("/foo/bar") assert.NoError(t, err) - d, err := ioutil.ReadAll(f) + d, err := io.ReadAll(f) assert.NoError(t, err) assert.Equal(t, d, []byte("data2")) diff --git a/pkg/fs/fs.go b/pkg/fs/fs.go index f243a95c..19a98feb 100644 --- a/pkg/fs/fs.go +++ b/pkg/fs/fs.go @@ -3,7 +3,7 @@ package fs import ( "encoding/json" "fmt" - "io/ioutil" + "io" "os" "github.com/argoproj-labs/argocd-autopilot/pkg/util" @@ -92,7 +92,7 @@ func (fs *fsimpl) ReadFile(filename string) ([]byte, error) { } defer f.Close() - return ioutil.ReadAll(f) + return io.ReadAll(f) } func (fs *fsimpl) ReadYamls(filename string, o ...interface{}) error { diff --git a/pkg/git/provider_bitbucket-server.go b/pkg/git/provider_bitbucket-server.go index 7e961219..cc9d61b6 100644 --- a/pkg/git/provider_bitbucket-server.go +++ b/pkg/git/provider_bitbucket-server.go @@ -6,7 +6,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "path" @@ -215,7 +215,7 @@ func (bbs *bitbucketServer) request(ctx context.Context, method, urlPath string, } defer response.Body.Close() - data, err := ioutil.ReadAll(response.Body) + data, err := io.ReadAll(response.Body) if err != nil { return nil, fmt.Errorf("failed to read from response body: %w", err) }