Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove uses of deprecated io/ioutil #2718

Merged
merged 2 commits into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ run:
linters:
enable:
- deadcode
- depguard
- gofmt
- goimports
- revive
Expand All @@ -30,6 +31,13 @@ linters:
disable-all: true

linters-settings:
depguard:
list-type: blacklist
include-go-root: true
packages:
# The io/ioutil package has been deprecated.
# https://go.dev/doc/go1.16#ioutil
- io/ioutil
importas:
alias:
- pkg: "github.com/opencontainers/image-spec/specs-go/v1"
Expand Down
37 changes: 18 additions & 19 deletions cache/contenthash/checksum_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"runtime"
Expand Down Expand Up @@ -43,7 +42,7 @@ const (

func TestChecksumSymlinkNoParentScan(t *testing.T) {
t.Parallel()
tmpdir, err := ioutil.TempDir("", "buildkit-state")
tmpdir, err := os.MkdirTemp("", "buildkit-state")
require.NoError(t, err)
defer os.RemoveAll(tmpdir)

Expand Down Expand Up @@ -72,7 +71,7 @@ func TestChecksumSymlinkNoParentScan(t *testing.T) {

func TestChecksumHardlinks(t *testing.T) {
t.Parallel()
tmpdir, err := ioutil.TempDir("", "buildkit-state")
tmpdir, err := os.MkdirTemp("", "buildkit-state")
require.NoError(t, err)
defer os.RemoveAll(tmpdir)

Expand Down Expand Up @@ -155,7 +154,7 @@ func TestChecksumHardlinks(t *testing.T) {

func TestChecksumWildcardOrFilter(t *testing.T) {
t.Parallel()
tmpdir, err := ioutil.TempDir("", "buildkit-state")
tmpdir, err := os.MkdirTemp("", "buildkit-state")
require.NoError(t, err)
defer os.RemoveAll(tmpdir)

Expand Down Expand Up @@ -212,7 +211,7 @@ func TestChecksumWildcardOrFilter(t *testing.T) {

func TestChecksumWildcardWithBadMountable(t *testing.T) {
t.Parallel()
tmpdir, err := ioutil.TempDir("", "buildkit-state")
tmpdir, err := os.MkdirTemp("", "buildkit-state")
require.NoError(t, err)
defer os.RemoveAll(tmpdir)

Expand All @@ -232,7 +231,7 @@ func TestChecksumWildcardWithBadMountable(t *testing.T) {

func TestSymlinksNoFollow(t *testing.T) {
t.Parallel()
tmpdir, err := ioutil.TempDir("", "buildkit-state")
tmpdir, err := os.MkdirTemp("", "buildkit-state")
require.NoError(t, err)
defer os.RemoveAll(tmpdir)

Expand Down Expand Up @@ -291,7 +290,7 @@ func TestSymlinksNoFollow(t *testing.T) {

func TestChecksumBasicFile(t *testing.T) {
t.Parallel()
tmpdir, err := ioutil.TempDir("", "buildkit-state")
tmpdir, err := os.MkdirTemp("", "buildkit-state")
require.NoError(t, err)
defer os.RemoveAll(tmpdir)

Expand Down Expand Up @@ -449,7 +448,7 @@ func TestChecksumIncludeExclude(t *testing.T) {
func testChecksumIncludeExclude(t *testing.T, wildcard bool) {
t.Parallel()

tmpdir, err := ioutil.TempDir("", "buildkit-state")
tmpdir, err := os.MkdirTemp("", "buildkit-state")
require.NoError(t, err)
defer os.RemoveAll(tmpdir)

Expand Down Expand Up @@ -584,7 +583,7 @@ func testChecksumIncludeExclude(t *testing.T, wildcard bool) {

func TestChecksumIncludeDoubleStar(t *testing.T) {
t.Parallel()
tmpdir, err := ioutil.TempDir("", "buildkit-state")
tmpdir, err := os.MkdirTemp("", "buildkit-state")
require.NoError(t, err)
defer os.RemoveAll(tmpdir)

Expand Down Expand Up @@ -652,7 +651,7 @@ func TestChecksumIncludeDoubleStar(t *testing.T) {

func TestChecksumIncludeSymlink(t *testing.T) {
t.Parallel()
tmpdir, err := ioutil.TempDir("", "buildkit-state")
tmpdir, err := os.MkdirTemp("", "buildkit-state")
require.NoError(t, err)
defer os.RemoveAll(tmpdir)

Expand Down Expand Up @@ -725,7 +724,7 @@ func TestChecksumIncludeSymlink(t *testing.T) {

func TestHandleChange(t *testing.T) {
t.Parallel()
tmpdir, err := ioutil.TempDir("", "buildkit-state")
tmpdir, err := os.MkdirTemp("", "buildkit-state")
require.NoError(t, err)
defer os.RemoveAll(tmpdir)

Expand Down Expand Up @@ -803,7 +802,7 @@ func TestHandleChange(t *testing.T) {

func TestHandleRecursiveDir(t *testing.T) {
t.Parallel()
tmpdir, err := ioutil.TempDir("", "buildkit-state")
tmpdir, err := os.MkdirTemp("", "buildkit-state")
require.NoError(t, err)
defer os.RemoveAll(tmpdir)

Expand Down Expand Up @@ -852,7 +851,7 @@ func TestHandleRecursiveDir(t *testing.T) {

func TestChecksumUnorderedFiles(t *testing.T) {
t.Parallel()
tmpdir, err := ioutil.TempDir("", "buildkit-state")
tmpdir, err := os.MkdirTemp("", "buildkit-state")
require.NoError(t, err)
defer os.RemoveAll(tmpdir)

Expand Down Expand Up @@ -905,7 +904,7 @@ func TestChecksumUnorderedFiles(t *testing.T) {

func TestSymlinkInPathScan(t *testing.T) {
t.Parallel()
tmpdir, err := ioutil.TempDir("", "buildkit-state")
tmpdir, err := os.MkdirTemp("", "buildkit-state")
require.NoError(t, err)
defer os.RemoveAll(tmpdir)

Expand Down Expand Up @@ -936,7 +935,7 @@ func TestSymlinkInPathScan(t *testing.T) {

func TestSymlinkNeedsScan(t *testing.T) {
t.Parallel()
tmpdir, err := ioutil.TempDir("", "buildkit-state")
tmpdir, err := os.MkdirTemp("", "buildkit-state")
require.NoError(t, err)
defer os.RemoveAll(tmpdir)

Expand Down Expand Up @@ -969,7 +968,7 @@ func TestSymlinkNeedsScan(t *testing.T) {

func TestSymlinkAbsDirSuffix(t *testing.T) {
t.Parallel()
tmpdir, err := ioutil.TempDir("", "buildkit-state")
tmpdir, err := os.MkdirTemp("", "buildkit-state")
require.NoError(t, err)
defer os.RemoveAll(tmpdir)

Expand All @@ -996,7 +995,7 @@ func TestSymlinkAbsDirSuffix(t *testing.T) {

func TestSymlinkThroughParent(t *testing.T) {
t.Parallel()
tmpdir, err := ioutil.TempDir("", "buildkit-state")
tmpdir, err := os.MkdirTemp("", "buildkit-state")
require.NoError(t, err)
defer os.RemoveAll(tmpdir)

Expand Down Expand Up @@ -1051,7 +1050,7 @@ func TestSymlinkThroughParent(t *testing.T) {

func TestSymlinkInPathHandleChange(t *testing.T) {
t.Parallel()
tmpdir, err := ioutil.TempDir("", "buildkit-state")
tmpdir, err := os.MkdirTemp("", "buildkit-state")
require.NoError(t, err)
defer os.RemoveAll(tmpdir)

Expand Down Expand Up @@ -1114,7 +1113,7 @@ func TestSymlinkInPathHandleChange(t *testing.T) {

func TestPersistence(t *testing.T) {
t.Parallel()
tmpdir, err := ioutil.TempDir("", "buildkit-state")
tmpdir, err := os.MkdirTemp("", "buildkit-state")
require.NoError(t, err)
defer os.RemoveAll(tmpdir)

Expand Down
Loading