Merge pull request #29 from mavenugo/netdisconnect

an option to disconnect an endpoint from a network forcefully
This commit is contained in:
Arnaud Porterie 2016-01-11 11:08:13 -08:00
Родитель 7b6d061ba5 d1c2a8739c
Коммит 9a05c21449
3 изменённых файлов: 5 добавлений и 4 удалений

Просмотреть файл

@ -60,7 +60,7 @@ type APIClient interface {
Info() (types.Info, error) Info() (types.Info, error)
NetworkConnect(networkID, containerID string, config *network.EndpointSettings) error NetworkConnect(networkID, containerID string, config *network.EndpointSettings) error
NetworkCreate(options types.NetworkCreate) (types.NetworkCreateResponse, error) NetworkCreate(options types.NetworkCreate) (types.NetworkCreateResponse, error)
NetworkDisconnect(networkID, containerID string) error NetworkDisconnect(networkID, containerID string, force bool) error
NetworkInspect(networkID string) (types.NetworkResource, error) NetworkInspect(networkID string) (types.NetworkResource, error)
NetworkList(options types.NetworkListOptions) ([]types.NetworkResource, error) NetworkList(options types.NetworkListOptions) ([]types.NetworkResource, error)
NetworkRemove(networkID string) error NetworkRemove(networkID string) error

Просмотреть файл

@ -42,9 +42,9 @@ func (cli *Client) NetworkConnect(networkID, containerID string, config *network
} }
// NetworkDisconnect disconnects a container from an existent network in the docker host. // NetworkDisconnect disconnects a container from an existent network in the docker host.
func (cli *Client) NetworkDisconnect(networkID, containerID string) error { func (cli *Client) NetworkDisconnect(networkID, containerID string, force bool) error {
nc := types.NetworkConnect{Container: containerID} nd := types.NetworkDisconnect{Container: containerID, Force: force}
resp, err := cli.post("/networks/"+networkID+"/disconnect", nil, nc, nil) resp, err := cli.post("/networks/"+networkID+"/disconnect", nil, nd, nil)
ensureReaderClosed(resp) ensureReaderClosed(resp)
return err return err
} }

Просмотреть файл

@ -422,4 +422,5 @@ type NetworkConnect struct {
// NetworkDisconnect represents the data to be used to disconnect a container from the network // NetworkDisconnect represents the data to be used to disconnect a container from the network
type NetworkDisconnect struct { type NetworkDisconnect struct {
Container string Container string
Force bool
} }