Skip to content

Commit

Permalink
removed deprecated ioutil
Browse files Browse the repository at this point in the history
Signed-off-by: Noam Gal <[email protected]>
  • Loading branch information
ATGardner committed Nov 17, 2022
1 parent 7d5563e commit 4f5b090
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
5 changes: 2 additions & 3 deletions hack/cmd-docs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/application/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package application
import (
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"reflect"
Expand Down Expand Up @@ -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)
}
Expand All @@ -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)
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/application/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package application

import (
"errors"
"io/ioutil"
"io"
"path/filepath"
"reflect"
"testing"
Expand Down Expand Up @@ -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"))
Expand All @@ -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"))
Expand Down
4 changes: 2 additions & 2 deletions pkg/fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package fs
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"os"

"github.com/argoproj-labs/argocd-autopilot/pkg/util"
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/git/provider_bitbucket-server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"path"
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 4f5b090

Please sign in to comment.