Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
8dc5334
cli/command/checkpoint: remove deprecated io/ioutil
thaJeztah Feb 25, 2022
bc1790c
cli/command/config: remove deprecated io/ioutil
thaJeztah Feb 25, 2022
e946bf0
cli/command/container: remove deprecated io/ioutil
thaJeztah Feb 25, 2022
76b4735
cli/command/context: remove deprecated io/ioutil and use t.TempDir()
thaJeztah Feb 25, 2022
d14b5bf
cli/command/image: remove deprecated io/ioutil and use t.TempDir()
thaJeztah Feb 25, 2022
43795ec
cli/command/manifest: remove deprecated io/ioutil and use t.TempDir()
thaJeztah Feb 25, 2022
f28c063
cli/command/context: remove deprecated io/ioutil
thaJeztah Feb 25, 2022
9bdeb09
cli/command/node: remove deprecated io/ioutil
thaJeztah Feb 25, 2022
f61aab5
cli/command/plugin: remove deprecated io/ioutil
thaJeztah Feb 25, 2022
3b3a0b8
cli/command/registry: remove deprecated io/ioutil
thaJeztah Feb 25, 2022
c558df7
cli/command/secret: remove deprecated io/ioutil
thaJeztah Feb 25, 2022
d1f26de
cli/command/service: remove deprecated io/ioutil
thaJeztah Feb 25, 2022
d59330f
cli/command/stack: remove deprecated io/ioutil
thaJeztah Feb 25, 2022
78cb61c
cli/command/swarm: remove deprecated io/ioutil and use t.TempDir()
thaJeztah Feb 25, 2022
e0299ff
cli/command/system: remove deprecated io/ioutil
thaJeztah Feb 25, 2022
b5dce3c
cli/command/trust: remove deprecated io/ioutil and use t.TempDir()
thaJeztah Feb 25, 2022
cca73bf
cli/command/volume: remove deprecated io/ioutil
thaJeztah Feb 25, 2022
3f7e7bf
cli/command: remove deprecated io/ioutil and use t.TempDir()
thaJeztah Feb 25, 2022
b9f0340
cli/compose: remove deprecated io/ioutil
thaJeztah Feb 25, 2022
71575ab
cli/config: remove deprecated io/ioutil and use t.TempDir()
thaJeztah Feb 25, 2022
cca80cd
cli/context: remove deprecated io/ioutil and use t.TempDir()
thaJeztah Feb 25, 2022
58cf16d
cli/manifest: remove deprecated io/ioutil and use t.TempDir()
thaJeztah Feb 25, 2022
1e54bca
cli/trust: remove deprecated io/ioutil and use t.TempDir()
thaJeztah Feb 25, 2022
86db51e
cli: remove deprecated io/ioutil
thaJeztah Feb 25, 2022
0e3197e
cmd/docker: remove deprecated io/ioutil
thaJeztah Feb 25, 2022
39ace68
docs/yaml: remove deprecated io/ioutil and use t.TempDir()
thaJeztah Feb 25, 2022
e89af84
e2e: remove deprecated io/ioutil and use t.TempDir()
thaJeztah Feb 25, 2022
7491c5a
internal/test: remove deprecated io/ioutil
thaJeztah Feb 25, 2022
85754c9
man: remove deprecated io/ioutil and use t.TempDir()
thaJeztah Feb 25, 2022
38e6257
opts: remove deprecated io/ioutil and use t.Cleanup()
thaJeztah Feb 25, 2022
6c06950
cli-plugins/manager: remove uses of deprecated io/ioutil
thaJeztah Feb 25, 2022
8c3ae38
golangci-lint: prevent io/ioutil from being used
thaJeztah Feb 25, 2022
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 @@ -2,6 +2,7 @@ linters:
enable:
- bodyclose
- deadcode
- depguard
- dogsled
- gocyclo
- goimports
Expand Down Expand Up @@ -33,6 +34,13 @@ run:
- .*generated.*

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
Comment on lines +37 to +43
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should have that in buildkit too (cc @tonistiigi)

