Update go-dockerclient godeps

Update go-dockerclient license
This commit is contained in:
Tim St. Clair 2016-04-08 15:21:38 -07:00
parent e73606b974
commit 903067c6c2
22 changed files with 611 additions and 108 deletions

2
Godeps/Godeps.json generated
View File

@ -506,7 +506,7 @@
}, },
{ {
"ImportPath": "github.com/fsouza/go-dockerclient", "ImportPath": "github.com/fsouza/go-dockerclient",
"Rev": "0099401a7342ad77e71ca9f9a57c5e72fb80f6b2" "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b"
}, },
{ {
"ImportPath": "github.com/garyburd/redigo/internal", "ImportPath": "github.com/garyburd/redigo/internal",

2
Godeps/LICENSES generated
View File

@ -18763,7 +18763,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
================================================================================ ================================================================================
= Godeps/_workspace/src/github.com/fsouza/go-dockerclient licensed under: = = Godeps/_workspace/src/github.com/fsouza/go-dockerclient licensed under: =
Copyright (c) 2015, go-dockerclient authors Copyright (c) 2016, go-dockerclient authors
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without

View File

@ -1,24 +1,27 @@
language: go language: go
sudo: required sudo: required
go: go:
- 1.3.3
- 1.4.2 - 1.4.2
- 1.5.3 - 1.5.3
- 1.6rc2 - 1.6
- tip - tip
os:
- linux
- osx
env: env:
- GOARCH=amd64 DOCKER_VERSION=1.7.1
- GOARCH=386 DOCKER_VERSION=1.7.1
- GOARCH=amd64 DOCKER_VERSION=1.8.3 - GOARCH=amd64 DOCKER_VERSION=1.8.3
- GOARCH=386 DOCKER_VERSION=1.8.3 - GOARCH=386 DOCKER_VERSION=1.8.3
- GOARCH=amd64 DOCKER_VERSION=1.9.1 - GOARCH=amd64 DOCKER_VERSION=1.9.1
- GOARCH=386 DOCKER_VERSION=1.9.1 - GOARCH=386 DOCKER_VERSION=1.9.1
- GOARCH=amd64 DOCKER_VERSION=1.10.0 - GOARCH=amd64 DOCKER_VERSION=1.10.3
- GOARCH=386 DOCKER_VERSION=1.10.0 - GOARCH=386 DOCKER_VERSION=1.10.3
install: install:
- make prepare_docker - travis_retry travis-scripts/install.bash
script: script:
- make test - travis-scripts/run-tests.bash
- DOCKER_HOST=tcp://127.0.0.1:2375 make integration
services: services:
- docker - docker
matrix:
fast_finish: true
allow_failures:
- go: tip

View File

@ -14,6 +14,7 @@ Ben Marini <ben@remind101.com>
Ben McCann <benmccann.com> Ben McCann <benmccann.com>
Ben Parees <bparees@redhat.com> Ben Parees <bparees@redhat.com>
Benno van den Berg <bennovandenberg@gmail.com> Benno van den Berg <bennovandenberg@gmail.com>
Bradley Cicenas <bradley.cicenas@gmail.com>
Brendan Fosberry <brendan@codeship.com> Brendan Fosberry <brendan@codeship.com>
Brian Lalor <blalor@bravo5.org> Brian Lalor <blalor@bravo5.org>
Brian P. Hamachek <brian@brianhama.com> Brian P. Hamachek <brian@brianhama.com>
@ -48,6 +49,8 @@ Fabio Rehm <fgrehm@gmail.com>
Fatih Arslan <ftharsln@gmail.com> Fatih Arslan <ftharsln@gmail.com>
Flavia Missi <flaviamissi@gmail.com> Flavia Missi <flaviamissi@gmail.com>
Francisco Souza <f@souza.cc> Francisco Souza <f@souza.cc>
Frank Groeneveld <frank@frankgroeneveld.nl>
George Moura <gwmoura@gmail.com>
Grégoire Delattre <gregoire.delattre@gmail.com> Grégoire Delattre <gregoire.delattre@gmail.com>
Guillermo Álvarez Fernández <guillermo@cientifico.net> Guillermo Álvarez Fernández <guillermo@cientifico.net>
Harry Zhang <harryzhang@zju.edu.cn> Harry Zhang <harryzhang@zju.edu.cn>
@ -84,7 +87,9 @@ Michael Schmatz <michaelschmatz@gmail.com>
Michal Fojtik <mfojtik@redhat.com> Michal Fojtik <mfojtik@redhat.com>
Mike Dillon <mike.dillon@synctree.com> Mike Dillon <mike.dillon@synctree.com>
Mrunal Patel <mrunalp@gmail.com> Mrunal Patel <mrunalp@gmail.com>
Nate Jones <nate@endot.org>
Nguyen Sy Thanh Son <sonnst@sigma-solutions.eu> Nguyen Sy Thanh Son <sonnst@sigma-solutions.eu>
Nicholas Van Wiggeren <nvanwiggeren@digitalocean.com>
Nick Ethier <ncethier@gmail.com> Nick Ethier <ncethier@gmail.com>
Omeid Matten <public@omeid.me> Omeid Matten <public@omeid.me>
Orivej Desh <orivej@gmx.fr> Orivej Desh <orivej@gmx.fr>
@ -98,9 +103,11 @@ Philippe Lafoucrière <philippe.lafoucriere@tech-angels.com>
Rafe Colton <rafael.colton@gmail.com> Rafe Colton <rafael.colton@gmail.com>
Rob Miller <rob@kalistra.com> Rob Miller <rob@kalistra.com>
Robert Williamson <williamson.robert@gmail.com> Robert Williamson <williamson.robert@gmail.com>
Roman Khlystik <roman.khlystik@gmail.com>
Salvador Gironès <salvadorgirones@gmail.com> Salvador Gironès <salvadorgirones@gmail.com>
Sam Rijs <srijs@airpost.net> Sam Rijs <srijs@airpost.net>
Sami Wagiaalla <swagiaal@redhat.com> Sami Wagiaalla <swagiaal@redhat.com>
Samuel Archambault <sarchambault@lapresse.ca>
Samuel Karp <skarp@amazon.com> Samuel Karp <skarp@amazon.com>
Silas Sewell <silas@sewell.org> Silas Sewell <silas@sewell.org>
Simon Eskildsen <sirup@sirupsen.com> Simon Eskildsen <sirup@sirupsen.com>

View File

@ -1,4 +1,4 @@
Copyright (c) 2015, go-dockerclient authors Copyright (c) 2016, go-dockerclient authors
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without

View File

@ -11,8 +11,7 @@
cov \ cov \
clean clean
SRCS = $(shell git ls-files '*.go' | grep -v '^external/') PKGS = . ./testing
PKGS = ./. ./testing
all: test all: test
@ -22,32 +21,30 @@ vendor:
lint: lint:
@ go get -v github.com/golang/lint/golint @ go get -v github.com/golang/lint/golint
$(foreach file,$(SRCS),golint $(file) || exit;) @for file in $$(git ls-files '*.go' | grep -v 'external/'); do \
export output="$$(golint $${file} | grep -v 'type name will be used as docker.DockerInfo')"; \
[ -n "$${output}" ] && echo "$${output}" && export status=1; \
done; \
exit $${status:-0}
vet: vet:
@-go get -v golang.org/x/tools/cmd/vet
$(foreach pkg,$(PKGS),go vet $(pkg);) $(foreach pkg,$(PKGS),go vet $(pkg);)
fmt: fmt:
gofmt -w $(SRCS) gofmt -s -w $(PKGS)
fmtcheck: fmtcheck:
$(foreach file,$(SRCS),gofmt -d $(file);) @ export output=$$(gofmt -s -d $(PKGS)); \
[ -n "$${output}" ] && echo "$${output}" && export status=1; \
prepare_docker: exit $${status:-0}
sudo stop docker
sudo rm -rf /var/lib/docker
sudo rm -f `which docker`
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt-get update
sudo apt-get install docker-engine=$(DOCKER_VERSION)-0~$(shell lsb_release -cs) -y --force-yes -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"
pretest: lint vet fmtcheck pretest: lint vet fmtcheck
test: pretest gotest:
$(foreach pkg,$(PKGS),go test $(pkg) || exit;) $(foreach pkg,$(PKGS),go test $(pkg) || exit;)
test: pretest gotest
integration: integration:
go test -tags docker_integration -run TestIntegration -v go test -tags docker_integration -run TestIntegration -v

View File

@ -4,7 +4,7 @@
[![GoDoc](https://img.shields.io/badge/api-Godoc-blue.svg?style=flat-square)](https://godoc.org/github.com/fsouza/go-dockerclient) [![GoDoc](https://img.shields.io/badge/api-Godoc-blue.svg?style=flat-square)](https://godoc.org/github.com/fsouza/go-dockerclient)
This package presents a client for the Docker remote API. It also provides This package presents a client for the Docker remote API. It also provides
support for the extensions in the [Swarm API](https://docs.docker.com/swarm/api/swarm-api/). support for the extensions in the [Swarm API](https://docs.docker.com/swarm/swarm-api/).
This package also provides support for docker's network API, which is a simple This package also provides support for docker's network API, which is a simple
passthrough to the libnetwork remote API. Note that docker's network API is passthrough to the libnetwork remote API. Note that docker's network API is

View File

@ -82,10 +82,12 @@ func parseDockerConfig(r io.Reader) (map[string]dockerConfig, error) {
buf.ReadFrom(r) buf.ReadFrom(r)
byteData := buf.Bytes() byteData := buf.Bytes()
var confsWrapper map[string]map[string]dockerConfig confsWrapper := struct {
Auths map[string]dockerConfig `json:"auths"`
}{}
if err := json.Unmarshal(byteData, &confsWrapper); err == nil { if err := json.Unmarshal(byteData, &confsWrapper); err == nil {
if confs, ok := confsWrapper["auths"]; ok { if len(confsWrapper.Auths) > 0 {
return confs, nil return confsWrapper.Auths, nil
} }
} }

View File

@ -555,6 +555,8 @@ type hijackOptions struct {
data interface{} data interface{}
} }
// CloseWaiter is an interface with methods for closing the underlying resource
// and then waiting for it to finish processing.
type CloseWaiter interface { type CloseWaiter interface {
io.Closer io.Closer
Wait() error Wait() error

View File

@ -14,6 +14,8 @@ import (
"strconv" "strconv"
"strings" "strings"
"time" "time"
"github.com/fsouza/go-dockerclient/external/github.com/docker/go-units"
) )
// ErrContainerAlreadyExists is the error returned by CreateContainer when the // ErrContainerAlreadyExists is the error returned by CreateContainer when the
@ -52,7 +54,14 @@ type APIContainers struct {
SizeRw int64 `json:"SizeRw,omitempty" yaml:"SizeRw,omitempty"` SizeRw int64 `json:"SizeRw,omitempty" yaml:"SizeRw,omitempty"`
SizeRootFs int64 `json:"SizeRootFs,omitempty" yaml:"SizeRootFs,omitempty"` SizeRootFs int64 `json:"SizeRootFs,omitempty" yaml:"SizeRootFs,omitempty"`
Names []string `json:"Names,omitempty" yaml:"Names,omitempty"` Names []string `json:"Names,omitempty" yaml:"Names,omitempty"`
Labels map[string]string `json:"Labels,omitempty" yaml:"Labels, omitempty"` Labels map[string]string `json:"Labels,omitempty" yaml:"Labels,omitempty"`
Networks NetworkList `json:"NetworkSettings,omitempty" yaml:"NetworkSettings,omitempty"`
}
// NetworkList encapsulates a map of networks, as returned by the Docker API in
// ListContainers.
type NetworkList struct {
Networks map[string]ContainerNetwork `json:"Networks" yaml:"Networks,omitempty"`
} }
// ListContainers returns a slice of containers matching the given criteria. // ListContainers returns a slice of containers matching the given criteria.
@ -92,26 +101,73 @@ func (p Port) Proto() string {
// State represents the state of a container. // State represents the state of a container.
type State struct { type State struct {
Running bool `json:"Running,omitempty" yaml:"Running,omitempty"` Status string `json:"Status,omitempty" yaml:"Status,omitempty"`
Paused bool `json:"Paused,omitempty" yaml:"Paused,omitempty"` Running bool `json:"Running,omitempty" yaml:"Running,omitempty"`
Restarting bool `json:"Restarting,omitempty" yaml:"Restarting,omitempty"` Paused bool `json:"Paused,omitempty" yaml:"Paused,omitempty"`
OOMKilled bool `json:"OOMKilled,omitempty" yaml:"OOMKilled,omitempty"` Restarting bool `json:"Restarting,omitempty" yaml:"Restarting,omitempty"`
Pid int `json:"Pid,omitempty" yaml:"Pid,omitempty"` OOMKilled bool `json:"OOMKilled,omitempty" yaml:"OOMKilled,omitempty"`
ExitCode int `json:"ExitCode,omitempty" yaml:"ExitCode,omitempty"` RemovalInProgress bool `json:"RemovalInProgress,omitempty" yaml:"RemovalInProgress,omitempty"`
Error string `json:"Error,omitempty" yaml:"Error,omitempty"` Dead bool `json:"Dead,omitempty" yaml:"Dead,omitempty"`
StartedAt time.Time `json:"StartedAt,omitempty" yaml:"StartedAt,omitempty"` Pid int `json:"Pid,omitempty" yaml:"Pid,omitempty"`
FinishedAt time.Time `json:"FinishedAt,omitempty" yaml:"FinishedAt,omitempty"` ExitCode int `json:"ExitCode,omitempty" yaml:"ExitCode,omitempty"`
Error string `json:"Error,omitempty" yaml:"Error,omitempty"`
StartedAt time.Time `json:"StartedAt,omitempty" yaml:"StartedAt,omitempty"`
FinishedAt time.Time `json:"FinishedAt,omitempty" yaml:"FinishedAt,omitempty"`
} }
// String returns the string representation of a state. // String returns a human-readable description of the state
func (s *State) String() string { func (s *State) String() string {
if s.Running {
if s.Paused {
return fmt.Sprintf("Up %s (Paused)", units.HumanDuration(time.Now().UTC().Sub(s.StartedAt)))
}
if s.Restarting {
return fmt.Sprintf("Restarting (%d) %s ago", s.ExitCode, units.HumanDuration(time.Now().UTC().Sub(s.FinishedAt)))
}
return fmt.Sprintf("Up %s", units.HumanDuration(time.Now().UTC().Sub(s.StartedAt)))
}
if s.RemovalInProgress {
return "Removal In Progress"
}
if s.Dead {
return "Dead"
}
if s.StartedAt.IsZero() {
return "Created"
}
if s.FinishedAt.IsZero() {
return ""
}
return fmt.Sprintf("Exited (%d) %s ago", s.ExitCode, units.HumanDuration(time.Now().UTC().Sub(s.FinishedAt)))
}
// StateString returns a single string to describe state
func (s *State) StateString() string {
if s.Running { if s.Running {
if s.Paused { if s.Paused {
return "paused" return "paused"
} }
return fmt.Sprintf("Up %s", time.Now().UTC().Sub(s.StartedAt)) if s.Restarting {
return "restarting"
}
return "running"
} }
return fmt.Sprintf("Exit %d", s.ExitCode)
if s.Dead {
return "dead"
}
if s.StartedAt.IsZero() {
return "created"
}
return "exited"
} }
// PortBinding represents the host/container port mapping as returned in the // PortBinding represents the host/container port mapping as returned in the
@ -135,6 +191,7 @@ type ContainerNetwork struct {
IPAddress string `json:"IPAddress,omitempty" yaml:"IPAddress,omitempty"` IPAddress string `json:"IPAddress,omitempty" yaml:"IPAddress,omitempty"`
Gateway string `json:"Gateway,omitempty" yaml:"Gateway,omitempty"` Gateway string `json:"Gateway,omitempty" yaml:"Gateway,omitempty"`
EndpointID string `json:"EndpointID,omitempty" yaml:"EndpointID,omitempty"` EndpointID string `json:"EndpointID,omitempty" yaml:"EndpointID,omitempty"`
NetworkID string `json:"NetworkID,omitempty" yaml:"NetworkID,omitempty"`
} }
// NetworkSettings contains network-related information about a container // NetworkSettings contains network-related information about a container
@ -308,6 +365,34 @@ type Container struct {
AppArmorProfile string `json:"AppArmorProfile,omitempty" yaml:"AppArmorProfile,omitempty"` AppArmorProfile string `json:"AppArmorProfile,omitempty" yaml:"AppArmorProfile,omitempty"`
} }
// UpdateContainerOptions specify parameters to the UpdateContainer function.
//
// See https://goo.gl/Y6fXUy for more details.
type UpdateContainerOptions struct {
BlkioWeight int `json:"BlkioWeight"`
CPUShares int `json:"CpuShares"`
CPUPeriod int `json:"CpuPeriod"`
CPUQuota int `json:"CpuQuota"`
CpusetCpus string `json:"CpusetCpus"`
CpusetMems string `json:"CpusetMems"`
Memory int `json:"Memory"`
MemorySwap int `json:"MemorySwap"`
MemoryReservation int `json:"MemoryReservation"`
KernelMemory int `json:"KernelMemory"`
}
// UpdateContainer updates the container at ID with the options
//
// See https://goo.gl/Y6fXUy for more details.
func (c *Client) UpdateContainer(id string, opts UpdateContainerOptions) error {
resp, err := c.do("POST", fmt.Sprintf("/containers/"+id+"/update"), doOptions{data: opts, forceJSON: true})
if err != nil {
return err
}
defer resp.Body.Close()
return nil
}
// RenameContainerOptions specify parameters to the RenameContainer function. // RenameContainerOptions specify parameters to the RenameContainer function.
// //
// See https://goo.gl/laSOIy for more details. // See https://goo.gl/laSOIy for more details.
@ -469,48 +554,71 @@ type Device struct {
CgroupPermissions string `json:"CgroupPermissions,omitempty" yaml:"CgroupPermissions,omitempty"` CgroupPermissions string `json:"CgroupPermissions,omitempty" yaml:"CgroupPermissions,omitempty"`
} }
// BlockWeight represents a relative device weight for an individual device inside
// of a container
//
// See https://goo.gl/FSdP0H for more details.
type BlockWeight struct {
Path string `json:"Path,omitempty"`
Weight string `json:"Weight,omitempty"`
}
// BlockLimit represents a read/write limit in IOPS or Bandwidth for a device
// inside of a container
//
// See https://goo.gl/FSdP0H for more details.
type BlockLimit struct {
Path string `json:"Path,omitempty"`
Rate string `json:"Rate,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 {
Binds []string `json:"Binds,omitempty" yaml:"Binds,omitempty"` Binds []string `json:"Binds,omitempty" yaml:"Binds,omitempty"`
CapAdd []string `json:"CapAdd,omitempty" yaml:"CapAdd,omitempty"` CapAdd []string `json:"CapAdd,omitempty" yaml:"CapAdd,omitempty"`
CapDrop []string `json:"CapDrop,omitempty" yaml:"CapDrop,omitempty"` CapDrop []string `json:"CapDrop,omitempty" yaml:"CapDrop,omitempty"`
GroupAdd []string `json:"GroupAdd,omitempty" yaml:"GroupAdd,omitempty"` GroupAdd []string `json:"GroupAdd,omitempty" yaml:"GroupAdd,omitempty"`
ContainerIDFile string `json:"ContainerIDFile,omitempty" yaml:"ContainerIDFile,omitempty"` ContainerIDFile string `json:"ContainerIDFile,omitempty" yaml:"ContainerIDFile,omitempty"`
LxcConf []KeyValuePair `json:"LxcConf,omitempty" yaml:"LxcConf,omitempty"` LxcConf []KeyValuePair `json:"LxcConf,omitempty" yaml:"LxcConf,omitempty"`
Privileged bool `json:"Privileged,omitempty" yaml:"Privileged,omitempty"` Privileged bool `json:"Privileged,omitempty" yaml:"Privileged,omitempty"`
PortBindings map[Port][]PortBinding `json:"PortBindings,omitempty" yaml:"PortBindings,omitempty"` PortBindings map[Port][]PortBinding `json:"PortBindings,omitempty" yaml:"PortBindings,omitempty"`
Links []string `json:"Links,omitempty" yaml:"Links,omitempty"` Links []string `json:"Links,omitempty" yaml:"Links,omitempty"`
PublishAllPorts bool `json:"PublishAllPorts,omitempty" yaml:"PublishAllPorts,omitempty"` PublishAllPorts bool `json:"PublishAllPorts,omitempty" yaml:"PublishAllPorts,omitempty"`
DNS []string `json:"Dns,omitempty" yaml:"Dns,omitempty"` // For Docker API v1.10 and above only DNS []string `json:"Dns,omitempty" yaml:"Dns,omitempty"` // For Docker API v1.10 and above only
DNSOptions []string `json:"DnsOptions,omitempty" yaml:"DnsOptions,omitempty"` DNSOptions []string `json:"DnsOptions,omitempty" yaml:"DnsOptions,omitempty"`
DNSSearch []string `json:"DnsSearch,omitempty" yaml:"DnsSearch,omitempty"` DNSSearch []string `json:"DnsSearch,omitempty" yaml:"DnsSearch,omitempty"`
ExtraHosts []string `json:"ExtraHosts,omitempty" yaml:"ExtraHosts,omitempty"` ExtraHosts []string `json:"ExtraHosts,omitempty" yaml:"ExtraHosts,omitempty"`
VolumesFrom []string `json:"VolumesFrom,omitempty" yaml:"VolumesFrom,omitempty"` VolumesFrom []string `json:"VolumesFrom,omitempty" yaml:"VolumesFrom,omitempty"`
NetworkMode string `json:"NetworkMode,omitempty" yaml:"NetworkMode,omitempty"` NetworkMode string `json:"NetworkMode,omitempty" yaml:"NetworkMode,omitempty"`
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"`
UTSMode string `json:"UTSMode,omitempty" yaml:"UTSMode,omitempty"` UTSMode string `json:"UTSMode,omitempty" yaml:"UTSMode,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"` Devices []Device `json:"Devices,omitempty" yaml:"Devices,omitempty"`
LogConfig LogConfig `json:"LogConfig,omitempty" yaml:"LogConfig,omitempty"` LogConfig LogConfig `json:"LogConfig,omitempty" yaml:"LogConfig,omitempty"`
ReadonlyRootfs bool `json:"ReadonlyRootfs,omitempty" yaml:"ReadonlyRootfs,omitempty"` ReadonlyRootfs bool `json:"ReadonlyRootfs,omitempty" yaml:"ReadonlyRootfs,omitempty"`
SecurityOpt []string `json:"SecurityOpt,omitempty" yaml:"SecurityOpt,omitempty"` SecurityOpt []string `json:"SecurityOpt,omitempty" yaml:"SecurityOpt,omitempty"`
CgroupParent string `json:"CgroupParent,omitempty" yaml:"CgroupParent,omitempty"` CgroupParent string `json:"CgroupParent,omitempty" yaml:"CgroupParent,omitempty"`
Memory int64 `json:"Memory,omitempty" yaml:"Memory,omitempty"` Memory int64 `json:"Memory,omitempty" yaml:"Memory,omitempty"`
MemorySwap int64 `json:"MemorySwap,omitempty" yaml:"MemorySwap,omitempty"` MemorySwap int64 `json:"MemorySwap,omitempty" yaml:"MemorySwap,omitempty"`
MemorySwappiness int64 `json:"MemorySwappiness,omitempty" yaml:"MemorySwappiness,omitempty"` MemorySwappiness int64 `json:"MemorySwappiness,omitempty" yaml:"MemorySwappiness,omitempty"`
OOMKillDisable bool `json:"OomKillDisable,omitempty" yaml:"OomKillDisable"` OOMKillDisable bool `json:"OomKillDisable,omitempty" yaml:"OomKillDisable"`
CPUShares int64 `json:"CpuShares,omitempty" yaml:"CpuShares,omitempty"` CPUShares int64 `json:"CpuShares,omitempty" yaml:"CpuShares,omitempty"`
CPUSet string `json:"Cpuset,omitempty" yaml:"Cpuset,omitempty"` CPUSet string `json:"Cpuset,omitempty" yaml:"Cpuset,omitempty"`
CPUSetCPUs string `json:"CpusetCpus,omitempty" yaml:"CpusetCpus,omitempty"` CPUSetCPUs string `json:"CpusetCpus,omitempty" yaml:"CpusetCpus,omitempty"`
CPUSetMEMs string `json:"CpusetMems,omitempty" yaml:"CpusetMems,omitempty"` CPUSetMEMs string `json:"CpusetMems,omitempty" yaml:"CpusetMems,omitempty"`
CPUQuota int64 `json:"CpuQuota,omitempty" yaml:"CpuQuota,omitempty"` CPUQuota int64 `json:"CpuQuota,omitempty" yaml:"CpuQuota,omitempty"`
CPUPeriod int64 `json:"CpuPeriod,omitempty" yaml:"CpuPeriod,omitempty"` CPUPeriod int64 `json:"CpuPeriod,omitempty" yaml:"CpuPeriod,omitempty"`
BlkioWeight int64 `json:"BlkioWeight,omitempty" yaml:"BlkioWeight"` BlkioWeight int64 `json:"BlkioWeight,omitempty" yaml:"BlkioWeight"`
Ulimits []ULimit `json:"Ulimits,omitempty" yaml:"Ulimits,omitempty"` BlkioWeightDevice []BlockWeight `json:"BlkioWeightDevice,omitempty" yaml:"BlkioWeightDevice"`
VolumeDriver string `json:"VolumeDriver,omitempty" yaml:"VolumeDriver,omitempty"` BlkioDeviceReadBps []BlockLimit `json:"BlkioDeviceReadBps,omitempty" yaml:"BlkioDeviceReadBps"`
OomScoreAdj int `json:"OomScoreAdj,omitempty" yaml:"OomScoreAdj,omitempty"` BlkioDeviceReadIOps []BlockLimit `json:"BlkioDeviceReadIOps,omitempty" yaml:"BlkioDeviceReadIOps"`
BlkioDeviceWriteBps []BlockLimit `json:"BlkioDeviceWriteBps,omitempty" yaml:"BlkioDeviceWriteBps"`
BlkioDeviceWriteIOps []BlockLimit `json:"BlkioDeviceWriteIOps,omitempty" yaml:"BlkioDeviceWriteIOps"`
Ulimits []ULimit `json:"Ulimits,omitempty" yaml:"Ulimits,omitempty"`
VolumeDriver string `json:"VolumeDriver,omitempty" yaml:"VolumeDriver,omitempty"`
OomScoreAdj int `json:"OomScoreAdj,omitempty" yaml:"OomScoreAdj,omitempty"`
} }
// StartContainer starts a container, returning an error in case of failure. // StartContainer starts a container, returning an error in case of failure.

View File

@ -18,12 +18,38 @@ import (
"time" "time"
) )
// APIEvents represents an event returned by the API. // APIEvents represents events coming from the Docker API
// The fields in the Docker API changed in API version 1.22, and
// events for more than images and containers are now fired off.
// To maintain forward and backward compatibility, go-dockerclient
// replicates the event in both the new and old format as faithfully as possible.
//
// For events that only exist in 1.22 in later, `Status` is filled in as
// `"Type:Action"` instead of just `Action` to allow for older clients to
// differentiate and not break if they rely on the pre-1.22 Status types.
//
// The transformEvent method can be consulted for more information about how
// events are translated from new/old API formats
type APIEvents struct { type APIEvents struct {
Status string `json:"Status,omitempty" yaml:"Status,omitempty"` // New API Fields in 1.22
ID string `json:"ID,omitempty" yaml:"ID,omitempty"` Action string `json:"action,omitempty"`
From string `json:"From,omitempty" yaml:"From,omitempty"` Type string `json:"type,omitempty"`
Time int64 `json:"Time,omitempty" yaml:"Time,omitempty"` Actor APIActor `json:"actor,omitempty"`
// Old API fields for < 1.22
Status string `json:"status,omitempty"`
ID string `json:"id,omitempty"`
From string `json:"from,omitempty"`
// Fields in both
Time int64 `json:"time,omitempty"`
TimeNano int64 `json:"timeNano,omitempty"`
}
// APIActor represents an actor that accomplishes something for an event
type APIActor struct {
ID string `json:"id,omitempty"`
Attributes map[string]string `json:"attributes,omitempty"`
} }
type eventMonitoringState struct { type eventMonitoringState struct {
@ -52,6 +78,7 @@ var (
// EOFEvent is sent when the event listener receives an EOF error. // EOFEvent is sent when the event listener receives an EOF error.
EOFEvent = &APIEvents{ EOFEvent = &APIEvents{
Type: "EOF",
Status: "EOF", Status: "EOF",
} }
) )
@ -297,8 +324,47 @@ func (c *Client) eventHijack(startTime int64, eventChan chan *APIEvents, errChan
if !c.eventMonitor.isEnabled() { if !c.eventMonitor.isEnabled() {
return return
} }
transformEvent(&event)
eventChan <- &event eventChan <- &event
} }
}(res, conn) }(res, conn)
return nil return nil
} }
// transformEvent takes an event and determines what version it is from
// then populates both versions of the event
func transformEvent(event *APIEvents) {
// if event version is <= 1.21 there will be no Action and no Type
if event.Action == "" && event.Type == "" {
event.Action = event.Status
event.Actor.ID = event.ID
event.Actor.Attributes = map[string]string{}
switch event.Status {
case "delete", "import", "pull", "push", "tag", "untag":
event.Type = "image"
default:
event.Type = "container"
if event.From != "" {
event.Actor.Attributes["image"] = event.From
}
}
} else {
if event.Status == "" {
if event.Type == "image" || event.Type == "container" {
event.Status = event.Action
} else {
// Because just the Status has been overloaded with different Types
// if an event is not for an image or a container, we prepend the type
// to avoid problems for people relying on actions being only for
// images and containers
event.Status = event.Type + ":" + event.Action
}
}
if event.ID == "" {
event.ID = event.Actor.ID
}
if event.From == "" {
event.From = event.Actor.Attributes["image"]
}
}
}

