From 1cff5d531efb32cd342651101d06d9cc94c23919 Mon Sep 17 00:00:00 2001 From: Per Goncalves da Silva Date: Thu, 18 Dec 2025 09:20:29 +0100 Subject: [PATCH] Migrate away from ioutil Signed-off-by: Per Goncalves da Silva --- pkg/manifests/bundleloader.go | 3 +-- pkg/validation/internal/community.go | 3 +-- pkg/validation/internal/crd_test.go | 4 ++-- pkg/validation/internal/csv_test.go | 4 ++-- pkg/validation/internal/object_test.go | 4 ++-- pkg/validation/internal/operatorgroup_test.go | 4 ++-- pkg/validation/internal/operatorhub.go | 4 ++-- 7 files changed, 12 insertions(+), 14 deletions(-) diff --git a/pkg/manifests/bundleloader.go b/pkg/manifests/bundleloader.go index 6ed1e4ddf..f557c4f35 100644 --- a/pkg/manifests/bundleloader.go +++ b/pkg/manifests/bundleloader.go @@ -2,7 +2,6 @@ package manifests import ( "fmt" - "io/ioutil" "os" "path/filepath" "strings" @@ -189,7 +188,7 @@ func (b *bundleLoader) LoadBundleWalkFunc(path string, f os.FileInfo, err error) // loadBundle takes the directory that a CSV is in and assumes the rest of the objects in that directory // are part of the bundle. func loadBundle(csvName string, dir string) (*Bundle, error) { - files, err := ioutil.ReadDir(dir) + files, err := os.ReadDir(dir) if err != nil { return nil, err } diff --git a/pkg/validation/internal/community.go b/pkg/validation/internal/community.go index debaae2ba..37473fd31 100644 --- a/pkg/validation/internal/community.go +++ b/pkg/validation/internal/community.go @@ -3,7 +3,6 @@ package internal import ( "encoding/json" "fmt" - "io/ioutil" "os" "strings" @@ -225,7 +224,7 @@ func validateImageFile(checks CommunityOperatorChecks, deprecatedAPImsg string) return checks } - b, err := ioutil.ReadFile(checks.indexImagePath) + b, err := os.ReadFile(checks.indexImagePath) if err != nil { checks.errs = append(checks.errs, fmt.Errorf("unable to read the index image in the path "+ "(%s). Error : %s", checks.indexImagePath, err)) diff --git a/pkg/validation/internal/crd_test.go b/pkg/validation/internal/crd_test.go index f28804fcf..19f125537 100644 --- a/pkg/validation/internal/crd_test.go +++ b/pkg/validation/internal/crd_test.go @@ -1,7 +1,7 @@ package internal import ( - "io/ioutil" + "os" "testing" "github.com/operator-framework/api/pkg/validation/errors" @@ -57,7 +57,7 @@ func TestValidateCRD(t *testing.T) { }, } for _, tt := range table { - b, err := ioutil.ReadFile(tt.filePath) + b, err := os.ReadFile(tt.filePath) if err != nil { t.Fatalf("Error reading CRD path %s: %v", tt.filePath, err) } diff --git a/pkg/validation/internal/csv_test.go b/pkg/validation/internal/csv_test.go index 440cbcf3c..dd80f318a 100644 --- a/pkg/validation/internal/csv_test.go +++ b/pkg/validation/internal/csv_test.go @@ -2,7 +2,7 @@ package internal import ( "fmt" - "io/ioutil" + "os" "path/filepath" "testing" @@ -121,7 +121,7 @@ func TestValidateCSV(t *testing.T) { } for _, c := range cases { - b, err := ioutil.ReadFile(c.csvPath) + b, err := os.ReadFile(c.csvPath) if err != nil { t.Fatalf("Error reading CSV path %s: %v", c.csvPath, err) } diff --git a/pkg/validation/internal/object_test.go b/pkg/validation/internal/object_test.go index 573497c6a..7f93be152 100644 --- a/pkg/validation/internal/object_test.go +++ b/pkg/validation/internal/object_test.go @@ -1,7 +1,7 @@ package internal import ( - "io/ioutil" + "os" "testing" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" @@ -66,7 +66,7 @@ func TestValidateObject(t *testing.T) { for _, tt := range table { u := unstructured.Unstructured{} - o, err := ioutil.ReadFile(tt.path) + o, err := os.ReadFile(tt.path) if err != nil { t.Fatalf("reading yaml object file: %s", err) } diff --git a/pkg/validation/internal/operatorgroup_test.go b/pkg/validation/internal/operatorgroup_test.go index b6eddac53..ee4d2ea8c 100644 --- a/pkg/validation/internal/operatorgroup_test.go +++ b/pkg/validation/internal/operatorgroup_test.go @@ -1,7 +1,7 @@ package internal import ( - "io/ioutil" + "os" "path/filepath" "testing" @@ -33,7 +33,7 @@ func TestValidateOperatorGroup(t *testing.T) { }, } for _, c := range cases { - b, err := ioutil.ReadFile(c.operatorGroupPath) + b, err := os.ReadFile(c.operatorGroupPath) if err != nil { t.Fatalf("Error reading OperatorGroup path %s: %v", c.operatorGroupPath, err) } diff --git a/pkg/validation/internal/operatorhub.go b/pkg/validation/internal/operatorhub.go index 2f5926cb9..fe0edee3a 100644 --- a/pkg/validation/internal/operatorhub.go +++ b/pkg/validation/internal/operatorhub.go @@ -3,9 +3,9 @@ package internal import ( "encoding/json" "fmt" - "io/ioutil" "net/mail" "net/url" + "os" "path/filepath" "strings" @@ -313,7 +313,7 @@ func extractCategories(path string) (map[string]struct{}, error) { return nil, fmt.Errorf("finding category file: %w", err) } - data, err := ioutil.ReadFile(path) + data, err := os.ReadFile(path) if err != nil { return nil, fmt.Errorf("reading category file: %w", err) }