gocyclo:
min-complexity: 16
govet:
Expand Down
5 changes: 2 additions & 3 deletions cli-plugins/manager/manager.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package manager

import (
"io/ioutil"
"os"
"path/filepath"
"sort"
Expand Down Expand Up @@ -57,12 +56,12 @@ func getPluginDirs(dockerCli command.Cli) ([]string, error) {
}

func addPluginCandidatesFromDir(res map[string][]string, d string) error {
dentries, err := ioutil.ReadDir(d)
dentries, err := os.ReadDir(d)
if err != nil {
return err
}
for _, dentry := range dentries {
switch dentry.Mode() & os.ModeType {
switch dentry.Type() & os.ModeType {
case 0, os.ModeSymlink:
// Regular file or symlink, keep going
default:
Expand Down
4 changes: 2 additions & 2 deletions cli/command/checkpoint/create_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package checkpoint

import (
"io/ioutil"
"io"
"strings"
"testing"

Expand Down Expand Up @@ -41,7 +41,7 @@ func TestCheckpointCreateErrors(t *testing.T) {
})
cmd := newCreateCommand(cli)
cmd.SetArgs(tc.args)
cmd.SetOut(ioutil.Discard)
cmd.SetOut(io.Discard)
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
}
}
Expand Down
4 changes: 2 additions & 2 deletions cli/command/checkpoint/list_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package checkpoint

import (
"io/ioutil"
"io"
"testing"

"github.com/docker/cli/internal/test"
Expand Down Expand Up @@ -41,7 +41,7 @@ func TestCheckpointListErrors(t *testing.T) {
})
cmd := newListCommand(cli)
cmd.SetArgs(tc.args)
cmd.SetOut(ioutil.Discard)
cmd.SetOut(io.Discard)
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
}
}
Expand Down
4 changes: 2 additions & 2 deletions cli/command/checkpoint/remove_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package checkpoint

import (
"io/ioutil"
"io"
"testing"

"github.com/docker/cli/internal/test"
Expand Down Expand Up @@ -40,7 +40,7 @@ func TestCheckpointRemoveErrors(t *testing.T) {
})
cmd := newRemoveCommand(cli)
cmd.SetArgs(tc.args)
cmd.SetOut(ioutil.Discard)
cmd.SetOut(io.Discard)
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
}
}
Expand Down
3 changes: 1 addition & 2 deletions cli/command/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package command
import (
"context"
"io"
"io/ioutil"
"os"
"path/filepath"
"runtime"
Expand Down Expand Up @@ -275,7 +274,7 @@ func NewAPIClientFromFlags(opts *cliflags.CommonOptions, configFile *configfile.
store := &ContextStoreWithDefault{
Store: store.New(cliconfig.ContextStoreDir(), storeConfig),
Resolver: func() (*DefaultContext, error) {
return ResolveDefaultContext(opts, configFile, storeConfig, ioutil.Discard)
return ResolveDefaultContext(opts, configFile, storeConfig, io.Discard)
},
}
contextName, err := resolveContextName(opts, configFile, store)
Expand Down
10 changes: 5 additions & 5 deletions cli/command/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"context"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"os"
Expand Down Expand Up @@ -225,23 +225,23 @@ func TestNewDockerCliAndOperators(t *testing.T) {
outbuf := bytes.NewBuffer(nil)
errbuf := bytes.NewBuffer(nil)
err = cli.Apply(
WithInputStream(ioutil.NopCloser(inbuf)),
WithInputStream(io.NopCloser(inbuf)),
WithOutputStream(outbuf),
WithErrorStream(errbuf),
)
assert.NilError(t, err)
// Check input stream
inputStream, err := ioutil.ReadAll(cli.In())
inputStream, err := io.ReadAll(cli.In())
assert.NilError(t, err)
assert.Equal(t, string(inputStream), "input")
// Check output stream
fmt.Fprintf(cli.Out(), "output")
outputStream, err := ioutil.ReadAll(outbuf)
outputStream, err := io.ReadAll(outbuf)
assert.NilError(t, err)
assert.Equal(t, string(outputStream), "output")
// Check error stream
fmt.Fprintf(cli.Err(), "error")
errStream, err := ioutil.ReadAll(errbuf)
errStream, err := io.ReadAll(errbuf)
assert.NilError(t, err)
assert.Equal(t, string(errStream), "error")
}
Expand Down
3 changes: 1 addition & 2 deletions cli/command/config/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"io"
"io/ioutil"

"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
Expand Down Expand Up @@ -61,7 +60,7 @@ func RunConfigCreate(dockerCli command.Cli, options CreateOptions) error {
defer file.Close()
}

configData, err := ioutil.ReadAll(in)
configData, err := io.ReadAll(in)
if err != nil {
return errors.Errorf("Error reading content from %q: %v", options.File, err)
}
Expand Down
7 changes: 4 additions & 3 deletions cli/command/config/create_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package config

import (
"io/ioutil"
"io"
"os"
"path/filepath"
"reflect"
"strings"
Expand Down Expand Up @@ -46,7 +47,7 @@ func TestConfigCreateErrors(t *testing.T) {
}),
)
cmd.SetArgs(tc.args)
cmd.SetOut(ioutil.Discard)
cmd.SetOut(io.Discard)
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
}
}
Expand Down Expand Up @@ -82,7 +83,7 @@ func TestConfigCreateWithLabels(t *testing.T) {
}
name := "foo"

