From a07637ae31590f8edda1db44426497e69c9c3d8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Scala?= Date: Fri, 9 Nov 2018 08:35:34 +0100 Subject: [PATCH] Updates ssh connhelper error messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: François Scala --- cli/connhelper/ssh/ssh.go | 14 +++++++------- cli/connhelper/ssh/ssh_test.go | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cli/connhelper/ssh/ssh.go b/cli/connhelper/ssh/ssh.go index 0f2cfabc07..f134df1386 100644 --- a/cli/connhelper/ssh/ssh.go +++ b/cli/connhelper/ssh/ssh.go @@ -12,7 +12,7 @@ import ( func New(daemonURL string) (string, []string, error) { sp, err := parseSSHURL(daemonURL) if err != nil { - return "", nil, err + return "", nil, errors.Wrap(err, "SSH host connection is not valid") } return "ssh", append(sp.Args(), []string{"--", "docker", "system", "dial-stdio"}...), nil } @@ -23,7 +23,7 @@ func parseSSHURL(daemonURL string) (*sshSpec, error) { return nil, err } if u.Scheme != "ssh" { - return nil, errors.Errorf("expected scheme ssh, got %s", u.Scheme) + return nil, errors.Errorf("expected scheme ssh, got %q", u.Scheme) } var sp sshSpec @@ -31,22 +31,22 @@ func parseSSHURL(daemonURL string) (*sshSpec, error) { if u.User != nil { sp.user = u.User.Username() if _, ok := u.User.Password(); ok { - return nil, errors.New("ssh helper does not accept plain-text password") + return nil, errors.New("plain-text password is not supported") } } sp.host = u.Hostname() if sp.host == "" { - return nil, errors.Errorf("host is not specified") + return nil, errors.Errorf("no host specified") } sp.port = u.Port() if u.Path != "" { - return nil, errors.Errorf("extra path: %s", u.Path) + return nil, errors.Errorf("extra path after the host: %q", u.Path) } if u.RawQuery != "" { - return nil, errors.Errorf("extra query: %s", u.RawQuery) + return nil, errors.Errorf("extra query after the host: %q", u.RawQuery) } if u.Fragment != "" { - return nil, errors.Errorf("extra fragment: %s", u.Fragment) + return nil, errors.Errorf("extra fragment after the host: %q", u.Fragment) } return &sp, err } diff --git a/cli/connhelper/ssh/ssh_test.go b/cli/connhelper/ssh/ssh_test.go index 30a638545c..8e1d33d895 100644 --- a/cli/connhelper/ssh/ssh_test.go +++ b/cli/connhelper/ssh/ssh_test.go @@ -29,27 +29,27 @@ func TestParseSSHURL(t *testing.T) { }, { url: "ssh://me:passw0rd@foo", - expectedError: "ssh helper does not accept plain-text password", + expectedError: "plain-text password is not supported", }, { url: "ssh://foo/bar", - expectedError: "extra path", + expectedError: `extra path after the host: "/bar"`, }, { url: "ssh://foo?bar", - expectedError: "extra query", + expectedError: `extra query after the host: "bar"`, }, { url: "ssh://foo#bar", - expectedError: "extra fragment", + expectedError: `extra fragment after the host: "bar"`, }, { url: "ssh://", - expectedError: "host is not specified", + expectedError: "no host specified", }, { url: "foo://bar", - expectedError: "expected scheme ssh", + expectedError: `expected scheme ssh, got "foo"`, }, } for _, tc := range testCases {