linting: fmt.Errorf can be replaced with errors.New (perfsprint)
internal/test/cli.go:175:14: fmt.Errorf can be replaced with errors.New (perfsprint) return nil, fmt.Errorf("no notary client available unless defined") ^ cli/command/cli.go:318:29: fmt.Errorf can be replaced with errors.New (perfsprint) return docker.Endpoint{}, fmt.Errorf("no context store initialized") ^ cli/command/container/attach.go:161:11: fmt.Errorf can be replaced with errors.New (perfsprint) return fmt.Errorf(result.Error.Message) ^ cli/command/container/opts.go:577:16: fmt.Errorf can be replaced with errors.New (perfsprint) return nil, fmt.Errorf("--health-start-period cannot be negative") ^ cli/command/container/opts.go:580:16: fmt.Errorf can be replaced with errors.New (perfsprint) return nil, fmt.Errorf("--health-start-interval cannot be negative") ^ cli/command/container/stats.go:221:11: fmt.Errorf can be replaced with errors.New (perfsprint) return fmt.Errorf("filtering is not supported when specifying a list of containers") ^ cli/command/container/attach_test.go:82:17: fmt.Errorf can be replaced with errors.New (perfsprint) expectedErr = fmt.Errorf("unexpected error") ^ cli/command/container/create_test.go:234:40: fmt.Errorf can be replaced with errors.New (perfsprint) return container.CreateResponse{}, fmt.Errorf("shouldn't try to pull image") ^ cli/command/container/list_test.go:150:17: fmt.Errorf can be replaced with errors.New (perfsprint) return nil, fmt.Errorf("error listing containers") ^ cli/command/container/rm_test.go:40:31: fmt.Errorf can be replaced with errors.New (perfsprint) return errdefs.NotFound(fmt.Errorf("Error: no such container: " + container)) ^ cli/command/container/run_test.go:138:40: fmt.Errorf can be replaced with errors.New (perfsprint) return container.CreateResponse{}, fmt.Errorf("shouldn't try to pull image") ^ cli/command/image/pull_test.go:115:49: fmt.Errorf can be replaced with errors.New (perfsprint) return io.NopCloser(strings.NewReader("")), fmt.Errorf("shouldn't try to pull image") ^ cli/command/network/connect.go:88:16: fmt.Errorf can be replaced with errors.New (perfsprint) return nil, fmt.Errorf("invalid key/value pair format in driver options") ^ cli/command/plugin/create_test.go:96:11: fmt.Errorf can be replaced with errors.New (perfsprint) return fmt.Errorf("Error creating plugin") ^ cli/command/plugin/disable_test.go:32:12: fmt.Errorf can be replaced with errors.New (perfsprint) return fmt.Errorf("Error disabling plugin") ^ cli/command/plugin/enable_test.go:32:12: fmt.Errorf can be replaced with errors.New (perfsprint) return fmt.Errorf("failed to enable plugin") ^ cli/command/plugin/inspect_test.go:55:22: fmt.Errorf can be replaced with errors.New (perfsprint) return nil, nil, fmt.Errorf("error inspecting plugin") ^ cli/command/plugin/install_test.go:43:17: fmt.Errorf can be replaced with errors.New (perfsprint) return nil, fmt.Errorf("Error installing plugin") ^ cli/command/plugin/install_test.go:51:17: fmt.Errorf can be replaced with errors.New (perfsprint) return nil, fmt.Errorf("(image) when fetching") ^ cli/command/plugin/install_test.go:95:17: fmt.Errorf can be replaced with errors.New (perfsprint) return nil, fmt.Errorf("should not try to install plugin") ^ cli/command/plugin/list_test.go:35:41: fmt.Errorf can be replaced with errors.New (perfsprint) return types.PluginsListResponse{}, fmt.Errorf("error listing plugins") ^ cli/command/plugin/remove_test.go:27:12: fmt.Errorf can be replaced with errors.New (perfsprint) return fmt.Errorf("Error removing plugin") ^ cli/command/registry/login_test.go:36:46: fmt.Errorf can be replaced with errors.New (perfsprint) return registrytypes.AuthenticateOKBody{}, fmt.Errorf("Invalid Username or Password") ^ cli/command/registry/login_test.go:44:46: fmt.Errorf can be replaced with errors.New (perfsprint) return registrytypes.AuthenticateOKBody{}, fmt.Errorf(errUnknownUser) ^ cli/command/system/info.go:190:10: fmt.Errorf can be replaced with errors.New (perfsprint) return fmt.Errorf("errors pretty printing info") ^ cli/command/system/prune.go:77:10: fmt.Errorf can be replaced with errors.New (perfsprint) return fmt.Errorf(`ERROR: The "until" filter is not supported with "--volumes"`) ^ cli/command/system/version_test.go:19:28: fmt.Errorf can be replaced with errors.New (perfsprint) return types.Version{}, fmt.Errorf("no server") ^ cli/command/trust/key_load.go:112:22: fmt.Errorf can be replaced with errors.New (perfsprint) return []byte{}, fmt.Errorf("could not decrypt key") ^ cli/command/trust/revoke.go:44:10: fmt.Errorf can be replaced with errors.New (perfsprint) return fmt.Errorf("cannot use a digest reference for IMAGE:TAG") ^ cli/command/trust/revoke.go:105:10: fmt.Errorf can be replaced with errors.New (perfsprint) return fmt.Errorf("no signed tags to remove") ^ cli/command/trust/signer_add.go:56:10: fmt.Errorf can be replaced with errors.New (perfsprint) return fmt.Errorf("releases is a reserved keyword, please use a different signer name") ^ cli/command/trust/signer_add.go:60:10: fmt.Errorf can be replaced with errors.New (perfsprint) return fmt.Errorf("path to a public key must be provided using the `--key` flag") ^ opts/config.go:71:10: fmt.Errorf can be replaced with errors.New (perfsprint) return fmt.Errorf("source is required") ^ opts/mount.go:168:10: fmt.Errorf can be replaced with errors.New (perfsprint) return fmt.Errorf("type is required") ^ opts/mount.go:172:10: fmt.Errorf can be replaced with errors.New (perfsprint) return fmt.Errorf("target is required") ^ opts/network.go:90:11: fmt.Errorf can be replaced with errors.New (perfsprint) return fmt.Errorf("network name/id is not specified") ^ opts/network.go:129:18: fmt.Errorf can be replaced with errors.New (perfsprint) return "", "", fmt.Errorf("invalid key value pair format in driver options") ^ opts/opts.go:404:13: fmt.Errorf can be replaced with errors.New (perfsprint) return 0, fmt.Errorf("value is too precise") ^ opts/opts.go:412:18: fmt.Errorf can be replaced with errors.New (perfsprint) return "", "", fmt.Errorf("empty string specified for links") ^ opts/parse.go:84:37: fmt.Errorf can be replaced with errors.New (perfsprint) return container.RestartPolicy{}, fmt.Errorf("invalid restart policy format: no policy provided before colon") ^ opts/parse.go:89:38: fmt.Errorf can be replaced with errors.New (perfsprint) return container.RestartPolicy{}, fmt.Errorf("invalid restart policy format: maximum retry count must be an integer") ^ opts/port.go:105:13: fmt.Errorf can be replaced with errors.New (perfsprint) return fmt.Errorf("hostip is not supported") ^ opts/secret.go:70:10: fmt.Errorf can be replaced with errors.New (perfsprint) return fmt.Errorf("source is required") ^ opts/env_test.go:57:11: fmt.Errorf can be replaced with errors.New (perfsprint) err: fmt.Errorf("invalid environment variable: =a"), ^ opts/env_test.go:93:11: fmt.Errorf can be replaced with errors.New (perfsprint) err: fmt.Errorf("invalid environment variable: ="), ^ cli-plugins/manager/error_test.go:16:11: fmt.Errorf can be replaced with errors.New (perfsprint) inner := fmt.Errorf("testing") ^ Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Родитель
e93abde7a0
Коммит
dfec976e84
|
@ -2,7 +2,7 @@ package manager
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"gotest.tools/v3/assert"
|
||||
|
@ -13,7 +13,7 @@ func TestPluginError(t *testing.T) {
|
|||
err := NewPluginError("new error")
|
||||
assert.Check(t, is.Error(err, "new error"))
|
||||
|
||||
inner := fmt.Errorf("testing")
|
||||
inner := errors.New("testing")
|
||||
err = wrapAsPluginError(inner, "wrapping")
|
||||
assert.Check(t, is.Error(err, "wrapping: testing"))
|
||||
assert.Check(t, is.ErrorIs(err, inner))
|
||||
|
|
|
@ -315,7 +315,7 @@ func newAPIClientFromEndpoint(ep docker.Endpoint, configFile *configfile.ConfigF
|
|||
|
||||
func resolveDockerEndpoint(s store.Reader, contextName string) (docker.Endpoint, error) {
|
||||
if s == nil {
|
||||
return docker.Endpoint{}, fmt.Errorf("no context store initialized")
|
||||
return docker.Endpoint{}, errors.New("no context store initialized")
|
||||
}
|
||||
ctxMeta, err := s.GetMetadata(contextName)
|
||||
if err != nil {
|
||||
|
|
|
@ -2,7 +2,6 @@ package container
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
|
@ -158,7 +157,7 @@ func getExitStatus(errC <-chan error, resultC <-chan container.WaitResponse) err
|
|||
select {
|
||||
case result := <-resultC:
|
||||
if result.Error != nil {
|
||||
return fmt.Errorf(result.Error.Message)
|
||||
return errors.New(result.Error.Message)
|
||||
}
|
||||
if result.StatusCode != 0 {
|
||||
return cli.StatusError{StatusCode: int(result.StatusCode)}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
|
@ -79,7 +78,7 @@ func TestNewAttachCommandErrors(t *testing.T) {
|
|||
|
||||
func TestGetExitStatus(t *testing.T) {
|
||||
var (
|
||||
expectedErr = fmt.Errorf("unexpected error")
|
||||
expectedErr = errors.New("unexpected error")
|
||||
errC = make(chan error, 1)
|
||||
resultC = make(chan container.WaitResponse, 1)
|
||||
)
|
||||
|
|
|
@ -3,7 +3,6 @@ package container
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"runtime"
|
||||
|
@ -231,7 +230,7 @@ func TestNewCreateCommandWithContentTrustErrors(t *testing.T) {
|
|||
platform *specs.Platform,
|
||||
containerName string,
|
||||
) (container.CreateResponse, error) {
|
||||
return container.CreateResponse{}, fmt.Errorf("shouldn't try to pull image")
|
||||
return container.CreateResponse{}, errors.New("shouldn't try to pull image")
|
||||
},
|
||||
}, test.EnableContentTrust)
|
||||
fakeCLI.SetNotaryClient(tc.notaryFunc)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
|
@ -147,7 +147,7 @@ func TestContainerListErrors(t *testing.T) {
|
|||
},
|
||||
{
|
||||
containerListFunc: func(_ container.ListOptions) ([]types.Container, error) {
|
||||
return nil, fmt.Errorf("error listing containers")
|
||||
return nil, errors.New("error listing containers")
|
||||
},
|
||||
expectedError: "error listing containers",
|
||||
},
|
||||
|
|
|
@ -574,10 +574,10 @@ func parse(flags *pflag.FlagSet, copts *containerOptions, serverOS string) (*con
|
|||
return nil, errors.Errorf("--health-retries cannot be negative")
|
||||
}
|
||||
if copts.healthStartPeriod < 0 {
|
||||
return nil, fmt.Errorf("--health-start-period cannot be negative")
|
||||
return nil, errors.New("--health-start-period cannot be negative")
|
||||
}
|
||||
if copts.healthStartInterval < 0 {
|
||||
return nil, fmt.Errorf("--health-start-interval cannot be negative")
|
||||
return nil, errors.New("--health-start-interval cannot be negative")
|
||||
}
|
||||
|
||||
healthConfig = &container.HealthConfig{
|
||||
|
|
|
@ -2,7 +2,7 @@ package container
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"errors"
|
||||
"io"
|
||||
"sort"
|
||||
"sync"
|
||||
|
@ -37,7 +37,7 @@ func TestRemoveForce(t *testing.T) {
|
|||
mutex.Unlock()
|
||||
|
||||
if container == "nosuchcontainer" {
|
||||
return errdefs.NotFound(fmt.Errorf("Error: no such container: " + container))
|
||||
return errdefs.NotFound(errors.New("Error: no such container: " + container))
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
|
|
@ -3,7 +3,6 @@ package container
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"os/signal"
|
||||
|
@ -135,7 +134,7 @@ func TestRunCommandWithContentTrustErrors(t *testing.T) {
|
|||
platform *specs.Platform,
|
||||
containerName string,
|
||||
) (container.CreateResponse, error) {
|
||||
return container.CreateResponse{}, fmt.Errorf("shouldn't try to pull image")
|
||||
return container.CreateResponse{}, errors.New("shouldn't try to pull image")
|
||||
},
|
||||
}, test.EnableContentTrust)
|
||||
fakeCLI.SetNotaryClient(tc.notaryFunc)
|
||||
|
|
|
@ -218,7 +218,7 @@ func RunStats(ctx context.Context, dockerCLI command.Cli, options *StatsOptions)
|
|||
// with a list of container names/IDs.
|
||||
|
||||
if options.Filters != nil && options.Filters.Len() > 0 {
|
||||
return fmt.Errorf("filtering is not supported when specifying a list of containers")
|
||||
return errors.New("filtering is not supported when specifying a list of containers")
|
||||
}
|
||||
|
||||
// Create the list of containers, and start collecting stats for all
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package image
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
|
@ -112,7 +113,7 @@ func TestNewPullCommandWithContentTrustErrors(t *testing.T) {
|
|||
for _, tc := range testCases {
|
||||
cli := test.NewFakeCli(&fakeClient{
|
||||
imagePullFunc: func(ref string, options image.PullOptions) (io.ReadCloser, error) {
|
||||
return io.NopCloser(strings.NewReader("")), fmt.Errorf("shouldn't try to pull image")
|
||||
return io.NopCloser(strings.NewReader("")), errors.New("shouldn't try to pull image")
|
||||
},
|
||||
}, test.EnableContentTrust)
|
||||
cli.SetNotaryClient(tc.notaryFunc)
|
||||
|
|
|
@ -2,7 +2,7 @@ package network
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/cli/cli"
|
||||
|
@ -83,7 +83,7 @@ func convertDriverOpt(options []string) (map[string]string, error) {
|
|||
// TODO(thaJeztah): we should probably not accept whitespace here (both for key and value).
|
||||
k = strings.TrimSpace(k)
|
||||
if !ok || k == "" {
|
||||
return nil, fmt.Errorf("invalid key/value pair format in driver options")
|
||||
return nil, errors.New("invalid key/value pair format in driver options")
|
||||
}
|
||||
driverOpt[k] = strings.TrimSpace(v)
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package plugin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"errors"
|
||||
"io"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
@ -91,16 +91,14 @@ func TestCreateErrorFromDaemon(t *testing.T) {
|
|||
fs.WithFile("config.json", `{ "Name": "plugin-foo" }`))
|
||||
defer tmpDir.Remove()
|
||||
|
||||
cli := test.NewFakeCli(&fakeClient{
|
||||
cmd := newCreateCommand(test.NewFakeCli(&fakeClient{
|
||||
pluginCreateFunc: func(createContext io.Reader, createOptions types.PluginCreateOptions) error {
|
||||
return fmt.Errorf("Error creating plugin")
|
||||
return errors.New("error creating plugin")
|
||||
},
|
||||
})
|
||||
|
||||
cmd := newCreateCommand(cli)
|
||||
}))
|
||||
cmd.SetArgs([]string{"plugin-foo", tmpDir.Path()})
|
||||
cmd.SetOut(io.Discard)
|
||||
assert.ErrorContains(t, cmd.Execute(), "Error creating plugin")
|
||||
assert.ErrorContains(t, cmd.Execute(), "error creating plugin")
|
||||
}
|
||||
|
||||
func TestCreatePlugin(t *testing.T) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package plugin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
|
@ -27,9 +27,9 @@ func TestPluginDisableErrors(t *testing.T) {
|
|||
},
|
||||
{
|
||||
args: []string{"plugin-foo"},
|
||||
expectedError: "Error disabling plugin",
|
||||
expectedError: "error disabling plugin",
|
||||
pluginDisableFunc: func(name string, disableOptions types.PluginDisableOptions) error {
|
||||
return fmt.Errorf("Error disabling plugin")
|
||||
return errors.New("error disabling plugin")
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package plugin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
|
@ -29,7 +29,7 @@ func TestPluginEnableErrors(t *testing.T) {
|
|||
{
|
||||
args: []string{"plugin-foo"},
|
||||
pluginEnableFunc: func(name string, options types.PluginEnableOptions) error {
|
||||
return fmt.Errorf("failed to enable plugin")
|
||||
return errors.New("failed to enable plugin")
|
||||
},
|
||||
expectedError: "failed to enable plugin",
|
||||
},
|
||||
|
@ -43,10 +43,9 @@ func TestPluginEnableErrors(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
cmd := newEnableCommand(
|
||||
test.NewFakeCli(&fakeClient{
|
||||
pluginEnableFunc: tc.pluginEnableFunc,
|
||||
}))
|
||||
cmd := newEnableCommand(test.NewFakeCli(&fakeClient{
|
||||
pluginEnableFunc: tc.pluginEnableFunc,
|
||||
}))
|
||||
cmd.SetArgs(tc.args)
|
||||
for key, value := range tc.flags {
|
||||
cmd.Flags().Set(key, value)
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package plugin
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/docker/api/types"
|
||||
|
||||
"gotest.tools/v3/assert"
|
||||
"gotest.tools/v3/golden"
|
||||
)
|
||||
|
@ -52,7 +52,7 @@ func TestInspectErrors(t *testing.T) {
|
|||
args: []string{"foo"},
|
||||
expectedError: "error inspecting plugin",
|
||||
inspectFunc: func(name string) (*types.Plugin, []byte, error) {
|
||||
return nil, nil, fmt.Errorf("error inspecting plugin")
|
||||
return nil, nil, errors.New("error inspecting plugin")
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package plugin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"errors"
|
||||
"io"
|
||||
"strings"
|
||||
"testing"
|
||||
|
@ -38,9 +38,9 @@ func TestInstallErrors(t *testing.T) {
|
|||
{
|
||||
description: "installation error",
|
||||
args: []string{"foo"},
|
||||
expectedError: "Error installing plugin",
|
||||
expectedError: "error installing plugin",
|
||||
installFunc: func(name string, options types.PluginInstallOptions) (io.ReadCloser, error) {
|
||||
return nil, fmt.Errorf("Error installing plugin")
|
||||
return nil, errors.New("error installing plugin")
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -48,7 +48,7 @@ func TestInstallErrors(t *testing.T) {
|
|||
args: []string{"foo"},
|
||||
expectedError: "docker image pull",
|
||||
installFunc: func(name string, options types.PluginInstallOptions) (io.ReadCloser, error) {
|
||||
return nil, fmt.Errorf("(image) when fetching")
|
||||
return nil, errors.New("(image) when fetching")
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ func TestInstallContentTrustErrors(t *testing.T) {
|
|||
for _, tc := range testCases {
|
||||
cli := test.NewFakeCli(&fakeClient{
|
||||
pluginInstallFunc: func(name string, options types.PluginInstallOptions) (io.ReadCloser, error) {
|
||||
return nil, fmt.Errorf("should not try to install plugin")
|
||||
return nil, errors.New("should not try to install plugin")
|
||||
},
|
||||
}, test.EnableContentTrust)
|
||||
cli.SetNotaryClient(tc.notaryFunc)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package plugin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
|
@ -32,7 +32,7 @@ func TestListErrors(t *testing.T) {
|
|||
args: []string{},
|
||||
expectedError: "error listing plugins",
|
||||
listFunc: func(filter filters.Args) (types.PluginsListResponse, error) {
|
||||
return types.PluginsListResponse{}, fmt.Errorf("error listing plugins")
|
||||
return types.PluginsListResponse{}, errors.New("error listing plugins")
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package plugin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"errors"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
|
@ -24,9 +24,9 @@ func TestRemoveErrors(t *testing.T) {
|
|||
{
|
||||
args: []string{"plugin-foo"},
|
||||
pluginRemoveFunc: func(name string, options types.PluginRemoveOptions) error {
|
||||
return fmt.Errorf("Error removing plugin")
|
||||
return errors.New("error removing plugin")
|
||||
},
|
||||
expectedError: "Error removing plugin",
|
||||
expectedError: "error removing plugin",
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package registry
|
|||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
|
@ -33,7 +34,7 @@ func (c fakeClient) Info(context.Context) (system.Info, error) {
|
|||
|
||||
func (c fakeClient) RegistryLogin(_ context.Context, auth registrytypes.AuthConfig) (registrytypes.AuthenticateOKBody, error) {
|
||||
if auth.Password == expiredPassword {
|
||||
return registrytypes.AuthenticateOKBody{}, fmt.Errorf("Invalid Username or Password")
|
||||
return registrytypes.AuthenticateOKBody{}, errors.New("Invalid Username or Password")
|
||||
}
|
||||
if auth.Password == useToken {
|
||||
return registrytypes.AuthenticateOKBody{
|
||||
|
@ -41,7 +42,7 @@ func (c fakeClient) RegistryLogin(_ context.Context, auth registrytypes.AuthConf
|
|||
}, nil
|
||||
}
|
||||
if auth.Username == unknownUser {
|
||||
return registrytypes.AuthenticateOKBody{}, fmt.Errorf(errUnknownUser)
|
||||
return registrytypes.AuthenticateOKBody{}, errors.New(errUnknownUser)
|
||||
}
|
||||
return registrytypes.AuthenticateOKBody{}, nil
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ package system
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"regexp"
|
||||
|
@ -187,7 +188,7 @@ func prettyPrintInfo(streams command.Streams, info dockerInfo) error {
|
|||
}
|
||||
|
||||
if len(info.ServerErrors) > 0 || len(info.ClientErrors) > 0 {
|
||||
return fmt.Errorf("errors pretty printing info")
|
||||
return errors.New("errors pretty printing info")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ Are you sure you want to continue?`
|
|||
func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions) error {
|
||||
// TODO version this once "until" filter is supported for volumes
|
||||
if options.pruneVolumes && options.filter.Value().Contains("until") {
|
||||
return fmt.Errorf(`ERROR: The "until" filter is not supported with "--volumes"`)
|
||||
return errors.New(`ERROR: The "until" filter is not supported with "--volumes"`)
|
||||
}
|
||||
if !options.force {
|
||||
r, err := command.PromptForConfirmation(ctx, dockerCli.In(), dockerCli.Out(), confirmationMessage(dockerCli, options))
|
||||
|
@ -105,11 +105,11 @@ func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions)
|
|||
}
|
||||
spaceReclaimed += spc
|
||||
if output != "" {
|
||||
fmt.Fprintln(dockerCli.Out(), output)
|
||||
_, _ = fmt.Fprintln(dockerCli.Out(), output)
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Fprintln(dockerCli.Out(), "Total reclaimed space:", units.HumanSize(float64(spaceReclaimed)))
|
||||
_, _ = fmt.Fprintln(dockerCli.Out(), "Total reclaimed space:", units.HumanSize(float64(spaceReclaimed)))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package system
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"errors"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
|
@ -16,7 +16,7 @@ import (
|
|||
func TestVersionWithoutServer(t *testing.T) {
|
||||
cli := test.NewFakeCli(&fakeClient{
|
||||
serverVersion: func(ctx context.Context) (types.Version, error) {
|
||||
return types.Version{}, fmt.Errorf("no server")
|
||||
return types.Version{}, errors.New("no server")
|
||||
},
|
||||
})
|
||||
cmd := NewVersionCommand(cli)
|
||||
|
|
|
@ -109,7 +109,7 @@ func decodePrivKeyIfNecessary(privPemBytes []byte, passRet notary.PassRetriever)
|
|||
if _, ok := pemBlock.Headers["path"]; !ok {
|
||||
privKey, _, err := trustmanager.GetPasswdDecryptBytes(passRet, privPemBytes, "", "encrypted")
|
||||
if err != nil {
|
||||
return []byte{}, fmt.Errorf("could not decrypt key")
|
||||
return []byte{}, errors.New("could not decrypt key")
|
||||
}
|
||||
privPemBytes = privKey.Private()
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ func revokeTrust(ctx context.Context, dockerCLI command.Cli, remote string, opti
|
|||
}
|
||||
tag := imgRefAndAuth.Tag()
|
||||
if imgRefAndAuth.Tag() == "" && imgRefAndAuth.Digest() != "" {
|
||||
return fmt.Errorf("cannot use a digest reference for IMAGE:TAG")
|
||||
return errors.New("cannot use a digest reference for IMAGE:TAG")
|
||||
}
|
||||
if imgRefAndAuth.Tag() == "" && !options.forceYes {
|
||||
deleteRemote, err := command.PromptForConfirmation(ctx, dockerCLI.In(), dockerCLI.Out(), fmt.Sprintf("Please confirm you would like to delete all signature data for %s?", remote))
|
||||
|
@ -65,7 +65,7 @@ func revokeTrust(ctx context.Context, dockerCLI command.Cli, remote string, opti
|
|||
if err := revokeSignature(notaryRepo, tag); err != nil {
|
||||
return errors.Wrapf(err, "could not remove signature for %s", remote)
|
||||
}
|
||||
fmt.Fprintf(dockerCLI.Out(), "Successfully deleted signature for %s\n", remote)
|
||||
_, _ = fmt.Fprintf(dockerCLI.Out(), "Successfully deleted signature for %s\n", remote)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ func revokeAllSigs(notaryRepo client.Repository) error {
|
|||
}
|
||||
|
||||
if len(releasedTargetWithRoleList) == 0 {
|
||||
return fmt.Errorf("no signed tags to remove")
|
||||
return errors.New("no signed tags to remove")
|
||||
}
|
||||
|
||||
// we need all the roles that signed each released target so we can remove from all roles.
|
||||
|
|
|
@ -53,11 +53,11 @@ func addSigner(ctx context.Context, dockerCLI command.Cli, options signerAddOpti
|
|||
return fmt.Errorf("signer name \"%s\" must start with lowercase alphanumeric characters and can include \"-\" or \"_\" after the first character", signerName)
|
||||
}
|
||||
if signerName == "releases" {
|
||||
return fmt.Errorf("releases is a reserved keyword, please use a different signer name")
|
||||
return errors.New("releases is a reserved keyword, please use a different signer name")
|
||||
}
|
||||
|
||||
if options.keys.Len() == 0 {
|
||||
return fmt.Errorf("path to a public key must be provided using the `--key` flag")
|
||||
return errors.New("path to a public key must be provided using the `--key` flag")
|
||||
}
|
||||
signerPubKeys, err := ingestPublicKeys(options.keys.GetAll())
|
||||
if err != nil {
|
||||
|
|
|
@ -2,7 +2,7 @@ package test
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"errors"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
|
@ -172,7 +172,7 @@ func (c *FakeCli) NotaryClient(imgRefAndAuth trust.ImageRefAndAuth, actions []st
|
|||
if c.notaryClientFunc != nil {
|
||||
return c.notaryClientFunc(imgRefAndAuth, actions)
|
||||
}
|
||||
return nil, fmt.Errorf("no notary client available unless defined")
|
||||
return nil, errors.New("no notary client available unless defined")
|
||||
}
|
||||
|
||||
// ManifestStore returns a fake store used for testing
|
||||
|
|
|
@ -2,6 +2,7 @@ package opts
|
|||
|
||||
import (
|
||||
"encoding/csv"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
|
@ -68,7 +69,7 @@ func (o *ConfigOpt) Set(value string) error {
|
|||
}
|
||||
|
||||
if options.ConfigName == "" {
|
||||
return fmt.Errorf("source is required")
|
||||
return errors.New("source is required")
|
||||
}
|
||||
if options.File.Name == "" {
|
||||
options.File.Name = options.ConfigName
|
||||
|
|
|
@ -11,9 +11,9 @@ import (
|
|||
|
||||
func TestValidateEnv(t *testing.T) {
|
||||
type testCase struct {
|
||||
value string
|
||||
expected string
|
||||
err error
|
||||
value string
|
||||
expected string
|
||||
expectedErr string
|
||||
}
|
||||
tests := []testCase{
|
||||
{
|
||||
|
@ -53,8 +53,8 @@ func TestValidateEnv(t *testing.T) {
|
|||
expected: fmt.Sprintf("PATH=%v", os.Getenv("PATH")),
|
||||
},
|
||||
{
|
||||
value: "=a",
|
||||
err: fmt.Errorf("invalid environment variable: =a"),
|
||||
value: "=a",
|
||||
expectedErr: "invalid environment variable: =a",
|
||||
},
|
||||
{
|
||||
value: "PATH=",
|
||||
|
@ -89,17 +89,17 @@ func TestValidateEnv(t *testing.T) {
|
|||
expected: "some space after ",
|
||||
},
|
||||
{
|
||||
value: "=",
|
||||
err: fmt.Errorf("invalid environment variable: ="),
|
||||
value: "=",
|
||||
expectedErr: "invalid environment variable: =",
|
||||
},
|
||||
}
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
// Environment variables are case in-sensitive on Windows
|
||||
tests = append(tests, testCase{
|
||||
value: "PaTh",
|
||||
expected: fmt.Sprintf("PaTh=%v", os.Getenv("PATH")),
|
||||
err: nil,
|
||||
value: "PaTh",
|
||||
expected: fmt.Sprintf("PaTh=%v", os.Getenv("PATH")),
|
||||
expectedErr: "",
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -108,10 +108,10 @@ func TestValidateEnv(t *testing.T) {
|
|||
t.Run(tc.value, func(t *testing.T) {
|
||||
actual, err := ValidateEnv(tc.value)
|
||||
|
||||
if tc.err == nil {
|
||||
if tc.expectedErr == "" {
|
||||
assert.NilError(t, err)
|
||||
} else {
|
||||
assert.Error(t, err, tc.err.Error())
|
||||
assert.Error(t, err, tc.expectedErr)
|
||||
}
|
||||
assert.Equal(t, actual, tc.expected)
|
||||
})
|
||||
|
|
|
@ -165,11 +165,11 @@ func (m *MountOpt) Set(value string) error {
|
|||
}
|
||||
|
||||
if mount.Type == "" {
|
||||
return fmt.Errorf("type is required")
|
||||
return errors.New("type is required")
|
||||
}
|
||||
|
||||
if mount.Target == "" {
|
||||
return fmt.Errorf("target is required")
|
||||
return errors.New("target is required")
|
||||
}
|
||||
|
||||
if mount.VolumeOptions != nil && mount.Type != mounttypes.TypeVolume {
|
||||
|
|
|
@ -2,6 +2,7 @@ package opts
|
|||
|
||||
import (
|
||||
"encoding/csv"
|
||||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
@ -83,11 +84,11 @@ func (n *NetworkOpt) Set(value string) error { //nolint:gocyclo
|
|||
}
|
||||
netOpt.DriverOpts[key] = val
|
||||
default:
|
||||
return fmt.Errorf("invalid field key %s", key)
|
||||
return errors.New("invalid field key " + key)
|
||||
}
|
||||
}
|
||||
if len(netOpt.Target) == 0 {
|
||||
return fmt.Errorf("network name/id is not specified")
|
||||
return errors.New("network name/id is not specified")
|
||||
}
|
||||
} else {
|
||||
netOpt.Target = value
|
||||
|
@ -126,7 +127,7 @@ func parseDriverOpt(driverOpt string) (string, string, error) {
|
|||
// TODO(thaJeztah): should value be converted to lowercase as well, or only the key?
|
||||
key, value, ok := strings.Cut(strings.ToLower(driverOpt), "=")
|
||||
if !ok || key == "" {
|
||||
return "", "", fmt.Errorf("invalid key value pair format in driver options")
|
||||
return "", "", errors.New("invalid key value pair format in driver options")
|
||||
}
|
||||
key = strings.TrimSpace(key)
|
||||
value = strings.TrimSpace(value)
|
||||
|
|
|
@ -401,7 +401,7 @@ func ParseCPUs(value string) (int64, error) {
|
|||
}
|
||||
nano := cpu.Mul(cpu, big.NewRat(1e9, 1))
|
||||
if !nano.IsInt() {
|
||||
return 0, fmt.Errorf("value is too precise")
|
||||
return 0, errors.New("value is too precise")
|
||||
}
|
||||
return nano.Num().Int64(), nil
|
||||
}
|
||||
|
@ -409,14 +409,14 @@ func ParseCPUs(value string) (int64, error) {
|
|||
// ParseLink parses and validates the specified string as a link format (name:alias)
|
||||
func ParseLink(val string) (string, string, error) {
|
||||
if val == "" {
|
||||
return "", "", fmt.Errorf("empty string specified for links")
|
||||
return "", "", errors.New("empty string specified for links")
|
||||
}
|
||||
// We expect two parts, but restrict to three to allow detecting invalid formats.
|
||||
arr := strings.SplitN(val, ":", 3)
|
||||
|
||||
// TODO(thaJeztah): clean up this logic!!
|
||||
if len(arr) > 2 {
|
||||
return "", "", fmt.Errorf("bad format for links: %s", val)
|
||||
return "", "", errors.New("bad format for links: " + val)
|
||||
}
|
||||
// TODO(thaJeztah): this should trim the "/" prefix as well??
|
||||
if len(arr) == 1 {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package opts
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"errors"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
@ -81,12 +81,12 @@ func ParseRestartPolicy(policy string) (container.RestartPolicy, error) {
|
|||
p := container.RestartPolicy{}
|
||||
k, v, ok := strings.Cut(policy, ":")
|
||||
if ok && k == "" {
|
||||
return container.RestartPolicy{}, fmt.Errorf("invalid restart policy format: no policy provided before colon")
|
||||
return container.RestartPolicy{}, errors.New("invalid restart policy format: no policy provided before colon")
|
||||
}
|
||||
if v != "" {
|
||||
count, err := strconv.Atoi(v)
|
||||
if err != nil {
|
||||
return container.RestartPolicy{}, fmt.Errorf("invalid restart policy format: maximum retry count must be an integer")
|
||||
return container.RestartPolicy{}, errors.New("invalid restart policy format: maximum retry count must be an integer")
|
||||
}
|
||||
p.MaximumRetryCount = count
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package opts
|
|||
|
||||
import (
|
||||
"encoding/csv"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"regexp"
|
||||
|
@ -102,7 +103,7 @@ func (p *PortOpt) Set(value string) error {
|
|||
for _, portBindings := range portBindingMap {
|
||||
for _, portBinding := range portBindings {
|
||||
if portBinding.HostIP != "" {
|
||||
return fmt.Errorf("hostip is not supported")
|
||||
return errors.New("hostip is not supported")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package opts
|
|||
|
||||
import (
|
||||
"encoding/csv"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
|
@ -62,12 +63,12 @@ func (o *SecretOpt) Set(value string) error {
|
|||
|
||||
options.File.Mode = os.FileMode(m)
|
||||
default:
|
||||
return fmt.Errorf("invalid field in secret request: %s", key)
|
||||
return errors.New("invalid field in secret request: " + key)
|
||||
}
|
||||
}
|
||||
|
||||
if options.SecretName == "" {
|
||||
return fmt.Errorf("source is required")
|
||||
return errors.New("source is required")
|
||||
}
|
||||
if options.File.Name == "" {
|
||||
options.File.Name = options.SecretName
|
||||
|
|
Загрузка…
Ссылка в новой задаче