View File

@ -0,0 +1,14 @@
// +build !windows
package system
import (
"time"
)
//setCTime will set the create time on a file. On Unix, the create
//time is updated as a side effect of setting the modified time, so
//no action is required.
func setCTime(path string, ctime time.Time) error {
return nil
}

View File

@ -0,0 +1,27 @@
// +build windows
package system
import (
"syscall"
"time"
)
//setCTime will set the create time on a file. On Windows, this requires
//calling SetFileTime and explicitly including the create time.
func setCTime(path string, ctime time.Time) error {
ctimespec := syscall.NsecToTimespec(ctime.UnixNano())
pathp, e := syscall.UTF16PtrFromString(path)
if e != nil {
return e
}
h, e := syscall.CreateFile(pathp,
syscall.FILE_WRITE_ATTRIBUTES, syscall.FILE_SHARE_WRITE, nil,
syscall.OPEN_EXISTING, syscall.FILE_FLAG_BACKUP_SEMANTICS, 0)
if e != nil {
return e
}
defer syscall.Close(h)
c := syscall.NsecToFiletime(syscall.TimespecToNsec(ctimespec))
return syscall.SetFileTime(h, &c, nil, nil)
}

View File

@ -0,0 +1,15 @@
package system
import (
"syscall"
)
// fromStatT creates a system.StatT type from a syscall.Stat_t type
func fromStatT(s *syscall.Stat_t) (*StatT, error) {
return &StatT{size: s.Size,
mode: uint32(s.Mode),
uid: s.Uid,
gid: s.Gid,
rdev: uint64(s.Rdev),
mtim: s.Mtim}, nil
}

