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:
parent
78d8df73b5
commit
6306eb3cd3
1 changed files with 3 additions and 2 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue