mirror of
https://github.com/rancher/os.git
synced 2025-07-06 19:38:37 +00:00
Newer github.com/fsouza/go-dockerclient
This commit is contained in:
parent
6a3240f865
commit
63bc3f64b2
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": "73a0e3760037ce30d63015a74af4ffe48329dbf8"
|
"Rev": "f7e250a5d56499f6591bc98fe58b3a6edaf479a8"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/guelfey/go.dbus",
|
"ImportPath": "github.com/guelfey/go.dbus",
|
||||||
|
9
Godeps/_workspace/src/github.com/fsouza/go-dockerclient/container.go
generated
vendored
9
Godeps/_workspace/src/github.com/fsouza/go-dockerclient/container.go
generated
vendored
@ -377,6 +377,14 @@ func NeverRestart() RestartPolicy {
|
|||||||
return RestartPolicy{Name: "no"}
|
return RestartPolicy{Name: "no"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Device represents a device mapping between the Docker host and the
|
||||||
|
// container.
|
||||||
|
type Device struct {
|
||||||
|
PathOnHost string `json:"PathOnHost,omitempty" yaml:"PathOnHost,omitempty"`
|
||||||
|
PathInContainer string `json:"PathInContainer,omitempty" yaml:"PathInContainer,omitempty"`
|
||||||
|
CgroupPermissions string `json:"CgroupPermissions,omitempty" yaml:"CgroupPermissions,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// HostConfig contains the container options related to starting a container on
|
// HostConfig contains the container options related to starting a container on
|
||||||
// a given host
|
// a given host
|
||||||
type HostConfig struct {
|
type HostConfig struct {
|
||||||
@ -397,6 +405,7 @@ type HostConfig struct {
|
|||||||
IpcMode string `json:"IpcMode,omitempty" yaml:"IpcMode,omitempty"`
|
IpcMode string `json:"IpcMode,omitempty" yaml:"IpcMode,omitempty"`
|
||||||
PidMode string `json:"PidMode,omitempty" yaml:"PidMode,omitempty"`
|
PidMode string `json:"PidMode,omitempty" yaml:"PidMode,omitempty"`
|
||||||
RestartPolicy RestartPolicy `json:"RestartPolicy,omitempty" yaml:"RestartPolicy,omitempty"`
|
RestartPolicy RestartPolicy `json:"RestartPolicy,omitempty" yaml:"RestartPolicy,omitempty"`
|
||||||
|
Devices []Device `json:"Devices,omitempty" yaml:"Devices,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// StartContainer starts a container, returning an error in case of failure.
|
// StartContainer starts a container, returning an error in case of failure.
|
||||||
|
20
Godeps/_workspace/src/github.com/fsouza/go-dockerclient/testing/server.go
generated
vendored
20
Godeps/_workspace/src/github.com/fsouza/go-dockerclient/testing/server.go
generated
vendored
@ -44,6 +44,7 @@ type DockerServer struct {
|
|||||||
mux *mux.Router
|
mux *mux.Router
|
||||||
hook func(*http.Request)
|
hook func(*http.Request)
|
||||||
failures map[string]string
|
failures map[string]string
|
||||||
|
multiFailures []map[string]string
|
||||||
execCallbacks map[string]func()
|
execCallbacks map[string]func()
|
||||||
customHandlers map[string]http.Handler
|
customHandlers map[string]http.Handler
|
||||||
handlerMutex sync.RWMutex
|
handlerMutex sync.RWMutex
|
||||||
@ -156,6 +157,12 @@ func (s *DockerServer) PrepareFailure(id string, urlRegexp string) {
|
|||||||
s.failures[id] = urlRegexp
|
s.failures[id] = urlRegexp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PrepareMultiFailures enqueues a new expected failure based on a URL regexp
|
||||||
|
// it receives an id for the failure.
|
||||||
|
func (s *DockerServer) PrepareMultiFailures(id string, urlRegexp string) {
|
||||||
|
s.multiFailures = append(s.multiFailures, map[string]string{"error": id, "url": urlRegexp})
|
||||||
|
}
|
||||||
|
|
||||||
// ResetFailure removes an expected failure identified by the given id.
|
// ResetFailure removes an expected failure identified by the given id.
|
||||||
func (s *DockerServer) ResetFailure(id string) {
|
func (s *DockerServer) ResetFailure(id string) {
|
||||||
delete(s.failures, id)
|
delete(s.failures, id)
|
||||||
@ -237,6 +244,19 @@ func (s *DockerServer) handlerWrapper(f func(http.ResponseWriter, *http.Request)
|
|||||||
http.Error(w, errorID, http.StatusBadRequest)
|
http.Error(w, errorID, http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
for i, failure := range s.multiFailures {
|
||||||
|
matched, err := regexp.MatchString(failure["url"], r.URL.Path)
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !matched {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
http.Error(w, failure["error"], http.StatusBadRequest)
|
||||||
|
s.multiFailures = append(s.multiFailures[:i], s.multiFailures[i+1:]...)
|
||||||
|
return
|
||||||
|
}
|
||||||
f(w, r)
|
f(w, r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
35
Godeps/_workspace/src/github.com/fsouza/go-dockerclient/testing/server_test.go
generated
vendored
35
Godeps/_workspace/src/github.com/fsouza/go-dockerclient/testing/server_test.go
generated
vendored
@ -1110,6 +1110,41 @@ func TestPrepareFailure(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPrepareMultiFailures(t *testing.T) {
|
||||||
|
server := DockerServer{multiFailures: []map[string]string{}}
|
||||||
|
server.buildMuxer()
|
||||||
|
errorID := "multi error"
|
||||||
|
server.PrepareMultiFailures(errorID, "containers/json")
|
||||||
|
server.PrepareMultiFailures(errorID, "containers/json")
|
||||||
|
recorder := httptest.NewRecorder()
|
||||||
|
request, _ := http.NewRequest("GET", "/containers/json?all=1", nil)
|
||||||
|
server.ServeHTTP(recorder, request)
|
||||||
|
if recorder.Code != http.StatusBadRequest {
|
||||||
|
t.Errorf("PrepareFailure: wrong status. Want %d. Got %d.", http.StatusBadRequest, recorder.Code)
|
||||||
|
}
|
||||||
|
if recorder.Body.String() != errorID+"\n" {
|
||||||
|
t.Errorf("PrepareFailure: wrong message. Want %s. Got %s.", errorID, recorder.Body.String())
|
||||||
|
}
|
||||||
|
recorder = httptest.NewRecorder()
|
||||||
|
request, _ = http.NewRequest("GET", "/containers/json?all=1", nil)
|
||||||
|
server.ServeHTTP(recorder, request)
|
||||||
|
if recorder.Code != http.StatusBadRequest {
|
||||||
|
t.Errorf("PrepareFailure: wrong status. Want %d. Got %d.", http.StatusBadRequest, recorder.Code)
|
||||||
|
}
|
||||||
|
if recorder.Body.String() != errorID+"\n" {
|
||||||
|
t.Errorf("PrepareFailure: wrong message. Want %s. Got %s.", errorID, recorder.Body.String())
|
||||||
|
}
|
||||||
|
recorder = httptest.NewRecorder()
|
||||||
|
request, _ = http.NewRequest("GET", "/containers/json?all=1", nil)
|
||||||
|
server.ServeHTTP(recorder, request)
|
||||||
|
if recorder.Code != http.StatusOK {
|
||||||
|
t.Errorf("PrepareFailure: wrong status. Want %d. Got %d.", http.StatusOK, recorder.Code)
|
||||||
|
}
|
||||||
|
if recorder.Body.String() == errorID+"\n" {
|
||||||
|
t.Errorf("PrepareFailure: wrong message. Want %s. Got %s.", errorID, recorder.Body.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestRemoveFailure(t *testing.T) {
|
func TestRemoveFailure(t *testing.T) {
|
||||||
server := DockerServer{failures: make(map[string]string)}
|
server := DockerServer{failures: make(map[string]string)}
|
||||||
server.buildMuxer()
|
server.buildMuxer()
|
||||||
|
Loading…
Reference in New Issue
Block a user