зеркало из https://github.com/microsoft/docker.git
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:
Родитель
78d8df73b5
Коммит
6306eb3cd3
|
@ -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)
|
||||
|
|
Загрузка…
Ссылка в новой задаче