From af6d77c40892c3dc2574758ece924de8354bb2cf Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Tue, 1 Dec 2015 11:58:11 +0000 Subject: [PATCH 1/2] Add IPAM options and config to CreateNetworkOptions struct --- network.go | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) 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, From 68cdd73f4b8be8f2244b06635e9d8900d2e25b03 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Tue, 1 Dec 2015 13:45:43 +0000 Subject: [PATCH 2/2] Fix test for CreateNetworkOptions changes --- network_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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)