Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IPAM options and config to CreateNetworkOptions struct #428

Merged
merged 2 commits into from
Dec 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions network.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down