From b58731fa4668cc0cc494a6439bf571720b8d029c Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 3 Sep 2022 00:04:53 +0200 Subject: [PATCH] linting: ST1005: error strings should not be capitalized (stylecheck) While fixing, also updated errors without placeholders to `errors.New()`, and updated some code to use pkg/errors if it was already in use in the file. cli/command/config/inspect.go:59:10: ST1005: error strings should not be capitalized (stylecheck) return fmt.Errorf("Cannot supply extra formatting options to the pretty template") ^ cli/command/node/inspect.go:61:10: ST1005: error strings should not be capitalized (stylecheck) return fmt.Errorf("Cannot supply extra formatting options to the pretty template") ^ cli/command/secret/inspect.go:57:10: ST1005: error strings should not be capitalized (stylecheck) return fmt.Errorf("Cannot supply extra formatting options to the pretty template") ^ cli/command/trust/common.go:77:74: ST1005: error strings should not be capitalized (stylecheck) return []trustTagRow{}, []client.RoleWithSignatures{}, []data.Role{}, fmt.Errorf("No signatures or cannot access %s", remote) ^ cli/command/trust/common.go:85:73: ST1005: error strings should not be capitalized (stylecheck) return []trustTagRow{}, []client.RoleWithSignatures{}, []data.Role{}, fmt.Errorf("No signers for %s", remote) ^ cli/command/trust/sign.go:137:10: ST1005: error strings should not be capitalized (stylecheck) return fmt.Errorf("No tag specified for %s", imgRefAndAuth.Name()) ^ cli/command/trust/sign.go:151:19: ST1005: error strings should not be capitalized (stylecheck) return *target, fmt.Errorf("No tag specified") ^ cli/command/trust/signer_add.go:77:10: ST1005: error strings should not be capitalized (stylecheck) return fmt.Errorf("Failed to add signer to: %s", strings.Join(errRepos, ", ")) ^ cli/command/trust/signer_remove.go:52:10: ST1005: error strings should not be capitalized (stylecheck) return fmt.Errorf("Error removing signer from: %s", strings.Join(errRepos, ", ")) ^ cli/command/trust/signer_remove.go:67:17: ST1005: error strings should not be capitalized (stylecheck) return false, fmt.Errorf("All signed tags are currently revoked, use docker trust sign to fix") ^ cli/command/trust/signer_remove.go:108:17: ST1005: error strings should not be capitalized (stylecheck) return false, fmt.Errorf("No signer %s for repository %s", signerName, repoName) ^ opts/hosts.go:89:14: ST1005: error strings should not be capitalized (stylecheck) return "", fmt.Errorf("Invalid bind address format: %s", addr) ^ opts/hosts.go:100:14: ST1005: error strings should not be capitalized (stylecheck) return "", fmt.Errorf("Invalid proto, expected %s: %s", proto, addr) ^ opts/hosts.go:119:14: ST1005: error strings should not be capitalized (stylecheck) return "", fmt.Errorf("Invalid proto, expected tcp: %s", tryAddr) ^ opts/hosts.go:144:14: ST1005: error strings should not be capitalized (stylecheck) return "", fmt.Errorf("Invalid bind address format: %s", tryAddr) ^ opts/hosts.go:155:14: ST1005: error strings should not be capitalized (stylecheck) return "", fmt.Errorf("Invalid bind address format: %s", tryAddr) ^ Signed-off-by: Sebastiaan van Stijn --- cli/command/config/inspect.go | 4 ++-- cli/command/node/inspect.go | 4 ++-- cli/command/secret/inspect.go | 4 ++-- cli/command/swarm/opts_test.go | 2 +- cli/command/trust/common.go | 4 ++-- cli/command/trust/inspect_pretty_test.go | 8 ++++---- cli/command/trust/inspect_test.go | 8 ++++---- cli/command/trust/sign.go | 6 +++--- cli/command/trust/sign_test.go | 4 ++-- cli/command/trust/signer_add.go | 2 +- cli/command/trust/signer_add_test.go | 2 +- cli/command/trust/signer_remove.go | 8 ++++---- cli/command/trust/signer_remove_test.go | 6 +++--- docs/reference/commandline/trust_inspect.md | 2 +- docs/reference/commandline/trust_sign.md | 2 +- .../reference/commandline/trust_signer_add.md | 4 ++-- opts/hosts.go | 10 +++++----- opts/hosts_test.go | 19 +++++++++---------- 18 files changed, 49 insertions(+), 50 deletions(-) diff --git a/cli/command/config/inspect.go b/cli/command/config/inspect.go index 1f0abd91c3..956246eba2 100644 --- a/cli/command/config/inspect.go +++ b/cli/command/config/inspect.go @@ -2,7 +2,7 @@ package config import ( "context" - "fmt" + "errors" "strings" "github.com/docker/cli/cli" @@ -56,7 +56,7 @@ func RunConfigInspect(dockerCli command.Cli, opts InspectOptions) error { // check if the user is trying to apply a template to the pretty format, which // is not supported if strings.HasPrefix(f, "pretty") && f != "pretty" { - return fmt.Errorf("Cannot supply extra formatting options to the pretty template") + return errors.New("cannot supply extra formatting options to the pretty template") } configCtx := formatter.Context{ diff --git a/cli/command/node/inspect.go b/cli/command/node/inspect.go index 977026f641..96abfd1927 100644 --- a/cli/command/node/inspect.go +++ b/cli/command/node/inspect.go @@ -2,7 +2,7 @@ package node import ( "context" - "fmt" + "errors" "strings" "github.com/docker/cli/cli" @@ -58,7 +58,7 @@ func runInspect(dockerCli command.Cli, opts inspectOptions) error { // check if the user is trying to apply a template to the pretty format, which // is not supported if strings.HasPrefix(f, "pretty") && f != "pretty" { - return fmt.Errorf("Cannot supply extra formatting options to the pretty template") + return errors.New("cannot supply extra formatting options to the pretty template") } nodeCtx := formatter.Context{ diff --git a/cli/command/secret/inspect.go b/cli/command/secret/inspect.go index 7df5fdafb7..2b63ecc4b2 100644 --- a/cli/command/secret/inspect.go +++ b/cli/command/secret/inspect.go @@ -2,7 +2,7 @@ package secret import ( "context" - "fmt" + "errors" "strings" "github.com/docker/cli/cli" @@ -54,7 +54,7 @@ func runSecretInspect(dockerCli command.Cli, opts inspectOptions) error { // check if the user is trying to apply a template to the pretty format, which // is not supported if strings.HasPrefix(f, "pretty") && f != "pretty" { - return fmt.Errorf("Cannot supply extra formatting options to the pretty template") + return errors.New("cannot supply extra formatting options to the pretty template") } secretCtx := formatter.Context{ diff --git a/cli/command/swarm/opts_test.go b/cli/command/swarm/opts_test.go index b3c0e8467b..407cfa0f9a 100644 --- a/cli/command/swarm/opts_test.go +++ b/cli/command/swarm/opts_test.go @@ -34,7 +34,7 @@ func TestNodeAddrOptionSetPortOnly(t *testing.T) { func TestNodeAddrOptionSetInvalidFormat(t *testing.T) { opt := NewListenAddrOption() - assert.Error(t, opt.Set("http://localhost:4545"), "Invalid proto, expected tcp: http://localhost:4545") + assert.Error(t, opt.Set("http://localhost:4545"), "invalid proto, expected tcp: http://localhost:4545") } func TestExternalCAOptionErrors(t *testing.T) { diff --git a/cli/command/trust/common.go b/cli/command/trust/common.go index 1e22bc1fcb..d2ad89ac2f 100644 --- a/cli/command/trust/common.go +++ b/cli/command/trust/common.go @@ -74,7 +74,7 @@ func lookupTrustInfo(cli command.Cli, remote string) ([]trustTagRow, []client.Ro logrus.Debug(trust.NotaryError(remote, err)) // print an empty table if we don't have signed targets, but have an initialized notary repo if _, ok := err.(client.ErrNoSuchTarget); !ok { - return []trustTagRow{}, []client.RoleWithSignatures{}, []data.Role{}, fmt.Errorf("No signatures or cannot access %s", remote) + return []trustTagRow{}, []client.RoleWithSignatures{}, []data.Role{}, fmt.Errorf("no signatures or cannot access %s", remote) } } signatureRows := matchReleasedSignatures(allSignedTargets) @@ -82,7 +82,7 @@ func lookupTrustInfo(cli command.Cli, remote string) ([]trustTagRow, []client.Ro // get the administrative roles adminRolesWithSigs, err := notaryRepo.ListRoles() if err != nil { - return []trustTagRow{}, []client.RoleWithSignatures{}, []data.Role{}, fmt.Errorf("No signers for %s", remote) + return []trustTagRow{}, []client.RoleWithSignatures{}, []data.Role{}, fmt.Errorf("no signers for %s", remote) } // get delegation roles with the canonical key IDs diff --git a/cli/command/trust/inspect_pretty_test.go b/cli/command/trust/inspect_pretty_test.go index 626d5f9b6d..4c6e3ffca9 100644 --- a/cli/command/trust/inspect_pretty_test.go +++ b/cli/command/trust/inspect_pretty_test.go @@ -77,7 +77,7 @@ func TestTrustInspectPrettyCommandOfflineErrors(t *testing.T) { cmd.Flags().Set("pretty", "true") cmd.SetArgs([]string{"nonexistent-reg-name.io/image"}) cmd.SetOut(io.Discard) - assert.ErrorContains(t, cmd.Execute(), "No signatures or cannot access nonexistent-reg-name.io/image") + assert.ErrorContains(t, cmd.Execute(), "no signatures or cannot access nonexistent-reg-name.io/image") cli = test.NewFakeCli(&fakeClient{}) cli.SetNotaryClient(notaryfake.GetOfflineNotaryRepository) @@ -85,7 +85,7 @@ func TestTrustInspectPrettyCommandOfflineErrors(t *testing.T) { cmd.Flags().Set("pretty", "true") cmd.SetArgs([]string{"nonexistent-reg-name.io/image:tag"}) cmd.SetOut(io.Discard) - assert.ErrorContains(t, cmd.Execute(), "No signatures or cannot access nonexistent-reg-name.io/image") + assert.ErrorContains(t, cmd.Execute(), "no signatures or cannot access nonexistent-reg-name.io/image") } func TestTrustInspectPrettyCommandUninitializedErrors(t *testing.T) { @@ -95,7 +95,7 @@ func TestTrustInspectPrettyCommandUninitializedErrors(t *testing.T) { cmd.Flags().Set("pretty", "true") cmd.SetArgs([]string{"reg/unsigned-img"}) cmd.SetOut(io.Discard) - assert.ErrorContains(t, cmd.Execute(), "No signatures or cannot access reg/unsigned-img") + assert.ErrorContains(t, cmd.Execute(), "no signatures or cannot access reg/unsigned-img") cli = test.NewFakeCli(&fakeClient{}) cli.SetNotaryClient(notaryfake.GetUninitializedNotaryRepository) @@ -103,7 +103,7 @@ func TestTrustInspectPrettyCommandUninitializedErrors(t *testing.T) { cmd.Flags().Set("pretty", "true") cmd.SetArgs([]string{"reg/unsigned-img:tag"}) cmd.SetOut(io.Discard) - assert.ErrorContains(t, cmd.Execute(), "No signatures or cannot access reg/unsigned-img:tag") + assert.ErrorContains(t, cmd.Execute(), "no signatures or cannot access reg/unsigned-img:tag") } func TestTrustInspectPrettyCommandEmptyNotaryRepoErrors(t *testing.T) { diff --git a/cli/command/trust/inspect_test.go b/cli/command/trust/inspect_test.go index af76731edd..692c5a6737 100644 --- a/cli/command/trust/inspect_test.go +++ b/cli/command/trust/inspect_test.go @@ -55,26 +55,26 @@ func TestTrustInspectCommandRepositoryErrors(t *testing.T) { doc: "OfflineErrors", args: []string{"nonexistent-reg-name.io/image"}, notaryRepository: notary.GetOfflineNotaryRepository, - err: "No signatures or cannot access nonexistent-reg-name.io/image", + err: "no signatures or cannot access nonexistent-reg-name.io/image", }, { doc: "OfflineErrorsWithImageTag", args: []string{"nonexistent-reg-name.io/image:tag"}, notaryRepository: notary.GetOfflineNotaryRepository, - err: "No signatures or cannot access nonexistent-reg-name.io/image:tag", + err: "no signatures or cannot access nonexistent-reg-name.io/image:tag", }, { doc: "UninitializedErrors", args: []string{"reg/unsigned-img"}, notaryRepository: notary.GetUninitializedNotaryRepository, - err: "No signatures or cannot access reg/unsigned-img", + err: "no signatures or cannot access reg/unsigned-img", golden: "trust-inspect-uninitialized.golden", }, { doc: "UninitializedErrorsWithImageTag", args: []string{"reg/unsigned-img:tag"}, notaryRepository: notary.GetUninitializedNotaryRepository, - err: "No signatures or cannot access reg/unsigned-img:tag", + err: "no signatures or cannot access reg/unsigned-img:tag", golden: "trust-inspect-uninitialized.golden", }, } diff --git a/cli/command/trust/sign.go b/cli/command/trust/sign.go index 0841e7b9c7..a34b5fc755 100644 --- a/cli/command/trust/sign.go +++ b/cli/command/trust/sign.go @@ -132,9 +132,9 @@ func validateTag(imgRefAndAuth trust.ImageRefAndAuth) error { tag := imgRefAndAuth.Tag() if tag == "" { if imgRefAndAuth.Digest() != "" { - return fmt.Errorf("cannot use a digest reference for IMAGE:TAG") + return errors.New("cannot use a digest reference for IMAGE:TAG") } - return fmt.Errorf("No tag specified for %s", imgRefAndAuth.Name()) + return fmt.Errorf("no tag specified for %s", imgRefAndAuth.Name()) } return nil } @@ -148,7 +148,7 @@ func createTarget(notaryRepo client.Repository, tag string) (client.Target, erro target := &client.Target{} var err error if tag == "" { - return *target, fmt.Errorf("No tag specified") + return *target, errors.New("no tag specified") } target.Name = tag target.Hashes, target.Length, err = getSignedManifestHashAndSize(notaryRepo, tag) diff --git a/cli/command/trust/sign_test.go b/cli/command/trust/sign_test.go index f318d95518..99e2facd30 100644 --- a/cli/command/trust/sign_test.go +++ b/cli/command/trust/sign_test.go @@ -52,7 +52,7 @@ func TestTrustSignCommandErrors(t *testing.T) { { name: "no-tag", args: []string{"reg/img"}, - expectedError: "No tag specified for reg/img", + expectedError: "no tag specified for reg/img", }, { name: "digest-reference", @@ -232,7 +232,7 @@ func TestCreateTarget(t *testing.T) { notaryRepo, err := client.NewFileCachedRepository(t.TempDir(), "gun", "https://localhost", nil, passphrase.ConstantRetriever(passwd), trustpinning.TrustPinConfig{}) assert.NilError(t, err) _, err = createTarget(notaryRepo, "") - assert.Error(t, err, "No tag specified") + assert.Error(t, err, "no tag specified") _, err = createTarget(notaryRepo, "1") assert.Error(t, err, "client is offline") } diff --git a/cli/command/trust/signer_add.go b/cli/command/trust/signer_add.go index 307d864dea..85d8ac4356 100644 --- a/cli/command/trust/signer_add.go +++ b/cli/command/trust/signer_add.go @@ -74,7 +74,7 @@ func addSigner(cli command.Cli, options signerAddOptions) error { } } if len(errRepos) > 0 { - return fmt.Errorf("Failed to add signer to: %s", strings.Join(errRepos, ", ")) + return fmt.Errorf("failed to add signer to: %s", strings.Join(errRepos, ", ")) } return nil } diff --git a/cli/command/trust/signer_add_test.go b/cli/command/trust/signer_add_test.go index 50165283bb..5452ecb5a9 100644 --- a/cli/command/trust/signer_add_test.go +++ b/cli/command/trust/signer_add_test.go @@ -111,7 +111,7 @@ func TestSignerAddCommandInvalidRepoName(t *testing.T) { cmd.SetArgs([]string{"--key", pubKeyFilepath, "alice", imageName}) cmd.SetOut(io.Discard) - assert.Error(t, cmd.Execute(), "Failed to add signer to: 870d292919d01a0af7e7f056271dc78792c05f55f49b9b9012b6d89725bd9abd") + assert.Error(t, cmd.Execute(), "failed to add signer to: 870d292919d01a0af7e7f056271dc78792c05f55f49b9b9012b6d89725bd9abd") expectedErr := fmt.Sprintf("invalid repository name (%s), cannot specify 64-byte hexadecimal strings\n\n", imageName) assert.Check(t, is.Equal(expectedErr, cli.ErrBuffer().String())) diff --git a/cli/command/trust/signer_remove.go b/cli/command/trust/signer_remove.go index d4e8eec42b..f92750c353 100644 --- a/cli/command/trust/signer_remove.go +++ b/cli/command/trust/signer_remove.go @@ -49,7 +49,7 @@ func removeSigner(cli command.Cli, options signerRemoveOptions) error { } } if len(errRepos) > 0 { - return fmt.Errorf("Error removing signer from: %s", strings.Join(errRepos, ", ")) + return errors.Errorf("error removing signer from: %s", strings.Join(errRepos, ", ")) } return nil } @@ -64,7 +64,7 @@ func isLastSignerForReleases(roleWithSig data.Role, allRoles []client.RoleWithSi } counter := len(releasesRoleWithSigs.Signatures) if counter == 0 { - return false, fmt.Errorf("All signed tags are currently revoked, use docker trust sign to fix") + return false, errors.New("all signed tags are currently revoked, use docker trust sign to fix") } for _, signature := range releasesRoleWithSigs.Signatures { for _, key := range roleWithSig.KeyIDs { @@ -87,7 +87,7 @@ func removeSingleSigner(cli command.Cli, repoName, signerName string, forceYes b signerDelegation := data.RoleName("targets/" + signerName) if signerDelegation == releasesRoleTUFName { - return false, fmt.Errorf("releases is a reserved keyword and cannot be removed") + return false, errors.Errorf("releases is a reserved keyword and cannot be removed") } notaryRepo, err := cli.NotaryClient(imgRefAndAuth, trust.ActionsPushAndPull) if err != nil { @@ -105,7 +105,7 @@ func removeSingleSigner(cli command.Cli, repoName, signerName string, forceYes b } } if role.Name == "" { - return false, fmt.Errorf("No signer %s for repository %s", signerName, repoName) + return false, errors.Errorf("no signer %s for repository %s", signerName, repoName) } allRoles, err := notaryRepo.ListRoles() if err != nil { diff --git a/cli/command/trust/signer_remove_test.go b/cli/command/trust/signer_remove_test.go index c268fc82a5..d8ad0bf04f 100644 --- a/cli/command/trust/signer_remove_test.go +++ b/cli/command/trust/signer_remove_test.go @@ -72,7 +72,7 @@ func TestRemoveSingleSigner(t *testing.T) { cli := test.NewFakeCli(&fakeClient{}) cli.SetNotaryClient(notaryfake.GetLoadedNotaryRepository) removed, err := removeSingleSigner(cli, "signed-repo", "test", true) - assert.Error(t, err, "No signer test for repository signed-repo") + assert.Error(t, err, "no signer test for repository signed-repo") assert.Equal(t, removed, false, "No signer should be removed") removed, err = removeSingleSigner(cli, "signed-repo", "releases", true) @@ -84,9 +84,9 @@ func TestRemoveMultipleSigners(t *testing.T) { cli := test.NewFakeCli(&fakeClient{}) cli.SetNotaryClient(notaryfake.GetLoadedNotaryRepository) err := removeSigner(cli, signerRemoveOptions{signer: "test", repos: []string{"signed-repo", "signed-repo"}, forceYes: true}) - assert.Error(t, err, "Error removing signer from: signed-repo, signed-repo") + assert.Error(t, err, "error removing signer from: signed-repo, signed-repo") assert.Check(t, is.Contains(cli.ErrBuffer().String(), - "No signer test for repository signed-repo")) + "no signer test for repository signed-repo")) assert.Check(t, is.Contains(cli.OutBuffer().String(), "Removing signer \"test\" from signed-repo...\n")) } func TestRemoveLastSignerWarning(t *testing.T) { diff --git a/docs/reference/commandline/trust_inspect.md b/docs/reference/commandline/trust_inspect.md index 48103117a9..7be776be75 100644 --- a/docs/reference/commandline/trust_inspect.md +++ b/docs/reference/commandline/trust_inspect.md @@ -160,7 +160,7 @@ display any signed tags. ```console $ docker trust inspect unsigned-img -No signatures or cannot access unsigned-img +no signatures or cannot access unsigned-img ``` However, if other tags are signed in the same image repository, diff --git a/docs/reference/commandline/trust_sign.md b/docs/reference/commandline/trust_sign.md index 9166f66908..605887b6b4 100644 --- a/docs/reference/commandline/trust_sign.md +++ b/docs/reference/commandline/trust_sign.md @@ -137,7 +137,7 @@ When signing an image on a repo for the first time, `docker trust sign` sets up ```console $ docker trust inspect --pretty example/trust-demo -No signatures or cannot access example/trust-demo +no signatures or cannot access example/trust-demo ``` ```console diff --git a/docs/reference/commandline/trust_signer_add.md b/docs/reference/commandline/trust_signer_add.md index 9c594a5550..4ae9a2f5fb 100644 --- a/docs/reference/commandline/trust_signer_add.md +++ b/docs/reference/commandline/trust_signer_add.md @@ -77,7 +77,7 @@ When adding a signer on a repo for the first time, `docker trust signer add` set ```console $ docker trust inspect --pretty example/trust-demo -No signatures or cannot access example/trust-demo +no signatures or cannot access example/trust-demo ``` ```console @@ -209,5 +209,5 @@ Adding signer "alice" to example/authorized... Enter passphrase for repository key with ID c6772a0: Successfully added signer: alice to example/authorized -Failed to add signer to: example/unauthorized +failed to add signer to: example/unauthorized ``` diff --git a/opts/hosts.go b/opts/hosts.go index de22161cbc..d59421b308 100644 --- a/opts/hosts.go +++ b/opts/hosts.go @@ -86,7 +86,7 @@ func parseDockerDaemonHost(addr string) (string, error) { case "ssh": return addr, nil default: - return "", fmt.Errorf("Invalid bind address format: %s", addr) + return "", fmt.Errorf("invalid bind address format: %s", addr) } } @@ -97,7 +97,7 @@ func parseDockerDaemonHost(addr string) (string, error) { func parseSimpleProtoAddr(proto, addr, defaultAddr string) (string, error) { addr = strings.TrimPrefix(addr, proto+"://") if strings.Contains(addr, "://") { - return "", fmt.Errorf("Invalid proto, expected %s: %s", proto, addr) + return "", fmt.Errorf("invalid proto, expected %s: %s", proto, addr) } if addr == "" { addr = defaultAddr @@ -116,7 +116,7 @@ func ParseTCPAddr(tryAddr string, defaultAddr string) (string, error) { } addr := strings.TrimPrefix(tryAddr, "tcp://") if strings.Contains(addr, "://") || addr == "" { - return "", fmt.Errorf("Invalid proto, expected tcp: %s", tryAddr) + return "", fmt.Errorf("invalid proto, expected tcp: %s", tryAddr) } defaultAddr = strings.TrimPrefix(defaultAddr, "tcp://") @@ -141,7 +141,7 @@ func ParseTCPAddr(tryAddr string, defaultAddr string) (string, error) { host, port, err = net.SplitHostPort(net.JoinHostPort(u.Host, defaultPort)) } if err != nil { - return "", fmt.Errorf("Invalid bind address format: %s", tryAddr) + return "", fmt.Errorf("invalid bind address format: %s", tryAddr) } if host == "" { @@ -152,7 +152,7 @@ func ParseTCPAddr(tryAddr string, defaultAddr string) (string, error) { } p, err := strconv.Atoi(port) if err != nil && p == 0 { - return "", fmt.Errorf("Invalid bind address format: %s", tryAddr) + return "", fmt.Errorf("invalid bind address format: %s", tryAddr) } return fmt.Sprintf("tcp://%s%s", net.JoinHostPort(host, port), u.Path), nil diff --git a/opts/hosts_test.go b/opts/hosts_test.go index 7618d117e2..3356ca3c0a 100644 --- a/opts/hosts_test.go +++ b/opts/hosts_test.go @@ -52,14 +52,13 @@ func TestParseHost(t *testing.T) { func TestParseDockerDaemonHost(t *testing.T) { invalids := map[string]string{ - "tcp:a.b.c.d": "", "tcp:a.b.c.d/path": "", - "udp://127.0.0.1": "Invalid bind address format: udp://127.0.0.1", - "udp://127.0.0.1:2375": "Invalid bind address format: udp://127.0.0.1:2375", - "tcp://unix:///run/docker.sock": "Invalid proto, expected tcp: unix:///run/docker.sock", - " tcp://:7777/path ": "Invalid bind address format: tcp://:7777/path ", - "": "Invalid bind address format: ", + "udp://127.0.0.1": "invalid bind address format: udp://127.0.0.1", + "udp://127.0.0.1:2375": "invalid bind address format: udp://127.0.0.1:2375", + "tcp://unix:///run/docker.sock": "invalid proto, expected tcp: unix:///run/docker.sock", + " tcp://:7777/path ": "invalid bind address format: tcp://:7777/path ", + "": "invalid bind address format: ", } valids := map[string]string{ "0.0.0.1:": "tcp://0.0.0.1:2375", @@ -101,8 +100,8 @@ func TestParseTCP(t *testing.T) { invalids := map[string]string{ "tcp:a.b.c.d": "", "tcp:a.b.c.d/path": "", - "udp://127.0.0.1": "Invalid proto, expected tcp: udp://127.0.0.1", - "udp://127.0.0.1:2375": "Invalid proto, expected tcp: udp://127.0.0.1:2375", + "udp://127.0.0.1": "invalid proto, expected tcp: udp://127.0.0.1", + "udp://127.0.0.1:2375": "invalid proto, expected tcp: udp://127.0.0.1:2375", } valids := map[string]string{ "": defaultHTTPHost, @@ -137,10 +136,10 @@ func TestParseTCP(t *testing.T) { } func TestParseInvalidUnixAddrInvalid(t *testing.T) { - if _, err := parseSimpleProtoAddr("unix", "tcp://127.0.0.1", "unix:///var/run/docker.sock"); err == nil || err.Error() != "Invalid proto, expected unix: tcp://127.0.0.1" { + if _, err := parseSimpleProtoAddr("unix", "tcp://127.0.0.1", "unix:///var/run/docker.sock"); err == nil || err.Error() != "invalid proto, expected unix: tcp://127.0.0.1" { t.Fatalf("Expected an error, got %v", err) } - if _, err := parseSimpleProtoAddr("unix", "unix://tcp://127.0.0.1", "/var/run/docker.sock"); err == nil || err.Error() != "Invalid proto, expected unix: tcp://127.0.0.1" { + if _, err := parseSimpleProtoAddr("unix", "unix://tcp://127.0.0.1", "/var/run/docker.sock"); err == nil || err.Error() != "invalid proto, expected unix: tcp://127.0.0.1" { t.Fatalf("Expected an error, got %v", err) } if v, err := parseSimpleProtoAddr("unix", "", "/var/run/docker.sock"); err != nil || v != "unix:///var/run/docker.sock" {