data, err := ioutil.ReadFile(filepath.Join("testdata", configDataFile))
data, err := os.ReadFile(filepath.Join("testdata", configDataFile))
assert.NilError(t, err)

expected := swarm.ConfigSpec{
Expand Down
4 changes: 2 additions & 2 deletions cli/command/config/inspect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package config

import (
"fmt"
"io/ioutil"
"io"
"testing"
"time"

Expand Down Expand Up @@ -59,7 +59,7 @@ func TestConfigInspectErrors(t *testing.T) {
for key, value := range tc.flags {
cmd.Flags().Set(key, value)
}
cmd.SetOut(ioutil.Discard)
cmd.SetOut(io.Discard)
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
}
}
Expand Down
4 changes: 2 additions & 2 deletions cli/command/config/ls_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package config

import (
"io/ioutil"
"io"
"testing"
"time"

Expand Down Expand Up @@ -40,7 +40,7 @@ func TestConfigListErrors(t *testing.T) {
}),
)
cmd.SetArgs(tc.args)
cmd.SetOut(ioutil.Discard)
cmd.SetOut(io.Discard)
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
}
}
Expand Down
6 changes: 3 additions & 3 deletions cli/command/config/remove_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package config

import (
"io/ioutil"
"io"
"strings"
"testing"

Expand Down Expand Up @@ -36,7 +36,7 @@ func TestConfigRemoveErrors(t *testing.T) {
}),
)
cmd.SetArgs(tc.args)
cmd.SetOut(ioutil.Discard)
cmd.SetOut(io.Discard)
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
}
}
Expand Down Expand Up @@ -73,7 +73,7 @@ func TestConfigRemoveContinueAfterError(t *testing.T) {

cmd := newConfigRemoveCommand(cli)
cmd.SetArgs(names)
cmd.SetOut(ioutil.Discard)
cmd.SetOut(io.Discard)
assert.Error(t, cmd.Execute(), "error removing config: foo")
assert.Check(t, is.DeepEqual(names, removedConfigs))
}
4 changes: 2 additions & 2 deletions cli/command/container/attach_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package container

