Browse Source

Updated the client/request.go sendClientRequest method to return a PermissionDenied error if the connection failed due to permissions.

Signed-off-by: Sean Rodman <srodman7689@gmail.com>

Updated the check for the permission error to use os.IsPermission instead of checking the error string. Also, changed the PermissionDenied method to just a new error.

Fixed a typo in client/request.go

Fixed Error name as specified by Pull request builder output.

Worked on making changes to the permissiondenied error.

Fixed typo

Signed-off-by: Sean Rodman <srodman7689@gmail.com>

Updated error message as requested.

Fixed the error as requested

Signed-off-by: Sean Rodman <srodman7689@gmail.com>
Sean Rodman 8 years ago
parent
commit
bec07890aa
1 changed files with 9 additions and 0 deletions
  1. 9 0
      client/request.go

+ 9 - 0
client/request.go

@@ -9,6 +9,7 @@ import (
 	"net"
 	"net/http"
 	"net/url"
+	"os"
 	"strings"
 
 	"github.com/docker/docker/api/types"
@@ -129,6 +130,14 @@ func (cli *Client) sendClientRequest(ctx context.Context, method, path string, q
 			return serverResp, err
 		}
 
+		if nErr, ok := err.(*url.Error); ok {
+			if nErr, ok := nErr.Err.(*net.OpError); ok {
+				if os.IsPermission(nErr.Err) {
+					return serverResp, errors.Wrapf(err, "Got permission denied while trying to connect to the Docker daemon socket at %v", cli.host)
+				}
+			}
+		}
+
 		if err, ok := err.(net.Error); ok {
 			if err.Timeout() {
 				return serverResp, ErrorConnectionFailed(cli.host)