Browse code

Modify docker network inspect client to check statusCode instead of string contain

Signed-off-by: Shuwei Hao <haoshuwei24@gmail.com>

Shuwei Hao authored on 2015/12/07 12:38:47
Showing 1 changed files
... ...
@@ -6,6 +6,7 @@ import (
6 6
 	"fmt"
7 7
 	"io"
8 8
 	"net"
9
+	"net/http"
9 10
 	"strings"
10 11
 	"text/tabwriter"
11 12
 	"text/template"
... ...
@@ -224,9 +225,9 @@ func (cli *DockerCli) CmdNetworkInspect(args ...string) error {
224 224
 	var networks []types.NetworkResource
225 225
 	buf := new(bytes.Buffer)
226 226
 	for _, name := range cmd.Args() {
227
-		obj, _, err := readBody(cli.call("GET", "/networks/"+name, nil, nil))
227
+		obj, statusCode, err := readBody(cli.call("GET", "/networks/"+name, nil, nil))
228 228
 		if err != nil {
229
-			if strings.Contains(err.Error(), "not found") {
229
+			if statusCode == http.StatusNotFound {
230 230
 				fmt.Fprintf(cli.err, "Error: No such network: %s\n", name)
231 231
 			} else {
232 232
 				fmt.Fprintf(cli.err, "%s\n", err)