mirror of https://github.com/docker/docs.git
Merge pull request #1291 from vieux/update_libnetwork
update libnetwork
This commit is contained in:
commit
ecb7eabe4f
|
|
@ -118,7 +118,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/samalba/dockerclient",
|
"ImportPath": "github.com/samalba/dockerclient",
|
||||||
"Rev": "32a9231a6d93f563010c5ffc2f6fb223b347b6b1"
|
"Rev": "ffec08181228917acac8dde69ce8a922f23a57ff"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/samuel/go-zookeeper/zk",
|
"ImportPath": "github.com/samuel/go-zookeeper/zk",
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,7 @@ func (client *DockerClient) doStreamRequest(method string, path string, in io.Re
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if resp.StatusCode == 404 {
|
if resp.StatusCode == 404 {
|
||||||
|
defer resp.Body.Close()
|
||||||
return nil, ErrNotFound
|
return nil, ErrNotFound
|
||||||
}
|
}
|
||||||
if resp.StatusCode >= 400 {
|
if resp.StatusCode >= 400 {
|
||||||
|
|
@ -525,6 +526,37 @@ func (client *DockerClient) Version() (*Version, error) {
|
||||||
return version, nil
|
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 {
|
func (client *DockerClient) PullImage(name string, auth *AuthConfig) error {
|
||||||
v := url.Values{}
|
v := url.Values{}
|
||||||
v.Set("fromImage", name)
|
v.Set("fromImage", name)
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ type Client interface {
|
||||||
TagImage(nameOrID string, repo string, tag string, force bool) error
|
TagImage(nameOrID string, repo string, tag string, force bool) error
|
||||||
Version() (*Version, error)
|
Version() (*Version, error)
|
||||||
PullImage(name string, auth *AuthConfig) error
|
PullImage(name string, auth *AuthConfig) error
|
||||||
|
PushImage(name string, tag string, auth *AuthConfig) error
|
||||||
LoadImage(reader io.Reader) error
|
LoadImage(reader io.Reader) error
|
||||||
RemoveContainer(id string, force, volumes bool) error
|
RemoveContainer(id string, force, volumes bool) error
|
||||||
ListImages(all bool) ([]*Image, error)
|
ListImages(all bool) ([]*Image, error)
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,11 @@ func (client *MockClient) PullImage(name string, auth *dockerclient.AuthConfig)
|
||||||
return args.Error(0)
|
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 {
|
func (client *MockClient) LoadImage(reader io.Reader) error {
|
||||||
args := client.Mock.Called(reader)
|
args := client.Mock.Called(reader)
|
||||||
return args.Error(0)
|
return args.Error(0)
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,10 @@ func (client *NopClient) PullImage(name string, auth *dockerclient.AuthConfig) e
|
||||||
return ErrNoEngine
|
return ErrNoEngine
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (client *NopClient) PushImage(name, tag string, auth *dockerclient.AuthConfig) error {
|
||||||
|
return ErrNoEngine
|
||||||
|
}
|
||||||
|
|
||||||
func (client *NopClient) LoadImage(reader io.Reader) error {
|
func (client *NopClient) LoadImage(reader io.Reader) error {
|
||||||
return ErrNoEngine
|
return ErrNoEngine
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -461,13 +461,28 @@ type VolumeCreateRequest struct {
|
||||||
DriverOpts map[string]string // DriverOpts holds the driver specific options to use for when creating the volume.
|
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
|
// NetworkResource is the body of the "get network" http response message
|
||||||
type NetworkResource struct {
|
type NetworkResource struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
|
Scope string `json:"scope"`
|
||||||
Driver string `json:"driver"`
|
Driver string `json:"driver"`
|
||||||
|
IPAM IPAM `json:"ipam"`
|
||||||
Containers map[string]EndpointResource `json:"containers"`
|
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
|
//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
|
// NetworkCreate is the expected body of the "create network" http request message
|
||||||
type NetworkCreate struct {
|
type NetworkCreate struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
CheckDuplicate bool `json:"check_duplicate"`
|
CheckDuplicate bool `json:"check_duplicate"`
|
||||||
Driver string `json:"driver"`
|
Driver string `json:"driver"`
|
||||||
Options map[string]interface{} `json:"options"`
|
IPAM IPAM `json:"ipam"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetworkCreateResponse is the response message sent by the server for network create call
|
// NetworkCreateResponse is the response message sent by the server for network create call
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ function teardown() {
|
||||||
[ "$status" -ne 0 ]
|
[ "$status" -ne 0 ]
|
||||||
|
|
||||||
run docker_swarm network inspect node-0/bridge
|
run docker_swarm network inspect node-0/bridge
|
||||||
[ "${#lines[@]}" -eq 13 ]
|
[ "${#lines[@]}" -eq 23 ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "docker network create" {
|
@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
|
docker_swarm run -d --name test_container -e constraint:node==node-0 busybox sleep 100
|
||||||
|
|
||||||
run docker_swarm network inspect node-0/bridge
|
run docker_swarm network inspect node-0/bridge
|
||||||
[ "${#lines[@]}" -eq 13 ]
|
[ "${#lines[@]}" -eq 23 ]
|
||||||
|
|
||||||
docker_swarm network disconnect node-0/bridge test_container
|
docker_swarm network disconnect node-0/bridge test_container
|
||||||
|
|
||||||
run docker_swarm network inspect node-0/bridge
|
run docker_swarm network inspect node-0/bridge
|
||||||
[ "${#lines[@]}" -eq 6 ]
|
[ "${#lines[@]}" -eq 16 ]
|
||||||
|
|
||||||
docker_swarm network connect node-0/bridge test_container
|
docker_swarm network connect node-0/bridge test_container
|
||||||
|
|
||||||
run docker_swarm network inspect node-0/bridge
|
run docker_swarm network inspect node-0/bridge
|
||||||
[ "${#lines[@]}" -eq 13 ]
|
[ "${#lines[@]}" -eq 23 ]
|
||||||
|
|
||||||
docker_swarm rm -f test_container
|
docker_swarm rm -f test_container
|
||||||
|
|
||||||
run docker_swarm network inspect node-0/bridge
|
run docker_swarm network inspect node-0/bridge
|
||||||
[ "${#lines[@]}" -eq 6 ]
|
[ "${#lines[@]}" -eq 16 ]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue