1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

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

Signed-off-by: Shuwei Hao <haoshuwei24@gmail.com>
This commit is contained in:
Shuwei Hao 2015-12-07 03:38:47 +00:00 committed by Shuwei Hao
parent 78d8df73b5
commit 6306eb3cd3

View file

@ -6,6 +6,7 @@ import (
"fmt"
"io"
"net"
"net/http"
"strings"
"text/tabwriter"
"text/template"
@ -224,9 +225,9 @@ func (cli *DockerCli) CmdNetworkInspect(args ...string) error {
var networks []types.NetworkResource
buf := new(bytes.Buffer)
for _, name := range cmd.Args() {
obj, _, err := readBody(cli.call("GET", "/networks/"+name, nil, nil))
obj, statusCode, err := readBody(cli.call("GET", "/networks/"+name, nil, nil))
if err != nil {
if strings.Contains(err.Error(), "not found") {
if statusCode == http.StatusNotFound {
fmt.Fprintf(cli.err, "Error: No such network: %s\n", name)
} else {
fmt.Fprintf(cli.err, "%s\n", err)