From 864e362aa05ed2207d71471780068e951fe9d02e Mon Sep 17 00:00:00 2001 From: "Kai Qiang Wu(Kennan)" Date: Mon, 6 Jun 2016 15:19:09 +0000 Subject: [PATCH] Fix the network inspect id This fixes #22231 Signed-off-by: Kai Qiang Wu(Kennan) --- api/client/network/inspect.go | 3 +-- integration-cli/docker_cli_network_unix_test.go | 11 +++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/api/client/network/inspect.go b/api/client/network/inspect.go index c2b872bf6c..4df137e324 100644 --- a/api/client/network/inspect.go +++ b/api/client/network/inspect.go @@ -36,8 +36,7 @@ func runInspect(dockerCli *client.DockerCli, opts inspectOptions) error { client := dockerCli.Client() getNetFunc := func(name string) (interface{}, []byte, error) { - i, err := client.NetworkInspect(context.Background(), name) - return i, nil, err + return client.NetworkInspectWithRaw(context.Background(), name) } return inspect.Inspect(dockerCli.Out(), opts.names, opts.format, getNetFunc) diff --git a/integration-cli/docker_cli_network_unix_test.go b/integration-cli/docker_cli_network_unix_test.go index 3699a22482..041c01ced5 100644 --- a/integration-cli/docker_cli_network_unix_test.go +++ b/integration-cli/docker_cli_network_unix_test.go @@ -427,6 +427,17 @@ func (s *DockerSuite) TestDockerNetworkInspect(c *check.C) { c.Assert(strings.TrimSpace(out), check.Equals, "host") } +func (s *DockerSuite) TestDockerNetworkInspectWithID(c *check.C) { + out, _ := dockerCmd(c, "network", "create", "test2") + networkID := strings.TrimSpace(out) + assertNwIsAvailable(c, "test2") + out, _ = dockerCmd(c, "network", "inspect", "--format={{ .Id }}", "test2") + c.Assert(strings.TrimSpace(out), check.Equals, networkID) + + out, _ = dockerCmd(c, "network", "inspect", "--format={{ .ID }}", "test2") + c.Assert(strings.TrimSpace(out), check.Equals, networkID) +} + func (s *DockerSuite) TestDockerInspectMultipleNetwork(c *check.C) { out, _ := dockerCmd(c, "network", "inspect", "host", "none") networkResources := []types.NetworkResource{}