diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 1b3111b2dc..01949720c1 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -118,7 +118,7 @@ }, { "ImportPath": "github.com/samalba/dockerclient", - "Rev": "32a9231a6d93f563010c5ffc2f6fb223b347b6b1" + "Rev": "ffec08181228917acac8dde69ce8a922f23a57ff" }, { "ImportPath": "github.com/samuel/go-zookeeper/zk", diff --git a/Godeps/_workspace/src/github.com/samalba/dockerclient/dockerclient.go b/Godeps/_workspace/src/github.com/samalba/dockerclient/dockerclient.go index c4302d539e..699e870df9 100644 --- a/Godeps/_workspace/src/github.com/samalba/dockerclient/dockerclient.go +++ b/Godeps/_workspace/src/github.com/samalba/dockerclient/dockerclient.go @@ -102,6 +102,7 @@ func (client *DockerClient) doStreamRequest(method string, path string, in io.Re return nil, err } if resp.StatusCode == 404 { + defer resp.Body.Close() return nil, ErrNotFound } if resp.StatusCode >= 400 { @@ -525,6 +526,37 @@ func (client *DockerClient) Version() (*Version, error) { return version, nil } +func (client *DockerClient) PushImage(name string, tag string, auth *AuthConfig) error { + v := url.Values{} + if tag != "" { + v.Set("tag", tag) + } + uri := fmt.Sprintf("/%s/images/%s/push?%s", APIVersion, url.QueryEscape(name), v.Encode()) + req, err := http.NewRequest("POST", client.URL.String()+uri, nil) + if auth != nil { + if encodedAuth, err := auth.encode(); err != nil { + return err + } else { + req.Header.Add("X-Registry-Auth", encodedAuth) + } + } + resp, err := client.HTTPClient.Do(req) + if err != nil { + return err + } + defer resp.Body.Close() + var finalObj map[string]interface{} + for decoder := json.NewDecoder(resp.Body); err == nil; err = decoder.Decode(&finalObj) { + } + if err != io.EOF { + return err + } + if err, ok := finalObj["error"]; ok { + return fmt.Errorf("%v", err) + } + return nil +} + func (client *DockerClient) PullImage(name string, auth *AuthConfig) error { v := url.Values{} v.Set("fromImage", name) diff --git a/Godeps/_workspace/src/github.com/samalba/dockerclient/interface.go b/Godeps/_workspace/src/github.com/samalba/dockerclient/interface.go index 4215ca4e2f..cb7a8b793e 100644 --- a/Godeps/_workspace/src/github.com/samalba/dockerclient/interface.go +++ b/Godeps/_workspace/src/github.com/samalba/dockerclient/interface.go @@ -36,6 +36,7 @@ type Client interface { TagImage(nameOrID string, repo string, tag string, force bool) error Version() (*Version, error) PullImage(name string, auth *AuthConfig) error + PushImage(name string, tag string, auth *AuthConfig) error LoadImage(reader io.Reader) error RemoveContainer(id string, force, volumes bool) error ListImages(all bool) ([]*Image, error) diff --git a/Godeps/_workspace/src/github.com/samalba/dockerclient/mockclient/mock.go b/Godeps/_workspace/src/github.com/samalba/dockerclient/mockclient/mock.go index 9944512e93..a54ee57535 100644 --- a/Godeps/_workspace/src/github.com/samalba/dockerclient/mockclient/mock.go +++ b/Godeps/_workspace/src/github.com/samalba/dockerclient/mockclient/mock.go @@ -111,6 +111,11 @@ func (client *MockClient) PullImage(name string, auth *dockerclient.AuthConfig) return args.Error(0) } +func (client *MockClient) PushImage(name string, tag string, auth *dockerclient.AuthConfig) error { + args := client.Mock.Called(name, tag, auth) + return args.Error(0) +} + func (client *MockClient) LoadImage(reader io.Reader) error { args := client.Mock.Called(reader) return args.Error(0) diff --git a/Godeps/_workspace/src/github.com/samalba/dockerclient/nopclient/nop.go b/Godeps/_workspace/src/github.com/samalba/dockerclient/nopclient/nop.go index ef64536304..03dfbab11a 100644 --- a/Godeps/_workspace/src/github.com/samalba/dockerclient/nopclient/nop.go +++ b/Godeps/_workspace/src/github.com/samalba/dockerclient/nopclient/nop.go @@ -98,6 +98,10 @@ func (client *NopClient) PullImage(name string, auth *dockerclient.AuthConfig) e return ErrNoEngine } +func (client *NopClient) PushImage(name, tag string, auth *dockerclient.AuthConfig) error { + return ErrNoEngine +} + func (client *NopClient) LoadImage(reader io.Reader) error { return ErrNoEngine } diff --git a/Godeps/_workspace/src/github.com/samalba/dockerclient/types.go b/Godeps/_workspace/src/github.com/samalba/dockerclient/types.go index b1f5a006c3..a43c16eaeb 100644 --- a/Godeps/_workspace/src/github.com/samalba/dockerclient/types.go +++ b/Godeps/_workspace/src/github.com/samalba/dockerclient/types.go @@ -461,13 +461,28 @@ type VolumeCreateRequest struct { DriverOpts map[string]string // DriverOpts holds the driver specific options to use for when creating the volume. } +// IPAM represents IP Address Management +type IPAM struct { + Driver string `json:"driver"` + Config []IPAMConfig `json:"config"` +} + +// IPAMConfig represents IPAM configurations +type IPAMConfig struct { + Subnet string `json:"subnet,omitempty"` + IPRange string `json:"ip_range,omitempty"` + Gateway string `json:"gateway,omitempty"` + AuxAddress map[string]string `json:"auxiliary_address,omitempty"` +} + // NetworkResource is the body of the "get network" http response message type NetworkResource struct { Name string `json:"name"` ID string `json:"id"` + Scope string `json:"scope"` Driver string `json:"driver"` + IPAM IPAM `json:"ipam"` Containers map[string]EndpointResource `json:"containers"` - Options map[string]interface{} `json:"options,omitempty"` } //EndpointResource contains network resources allocated and usd for a container in a network @@ -480,10 +495,10 @@ type EndpointResource struct { // NetworkCreate is the expected body of the "create network" http request message type NetworkCreate struct { - Name string `json:"name"` - CheckDuplicate bool `json:"check_duplicate"` - Driver string `json:"driver"` - Options map[string]interface{} `json:"options"` + Name string `json:"name"` + CheckDuplicate bool `json:"check_duplicate"` + Driver string `json:"driver"` + IPAM IPAM `json:"ipam"` } // NetworkCreateResponse is the response message sent by the server for network create call diff --git a/test/integration/api/network.bats b/test/integration/api/network.bats index d5c52ce1fa..c6b797f363 100644 --- a/test/integration/api/network.bats +++ b/test/integration/api/network.bats @@ -26,7 +26,7 @@ function teardown() { [ "$status" -ne 0 ] run docker_swarm network inspect node-0/bridge - [ "${#lines[@]}" -eq 13 ] + [ "${#lines[@]}" -eq 23 ] } @test "docker network create" { @@ -75,20 +75,20 @@ function teardown() { docker_swarm run -d --name test_container -e constraint:node==node-0 busybox sleep 100 run docker_swarm network inspect node-0/bridge - [ "${#lines[@]}" -eq 13 ] + [ "${#lines[@]}" -eq 23 ] docker_swarm network disconnect node-0/bridge test_container run docker_swarm network inspect node-0/bridge - [ "${#lines[@]}" -eq 6 ] + [ "${#lines[@]}" -eq 16 ] docker_swarm network connect node-0/bridge test_container run docker_swarm network inspect node-0/bridge - [ "${#lines[@]}" -eq 13 ] + [ "${#lines[@]}" -eq 23 ] docker_swarm rm -f test_container run docker_swarm network inspect node-0/bridge - [ "${#lines[@]}" -eq 6 ] + [ "${#lines[@]}" -eq 16 ] }