Skip to content

Commit a4ca444

Browse files
committed
Migrate away from deprecated ioutil
1 parent a38d192 commit a4ca444

File tree

10 files changed

+16
-20
lines changed

10 files changed

+16
-20
lines changed

pkg/profiling/config/config.go

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

33
import (
4-
"io/ioutil"
4+
"os"
55
"path/filepath"
66

77
"gopkg.in/yaml.v2"
@@ -44,7 +44,7 @@ type config struct {
4444
}
4545

4646
func GetConfig(path string) (*config, error) {
47-
data, err := ioutil.ReadFile(filepath.Join(path, "pprof-config.yaml"))
47+
data, err := os.ReadFile(filepath.Join(path, "pprof-config.yaml"))
4848
if err != nil {
4949
return nil, err
5050
}

staging/api/pkg/manifests/bundleloader.go

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

33
import (
44
"fmt"
5-
"io/ioutil"
65
"os"
76
"path/filepath"
87
"strings"
@@ -180,7 +179,7 @@ func (b *bundleLoader) LoadBundleWalkFunc(path string, f os.FileInfo, err error)
180179
// loadBundle takes the directory that a CSV is in and assumes the rest of the objects in that directory
181180
// are part of the bundle.
182181
func loadBundle(csvName string, dir string) (*Bundle, error) {
183-
files, err := ioutil.ReadDir(dir)
182+
files, err := os.ReadDir(dir)
184183
if err != nil {
185184
return nil, err
186185
}

staging/api/pkg/validation/internal/community.go

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

@@ -225,7 +224,7 @@ func validateImageFile(checks CommunityOperatorChecks, deprecatedAPImsg string)
225224
return checks
226225
}
227226

228-
b, err := ioutil.ReadFile(checks.indexImagePath)
227+
b, err := os.ReadFile(checks.indexImagePath)
229228
if err != nil {
230229
checks.errs = append(checks.errs, fmt.Errorf("unable to read the index image in the path "+
231230
"(%s). Error : %s", checks.indexImagePath, err))

staging/api/pkg/validation/internal/crd_test.go

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

33
import (
4-
"io/ioutil"
4+
"os"
55
"testing"
66

77
"github.com/operator-framework/api/pkg/validation/errors"
@@ -57,7 +57,7 @@ func TestValidateCRD(t *testing.T) {
5757
},
5858
}
5959
for _, tt := range table {
60-
b, err := ioutil.ReadFile(tt.filePath)
60+
b, err := os.ReadFile(tt.filePath)
6161
if err != nil {
6262
t.Fatalf("Error reading CRD path %s: %v", tt.filePath, err)
6363
}

staging/api/pkg/validation/internal/csv_test.go

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

33
import (
44
"fmt"
5-
"io/ioutil"
5+
"os"
66
"path/filepath"
77
"testing"
88

@@ -121,7 +121,7 @@ func TestValidateCSV(t *testing.T) {
121121
}
122122

123123
for _, c := range cases {
124-
b, err := ioutil.ReadFile(c.csvPath)
124+
b, err := os.ReadFile(c.csvPath)
125125
if err != nil {
126126
t.Fatalf("Error reading CSV path %s: %v", c.csvPath, err)
127127
}

staging/api/pkg/validation/internal/object_test.go

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

33
import (
4-
"io/ioutil"
4+
"os"
55
"testing"
66

77
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
@@ -66,7 +66,7 @@ func TestValidateObject(t *testing.T) {
6666

6767
for _, tt := range table {
6868
u := unstructured.Unstructured{}
69-
o, err := ioutil.ReadFile(tt.path)
69+
o, err := os.ReadFile(tt.path)
7070
if err != nil {
7171
t.Fatalf("reading yaml object file: %s", err)
7272
}

staging/api/pkg/validation/internal/operatorgroup_test.go

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

33
import (
4-
"io/ioutil"
4+
"os"
55
"path/filepath"
66
"testing"
77

@@ -33,7 +33,7 @@ func TestValidateOperatorGroup(t *testing.T) {
3333
},
3434
}
3535
for _, c := range cases {
36-
b, err := ioutil.ReadFile(c.operatorGroupPath)
36+
b, err := os.ReadFile(c.operatorGroupPath)
3737
if err != nil {
3838
t.Fatalf("Error reading OperatorGroup path %s: %v", c.operatorGroupPath, err)
3939
}

staging/api/pkg/validation/internal/operatorhub.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ package internal
33
import (
44
"encoding/json"
55
"fmt"
6-
"io/ioutil"
76
"net/mail"
87
"net/url"
8+
"os"
99
"path/filepath"
1010
"strings"
1111

@@ -313,7 +313,7 @@ func extractCategories(path string) (map[string]struct{}, error) {
313313
return nil, fmt.Errorf("finding category file: %w", err)
314314
}
315315

316-
data, err := ioutil.ReadFile(path)
316+
data, err := os.ReadFile(path)
317317
if err != nil {
318318
return nil, fmt.Errorf("reading category file: %w", err)
319319
}

staging/operator-registry/pkg/image/buildahregistry/_options.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package buildahregistry
55

66
import (
7-
"io/ioutil"
87
"os"
98
"path"
109
"path/filepath"
@@ -95,7 +94,7 @@ func NewRegistry(options ...RegistryOption) (registry *Registry, destroy func()
9594
}
9695

9796
// TODO: probably don't want the signature policy to be here
98-
ioutil.WriteFile(path.Join(config.CacheDir, "policy.json"), []byte(`
97+
os.WriteFile(path.Join(config.CacheDir, "policy.json"), []byte(`
9998
{
10099
"default": [
101100
{

staging/operator-registry/test/e2e/ctx/provisioner_kind.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"encoding/csv"
99
"flag"
1010
"fmt"
11-
"io/ioutil"
1211
"os"
1312
"os/exec"
1413
"path/filepath"
@@ -69,7 +68,7 @@ func (kl kindLogAdapter) V(log.Level) log.InfoLogger {
6968
}
7069

7170
func Provision(ctx *TestContext) (func(), error) {
72-
dir, err := ioutil.TempDir("", "kind.")
71+
dir, err := os.MkdirTemp("", "kind.")
7372
if err != nil {
7473
return nil, fmt.Errorf("failed to create temporary directory: %s", err.Error())
7574
}

0 commit comments

Comments
 (0)