Merge pull request #5973 from Juneezee/deprecate-ioutil
refactor: move from io/ioutil to io and os package
This commit is contained in:
@@ -22,7 +22,6 @@ package apparmor
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/containerd/containerd/containers"
|
||||
@@ -65,7 +64,7 @@ func LoadDefaultProfile(name string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
f, err := ioutil.TempFile(os.Getenv("XDG_RUNTIME_DIR"), p.Name)
|
||||
f, err := os.CreateTemp(os.Getenv("XDG_RUNTIME_DIR"), p.Name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@@ -25,7 +25,6 @@ import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"strconv"
|
||||
@@ -131,7 +130,7 @@ func loadData(name string) (*data, error) {
|
||||
p.Version = ver
|
||||
|
||||
// Figure out the daemon profile.
|
||||
currentProfile, err := ioutil.ReadFile("/proc/self/attr/current")
|
||||
currentProfile, err := os.ReadFile("/proc/self/attr/current")
|
||||
if err != nil {
|
||||
// If we couldn't get the daemon profile, assume we are running
|
||||
// unconfined which is generally the default.
|
||||
|
@@ -18,7 +18,6 @@ package fuzz
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
fuzz "github.com/AdaLogics/go-fuzz-headers"
|
||||
@@ -37,7 +36,7 @@ func FuzzApply(data []byte) int {
|
||||
return 0
|
||||
}
|
||||
maxIters := 20
|
||||
tmpDir, err := ioutil.TempDir("", "prefix-test")
|
||||
tmpDir, err := os.MkdirTemp("", "prefix-test")
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
@@ -63,7 +62,7 @@ func FuzzImportIndex(data []byte) int {
|
||||
}
|
||||
ctx := context.Background()
|
||||
r := bytes.NewReader(tarBytes)
|
||||
tmpdir, err := ioutil.TempDir("", "fuzzing-")
|
||||
tmpdir, err := os.MkdirTemp("", "fuzzing-")
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
|
@@ -27,7 +27,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
@@ -148,7 +147,7 @@ func checkIfShouldRestart(err error) {
|
||||
// startDaemon() starts the daemon.
|
||||
func startDaemon(ctx context.Context, shouldTearDown bool) {
|
||||
buf := bytes.NewBuffer(nil)
|
||||
stdioFile, err := ioutil.TempFile("", "")
|
||||
stdioFile, err := os.CreateTemp("", "")
|
||||
if err != nil {
|
||||
// We panic here as it is a fuzz-blocker that
|
||||
// may need fixing
|
||||
|
@@ -21,7 +21,6 @@ import (
|
||||
"context"
|
||||
_ "crypto/sha256" // required by go-digest
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
@@ -101,7 +100,7 @@ func FuzzCSWalk(data []byte) int {
|
||||
ctx := context.Background()
|
||||
expected := map[digest.Digest]struct{}{}
|
||||
found := map[digest.Digest]struct{}{}
|
||||
tmpdir, err := ioutil.TempDir("", "fuzzing-")
|
||||
tmpdir, err := os.MkdirTemp("", "fuzzing-")
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
@@ -145,7 +144,7 @@ func FuzzArchiveExport(data []byte) int {
|
||||
return 0
|
||||
}
|
||||
ctx := context.Background()
|
||||
tmpdir, err := ioutil.TempDir("", "fuzzing-")
|
||||
tmpdir, err := os.MkdirTemp("", "fuzzing-")
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@ package docker
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
@@ -67,7 +67,7 @@ func FuzzFetcher(data []byte) int {
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
b, err := ioutil.ReadAll(rc)
|
||||
b, err := io.ReadAll(rc)
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
|
@@ -20,7 +20,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/containerd/containerd/containers"
|
||||
"github.com/containerd/containerd/oci"
|
||||
@@ -33,7 +33,7 @@ import (
|
||||
func WithProfile(profile string) oci.SpecOpts {
|
||||
return func(_ context.Context, _ oci.Client, _ *containers.Container, s *specs.Spec) error {
|
||||
s.Linux.Seccomp = &specs.LinuxSeccomp{}
|
||||
f, err := ioutil.ReadFile(profile)
|
||||
f, err := os.ReadFile(profile)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot load seccomp profile %q: %v", profile, err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user