cli/command/stack: remove deprecated io/ioutil

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-02-25 14:31:31 +01:00
parent d1f26de646
commit d59330f40d
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
6 changed files with 15 additions and 16 deletions

View File

@ -1,7 +1,7 @@
package stack
import (
"io/ioutil"
"io"
"testing"
"github.com/docker/cli/internal/test"
@ -11,7 +11,7 @@ import (
func TestDeployWithEmptyName(t *testing.T) {
cmd := newDeployCommand(test.NewFakeCli(&fakeClient{}))
cmd.SetArgs([]string{"' '"})
cmd.SetOut(ioutil.Discard)
cmd.SetOut(io.Discard)
assert.ErrorContains(t, cmd.Execute(), `invalid stack name: "' '"`)
}

View File

@ -1,7 +1,7 @@
package stack
import (
"io/ioutil"
"io"
"testing"
"github.com/docker/cli/internal/test"
@ -49,7 +49,7 @@ func TestListErrors(t *testing.T) {
serviceListFunc: tc.serviceListFunc,
}))
cmd.SetArgs(tc.args)
cmd.SetOut(ioutil.Discard)
cmd.SetOut(io.Discard)
for key, value := range tc.flags {
cmd.Flags().Set(key, value)
}

View File

@ -3,7 +3,6 @@ package loader
import (
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"sort"
@ -132,9 +131,9 @@ func loadConfigFile(filename string, stdin io.Reader) (*composetypes.ConfigFile,
var err error
if filename == "-" {
bytes, err = ioutil.ReadAll(stdin)
bytes, err = io.ReadAll(stdin)
} else {
bytes, err = ioutil.ReadFile(filename)
bytes, err = os.ReadFile(filename)
}
if err != nil {
return nil, err

View File

@ -1,7 +1,7 @@
package stack
import (
"io/ioutil"
"io"
"testing"
"time"
@ -45,7 +45,7 @@ func TestStackPsErrors(t *testing.T) {
taskListFunc: tc.taskListFunc,
}))
cmd.SetArgs(tc.args)
cmd.SetOut(ioutil.Discard)
cmd.SetOut(io.Discard)
assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
}
}
@ -169,7 +169,7 @@ func TestStackPs(t *testing.T) {
for key, value := range tc.flags {
cmd.Flags().Set(key, value)
}
cmd.SetOut(ioutil.Discard)
cmd.SetOut(io.Discard)
if tc.expectedErr != "" {
assert.Error(t, cmd.Execute(), tc.expectedErr)

View File

@ -2,7 +2,7 @@ package stack
import (
"errors"
"io/ioutil"
"io"
"strings"
"testing"
@ -44,7 +44,7 @@ func fakeClientForRemoveStackTest(version string) *fakeClient {
func TestRemoveWithEmptyName(t *testing.T) {
cmd := newRemoveCommand(test.NewFakeCli(&fakeClient{}))
cmd.SetArgs([]string{"good", "' '", "alsogood"})
cmd.SetOut(ioutil.Discard)
cmd.SetOut(io.Discard)
assert.ErrorContains(t, cmd.Execute(), `invalid stack name: "' '"`)
}
@ -155,7 +155,7 @@ func TestRemoveContinueAfterError(t *testing.T) {
},
}
cmd := newRemoveCommand(test.NewFakeCli(cli))
cmd.SetOut(ioutil.Discard)
cmd.SetOut(io.Discard)
cmd.SetArgs([]string{"foo", "bar"})
assert.Error(t, cmd.Execute(), "Failed to remove some resources from stack: foo")

View File

@ -1,7 +1,7 @@
package stack
import (
"io/ioutil"
"io"
"testing"
"github.com/docker/cli/cli/config/configfile"
@ -79,7 +79,7 @@ func TestStackServicesErrors(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)
})
}
@ -88,7 +88,7 @@ func TestStackServicesErrors(t *testing.T) {
func TestRunServicesWithEmptyName(t *testing.T) {
cmd := newServicesCommand(test.NewFakeCli(&fakeClient{}))
cmd.SetArgs([]string{"' '"})
cmd.SetOut(ioutil.Discard)
cmd.SetOut(io.Discard)
assert.ErrorContains(t, cmd.Execute(), `invalid stack name: "' '"`)
}