From 04bd3b64a642e0cb11a5ebd1e2b348bcc3bf1e07 Mon Sep 17 00:00:00 2001 From: Louis Abel Date: Mon, 10 Jun 2024 08:31:26 -0700 Subject: [PATCH] remove deprecated ioutil functions --- pkg/blob/file/file.go | 4 ++-- pkg/blob/gcs/gcs.go | 4 ++-- pkg/blob/s3/s3.go | 4 ++-- pkg/directives/add.go | 4 ++-- pkg/directives/lookaside.go | 4 ++-- pkg/directives/replace.go | 4 ++-- pkg/directives/spec_change.go | 4 ++-- pkg/modes/git.go | 6 +++--- pkg/srpmproc/fetch.go | 5 ++--- pkg/srpmproc/process.go | 5 ++--- 10 files changed, 21 insertions(+), 23 deletions(-) diff --git a/pkg/blob/file/file.go b/pkg/blob/file/file.go index 641cfa1..fcf3b4f 100644 --- a/pkg/blob/file/file.go +++ b/pkg/blob/file/file.go @@ -22,7 +22,7 @@ package file import ( "fmt" - "io/ioutil" + "io" "os" "path/filepath" ) @@ -65,7 +65,7 @@ func (f *File) Read(path string) ([]byte, error) { return nil, err } - body, err := ioutil.ReadAll(r) + body, err := io.ReadAll(r) if err != nil { return nil, err } diff --git a/pkg/blob/gcs/gcs.go b/pkg/blob/gcs/gcs.go index f897034..be46594 100644 --- a/pkg/blob/gcs/gcs.go +++ b/pkg/blob/gcs/gcs.go @@ -23,7 +23,7 @@ package gcs import ( "context" "fmt" - "io/ioutil" + "io" "cloud.google.com/go/storage" ) @@ -71,7 +71,7 @@ func (g *GCS) Read(path string) ([]byte, error) { return nil, err } - body, err := ioutil.ReadAll(r) + body, err := io.ReadAll(r) if err != nil { return nil, err } diff --git a/pkg/blob/s3/s3.go b/pkg/blob/s3/s3.go index 1d475c1..c190749 100644 --- a/pkg/blob/s3/s3.go +++ b/pkg/blob/s3/s3.go @@ -22,7 +22,7 @@ package s3 import ( "bytes" - "io/ioutil" + "io" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" @@ -99,7 +99,7 @@ func (s *S3) Read(path string) ([]byte, error) { return nil, nil } - body, err := ioutil.ReadAll(obj.Body) + body, err := io.ReadAll(obj.Body) if err != nil { return nil, err } diff --git a/pkg/directives/add.go b/pkg/directives/add.go index 079bb85..fac47bb 100644 --- a/pkg/directives/add.go +++ b/pkg/directives/add.go @@ -23,7 +23,7 @@ package directives import ( "errors" "fmt" - "io/ioutil" + "io" "os" "path/filepath" @@ -55,7 +55,7 @@ func add(cfg *srpmprocpb.Cfg, pd *data.ProcessData, md *data.ModeData, patchTree return errors.New(fmt.Sprintf("COULD_NOT_OPEN_FROM:%s", addType.File)) } - replacingBytes, err = ioutil.ReadAll(fPatch) + replacingBytes, err = io.ReadAll(fPatch) if err != nil { return errors.New(fmt.Sprintf("COULD_NOT_READ_FROM:%s", addType.File)) } diff --git a/pkg/directives/lookaside.go b/pkg/directives/lookaside.go index d8d4f59..07ea629 100644 --- a/pkg/directives/lookaside.go +++ b/pkg/directives/lookaside.go @@ -27,7 +27,7 @@ import ( "crypto/sha256" "errors" "fmt" - "io/ioutil" + "io" "os" "path/filepath" "time" @@ -66,7 +66,7 @@ func lookaside(cfg *srpmprocpb.Cfg, _ *data.ProcessData, md *data.ModeData, patc return errors.New(fmt.Sprintf("COULD_NOT_OPEN_FILE:%s", path)) } - bts, err := ioutil.ReadAll(f) + bts, err := io.ReadAll(f) if err != nil { return errors.New(fmt.Sprintf("COULD_NOT_READ_FILE:%s", path)) } diff --git a/pkg/directives/replace.go b/pkg/directives/replace.go index 41d31d0..36ad84c 100644 --- a/pkg/directives/replace.go +++ b/pkg/directives/replace.go @@ -23,7 +23,7 @@ package directives import ( "errors" "fmt" - "io/ioutil" + "io" "os" "github.com/go-git/go-git/v5" @@ -56,7 +56,7 @@ func replace(cfg *srpmprocpb.Cfg, pd *data.ProcessData, _ *data.ModeData, patchT return errors.New(fmt.Sprintf("COULD_NOT_OPEN_REPLACING:%s", replacing.WithFile)) } - replacingBytes, err := ioutil.ReadAll(fPatch) + replacingBytes, err := io.ReadAll(fPatch) if err != nil { return errors.New(fmt.Sprintf("COULD_NOT_READ_REPLACING:%s", replacing.WithFile)) } diff --git a/pkg/directives/spec_change.go b/pkg/directives/spec_change.go index ea1152b..80e0ed6 100644 --- a/pkg/directives/spec_change.go +++ b/pkg/directives/spec_change.go @@ -23,7 +23,7 @@ package directives import ( "errors" "fmt" - "io/ioutil" + "io" "math" "os" "path/filepath" @@ -215,7 +215,7 @@ func specChange(cfg *srpmprocpb.Cfg, pd *data.ProcessData, md *data.ModeData, _ return errors.New("COULD_NOT_READ_SPEC_FILE") } - specBts, err := ioutil.ReadAll(specFile) + specBts, err := io.ReadAll(specFile) if err != nil { return errors.New("COULD_NOT_READ_ALL_BYTES") } diff --git a/pkg/modes/git.go b/pkg/modes/git.go index 4843b12..452e753 100644 --- a/pkg/modes/git.go +++ b/pkg/modes/git.go @@ -23,7 +23,7 @@ package modes import ( "bytes" "fmt" - "io/ioutil" + "io" "log" "net/http" "path/filepath" @@ -317,7 +317,7 @@ func (g *GitMode) WriteSource(pd *data.ProcessData, md *data.ModeData) error { return nil } - fileBytes, err := ioutil.ReadAll(metadataFile) + fileBytes, err := io.ReadAll(metadataFile) if err != nil { return fmt.Errorf("could not read metadata file: %v", err) } @@ -427,7 +427,7 @@ func (g *GitMode) WriteSource(pd *data.ProcessData, md *data.ModeData) error { } } - body, err = ioutil.ReadAll(resp.Body) + body, err = io.ReadAll(resp.Body) if err != nil { return fmt.Errorf("could not read the whole dist-git file: %v", err) } diff --git a/pkg/srpmproc/fetch.go b/pkg/srpmproc/fetch.go index da7d0df..924f2c6 100644 --- a/pkg/srpmproc/fetch.go +++ b/pkg/srpmproc/fetch.go @@ -4,7 +4,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "log" "net/http" "path/filepath" @@ -42,7 +41,7 @@ func Fetch(logger io.Writer, cdnUrl string, dir string, fs billy.Filesystem, sto return fmt.Errorf("could not open metadata file: %v", err) } - fileBytes, err := ioutil.ReadAll(metadataFile) + fileBytes, err := io.ReadAll(metadataFile) if err != nil { return fmt.Errorf("could not read metadata file: %v", err) } @@ -87,7 +86,7 @@ func Fetch(logger io.Writer, cdnUrl string, dir string, fs billy.Filesystem, sto return fmt.Errorf("could not download dist-git file: %v", err) } - body, err = ioutil.ReadAll(resp.Body) + body, err = io.ReadAll(resp.Body) if err != nil { return fmt.Errorf("could not read the whole dist-git file: %v", err) } diff --git a/pkg/srpmproc/process.go b/pkg/srpmproc/process.go index 0075f35..0695c77 100644 --- a/pkg/srpmproc/process.go +++ b/pkg/srpmproc/process.go @@ -25,7 +25,6 @@ import ( "encoding/hex" "fmt" "io" - "io/ioutil" "log" "os" "os/exec" @@ -1130,7 +1129,7 @@ func convertLocalRepo(pkgName string, localRepo string) (bool, error) { } // Loop through each file/folder and operate accordingly: - files, err := ioutil.ReadDir(localRepo) + files, err := os.ReadDir(localRepo) if err != nil { return false, err } @@ -1239,7 +1238,7 @@ func getVersionFromSpec(localRepo string, majorVersion int) (string, error) { // Read the first file from SPECS/ to get our spec file // (there should only be one file - we check that it ends in ".spec" just to be sure!) - lsTmp, err := ioutil.ReadDir(fmt.Sprintf("%s/SPECS/", localRepo)) + lsTmp, err := os.ReadDir(fmt.Sprintf("%s/SPECS/", localRepo)) if err != nil { return "", err }