Browse code

Raise a more relevant error when dockerd is not available on the platform.

Signed-off-by: Daniel Nephin <dnephin@docker.com>

Daniel Nephin authored on 2016/04/28 02:08:20
Showing 7 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,16 @@
0
+// +build !daemon
1
+
2
+package main
3
+
4
+import (
5
+	"fmt"
6
+	"runtime"
7
+	"strings"
8
+)
9
+
10
+// CmdDaemon reports on an error on windows, because there is no exec
11
+func (p DaemonProxy) CmdDaemon(args ...string) error {
12
+	return fmt.Errorf(
13
+		"`docker daemon` is not supported on %s. Please run `dockerd` directly",
14
+		strings.Title(runtime.GOOS))
15
+}
0 16
new file mode 100644
... ...
@@ -0,0 +1,20 @@
0
+// +build !daemon
1
+
2
+package main
3
+
4
+import (
5
+	"strings"
6
+	"testing"
7
+)
8
+
9
+func TestCmdDaemon(t *testing.T) {
10
+	proxy := NewDaemonProxy()
11
+	err := proxy.CmdDaemon("--help")
12
+	if err == nil {
13
+		t.Fatal("Expected CmdDaemon to fail on Windows.")
14
+	}
15
+
16
+	if !strings.Contains(err.Error(), "Please run `dockerd`") {
17
+		t.Fatalf("Expected an error about running dockerd, got %s", err)
18
+	}
19
+}
... ...
@@ -1,4 +1,4 @@
1
-// +build !windows
1
+// +build daemon
2 2
 
3 3
 package main
4 4
 
5 5
deleted file mode 100644
... ...
@@ -1,11 +0,0 @@
1
-package main
2
-
3
-import (
4
-	"fmt"
5
-)
6
-
7
-// CmdDaemon reports on an error on windows, because there is no exec
8
-func (p DaemonProxy) CmdDaemon(args ...string) error {
9
-	return fmt.Errorf(
10
-		"`docker daemon` does not exist on windows. Please run `dockerd` directly")
11
-}
12 1
deleted file mode 100644
... ...
@@ -1,18 +0,0 @@
1
-package main
2
-
3
-import (
4
-	"strings"
5
-	"testing"
6
-)
7
-
8
-func TestCmdDaemon(t *testing.T) {
9
-	proxy := NewDaemonProxy()
10
-	err := proxy.CmdDaemon("--help")
11
-	if err == nil {
12
-		t.Fatal("Expected CmdDaemon to fail in Windows.")
13
-	}
14
-
15
-	if !strings.Contains(err.Error(), "Please run `dockerd`") {
16
-		t.Fatalf("Expected an error about running dockerd, got %s", err)
17
-	}
18
-}
... ...
@@ -127,6 +127,7 @@ if [ "$DOCKER_EXPERIMENTAL" ]; then
127 127
 	DOCKER_BUILDTAGS+=" experimental"
128 128
 fi
129 129
 
130
+DOCKER_BUILDTAGS+=" daemon"
130 131
 if pkg-config 'libsystemd >= 209' 2> /dev/null ; then
131 132
 	DOCKER_BUILDTAGS+=" journald"
132 133
 elif pkg-config 'libsystemd-journal' 2> /dev/null ; then
... ...
@@ -35,7 +35,10 @@ for platform in $DOCKER_CROSSPLATFORMS; do
35 35
 		fi
36 36
 
37 37
 		if [ -z "${daemonSupporting[$platform]}" ]; then
38
-			export LDFLAGS_STATIC_DOCKER="" # we just need a simple client for these platforms
38
+            # we just need a simple client for these platforms
39
+			export LDFLAGS_STATIC_DOCKER=""
40
+            # remove the "daemon" build tag from platforms that aren't supported
41
+            export BUILDFLAGS=( "${ORIG_BUILDFLAGS[@]/ daemon/}" )
39 42
 		    source "${MAKEDIR}/binary-client"
40 43
         else
41 44
 		    source "${MAKEDIR}/binary-client"