Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #179 from thaJeztah/17.06-backport-fix_api_server_…
Browse files Browse the repository at this point in the history
…null

[17.06] Fix api server null pointer def on inspect/ls null ipam-driver networks
  • Loading branch information
andrewhsu authored Aug 8, 2017
2 parents d4e4888 + 280ee18 commit c1e16c7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,9 @@ func buildIpamResources(r *types.NetworkResource, nwInfo libnetwork.NetworkInfo)
for _, ip4Info := range ipv4Info {
iData := network.IPAMConfig{}
iData.Subnet = ip4Info.IPAMData.Pool.String()
iData.Gateway = ip4Info.IPAMData.Gateway.IP.String()
if ip4Info.IPAMData.Gateway != nil {
iData.Gateway = ip4Info.IPAMData.Gateway.IP.String()
}
r.IPAM.Config = append(r.IPAM.Config, iData)
}
}
Expand Down
15 changes: 15 additions & 0 deletions components/engine/integration-cli/docker_cli_network_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,21 @@ func (s *DockerNetworkSuite) TestDockerNetworkIPAMOptions(c *check.C) {
c.Assert(opts["opt2"], checker.Equals, "drv2")
}

func (s *DockerNetworkSuite) TestDockerNetworkNullIPAMDriver(c *check.C) {
// Create a network with null ipam driver
_, _, err := dockerCmdWithError("network", "create", "-d", dummyNetworkDriver, "--ipam-driver", "null", "test000")
c.Assert(err, check.IsNil)
assertNwIsAvailable(c, "test000")

// Verify the inspect data contains the default subnet provided by the null
// ipam driver and no gateway, as the null ipam driver does not provide one
nr := getNetworkResource(c, "test000")
c.Assert(nr.IPAM.Driver, checker.Equals, "null")
c.Assert(len(nr.IPAM.Config), checker.Equals, 1)
c.Assert(nr.IPAM.Config[0].Subnet, checker.Equals, "0.0.0.0/0")
c.Assert(nr.IPAM.Config[0].Gateway, checker.Equals, "")
}

func (s *DockerNetworkSuite) TestDockerNetworkInspectDefault(c *check.C) {
nr := getNetworkResource(c, "none")
c.Assert(nr.Driver, checker.Equals, "null")
Expand Down

0 comments on commit c1e16c7

Please sign in to comment.