mirror of
https://github.com/rancher/os.git
synced 2025-09-21 18:40:27 +00:00
Godeps updates
This commit is contained in:
2
Godeps/Godeps.json
generated
2
Godeps/Godeps.json
generated
@@ -180,7 +180,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/fsouza/go-dockerclient",
|
"ImportPath": "github.com/fsouza/go-dockerclient",
|
||||||
"Rev": "96713c2fd1829362fa590fec24594e0c115ce64b"
|
"Rev": "73a0e3760037ce30d63015a74af4ffe48329dbf8"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/guelfey/go.dbus",
|
"ImportPath": "github.com/guelfey/go.dbus",
|
||||||
|
6
Godeps/_workspace/src/github.com/fsouza/go-dockerclient/container.go
generated
vendored
6
Godeps/_workspace/src/github.com/fsouza/go-dockerclient/container.go
generated
vendored
@@ -406,7 +406,7 @@ func (c *Client) StartContainer(id string, hostConfig *HostConfig) error {
|
|||||||
path := "/containers/" + id + "/start"
|
path := "/containers/" + id + "/start"
|
||||||
_, status, err := c.do("POST", path, hostConfig, true)
|
_, status, err := c.do("POST", path, hostConfig, true)
|
||||||
if status == http.StatusNotFound {
|
if status == http.StatusNotFound {
|
||||||
return &NoSuchContainer{ID: id}
|
return &NoSuchContainer{ID: id, Err: err}
|
||||||
}
|
}
|
||||||
if status == http.StatusNotModified {
|
if status == http.StatusNotModified {
|
||||||
return &ContainerAlreadyRunning{ID: id}
|
return &ContainerAlreadyRunning{ID: id}
|
||||||
@@ -768,9 +768,13 @@ func (c *Client) ExportContainer(opts ExportContainerOptions) error {
|
|||||||
// NoSuchContainer is the error returned when a given container does not exist.
|
// NoSuchContainer is the error returned when a given container does not exist.
|
||||||
type NoSuchContainer struct {
|
type NoSuchContainer struct {
|
||||||
ID string
|
ID string
|
||||||
|
Err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (err *NoSuchContainer) Error() string {
|
func (err *NoSuchContainer) Error() string {
|
||||||
|
if err.Err != nil {
|
||||||
|
return err.Err.Error()
|
||||||
|
}
|
||||||
return "No such container: " + err.ID
|
return "No such container: " + err.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
11
Godeps/_workspace/src/github.com/fsouza/go-dockerclient/container_test.go
generated
vendored
11
Godeps/_workspace/src/github.com/fsouza/go-dockerclient/container_test.go
generated
vendored
@@ -7,6 +7,7 @@ package docker
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -536,7 +537,7 @@ func TestStartContainerNilHostConfig(t *testing.T) {
|
|||||||
func TestStartContainerNotFound(t *testing.T) {
|
func TestStartContainerNotFound(t *testing.T) {
|
||||||
client := newTestClient(&FakeRoundTripper{message: "no such container", status: http.StatusNotFound})
|
client := newTestClient(&FakeRoundTripper{message: "no such container", status: http.StatusNotFound})
|
||||||
err := client.StartContainer("a2344", &HostConfig{})
|
err := client.StartContainer("a2344", &HostConfig{})
|
||||||
expected := &NoSuchContainer{ID: "a2344"}
|
expected := &NoSuchContainer{ID: "a2344", Err: err.(*NoSuchContainer).Err}
|
||||||
if !reflect.DeepEqual(err, expected) {
|
if !reflect.DeepEqual(err, expected) {
|
||||||
t.Errorf("StartContainer: Wrong error returned. Want %#v. Got %#v.", expected, err)
|
t.Errorf("StartContainer: Wrong error returned. Want %#v. Got %#v.", expected, err)
|
||||||
}
|
}
|
||||||
@@ -1307,6 +1308,14 @@ func TestNoSuchContainerError(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNoSuchContainerErrorMessage(t *testing.T) {
|
||||||
|
var err = &NoSuchContainer{ID: "i345", Err: errors.New("some advanced error info")}
|
||||||
|
expected := "some advanced error info"
|
||||||
|
if got := err.Error(); got != expected {
|
||||||
|
t.Errorf("NoSuchContainer: wrong message. Want %q. Got %q.", expected, got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestExportContainer(t *testing.T) {
|
func TestExportContainer(t *testing.T) {
|
||||||
content := "exported container tar content"
|
content := "exported container tar content"
|
||||||
out := stdoutMock{bytes.NewBufferString(content)}
|
out := stdoutMock{bytes.NewBufferString(content)}
|
||||||
|
18
Godeps/_workspace/src/github.com/fsouza/go-dockerclient/testing/server.go
generated
vendored
18
Godeps/_workspace/src/github.com/fsouza/go-dockerclient/testing/server.go
generated
vendored
@@ -92,6 +92,7 @@ func (s *DockerServer) buildMuxer() {
|
|||||||
s.mux.Path("/containers/json").Methods("GET").HandlerFunc(s.handlerWrapper(s.listContainers))
|
s.mux.Path("/containers/json").Methods("GET").HandlerFunc(s.handlerWrapper(s.listContainers))
|
||||||
s.mux.Path("/containers/create").Methods("POST").HandlerFunc(s.handlerWrapper(s.createContainer))
|
s.mux.Path("/containers/create").Methods("POST").HandlerFunc(s.handlerWrapper(s.createContainer))
|
||||||
s.mux.Path("/containers/{id:.*}/json").Methods("GET").HandlerFunc(s.handlerWrapper(s.inspectContainer))
|
s.mux.Path("/containers/{id:.*}/json").Methods("GET").HandlerFunc(s.handlerWrapper(s.inspectContainer))
|
||||||
|
s.mux.Path("/containers/{id:.*}/rename").Methods("POST").HandlerFunc(s.handlerWrapper(s.renameContainer))
|
||||||
s.mux.Path("/containers/{id:.*}/top").Methods("GET").HandlerFunc(s.handlerWrapper(s.topContainer))
|
s.mux.Path("/containers/{id:.*}/top").Methods("GET").HandlerFunc(s.handlerWrapper(s.topContainer))
|
||||||
s.mux.Path("/containers/{id:.*}/start").Methods("POST").HandlerFunc(s.handlerWrapper(s.startContainer))
|
s.mux.Path("/containers/{id:.*}/start").Methods("POST").HandlerFunc(s.handlerWrapper(s.startContainer))
|
||||||
s.mux.Path("/containers/{id:.*}/kill").Methods("POST").HandlerFunc(s.handlerWrapper(s.stopContainer))
|
s.mux.Path("/containers/{id:.*}/kill").Methods("POST").HandlerFunc(s.handlerWrapper(s.stopContainer))
|
||||||
@@ -372,6 +373,23 @@ func (s *DockerServer) generateID() string {
|
|||||||
return fmt.Sprintf("%x", buf)
|
return fmt.Sprintf("%x", buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *DockerServer) renameContainer(w http.ResponseWriter, r *http.Request) {
|
||||||
|
id := mux.Vars(r)["id"]
|
||||||
|
container, index, err := s.findContainer(id)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
copy := *container
|
||||||
|
copy.Name = r.URL.Query().Get("name")
|
||||||
|
s.cMut.Lock()
|
||||||
|
defer s.cMut.Unlock()
|
||||||
|
if s.containers[index].ID == copy.ID {
|
||||||
|
s.containers[index] = ©
|
||||||
|
}
|
||||||
|
w.WriteHeader(http.StatusNoContent)
|
||||||
|
}
|
||||||
|
|
||||||
func (s *DockerServer) inspectContainer(w http.ResponseWriter, r *http.Request) {
|
func (s *DockerServer) inspectContainer(w http.ResponseWriter, r *http.Request) {
|
||||||
id := mux.Vars(r)["id"]
|
id := mux.Vars(r)["id"]
|
||||||
container, _, err := s.findContainer(id)
|
container, _, err := s.findContainer(id)
|
||||||
|
29
Godeps/_workspace/src/github.com/fsouza/go-dockerclient/testing/server_test.go
generated
vendored
29
Godeps/_workspace/src/github.com/fsouza/go-dockerclient/testing/server_test.go
generated
vendored
@@ -255,6 +255,35 @@ func TestCreateContainerImageNotFound(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestRenameContainer(t *testing.T) {
|
||||||
|
server := DockerServer{}
|
||||||
|
addContainers(&server, 2)
|
||||||
|
server.buildMuxer()
|
||||||
|
recorder := httptest.NewRecorder()
|
||||||
|
newName := server.containers[0].Name + "abc"
|
||||||
|
path := fmt.Sprintf("/containers/%s/rename?name=%s", server.containers[0].ID, newName)
|
||||||
|
request, _ := http.NewRequest("POST", path, nil)
|
||||||
|
server.ServeHTTP(recorder, request)
|
||||||
|
if recorder.Code != http.StatusNoContent {
|
||||||
|
t.Errorf("RenameContainer: wrong status. Want %d. Got %d.", http.StatusNoContent, recorder.Code)
|
||||||
|
}
|
||||||
|
container := server.containers[0]
|
||||||
|
if container.Name != newName {
|
||||||
|
t.Errorf("RenameContainer: did not rename the container. Want %q. Got %q.", newName, container.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRenameContainerNotFound(t *testing.T) {
|
||||||
|
server := DockerServer{}
|
||||||
|
server.buildMuxer()
|
||||||
|
recorder := httptest.NewRecorder()
|
||||||
|
request, _ := http.NewRequest("POST", "/containers/blabla/rename?name=something", nil)
|
||||||
|
server.ServeHTTP(recorder, request)
|
||||||
|
if recorder.Code != http.StatusNotFound {
|
||||||
|
t.Errorf("RenameContainer: wrong status. Want %d. Got %d.", http.StatusNotFound, recorder.Code)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestCommitContainer(t *testing.T) {
|
func TestCommitContainer(t *testing.T) {
|
||||||
server := DockerServer{}
|
server := DockerServer{}
|
||||||
addContainers(&server, 2)
|
addContainers(&server, 2)
|
||||||
|
Reference in New Issue
Block a user