View File

@ -1,4 +1,4 @@
// +build !linux,!windows,!freebsd,!solaris // +build !linux,!windows,!freebsd,!solaris,!openbsd
package system package system

View File

@ -210,13 +210,13 @@ type CancelFunc func()
// call cancel as soon as the operations running in this Context complete. // call cancel as soon as the operations running in this Context complete.
func WithCancel(parent Context) (ctx Context, cancel CancelFunc) { func WithCancel(parent Context) (ctx Context, cancel CancelFunc) {
c := newCancelCtx(parent) c := newCancelCtx(parent)
propagateCancel(parent, &c) propagateCancel(parent, c)
return &c, func() { c.cancel(true, Canceled) } return c, func() { c.cancel(true, Canceled) }
} }
// newCancelCtx returns an initialized cancelCtx. // newCancelCtx returns an initialized cancelCtx.
func newCancelCtx(parent Context) cancelCtx { func newCancelCtx(parent Context) *cancelCtx {
return cancelCtx{ return &cancelCtx{
Context: parent, Context: parent,
done: make(chan struct{}), done: make(chan struct{}),
} }
@ -259,7 +259,7 @@ func parentCancelCtx(parent Context) (*cancelCtx, bool) {
case *cancelCtx: case *cancelCtx:
return c, true return c, true
case *timerCtx: case *timerCtx:
return &c.cancelCtx, true return c.cancelCtx, true
case *valueCtx: case *valueCtx:
parent = c.Context parent = c.Context
default: default:
@ -377,7 +377,7 @@ func WithDeadline(parent Context, deadline time.Time) (Context, CancelFunc) {
// implement Done and Err. It implements cancel by stopping its timer then // implement Done and Err. It implements cancel by stopping its timer then
// delegating to cancelCtx.cancel. // delegating to cancelCtx.cancel.
type timerCtx struct { type timerCtx struct {
cancelCtx *cancelCtx
timer *time.Timer // Under cancelCtx.mu. timer *time.Timer // Under cancelCtx.mu.
deadline time.Time deadline time.Time

View File

@ -32,6 +32,7 @@ type APIImages struct {
// Image is the type representing a docker image and its various properties // Image is the type representing a docker image and its various properties
type Image struct { type Image struct {
ID string `json:"Id" yaml:"Id"` ID string `json:"Id" yaml:"Id"`
RepoTags []string `json:"RepoTags,omitempty" yaml:"RepoTags,omitempty"`
Parent string `json:"Parent,omitempty" yaml:"Parent,omitempty"` Parent string `json:"Parent,omitempty" yaml:"Parent,omitempty"`
Comment string `json:"Comment,omitempty" yaml:"Comment,omitempty"` Comment string `json:"Comment,omitempty" yaml:"Comment,omitempty"`
Created time.Time `json:"Created,omitempty" yaml:"Created,omitempty"` Created time.Time `json:"Created,omitempty" yaml:"Created,omitempty"`
@ -421,6 +422,17 @@ type BuildImageOptions struct {
AuthConfigs AuthConfigurations `qs:"-"` // for newer docker X-Registry-Config header AuthConfigs AuthConfigurations `qs:"-"` // for newer docker X-Registry-Config header
ContextDir string `qs:"-"` ContextDir string `qs:"-"`
Ulimits []ULimit `qs:"-"` Ulimits []ULimit `qs:"-"`
BuildArgs []BuildArg `qs:"-"`
}
// BuildArg represents arguments that can be passed to the image when building
// it from a Dockerfile.
//
// For more details about the Docker building process, see
// http://goo.gl/tlPXPu.
type BuildArg struct {
Name string `json:"Name,omitempty" yaml:"Name,omitempty"`
Value string `json:"Value,omitempty" yaml:"Value,omitempty"`
} }
// BuildImage builds an image from a tarball's url or a Dockerfile in the input // BuildImage builds an image from a tarball's url or a Dockerfile in the input
@ -463,6 +475,18 @@ func (c *Client) BuildImage(opts BuildImageOptions) error {
} }
} }
if len(opts.BuildArgs) > 0 {
v := make(map[string]string)
for _, arg := range opts.BuildArgs {
v[arg.Name] = arg.Value
}
if b, err := json.Marshal(v); err == nil {
item := url.Values(map[string][]string{})
item.Add("buildargs", string(b))
qs = fmt.Sprintf("%s&%s", qs, item.Encode())
}
}
return c.stream("POST", fmt.Sprintf("/build?%s", qs), streamOptions{ return c.stream("POST", fmt.Sprintf("/build?%s", qs), streamOptions{
setRawTerminal: true, setRawTerminal: true,
rawJSONStream: opts.RawJSONStream, rawJSONStream: opts.RawJSONStream,

View File

@ -4,7 +4,10 @@
package docker package docker
import "strings" import (
"encoding/json"
"strings"
)
// Version returns version information about the docker server. // Version returns version information about the docker server.
// //
@ -22,17 +25,81 @@ func (c *Client) Version() (*Env, error) {
return &env, nil return &env, nil
} }
// DockerInfo contains information about the Docker server
//
// See https://goo.gl/bHUoz9 for more details.
type DockerInfo struct {
ID string
Containers int
ContainersRunning int
ContainersPaused int
ContainersStopped int
Images int
Driver string
DriverStatus [][2]string
SystemStatus [][2]string
Plugins PluginsInfo
MemoryLimit bool
SwapLimit bool
KernelMemory bool
CPUCfsPeriod bool `json:"CpuCfsPeriod"`
CPUCfsQuota bool `json:"CpuCfsQuota"`
CPUShares bool
CPUSet bool
IPv4Forwarding bool
BridgeNfIptables bool
BridgeNfIP6tables bool `json:"BridgeNfIp6tables"`
Debug bool
NFd int
OomKillDisable bool
NGoroutines int
SystemTime string
ExecutionDriver string
LoggingDriver string
CgroupDriver string
NEventsListener int
KernelVersion string
OperatingSystem string
OSType string
Architecture string
IndexServerAddress string
NCPU int
MemTotal int64
DockerRootDir string
HTTPProxy string `json:"HttpProxy"`
HTTPSProxy string `json:"HttpsProxy"`
NoProxy string
Name string
Labels []string
ExperimentalBuild bool
ServerVersion string
ClusterStore string
ClusterAdvertise string
}
// PluginsInfo is a struct with the plugins registered with the docker daemon
//
// for more information, see: https://goo.gl/bHUoz9
type PluginsInfo struct {
// List of Volume plugins registered
Volume []string
// List of Network plugins registered
Network []string
// List of Authorization plugins registered
Authorization []string
}
// Info returns system-wide information about the Docker server. // Info returns system-wide information about the Docker server.
// //
// See https://goo.gl/ElTHi2 for more details. // See https://goo.gl/ElTHi2 for more details.
func (c *Client) Info() (*Env, error) { func (c *Client) Info() (*DockerInfo, error) {
resp, err := c.do("GET", "/info", doOptions{}) resp, err := c.do("GET", "/info", doOptions{})
if err != nil { if err != nil {
return nil, err return nil, err
} }
defer resp.Body.Close() defer resp.Body.Close()
var info Env var info DockerInfo
if err := info.Decode(resp.Body); err != nil { if err := json.NewDecoder(resp.Body).Decode(&info); err != nil {
return nil, err return nil, err
} }
return &info, nil return &info, nil

View File

@ -5,6 +5,7 @@
package docker package docker
import ( import (
"bytes"
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
@ -26,6 +27,7 @@ type Network struct {
IPAM IPAMOptions IPAM IPAMOptions
Containers map[string]Endpoint Containers map[string]Endpoint
Options map[string]string Options map[string]string
Internal bool
} }
// Endpoint contains network resources allocated and used for a container in a network // Endpoint contains network resources allocated and used for a container in a network
@ -55,6 +57,31 @@ func (c *Client) ListNetworks() ([]Network, error) {
return networks, nil return networks, nil
} }
// NetworkFilterOpts is an aggregation of key=value that Docker
// uses to filter networks
type NetworkFilterOpts map[string]map[string]bool
// FilteredListNetworks returns all networks with the filters applied
//
// See goo.gl/zd2mx4 for more details.
func (c *Client) FilteredListNetworks(opts NetworkFilterOpts) ([]Network, error) {
params := bytes.NewBuffer(nil)
if err := json.NewEncoder(params).Encode(&opts); err != nil {
return nil, err
}
path := "/networks?filters=" + params.String()
resp, err := c.do("GET", path, doOptions{})
if err != nil {
return nil, err
}
defer resp.Body.Close()
var networks []Network
if err := json.NewDecoder(resp.Body).Decode(&networks); err != nil {
return nil, err
}
return networks, nil
}
// NetworkInfo returns information about a network by its ID. // NetworkInfo returns information about a network by its ID.
// //
// See https://goo.gl/6GugX3 for more details. // See https://goo.gl/6GugX3 for more details.
@ -158,14 +185,40 @@ func (c *Client) RemoveNetwork(id string) error {
return nil return nil
} }
// NetworkConnectionOptions specify parameters to the ConnectNetwork and DisconnectNetwork function. // NetworkConnectionOptions specify parameters to the ConnectNetwork and
// DisconnectNetwork function.
// //
// See https://goo.gl/6GugX3 for more details. // See https://goo.gl/RV7BJU for more details.
type NetworkConnectionOptions struct { type NetworkConnectionOptions struct {
Container string Container string
// EndpointConfig is only applicable to the ConnectNetwork call
EndpointConfig *EndpointConfig `json:"EndpointConfig,omitempty"`
// Force is only applicable to the DisconnectNetwork call
Force bool
} }
// ConnectNetwork adds a container to a network or returns an error in case of failure. // EndpointConfig stores network endpoint details
//
// See https://goo.gl/RV7BJU for more details.
type EndpointConfig struct {
IPAMConfig *EndpointIPAMConfig
Links []string
Aliases []string
}
// EndpointIPAMConfig represents IPAM configurations for an
// endpoint
//
// See https://goo.gl/RV7BJU for more details.
type EndpointIPAMConfig struct {
IPv4Address string `json:",omitempty"`
IPv6Address string `json:",omitempty"`
}
// ConnectNetwork adds a container to a network or returns an error in case of
// failure.
// //
// See https://goo.gl/6GugX3 for more details. // See https://goo.gl/6GugX3 for more details.
func (c *Client) ConnectNetwork(id string, opts NetworkConnectionOptions) error { func (c *Client) ConnectNetwork(id string, opts NetworkConnectionOptions) error {
@ -180,7 +233,8 @@ func (c *Client) ConnectNetwork(id string, opts NetworkConnectionOptions) error
return nil return nil
} }
// DisconnectNetwork removes a container from a network or returns an error in case of failure. // DisconnectNetwork removes a container from a network or returns an error in
// case of failure.
// //
// See https://goo.gl/6GugX3 for more details. // See https://goo.gl/6GugX3 for more details.
func (c *Client) DisconnectNetwork(id string, opts NetworkConnectionOptions) error { func (c *Client) DisconnectNetwork(id string, opts NetworkConnectionOptions) error {
@ -204,7 +258,8 @@ func (err *NoSuchNetwork) Error() string {
return fmt.Sprintf("No such network: %s", err.ID) return fmt.Sprintf("No such network: %s", err.ID)
} }
// NoSuchNetwork is the error returned when a given network or container does not exist. // NoSuchNetworkOrContainer is the error returned when a given network or
// container does not exist.
type NoSuchNetworkOrContainer struct { type NoSuchNetworkOrContainer struct {
NetworkID string NetworkID string
ContainerID string ContainerID string

View File

@ -144,6 +144,7 @@ func (s *DockerServer) buildMuxer() {
s.mux.Path("/volumes/create").Methods("POST").HandlerFunc(s.handlerWrapper(s.createVolume)) s.mux.Path("/volumes/create").Methods("POST").HandlerFunc(s.handlerWrapper(s.createVolume))
s.mux.Path("/volumes/{name:.*}").Methods("GET").HandlerFunc(s.handlerWrapper(s.inspectVolume)) s.mux.Path("/volumes/{name:.*}").Methods("GET").HandlerFunc(s.handlerWrapper(s.inspectVolume))
s.mux.Path("/volumes/{name:.*}").Methods("DELETE").HandlerFunc(s.handlerWrapper(s.removeVolume)) s.mux.Path("/volumes/{name:.*}").Methods("DELETE").HandlerFunc(s.handlerWrapper(s.removeVolume))
s.mux.Path("/info").Methods("GET").HandlerFunc(s.handlerWrapper(s.infoDocker))
} }
// SetHook changes the hook function used by the server. // SetHook changes the hook function used by the server.
@ -743,10 +744,9 @@ func (s *DockerServer) commitContainer(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), http.StatusNotFound) http.Error(w, err.Error(), http.StatusNotFound)
return return
} }
var config *docker.Config config := new(docker.Config)
runConfig := r.URL.Query().Get("run") runConfig := r.URL.Query().Get("run")
if runConfig != "" { if runConfig != "" {
config = new(docker.Config)
err = json.Unmarshal([]byte(runConfig), config) err = json.Unmarshal([]byte(runConfig), config)
if err != nil { if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
@ -828,7 +828,8 @@ func (s *DockerServer) pullImage(w http.ResponseWriter, r *http.Request) {
fromImageName := r.URL.Query().Get("fromImage") fromImageName := r.URL.Query().Get("fromImage")
tag := r.URL.Query().Get("tag") tag := r.URL.Query().Get("tag")
image := docker.Image{ image := docker.Image{
ID: s.generateID(), ID: s.generateID(),
Config: &docker.Config{},
} }
s.iMut.Lock() s.iMut.Lock()
s.images = append(s.images, image) s.images = append(s.images, image)
@ -1244,3 +1245,86 @@ func (s *DockerServer) removeVolume(w http.ResponseWriter, r *http.Request) {
s.volStore[vol.volume.Name] = nil s.volStore[vol.volume.Name] = nil
w.WriteHeader(http.StatusNoContent) w.WriteHeader(http.StatusNoContent)
} }
func (s *DockerServer) infoDocker(w http.ResponseWriter, r *http.Request) {
s.cMut.RLock()
defer s.cMut.RUnlock()
s.iMut.RLock()
defer s.iMut.RUnlock()
var running, stopped, paused int
for _, c := range s.containers {
if c.State.Running {
running++
} else {
stopped++
}
if c.State.Paused {
paused++
}
}
envs := map[string]interface{}{
"ID": "AAAA:XXXX:0000:BBBB:AAAA:XXXX:0000:BBBB:AAAA:XXXX:0000:BBBB",
"Containers": len(s.containers),
"ContainersRunning": running,
"ContainersPaused": paused,
"ContainersStopped": stopped,
"Images": len(s.images),
"Driver": "aufs",
"DriverStatus": [][]string{},
"SystemStatus": nil,
"Plugins": map[string]interface{}{
"Volume": []string{
"local",
},
"Network": []string{
"bridge",
"null",
"host",
},
"Authorization": nil,
},
"MemoryLimit": true,
"SwapLimit": false,
"CpuCfsPeriod": true,
"CpuCfsQuota": true,
"CPUShares": true,
"CPUSet": true,
"IPv4Forwarding": true,
"BridgeNfIptables": true,
"BridgeNfIp6tables": true,
"Debug": false,
"NFd": 79,
"OomKillDisable": true,
"NGoroutines": 101,
"SystemTime": "2016-02-25T18:13:10.25870078Z",
"ExecutionDriver": "native-0.2",
"LoggingDriver": "json-file",
"NEventsListener": 0,
"KernelVersion": "3.13.0-77-generic",
"OperatingSystem": "Ubuntu 14.04.3 LTS",
"OSType": "linux",
"Architecture": "x86_64",
"IndexServerAddress": "https://index.docker.io/v1/",
"RegistryConfig": map[string]interface{}{
"InsecureRegistryCIDRs": []string{},
"IndexConfigs": map[string]interface{}{},
"Mirrors": nil,
},
"InitSha1": "e2042dbb0fcf49bb9da199186d9a5063cda92a01",
"InitPath": "/usr/lib/docker/dockerinit",
"NCPU": 1,
"MemTotal": 2099204096,
"DockerRootDir": "/var/lib/docker",
"HttpProxy": "",
"HttpsProxy": "",
"NoProxy": "",
"Name": "vagrant-ubuntu-trusty-64",
"Labels": nil,
"ExperimentalBuild": false,
"ServerVersion": "1.10.1",
"ClusterStore": "",
"ClusterAdvertise": "",
}
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(envs)
}

View File

@ -0,0 +1,17 @@
#!/bin/bash -x
# Copyright 2016 go-dockerclient authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
if [[ $TRAVIS_OS_NAME == "linux" ]]; then
sudo stop docker || true
sudo rm -rf /var/lib/docker
sudo rm -f `which docker`
set -e
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt-get update
sudo apt-get install docker-engine=${DOCKER_VERSION}-0~$(lsb_release -cs) -y --force-yes -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"
fi

View File

@ -0,0 +1,15 @@
#!/bin/bash -ex
# Copyright 2016 go-dockerclient authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
if ! [[ $TRAVIS_GO_VERSION =~ ^1\.[34] ]]; then
make lint vet
fi
make fmtcheck gotest
if [[ $TRAVIS_OS_NAME == "linux" ]]; then
DOCKER_HOST=tcp://127.0.0.1:2375 make integration
fi