cli/command/config: remove deprecated io/ioutil

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-02-25 13:04:43 +01:00
parent 8dc53344e0
commit bc1790c5c2
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"
@ -61,7 +60,7 @@ func RunConfigCreate(dockerCli command.Cli, options CreateOptions) error {
defer file.Close() defer file.Close()
} }
configData, err := ioutil.ReadAll(in) configData, err := io.ReadAll(in)
if err != nil { if err != nil {
return errors.Errorf("Error reading content from %q: %v", options.File, err) return errors.Errorf("Error reading content from %q: %v", options.File, err)
} }

View File

@ -1,7 +1,8 @@
package config package config
import ( import (
"io/ioutil" "io"
"os"
"path/filepath" "path/filepath"
"reflect" "reflect"
"strings" "strings"
@ -46,7 +47,7 @@ func TestConfigCreateErrors(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)
} }
} }
@ -82,7 +83,7 @@ func TestConfigCreateWithLabels(t *testing.T) {
} }
name := "foo" name := "foo"
data, err := ioutil.ReadFile(filepath.Join("testdata", configDataFile)) data, err := os.ReadFile(filepath.Join("testdata", configDataFile))
assert.NilError(t, err) assert.NilError(t, err)
expected := swarm.ConfigSpec{ expected := swarm.ConfigSpec{

View File

@ -2,7 +2,7 @@ package config
import ( import (
"fmt" "fmt"
"io/ioutil" "io"
"testing" "testing"
"time" "time"
@ -59,7 +59,7 @@ func TestConfigInspectErrors(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 config package config
import ( import (
"io/ioutil" "io"
"testing" "testing"
"time" "time"
@ -40,7 +40,7 @@ func TestConfigListErrors(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 config package config
import ( import (
"io/ioutil" "io"
"strings" "strings"
"testing" "testing"
@ -36,7 +36,7 @@ func TestConfigRemoveErrors(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)
} }
} }
@ -73,7 +73,7 @@ func TestConfigRemoveContinueAfterError(t *testing.T) {
cmd := newConfigRemoveCommand(cli) cmd := newConfigRemoveCommand(cli)
cmd.SetArgs(names) cmd.SetArgs(names)
cmd.SetOut(ioutil.Discard) cmd.SetOut(io.Discard)
assert.Error(t, cmd.Execute(), "error removing config: foo") assert.Error(t, cmd.Execute(), "error removing config: foo")
assert.Check(t, is.DeepEqual(names, removedConfigs)) assert.Check(t, is.DeepEqual(names, removedConfigs))
} }