update dockerclient

Signed-off-by: Victor Vieux <vieux@docker.com>
This commit is contained in:
Victor Vieux 2015-02-27 14:17:02 -08:00
parent 4a18b36bbc
commit 150940a67b
5 changed files with 11 additions and 10 deletions

2
Godeps/Godeps.json generated
View File

@ -60,7 +60,7 @@
}, },
{ {
"ImportPath": "github.com/samalba/dockerclient", "ImportPath": "github.com/samalba/dockerclient",
"Rev": "7e4366cfab2f2b44fcb493bee93a156a763d58b6" "Rev": "0fdc3ca0e58365801f1212900def9c7c60bbe2c7"
}, },
{ {
"ImportPath": "github.com/samuel/go-zookeeper/zk", "ImportPath": "github.com/samuel/go-zookeeper/zk",

View File

@ -8,7 +8,6 @@ import (
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
"log"
"net/http" "net/http"
"net/url" "net/url"
"strconv" "strconv"
@ -247,7 +246,6 @@ func (client *DockerClient) getEvents(cb Callback, ec chan error, args ...interf
uri := fmt.Sprintf("%s/%s/events", client.URL.String(), APIVersion) uri := fmt.Sprintf("%s/%s/events", client.URL.String(), APIVersion)
resp, err := client.HTTPClient.Get(uri) resp, err := client.HTTPClient.Get(uri)
if err != nil { if err != nil {
log.Printf("GET %s failed: %v", uri, err)
ec <- err ec <- err
return return
} }
@ -257,7 +255,6 @@ func (client *DockerClient) getEvents(cb Callback, ec chan error, args ...interf
for atomic.LoadInt32(&client.monitorEvents) > 0 { for atomic.LoadInt32(&client.monitorEvents) > 0 {
var event *Event var event *Event
if err := dec.Decode(&event); err != nil { if err := dec.Decode(&event); err != nil {
log.Printf("Event decoding failed: %v", err)
ec <- err ec <- err
return return
} }
@ -308,12 +305,16 @@ func (client *DockerClient) PullImage(name string, auth *AuthConfig) error {
return nil return nil
} }
func (client *DockerClient) RemoveContainer(id string, force bool) error { func (client *DockerClient) RemoveContainer(id string, force, volumes bool) error {
argForce := 0 argForce := 0
argVolumes := 0
if force == true { if force == true {
argForce = 1 argForce = 1
} }
args := fmt.Sprintf("force=%d", argForce) if volumes == true {
argVolumes = 1
}
args := fmt.Sprintf("force=%d&v=%d", argForce, argVolumes)
uri := fmt.Sprintf("/%s/containers/%s?%s", APIVersion, id, args) uri := fmt.Sprintf("/%s/containers/%s?%s", APIVersion, id, args)
_, err := client.doRequest("DELETE", uri, nil, nil) _, err := client.doRequest("DELETE", uri, nil, nil)
return err return err

View File

@ -21,7 +21,7 @@ type Client interface {
StopAllMonitorEvents() StopAllMonitorEvents()
Version() (*Version, error) Version() (*Version, error)
PullImage(name string, auth *AuthConfig) error PullImage(name string, auth *AuthConfig) error
RemoveContainer(id string, force bool) error RemoveContainer(id string, force, volumes bool) error
ListImages() ([]*Image, error) ListImages() ([]*Image, error)
RemoveImage(name string) error RemoveImage(name string) error
PauseContainer(name string) error PauseContainer(name string) error

View File

@ -78,8 +78,8 @@ func (client *MockClient) PullImage(name string, auth *dockerclient.AuthConfig)
return args.Error(0) return args.Error(0)
} }
func (client *MockClient) RemoveContainer(id string, force bool) error { func (client *MockClient) RemoveContainer(id string, force, volumes bool) error {
args := client.Mock.Called(id, force) args := client.Mock.Called(id, force, volumes)
return args.Error(0) return args.Error(0)
} }

View File

@ -365,7 +365,7 @@ func (n *Node) Create(config *dockerclient.ContainerConfig, name string, pullIma
// Destroy and remove a container from the node. // Destroy and remove a container from the node.
func (n *Node) Destroy(container *Container, force bool) error { func (n *Node) Destroy(container *Container, force bool) error {
if err := n.client.RemoveContainer(container.Id, force); err != nil { if err := n.client.RemoveContainer(container.Id, force, true); err != nil {
return err return err
} }