diff --git a/cli/command/container/attach_test.go b/cli/command/container/attach_test.go index 7790f351c9..d0b45a6827 100644 --- a/cli/command/container/attach_test.go +++ b/cli/command/container/attach_test.go @@ -2,7 +2,7 @@ package container import ( "fmt" - "io/ioutil" + "io" "testing" "github.com/docker/cli/cli" @@ -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) } diff --git a/cli/command/container/cp_test.go b/cli/command/container/cp_test.go index f599049d05..65ab038e78 100644 --- a/cli/command/container/cp_test.go +++ b/cli/command/container/cp_test.go @@ -2,7 +2,6 @@ package container import ( "io" - "io/ioutil" "os" "runtime" "strings" @@ -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: "-"} @@ -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))) } diff --git a/cli/command/container/create_test.go b/cli/command/container/create_test.go index 19c3de366a..a17898c717 100644 --- a/cli/command/container/create_test.go +++ b/cli/command/container/create_test.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "io" - "io/ioutil" "os" "runtime" "sort" @@ -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))) @@ -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 @@ -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) @@ -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) @@ -303,7 +302,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) diff --git a/cli/command/container/exec_test.go b/cli/command/container/exec_test.go index 0a83a5f159..998a02a4c4 100644 --- a/cli/command/container/exec_test.go +++ b/cli/command/container/exec_test.go @@ -2,7 +2,7 @@ package container import ( "context" - "io/ioutil" + "io" "os" "testing" @@ -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) } diff --git a/cli/command/container/export_test.go b/cli/command/container/export_test.go index 30e80730bf..891317fff3 100644 --- a/cli/command/container/export_test.go +++ b/cli/command/container/export_test.go @@ -2,7 +2,6 @@ package container import ( "io" - "io/ioutil" "strings" "testing" @@ -17,11 +16,11 @@ func TestContainerExportOutputToFile(t *testing.T) { cli := test.NewFakeCli(&fakeClient{ containerExportFunc: func(container string) (io.ReadCloser, error) { - return ioutil.NopCloser(strings.NewReader("bar")), nil + return io.NopCloser(strings.NewReader("bar")), nil }, }) cmd := NewExportCommand(cli) - cmd.SetOut(ioutil.Discard) + cmd.SetOut(io.Discard) cmd.SetArgs([]string{"-o", dir.Join("foo"), "container"}) assert.NilError(t, cmd.Execute()) @@ -35,11 +34,11 @@ func TestContainerExportOutputToFile(t *testing.T) { func TestContainerExportOutputToIrregularFile(t *testing.T) { cli := test.NewFakeCli(&fakeClient{ containerExportFunc: func(container string) (io.ReadCloser, error) { - return ioutil.NopCloser(strings.NewReader("foo")), nil + return io.NopCloser(strings.NewReader("foo")), nil }, }) cmd := NewExportCommand(cli) - cmd.SetOut(ioutil.Discard) + cmd.SetOut(io.Discard) cmd.SetArgs([]string{"-o", "/dev/random", "container"}) err := cmd.Execute() diff --git a/cli/command/container/list.go b/cli/command/container/list.go index 0689cee9e3..b9146506c6 100644 --- a/cli/command/container/list.go +++ b/cli/command/container/list.go @@ -2,7 +2,7 @@ package container import ( "context" - "io/ioutil" + "io" "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" @@ -89,7 +89,7 @@ func buildContainerListOptions(opts *psOptions) (*types.ContainerListOptions, er // This shouldn't error out but swallowing the error makes it harder // to track down if preProcessor issues come up. - if err := tmpl.Execute(ioutil.Discard, optionsProcessor); err != nil { + if err := tmpl.Execute(io.Discard, optionsProcessor); err != nil { return nil, errors.Wrap(err, "failed to execute template") } diff --git a/cli/command/container/list_test.go b/cli/command/container/list_test.go index 0c33d048b8..3c5720d60e 100644 --- a/cli/command/container/list_test.go +++ b/cli/command/container/list_test.go @@ -2,7 +2,7 @@ package container import ( "fmt" - "io/ioutil" + "io" "testing" "github.com/docker/cli/cli/config/configfile" @@ -161,7 +161,7 @@ func TestContainerListErrors(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) } } diff --git a/cli/command/container/logs_test.go b/cli/command/container/logs_test.go index 23d8973a91..711e7bf7b6 100644 --- a/cli/command/container/logs_test.go +++ b/cli/command/container/logs_test.go @@ -2,7 +2,6 @@ package container import ( "io" - "io/ioutil" "strings" "testing" @@ -15,7 +14,7 @@ import ( var logFn = func(expectedOut string) func(string, types.ContainerLogsOptions) (io.ReadCloser, error) { return func(container string, opts types.ContainerLogsOptions) (io.ReadCloser, error) { - return ioutil.NopCloser(strings.NewReader(expectedOut)), nil + return io.NopCloser(strings.NewReader(expectedOut)), nil } } diff --git a/cli/command/container/opts.go b/cli/command/container/opts.go index f53ae5960d..c97799ce10 100644 --- a/cli/command/container/opts.go +++ b/cli/command/container/opts.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "os" "path" "reflect" "regexp" @@ -848,7 +848,7 @@ func parseSecurityOpts(securityOpts []string) ([]string, error) { } } if con[0] == "seccomp" && con[1] != "unconfined" { - f, err := ioutil.ReadFile(con[1]) + f, err := os.ReadFile(con[1]) if err != nil { return securityOpts, errors.Errorf("opening seccomp profile (%s) failed: %v", con[1], err) } diff --git a/cli/command/container/opts_test.go b/cli/command/container/opts_test.go index 3fe5a2d625..56b0f07f9d 100644 --- a/cli/command/container/opts_test.go +++ b/cli/command/container/opts_test.go @@ -2,7 +2,7 @@ package container import ( "fmt" - "io/ioutil" + "io" "os" "runtime" "strings" @@ -58,7 +58,7 @@ func parseRun(args []string) (*container.Config, *container.HostConfig, *network func setupRunFlags() (*pflag.FlagSet, *containerOptions) { flags := pflag.NewFlagSet("run", pflag.ContinueOnError) - flags.SetOutput(ioutil.Discard) + flags.SetOutput(io.Discard) flags.Usage = nil copts := addFlags(flags) return flags, copts diff --git a/cli/command/container/rm_test.go b/cli/command/container/rm_test.go index 674035e2ab..7ab83dd2c9 100644 --- a/cli/command/container/rm_test.go +++ b/cli/command/container/rm_test.go @@ -3,7 +3,7 @@ package container import ( "context" "fmt" - "io/ioutil" + "io" "sort" "sync" "testing" @@ -44,7 +44,7 @@ func TestRemoveForce(t *testing.T) { Version: "1.36", }) cmd := NewRmCommand(cli) - cmd.SetOut(ioutil.Discard) + cmd.SetOut(io.Discard) cmd.SetArgs(tc.args) err := cmd.Execute() diff --git a/cli/command/container/run_test.go b/cli/command/container/run_test.go index 5821d66e66..1b81eb4dad 100644 --- a/cli/command/container/run_test.go +++ b/cli/command/container/run_test.go @@ -2,7 +2,7 @@ package container import ( "fmt" - "io/ioutil" + "io" "testing" "github.com/docker/cli/internal/test" @@ -68,7 +68,7 @@ func TestRunCommandWithContentTrustErrors(t *testing.T) { cli.SetNotaryClient(tc.notaryFunc) cmd := NewRunCommand(cli) cmd.SetArgs(tc.args) - cmd.SetOut(ioutil.Discard) + cmd.SetOut(io.Discard) err := cmd.Execute() assert.Assert(t, err != nil) assert.Assert(t, is.Contains(cli.ErrBuffer().String(), tc.expectedError))