Merge pull request #20033 from bparees/dockerclient_bump

Auto commit by PR queue bot
This commit is contained in:
k8s-merge-robot 2016-02-05 19:37:22 -08:00
commit 1eff1d52e2
6 changed files with 41 additions and 16 deletions

4
Godeps/Godeps.json generated
View File

@ -425,8 +425,8 @@
},
{
"ImportPath": "github.com/fsouza/go-dockerclient",
"Comment": "0.2.1-728-g1399676",
"Rev": "299d728486342c894e7fafd68e3a4b89623bef1d"
"Comment": "0.2.1-860-g25bc220",
"Rev": "25bc220b299845ae5489fd19bf89c5278864b050"
},
{
"ImportPath": "github.com/garyburd/redigo/internal",

View File

@ -3,8 +3,8 @@ sudo: required
go:
- 1.3.3
- 1.4.2
- 1.5.2
- 1.6beta1
- 1.5.3
- 1.6beta2
- tip
env:
- GOARCH=amd64 DOCKER_VERSION=1.7.1

View File

@ -12,6 +12,7 @@ Antonio Murdaca <runcom@redhat.com>
Artem Sidorenko <artem@2realities.com>
Ben Marini <ben@remind101.com>
Ben McCann <benmccann.com>
Ben Parees <bparees@redhat.com>
Benno van den Berg <bennovandenberg@gmail.com>
Brendan Fosberry <brendan@codeship.com>
Brian Lalor <blalor@bravo5.org>
@ -37,6 +38,7 @@ Dave Choi <dave.choi@daumkakao.com>
David Huie <dahuie@gmail.com>
Dawn Chen <dawnchen@google.com>
Dinesh Subhraveti <dinesh@gemini-systems.net>
Drew Wells <drew.wells00@gmail.com>
Ed <edrocksit@gmail.com>
Elias G. Schneevoigt <eliasgs@gmail.com>
Erez Horev <erez.horev@elastifile.com>

View File

@ -410,6 +410,8 @@ type BuildImageOptions struct {
Memory int64 `qs:"memory"`
Memswap int64 `qs:"memswap"`
CPUShares int64 `qs:"cpushares"`
CPUQuota int64 `qs:"cpuquota"`
CPUPeriod int64 `qs:"cpuperiod"`
CPUSetCPUs string `qs:"cpusetcpus"`
InputStream io.Reader `qs:"-"`
OutputStream io.Writer `qs:"-"`

View File

@ -17,19 +17,20 @@ var ErrNetworkAlreadyExists = errors.New("network already exists")
// Network represents a network.
//
// See https://goo.gl/1kmPKZ for more details.
// See https://goo.gl/6GugX3 for more details.
type Network struct {
Name string
ID string `json:"Id"`
Scope string
Driver string
IPAM IPAMOptions
Containers map[string]Endpoint
Options map[string]string
}
// Endpoint contains network resources allocated and used for a container in a network
//
// See https://goo.gl/1kmPKZ for more details.
// See https://goo.gl/6GugX3 for more details.
type Endpoint struct {
Name string
ID string `json:"EndpointID"`
@ -40,7 +41,7 @@ type Endpoint struct {
// ListNetworks returns all networks.
//
// See https://goo.gl/1kmPKZ for more details.
// See https://goo.gl/6GugX3 for more details.
func (c *Client) ListNetworks() ([]Network, error) {
resp, err := c.do("GET", "/networks", doOptions{})
if err != nil {
@ -56,7 +57,7 @@ func (c *Client) ListNetworks() ([]Network, error) {
// NetworkInfo returns information about a network by its ID.
//
// See https://goo.gl/1kmPKZ for more details.
// See https://goo.gl/6GugX3 for more details.
func (c *Client) NetworkInfo(id string) (*Network, error) {
path := "/networks/" + id
resp, err := c.do("GET", path, doOptions{})
@ -77,7 +78,7 @@ func (c *Client) NetworkInfo(id string) (*Network, error) {
// CreateNetworkOptions specify parameters to the CreateNetwork function and
// (for now) is the expected body of the "create network" http request message
//
// See https://goo.gl/1kmPKZ for more details.
// See https://goo.gl/6GugX3 for more details.
type CreateNetworkOptions struct {
Name string `json:"Name"`
CheckDuplicate bool `json:"CheckDuplicate"`
@ -107,7 +108,7 @@ type IPAMConfig struct {
// CreateNetwork creates a new network, returning the network instance,
// or an error in case of failure.
//
// See https://goo.gl/1kmPKZ for more details.
// See https://goo.gl/6GugX3 for more details.
func (c *Client) CreateNetwork(opts CreateNetworkOptions) (*Network, error) {
resp, err := c.do(
"POST",
@ -144,7 +145,7 @@ func (c *Client) CreateNetwork(opts CreateNetworkOptions) (*Network, error) {
// RemoveNetwork removes a network or returns an error in case of failure.
//
// See https://goo.gl/1kmPKZ for more details.
// See https://goo.gl/6GugX3 for more details.
func (c *Client) RemoveNetwork(id string) error {
resp, err := c.do("DELETE", "/networks/"+id, doOptions{})
if err != nil {
@ -159,14 +160,14 @@ func (c *Client) RemoveNetwork(id string) error {
// NetworkConnectionOptions specify parameters to the ConnectNetwork and DisconnectNetwork function.
//
// See https://goo.gl/1kmPKZ for more details.
// See https://goo.gl/6GugX3 for more details.
type NetworkConnectionOptions struct {
Container string
}
// ConnectNetwork adds a container to a network or returns an error in case of failure.
//
// See https://goo.gl/1kmPKZ for more details.
// See https://goo.gl/6GugX3 for more details.
func (c *Client) ConnectNetwork(id string, opts NetworkConnectionOptions) error {
resp, err := c.do("POST", "/networks/"+id+"/connect", doOptions{data: opts})
if err != nil {
@ -181,7 +182,7 @@ func (c *Client) ConnectNetwork(id string, opts NetworkConnectionOptions) error
// DisconnectNetwork removes a container from a network or returns an error in case of failure.
//
// See https://goo.gl/1kmPKZ for more details.
// See https://goo.gl/6GugX3 for more details.
func (c *Client) DisconnectNetwork(id string, opts NetworkConnectionOptions) error {
resp, err := c.do("POST", "/networks/"+id+"/disconnect", doOptions{data: opts})
if err != nil {

View File

@ -38,6 +38,7 @@ var nameRegexp = regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9_.-]+$`)
// For more details on the remote API, check http://goo.gl/G3plxW.
type DockerServer struct {
containers []*docker.Container
uploadedFiles map[string]string
execs []*docker.ExecInspect
execMut sync.RWMutex
cMut sync.RWMutex
@ -89,6 +90,7 @@ func NewServer(bind string, containerChan chan<- *docker.Container, hook func(*h
execCallbacks: make(map[string]func()),
statsCallbacks: make(map[string]func(string) docker.Stats),
customHandlers: make(map[string]http.Handler),
uploadedFiles: make(map[string]string),
cChan: containerChan,
}
server.buildMuxer()
@ -120,6 +122,7 @@ func (s *DockerServer) buildMuxer() {
s.mux.Path("/containers/{id:.*}").Methods("DELETE").HandlerFunc(s.handlerWrapper(s.removeContainer))
s.mux.Path("/containers/{id:.*}/exec").Methods("POST").HandlerFunc(s.handlerWrapper(s.createExecContainer))
s.mux.Path("/containers/{id:.*}/stats").Methods("GET").HandlerFunc(s.handlerWrapper(s.statsContainer))
s.mux.Path("/containers/{id:.*}/archive").Methods("PUT").HandlerFunc(s.handlerWrapper(s.uploadToContainer))
s.mux.Path("/exec/{id:.*}/resize").Methods("POST").HandlerFunc(s.handlerWrapper(s.resizeExecContainer))
s.mux.Path("/exec/{id:.*}/start").Methods("POST").HandlerFunc(s.handlerWrapper(s.startExecContainer))
s.mux.Path("/exec/{id:.*}/json").Methods("GET").HandlerFunc(s.handlerWrapper(s.inspectExecContainer))
@ -440,8 +443,8 @@ func (s *DockerServer) createContainer(w http.ResponseWriter, r *http.Request) {
s.cMut.Unlock()
w.WriteHeader(http.StatusCreated)
s.notify(&container)
var c = struct{ ID string }{ID: container.ID}
json.NewEncoder(w).Encode(c)
json.NewEncoder(w).Encode(container)
}
func (s *DockerServer) generateID() string {
@ -503,6 +506,23 @@ func (s *DockerServer) statsContainer(w http.ResponseWriter, r *http.Request) {
}
}
func (s *DockerServer) uploadToContainer(w http.ResponseWriter, r *http.Request) {
id := mux.Vars(r)["id"]
container, _, err := s.findContainer(id)
if err != nil {
http.Error(w, err.Error(), http.StatusNotFound)
return
}
if !container.State.Running {
w.WriteHeader(http.StatusInternalServerError)
fmt.Fprintf(w, "Container %s is not running", id)
return
}
path := r.URL.Query().Get("path")
s.uploadedFiles[id] = path
w.WriteHeader(http.StatusOK)
}
func (s *DockerServer) topContainer(w http.ResponseWriter, r *http.Request) {
id := mux.Vars(r)["id"]
container, _, err := s.findContainer(id)