diff --git a/network.go b/network.go index 1a736dde..45137d85 100644 --- a/network.go +++ b/network.go @@ -73,11 +73,31 @@ func (c *Client) NetworkInfo(id string) (*Network, error) { // CreateNetworkOptions specify parameters to the CreateNetwork function and // (for now) is the expected body of the "create network" http request message // -// See https://goo.gl/FDkCdQ for more details. +// See https://goo.gl/1kmPKZ for more details. type CreateNetworkOptions struct { - Name string `json:"Name"` - Driver string `json:"Driver"` - Options map[string]interface{} `json:"options"` + Name string `json:"Name"` + CheckDuplicate bool `json:"CheckDuplicate"` + Driver string `json:"Driver"` + IPAM IPAMOptions `json:"IPAM"` + Options map[string]interface{} `json:"options"` +} + +// IPAMOptions controls IP Address Management when creating a network +// +// See https://goo.gl/T8kRVH for more details. +type IPAMOptions struct { + Driver string `json:"Driver"` + Config []IPAMConfig `json:"IPAMConfig"` +} + +// IPAMConfig represents IPAM configurations +// +// See https://goo.gl/T8kRVH for more details. +type IPAMConfig struct { + Subnet string `json:",omitempty"` + IPRange string `json:",omitempty"` + Gateway string `json:",omitempty"` + AuxAddress map[string]string `json:"AuxiliaryAddresses,omitempty"` } // CreateNetwork creates a new network, returning the network instance, diff --git a/network_test.go b/network_test.go index b5aef208..19a6f456 100644 --- a/network_test.go +++ b/network_test.go @@ -84,7 +84,7 @@ func TestNetworkCreate(t *testing.T) { } client := newTestClient(&FakeRoundTripper{message: jsonID, status: http.StatusOK}) - opts := CreateNetworkOptions{"foobar", "bridge", nil} + opts := CreateNetworkOptions{"foobar", false, "bridge", IPAMOptions{}, nil} network, err := client.CreateNetwork(opts) if err != nil { t.Fatal(err)