cli/command/secret: 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:30:27 +01:00
parent 3b3a0b898f
commit c558df7ced
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
5 changed files with 12 additions and 12 deletions

View File

@ -4,7 +4,6 @@ import (
"context" "context"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"github.com/docker/cli/cli" "github.com/docker/cli/cli"
"github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command"
@ -101,7 +100,7 @@ func readSecretData(in io.ReadCloser, file string) ([]byte, error) {
} }
defer in.Close() defer in.Close()
} }
data, err := ioutil.ReadAll(in) data, err := io.ReadAll(in)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -1,7 +1,8 @@
package secret package secret
import ( import (
"io/ioutil" "io"
"os"
"path/filepath" "path/filepath"
"reflect" "reflect"
"strings" "strings"
@ -44,14 +45,14 @@ func TestSecretCreateErrors(t *testing.T) {
}), }),
) )
cmd.SetArgs(tc.args) cmd.SetArgs(tc.args)
cmd.SetOut(ioutil.Discard) cmd.SetOut(io.Discard)
assert.ErrorContains(t, cmd.Execute(), tc.expectedError) assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
} }
} }
func TestSecretCreateWithName(t *testing.T) { func TestSecretCreateWithName(t *testing.T) {
name := "foo" name := "foo"
data, err := ioutil.ReadFile(filepath.Join("testdata", secretDataFile)) data, err := os.ReadFile(filepath.Join("testdata", secretDataFile))
assert.NilError(t, err) assert.NilError(t, err)
expected := swarm.SecretSpec{ expected := swarm.SecretSpec{

View File

@ -2,7 +2,7 @@ package secret
import ( import (
"fmt" "fmt"
"io/ioutil" "io"
"testing" "testing"
"time" "time"
@ -59,7 +59,7 @@ func TestSecretInspectErrors(t *testing.T) {
for key, value := range tc.flags { for key, value := range tc.flags {
cmd.Flags().Set(key, value) cmd.Flags().Set(key, value)
} }
cmd.SetOut(ioutil.Discard) cmd.SetOut(io.Discard)
assert.ErrorContains(t, cmd.Execute(), tc.expectedError) assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
} }
} }

View File

@ -1,7 +1,7 @@
package secret package secret
import ( import (
"io/ioutil" "io"
"testing" "testing"
"time" "time"
@ -40,7 +40,7 @@ func TestSecretListErrors(t *testing.T) {
}), }),
) )
cmd.SetArgs(tc.args) cmd.SetArgs(tc.args)
cmd.SetOut(ioutil.Discard) cmd.SetOut(io.Discard)
assert.ErrorContains(t, cmd.Execute(), tc.expectedError) assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
} }
} }

View File

@ -1,7 +1,7 @@
package secret package secret
import ( import (
"io/ioutil" "io"
"strings" "strings"
"testing" "testing"
@ -36,7 +36,7 @@ func TestSecretRemoveErrors(t *testing.T) {
}), }),
) )
cmd.SetArgs(tc.args) cmd.SetArgs(tc.args)
cmd.SetOut(ioutil.Discard) cmd.SetOut(io.Discard)
assert.ErrorContains(t, cmd.Execute(), tc.expectedError) assert.ErrorContains(t, cmd.Execute(), tc.expectedError)
} }
} }
@ -72,7 +72,7 @@ func TestSecretRemoveContinueAfterError(t *testing.T) {
}) })
cmd := newSecretRemoveCommand(cli) cmd := newSecretRemoveCommand(cli)
cmd.SetOut(ioutil.Discard) cmd.SetOut(io.Discard)
cmd.SetArgs(names) cmd.SetArgs(names)
assert.Error(t, cmd.Execute(), "error removing secret: foo") assert.Error(t, cmd.Execute(), "error removing secret: foo")
assert.Check(t, is.DeepEqual(names, removedSecrets)) assert.Check(t, is.DeepEqual(names, removedSecrets))