diff --git a/contrib/nydusify/cmd/nydusify_test.go b/contrib/nydusify/cmd/nydusify_test.go index 2ffd572cb3a..019be92fa2c 100644 --- a/contrib/nydusify/cmd/nydusify_test.go +++ b/contrib/nydusify/cmd/nydusify_test.go @@ -6,7 +6,6 @@ package main import ( "encoding/json" - "io/ioutil" "os" "testing" @@ -50,7 +49,7 @@ func TestParseBackendConfig(t *testing.T) { }` require.True(t, json.Valid([]byte(configJSON))) - file, err := ioutil.TempFile("", "nydusify-backend-config-test.json") + file, err := os.CreateTemp("", "nydusify-backend-config-test.json") require.NoError(t, err) defer os.RemoveAll(file.Name()) diff --git a/smoke/tests/api_test.go b/smoke/tests/api_test.go index a05ac84f86c..a48a8b9f50e 100644 --- a/smoke/tests/api_test.go +++ b/smoke/tests/api_test.go @@ -7,7 +7,7 @@ package tests import ( "context" "fmt" - "io/ioutil" + "io" "os" "path/filepath" "testing" @@ -231,7 +231,7 @@ func (a *APIV1TestSuite) visit(path string) error { } defer f.Close() - ioutil.ReadAll(f) + io.ReadAll(f) return nil } diff --git a/smoke/tests/blobcache_test.go b/smoke/tests/blobcache_test.go index 36ba897c540..b45eb039bbb 100644 --- a/smoke/tests/blobcache_test.go +++ b/smoke/tests/blobcache_test.go @@ -4,7 +4,6 @@ import ( "fmt" "io" "io/fs" - "io/ioutil" "os" "path/filepath" "testing" @@ -47,7 +46,7 @@ func (a *BlobCacheTestSuite) prepareTestEnv(t *testing.T) (*tool.Context, string rootfsReader := rootFs.ToOCITar(t) ociBlobDigester := digest.Canonical.Digester() - ociBlob, err := ioutil.TempFile(ctx.Env.BlobDir, "oci-blob-") + ociBlob, err := os.CreateTemp(ctx.Env.BlobDir, "oci-blob-") require.NoError(t, err) _, err = io.Copy(io.MultiWriter(ociBlobDigester.Hash(), ociBlob), rootfsReader) diff --git a/smoke/tests/tool/context.go b/smoke/tests/tool/context.go index 703613be264..7d409d3b996 100644 --- a/smoke/tests/tool/context.go +++ b/smoke/tests/tool/context.go @@ -5,7 +5,6 @@ package tool import ( - "io/ioutil" "os" "path/filepath" "testing" @@ -86,7 +85,7 @@ func (ctx *Context) PrepareWorkDir(t *testing.T) { if tempDir == "" { tempDir = os.TempDir() } - workDir, err := ioutil.TempDir(tempDir, "nydus-smoke-") + workDir, err := os.MkdirTemp(tempDir, "nydus-smoke-") require.NoError(t, err) blobDir := filepath.Join(workDir, "blobs") diff --git a/smoke/tests/tool/layer.go b/smoke/tests/tool/layer.go index 452c6584f65..0c0956ffec2 100644 --- a/smoke/tests/tool/layer.go +++ b/smoke/tests/tool/layer.go @@ -10,7 +10,6 @@ import ( "context" "crypto/rand" "io" - "io/ioutil" "os" "path/filepath" "strings" @@ -121,7 +120,7 @@ func (l *Layer) Pack(t *testing.T, packOption converter.PackOption, blobDir stri l.recordFileTree(t) // Pack OCI tar to nydus native blob - blob, err := ioutil.TempFile(blobDir, "blob-") + blob, err := os.CreateTemp(blobDir, "blob-") require.NoError(t, err) defer blob.Close() blobDigester := digest.Canonical.Digester() @@ -160,7 +159,7 @@ func (l *Layer) PackRef(t *testing.T, ctx Context, blobDir string, compress bool } // Pack OCI blob to nydus zran blob - rafsBlob, err := ioutil.TempFile(blobDir, "rafs-blob-") + rafsBlob, err := os.CreateTemp(blobDir, "rafs-blob-") require.NoError(t, err) defer rafsBlob.Close() rafsBlobDigester := digest.Canonical.Digester() @@ -172,7 +171,7 @@ func (l *Layer) PackRef(t *testing.T, ctx Context, blobDir string, compress bool require.NoError(t, err) ociBlobDigester := digest.Canonical.Digester() - ociBlob, err := ioutil.TempFile(blobDir, "oci-blob-") + ociBlob, err := os.CreateTemp(blobDir, "oci-blob-") require.NoError(t, err) _, err = io.Copy(io.MultiWriter(twc, ociBlobDigester.Hash(), ociBlob), ociBlobReader) @@ -250,7 +249,7 @@ func MergeLayers(t *testing.T, ctx Context, mergeOption converter.MergeOption, l layers[idx].ReaderAt = ra } - bootstrap, err := ioutil.TempFile(ctx.Env.WorkDir, "bootstrap-") + bootstrap, err := os.CreateTemp(ctx.Env.WorkDir, "bootstrap-") require.NoError(t, err) defer bootstrap.Close() actualDigests, err := converter.Merge(context.Background(), layers, bootstrap, mergeOption) diff --git a/smoke/tests/tool/nydusd.go b/smoke/tests/tool/nydusd.go index adfae105743..a56b85aeeb0 100644 --- a/smoke/tests/tool/nydusd.go +++ b/smoke/tests/tool/nydusd.go @@ -10,7 +10,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net" "net/http" "os" @@ -246,7 +245,7 @@ func (nydusd *Nydusd) MountByAPI(config NydusdConfig) error { return err } defer f.Close() - rafsConfig, err := ioutil.ReadAll(f) + rafsConfig, err := io.ReadAll(f) if err != nil { return err }