import (
"fmt"
"io/ioutil"
"io"
"testing"

"github.com/docker/cli/cli"
Expand Down Expand Up @@ -71,7 +71,7 @@ func TestNewAttachCommandErrors(t *testing.T) {
}
for _, tc := range testCases {
cmd := NewAttachCommand(test.NewFakeCli(&fakeClient{inspectFunc: tc.containerInspectFunc}))
cmd.SetOut(ioutil.Discard)
cmd.SetOut(io.Discard)
cmd.SetArgs(tc.args)
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
}
Expand Down
5 changes: 2 additions & 3 deletions cli/command/container/cp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package container

import (
"io"
"io/ioutil"
"os"
"runtime"
"strings"
Expand Down Expand Up @@ -54,7 +53,7 @@ func TestRunCopyFromContainerToStdout(t *testing.T) {
fakeClient := &fakeClient{
containerCopyFromFunc: func(container, srcPath string) (io.ReadCloser, types.ContainerPathStat, error) {
assert.Check(t, is.Equal("container", container))
return ioutil.NopCloser(strings.NewReader(tarContent)), types.ContainerPathStat{}, nil
return io.NopCloser(strings.NewReader(tarContent)), types.ContainerPathStat{}, nil
},
}
options := copyOptions{source: "container:/path", destination: "-"}
Expand Down Expand Up @@ -84,7 +83,7 @@ func TestRunCopyFromContainerToFilesystem(t *testing.T) {
assert.Check(t, is.Equal("", cli.OutBuffer().String()))
assert.Check(t, is.Equal("", cli.ErrBuffer().String()))

content, err := ioutil.ReadFile(destDir.Join("file1"))
content, err := os.ReadFile(destDir.Join("file1"))
assert.NilError(t, err)
assert.Check(t, is.Equal("content\n", string(content)))
}
Expand Down
11 changes: 5 additions & 6 deletions cli/command/container/create_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"
"runtime"
"sort"
Expand Down Expand Up @@ -67,7 +66,7 @@ func TestCIDFileCloseWithWrite(t *testing.T) {
content := "id"
assert.NilError(t, file.Write(content))

actual, err := ioutil.ReadFile(path)
actual, err := os.ReadFile(path)
assert.NilError(t, err)
assert.Check(t, is.Equal(content, string(actual)))

Expand Down Expand Up @@ -130,7 +129,7 @@ func TestCreateContainerImagePullPolicy(t *testing.T) {
},
imageCreateFunc: func(parentReference string, options types.ImageCreateOptions) (io.ReadCloser, error) {
defer func() { pullCounter++ }()
return ioutil.NopCloser(strings.NewReader("")), nil
return io.NopCloser(strings.NewReader("")), nil
},
infoFunc: func() (types.Info, error) {
return types.Info{IndexServerAddress: "https://indexserver.example.com"}, nil
Expand Down Expand Up @@ -194,7 +193,7 @@ func TestNewCreateCommandWithContentTrustErrors(t *testing.T) {
}, test.EnableContentTrust)
cli.SetNotaryClient(tc.notaryFunc)
cmd := NewCreateCommand(cli)
cmd.SetOut(ioutil.Discard)
cmd.SetOut(io.Discard)
cmd.SetArgs(tc.args)
err := cmd.Execute()
assert.ErrorContains(t, err, tc.expectedError)
Expand Down Expand Up @@ -254,7 +253,7 @@ func TestNewCreateCommandWithWarnings(t *testing.T) {
},
})
cmd := NewCreateCommand(cli)
cmd.SetOut(ioutil.Discard)
cmd.SetOut(io.Discard)
cmd.SetArgs(tc.args)
err := cmd.Execute()
assert.NilError(t, err)
Expand Down Expand Up @@ -306,7 +305,7 @@ func TestCreateContainerWithProxyConfig(t *testing.T) {
},
})
cmd := NewCreateCommand(cli)
cmd.SetOut(ioutil.Discard)
cmd.SetOut(io.Discard)
cmd.SetArgs([]string{"image:tag"})
err := cmd.Execute()
assert.NilError(t, err)
Expand Down
4 changes: 2 additions & 2 deletions cli/command/container/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package container

import (
"context"
"io/ioutil"
"io"
"os"
"testing"

Expand Down Expand Up @@ -267,7 +267,7 @@ func TestNewExecCommandErrors(t *testing.T) {
for _, tc := range testCases {
cli := test.NewFakeCli(&fakeClient{inspectFunc: tc.containerInspectFunc})
cmd := NewExecCommand(cli)
cmd.SetOut(ioutil.Discard)
cmd.SetOut(io.Discard)
cmd.SetArgs(tc.args)
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
}
Expand Down
Loading