Skip to content

Commit de324dc

Browse files
testwillci-robot
authored andcommitted
chore: remove refs to deprecated io/ioutil (#1167)
Signed-off-by: guoguangwu <[email protected]> Upstream-repository: operator-registry Upstream-commit: 1554be32b633b729001a71d5e7fee9f9f965989d
1 parent 29f1916 commit de324dc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+135
-176
lines changed

staging/operator-registry/alpha/action/init.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package action
33
import (
44
"fmt"
55
"io"
6-
"io/ioutil"
76

87
"github.com/h2non/filetype"
98

@@ -25,15 +24,15 @@ func (i Init) Run() (*declcfg.Package, error) {
2524
DefaultChannel: i.DefaultChannel,
2625
}
2726
if i.DescriptionReader != nil {
28-
descriptionData, err := ioutil.ReadAll(i.DescriptionReader)
27+
descriptionData, err := io.ReadAll(i.DescriptionReader)
2928
if err != nil {
3029
return nil, fmt.Errorf("read description: %v", err)
3130
}
3231
pkg.Description = string(descriptionData)
3332
}
3433

3534
if i.IconReader != nil {
36-
iconData, err := ioutil.ReadAll(i.IconReader)
35+
iconData, err := io.ReadAll(i.IconReader)
3736
if err != nil {
3837
return nil, fmt.Errorf("read icon: %v", err)
3938
}

staging/operator-registry/alpha/action/migrate.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package action
33
import (
44
"context"
55
"fmt"
6-
"io/ioutil"
76
"os"
87

98
"github.com/operator-framework/operator-registry/alpha/declcfg"
@@ -20,7 +19,7 @@ type Migrate struct {
2019
}
2120

2221
func (m Migrate) Run(ctx context.Context) error {
23-
entries, err := ioutil.ReadDir(m.OutputDir)
22+
entries, err := os.ReadDir(m.OutputDir)
2423
if err != nil && !os.IsNotExist(err) {
2524
return err
2625
}

staging/operator-registry/alpha/action/render.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"encoding/json"
77
"errors"
88
"fmt"
9-
"io/ioutil"
9+
"io"
1010
"os"
1111
"path/filepath"
1212
"sort"
@@ -60,7 +60,7 @@ type Render struct {
6060

6161
func nullLogger() *logrus.Entry {
6262
logger := logrus.New()
63-
logger.SetOutput(ioutil.Discard)
63+
logger.SetOutput(io.Discard)
6464
return logrus.NewEntry(logger)
6565
}
6666

@@ -155,7 +155,7 @@ func (r Render) imageToDeclcfg(ctx context.Context, imageRef string) (*declcfg.D
155155
if err != nil {
156156
return nil, err
157157
}
158-
tmpDir, err := ioutil.TempDir("", "render-unpack-")
158+
tmpDir, err := os.MkdirTemp("", "render-unpack-")
159159
if err != nil {
160160
return nil, err
161161
}

staging/operator-registry/cmd/opm/alpha/bundle/unpack.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"crypto/x509"
66
"fmt"
7-
"io/ioutil"
87
"os"
98
"path/filepath"
109

@@ -99,7 +98,7 @@ func unpackBundle(cmd *cobra.Command, args []string) error {
9998
}
10099
if rootCA != "" {
101100
rootCAs := x509.NewCertPool()
102-
certs, err := ioutil.ReadFile(rootCA)
101+
certs, err := os.ReadFile(rootCA)
103102
if err != nil {
104103
return err
105104
}
@@ -129,7 +128,7 @@ func unpackBundle(cmd *cobra.Command, args []string) error {
129128
return err
130129
}
131130

132-
dir, err := ioutil.TempDir("", "bundle-")
131+
dir, err := os.MkdirTemp("", "bundle-")
133132
if err != nil {
134133
return err
135134
}

staging/operator-registry/cmd/opm/alpha/bundle/validate.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package bundle
22

33
import (
44
"fmt"
5-
"io/ioutil"
65
"os"
76
"path/filepath"
87

@@ -80,7 +79,7 @@ func validateFunc(cmd *cobra.Command, _ []string) error {
8079
}
8180
imageValidator := bundle.NewImageValidator(registry, logger, optional)
8281

83-
dir, err := ioutil.TempDir("", "bundle-")
82+
dir, err := os.MkdirTemp("", "bundle-")
8483
logger.Infof("Create a temp directory at %s", dir)
8584
if err != nil {
8685
return err

staging/operator-registry/cmd/opm/alpha/template/basic.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package template
22

33
import (
44
"io"
5-
"io/ioutil"
65
"log"
76
"os"
87

@@ -50,7 +49,7 @@ When FILE is '-' or not provided, the template is read from standard input`,
5049
// The bundle loading impl is somewhat verbose, even on the happy path,
5150
// so discard all logrus default logger logs. Any important failures will be
5251
// returned from template.Render and logged as fatal errors.
53-
logrus.SetOutput(ioutil.Discard)
52+
logrus.SetOutput(io.Discard)
5453

5554
reg, err := util.CreateCLIRegistry(cmd)
5655
if err != nil {

staging/operator-registry/cmd/opm/alpha/template/semver.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package template
33
import (
44
"fmt"
55
"io"
6-
"io/ioutil"
76
"log"
87
"os"
98

@@ -53,7 +52,7 @@ When FILE is '-' or not provided, the template is read from standard input`,
5352
// The bundle loading impl is somewhat verbose, even on the happy path,
5453
// so discard all logrus default logger logs. Any important failures will be
5554
// returned from template.Render and logged as fatal errors.
56-
logrus.SetOutput(ioutil.Discard)
55+
logrus.SetOutput(io.Discard)
5756

5857
reg, err := util.CreateCLIRegistry(cmd)
5958
if err != nil {

staging/operator-registry/cmd/opm/internal/util/util.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package util
22

33
import (
44
"errors"
5-
"io/ioutil"
5+
"io"
66
"os"
77

88
"github.com/operator-framework/operator-registry/pkg/image/containerdregistry"
@@ -69,6 +69,6 @@ func CreateCLIRegistry(cmd *cobra.Command) (*containerdregistry.Registry, error)
6969

7070
func nullLogger() *logrus.Entry {
7171
logger := logrus.New()
72-
logger.SetOutput(ioutil.Discard)
72+
logger.SetOutput(io.Discard)
7373
return logrus.NewEntry(logger)
7474
}

staging/operator-registry/cmd/opm/render/cmd.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package render
22

33
import (
44
"io"
5-
"io/ioutil"
65
"log"
76
"os"
87

@@ -45,7 +44,7 @@ database files.
4544
// The bundle loading impl is somewhat verbose, even on the happy path,
4645
// so discard all logrus default logger logs. Any important failures will be
4746
// returned from render.Run and logged as fatal errors.
48-
logrus.SetOutput(ioutil.Discard)
47+
logrus.SetOutput(io.Discard)
4948

5049
reg, err := util.CreateCLIRegistry(cmd)
5150
if err != nil {
@@ -72,6 +71,6 @@ database files.
7271

7372
func nullLogger() *logrus.Entry {
7473
logger := logrus.New()
75-
logger.SetOutput(ioutil.Discard)
74+
logger.SetOutput(io.Discard)
7675
return logrus.NewEntry(logger)
7776
}

staging/operator-registry/pkg/configmap/configmap_writer.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package configmap
33
import (
44
"context"
55
"fmt"
6-
"io/ioutil"
76
"os"
87
"regexp"
98

@@ -85,7 +84,7 @@ func (c *ConfigMapWriter) Populate(maxDataSizeLimit uint64) error {
8584
var totalSize uint64
8685
for _, dir := range subDirs {
8786
completePath := c.manifestsDir + dir
88-
files, err := ioutil.ReadDir(completePath)
87+
files, err := os.ReadDir(completePath)
8988
if err != nil {
9089
logrus.Errorf("read dir failed: %v", err)
9190
return err
@@ -95,7 +94,7 @@ func (c *ConfigMapWriter) Populate(maxDataSizeLimit uint64) error {
9594
log := logrus.WithField("file", completePath+file.Name())
9695
log.Info("Reading file")
9796

98-
content, err := ioutil.ReadFile(completePath + file.Name())
97+
content, err := os.ReadFile(completePath + file.Name())
9998
if err != nil {
10099
log.Errorf("read failed: %v", err)
101100
return err

0 commit comments

Comments
 (0)