Merge pull request #6113 from hashicorp/b-update-dockerclient
deps: Update github.com/fsouza/go-dockerclient
This commit is contained in:
commit
9a315bb83f
|
@ -561,75 +561,75 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "github.com/fsouza/go-dockerclient",
|
||||
"Rev": "02a8beb401b20e112cff3ea740545960b667eab1"
|
||||
"Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/Sirupsen/logrus",
|
||||
"Rev": "02a8beb401b20e112cff3ea740545960b667eab1"
|
||||
"Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/opts",
|
||||
"Rev": "02a8beb401b20e112cff3ea740545960b667eab1"
|
||||
"Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/archive",
|
||||
"Rev": "02a8beb401b20e112cff3ea740545960b667eab1"
|
||||
"Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/fileutils",
|
||||
"Rev": "02a8beb401b20e112cff3ea740545960b667eab1"
|
||||
"Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/homedir",
|
||||
"Rev": "02a8beb401b20e112cff3ea740545960b667eab1"
|
||||
"Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/idtools",
|
||||
"Rev": "02a8beb401b20e112cff3ea740545960b667eab1"
|
||||
"Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/ioutils",
|
||||
"Rev": "02a8beb401b20e112cff3ea740545960b667eab1"
|
||||
"Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/longpath",
|
||||
"Rev": "02a8beb401b20e112cff3ea740545960b667eab1"
|
||||
"Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/pools",
|
||||
"Rev": "02a8beb401b20e112cff3ea740545960b667eab1"
|
||||
"Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/promise",
|
||||
"Rev": "02a8beb401b20e112cff3ea740545960b667eab1"
|
||||
"Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/stdcopy",
|
||||
"Rev": "02a8beb401b20e112cff3ea740545960b667eab1"
|
||||
"Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system",
|
||||
"Rev": "02a8beb401b20e112cff3ea740545960b667eab1"
|
||||
"Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/go-units",
|
||||
"Rev": "02a8beb401b20e112cff3ea740545960b667eab1"
|
||||
"Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/hashicorp/go-cleanhttp",
|
||||
"Rev": "02a8beb401b20e112cff3ea740545960b667eab1"
|
||||
"Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/opencontainers/runc/libcontainer/user",
|
||||
"Rev": "02a8beb401b20e112cff3ea740545960b667eab1"
|
||||
"Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/fsouza/go-dockerclient/external/golang.org/x/net/context",
|
||||
"Rev": "02a8beb401b20e112cff3ea740545960b667eab1"
|
||||
"Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/fsouza/go-dockerclient/external/golang.org/x/sys/unix",
|
||||
"Rev": "02a8beb401b20e112cff3ea740545960b667eab1"
|
||||
"Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/go-chef/chef",
|
||||
|
|
|
@ -1,22 +1,27 @@
|
|||
language: go
|
||||
sudo: required
|
||||
go:
|
||||
- 1.3.3
|
||||
- 1.4.2
|
||||
- 1.5.3
|
||||
- 1.6rc1
|
||||
- 1.6
|
||||
- tip
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
env:
|
||||
- GOARCH=amd64 DOCKER_VERSION=1.7.1
|
||||
- GOARCH=386 DOCKER_VERSION=1.7.1
|
||||
- GOARCH=amd64 DOCKER_VERSION=1.8.3
|
||||
- GOARCH=386 DOCKER_VERSION=1.8.3
|
||||
- GOARCH=amd64 DOCKER_VERSION=1.9.1
|
||||
- GOARCH=386 DOCKER_VERSION=1.9.1
|
||||
- GOARCH=amd64 DOCKER_VERSION=1.10.3
|
||||
- GOARCH=386 DOCKER_VERSION=1.10.3
|
||||
install:
|
||||
- make prepare_docker
|
||||
- travis_retry travis-scripts/install.bash
|
||||
script:
|
||||
- make test
|
||||
- DOCKER_HOST=tcp://127.0.0.1:2375 make integration
|
||||
- travis-scripts/run-tests.bash
|
||||
services:
|
||||
- docker
|
||||
matrix:
|
||||
fast_finish: true
|
||||
allow_failures:
|
||||
- go: tip
|
||||
|
|
|
@ -14,6 +14,7 @@ Ben Marini <ben@remind101.com>
|
|||
Ben McCann <benmccann.com>
|
||||
Ben Parees <bparees@redhat.com>
|
||||
Benno van den Berg <bennovandenberg@gmail.com>
|
||||
Bradley Cicenas <bradley.cicenas@gmail.com>
|
||||
Brendan Fosberry <brendan@codeship.com>
|
||||
Brian Lalor <blalor@bravo5.org>
|
||||
Brian P. Hamachek <brian@brianhama.com>
|
||||
|
@ -48,6 +49,8 @@ Fabio Rehm <fgrehm@gmail.com>
|
|||
Fatih Arslan <ftharsln@gmail.com>
|
||||
Flavia Missi <flaviamissi@gmail.com>
|
||||
Francisco Souza <f@souza.cc>
|
||||
Frank Groeneveld <frank@frankgroeneveld.nl>
|
||||
George Moura <gwmoura@gmail.com>
|
||||
Grégoire Delattre <gregoire.delattre@gmail.com>
|
||||
Guillermo Álvarez Fernández <guillermo@cientifico.net>
|
||||
Harry Zhang <harryzhang@zju.edu.cn>
|
||||
|
@ -84,7 +87,9 @@ Michael Schmatz <michaelschmatz@gmail.com>
|
|||
Michal Fojtik <mfojtik@redhat.com>
|
||||
Mike Dillon <mike.dillon@synctree.com>
|
||||
Mrunal Patel <mrunalp@gmail.com>
|
||||
Nate Jones <nate@endot.org>
|
||||
Nguyen Sy Thanh Son <sonnst@sigma-solutions.eu>
|
||||
Nicholas Van Wiggeren <nvanwiggeren@digitalocean.com>
|
||||
Nick Ethier <ncethier@gmail.com>
|
||||
Omeid Matten <public@omeid.me>
|
||||
Orivej Desh <orivej@gmx.fr>
|
||||
|
@ -98,9 +103,11 @@ Philippe Lafoucrière <philippe.lafoucriere@tech-angels.com>
|
|||
Rafe Colton <rafael.colton@gmail.com>
|
||||
Rob Miller <rob@kalistra.com>
|
||||
Robert Williamson <williamson.robert@gmail.com>
|
||||
Roman Khlystik <roman.khlystik@gmail.com>
|
||||
Salvador Gironès <salvadorgirones@gmail.com>
|
||||
Sam Rijs <srijs@airpost.net>
|
||||
Sami Wagiaalla <swagiaal@redhat.com>
|
||||
Samuel Archambault <sarchambault@lapresse.ca>
|
||||
Samuel Karp <skarp@amazon.com>
|
||||
Silas Sewell <silas@sewell.org>
|
||||
Simon Eskildsen <sirup@sirupsen.com>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 2015, go-dockerclient authors
|
||||
Copyright (c) 2016, go-dockerclient authors
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
@ -11,8 +11,7 @@
|
|||
cov \
|
||||
clean
|
||||
|
||||
SRCS = $(shell git ls-files '*.go' | grep -v '^external/')
|
||||
PKGS = ./. ./testing
|
||||
PKGS = . ./testing
|
||||
|
||||
all: test
|
||||
|
||||
|
@ -22,32 +21,30 @@ vendor:
|
|||
|
||||
lint:
|
||||
@ 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:
|
||||
@-go get -v golang.org/x/tools/cmd/vet
|
||||
$(foreach pkg,$(PKGS),go vet $(pkg);)
|
||||
|
||||
fmt:
|
||||
gofmt -w $(SRCS)
|
||||
gofmt -s -w $(PKGS)
|
||||
|
||||
fmtcheck:
|
||||
$(foreach file,$(SRCS),gofmt -d $(file);)
|
||||
|
||||
prepare_docker:
|
||||
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
|
||||
@ export output=$$(gofmt -s -d $(PKGS)); \
|
||||
[ -n "$${output}" ] && echo "$${output}" && export status=1; \
|
||||
exit $${status:-0}
|
||||
|
||||
pretest: lint vet fmtcheck
|
||||
|
||||
test: pretest
|
||||
gotest:
|
||||
$(foreach pkg,$(PKGS),go test $(pkg) || exit;)
|
||||
|
||||
test: pretest gotest
|
||||
|
||||
integration:
|
||||
go test -tags docker_integration -run TestIntegration -v
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
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
|
||||
passthrough to the libnetwork remote API. Note that docker's network API is
|
||||
|
|
|
@ -82,10 +82,12 @@ func parseDockerConfig(r io.Reader) (map[string]dockerConfig, error) {
|
|||
buf.ReadFrom(r)
|
||||
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 confs, ok := confsWrapper["auths"]; ok {
|
||||
return confs, nil
|
||||
if len(confsWrapper.Auths) > 0 {
|
||||
return confsWrapper.Auths, nil
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -555,6 +555,8 @@ type hijackOptions struct {
|
|||
data interface{}
|
||||
}
|
||||
|
||||
// CloseWaiter is an interface with methods for closing the underlying resource
|
||||
// and then waiting for it to finish processing.
|
||||
type CloseWaiter interface {
|
||||
io.Closer
|
||||
Wait() error
|
||||
|
@ -587,7 +589,7 @@ func (c *Client) hijack(method, path string, hijackOptions hijackOptions) (Close
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req.Header.Set("Content-Type", "plain/text")
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Connection", "Upgrade")
|
||||
req.Header.Set("Upgrade", "tcp")
|
||||
protocol := c.endpointURL.Scheme
|
||||
|
|
|
@ -14,6 +14,8 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/fsouza/go-dockerclient/external/github.com/docker/go-units"
|
||||
)
|
||||
|
||||
// ErrContainerAlreadyExists is the error returned by CreateContainer when the
|
||||
|
@ -52,7 +54,14 @@ type APIContainers struct {
|
|||
SizeRw int64 `json:"SizeRw,omitempty" yaml:"SizeRw,omitempty"`
|
||||
SizeRootFs int64 `json:"SizeRootFs,omitempty" yaml:"SizeRootFs,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.
|
||||
|
@ -92,26 +101,73 @@ func (p Port) Proto() string {
|
|||
|
||||
// State represents the state of a container.
|
||||
type State struct {
|
||||
Running bool `json:"Running,omitempty" yaml:"Running,omitempty"`
|
||||
Paused bool `json:"Paused,omitempty" yaml:"Paused,omitempty"`
|
||||
Restarting bool `json:"Restarting,omitempty" yaml:"Restarting,omitempty"`
|
||||
OOMKilled bool `json:"OOMKilled,omitempty" yaml:"OOMKilled,omitempty"`
|
||||
Pid int `json:"Pid,omitempty" yaml:"Pid,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"`
|
||||
Status string `json:"Status,omitempty" yaml:"Status,omitempty"`
|
||||
Running bool `json:"Running,omitempty" yaml:"Running,omitempty"`
|
||||
Paused bool `json:"Paused,omitempty" yaml:"Paused,omitempty"`
|
||||
Restarting bool `json:"Restarting,omitempty" yaml:"Restarting,omitempty"`
|
||||
OOMKilled bool `json:"OOMKilled,omitempty" yaml:"OOMKilled,omitempty"`
|
||||
RemovalInProgress bool `json:"RemovalInProgress,omitempty" yaml:"RemovalInProgress,omitempty"`
|
||||
Dead bool `json:"Dead,omitempty" yaml:"Dead,omitempty"`
|
||||
Pid int `json:"Pid,omitempty" yaml:"Pid,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 {
|
||||
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.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
|
||||
|
@ -135,6 +191,7 @@ type ContainerNetwork struct {
|
|||
IPAddress string `json:"IPAddress,omitempty" yaml:"IPAddress,omitempty"`
|
||||
Gateway string `json:"Gateway,omitempty" yaml:"Gateway,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
|
||||
|
@ -308,6 +365,34 @@ type Container struct {
|
|||
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.
|
||||
//
|
||||
// See https://goo.gl/laSOIy for more details.
|
||||
|
@ -469,48 +554,71 @@ type Device struct {
|
|||
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
|
||||
// a given host
|
||||
type HostConfig struct {
|
||||
Binds []string `json:"Binds,omitempty" yaml:"Binds,omitempty"`
|
||||
CapAdd []string `json:"CapAdd,omitempty" yaml:"CapAdd,omitempty"`
|
||||
CapDrop []string `json:"CapDrop,omitempty" yaml:"CapDrop,omitempty"`
|
||||
GroupAdd []string `json:"GroupAdd,omitempty" yaml:"GroupAdd,omitempty"`
|
||||
ContainerIDFile string `json:"ContainerIDFile,omitempty" yaml:"ContainerIDFile,omitempty"`
|
||||
LxcConf []KeyValuePair `json:"LxcConf,omitempty" yaml:"LxcConf,omitempty"`
|
||||
Privileged bool `json:"Privileged,omitempty" yaml:"Privileged,omitempty"`
|
||||
PortBindings map[Port][]PortBinding `json:"PortBindings,omitempty" yaml:"PortBindings,omitempty"`
|
||||
Links []string `json:"Links,omitempty" yaml:"Links,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
|
||||
DNSOptions []string `json:"DnsOptions,omitempty" yaml:"DnsOptions,omitempty"`
|
||||
DNSSearch []string `json:"DnsSearch,omitempty" yaml:"DnsSearch,omitempty"`
|
||||
ExtraHosts []string `json:"ExtraHosts,omitempty" yaml:"ExtraHosts,omitempty"`
|
||||
VolumesFrom []string `json:"VolumesFrom,omitempty" yaml:"VolumesFrom,omitempty"`
|
||||
NetworkMode string `json:"NetworkMode,omitempty" yaml:"NetworkMode,omitempty"`
|
||||
IpcMode string `json:"IpcMode,omitempty" yaml:"IpcMode,omitempty"`
|
||||
PidMode string `json:"PidMode,omitempty" yaml:"PidMode,omitempty"`
|
||||
UTSMode string `json:"UTSMode,omitempty" yaml:"UTSMode,omitempty"`
|
||||
RestartPolicy RestartPolicy `json:"RestartPolicy,omitempty" yaml:"RestartPolicy,omitempty"`
|
||||
Devices []Device `json:"Devices,omitempty" yaml:"Devices,omitempty"`
|
||||
LogConfig LogConfig `json:"LogConfig,omitempty" yaml:"LogConfig,omitempty"`
|
||||
ReadonlyRootfs bool `json:"ReadonlyRootfs,omitempty" yaml:"ReadonlyRootfs,omitempty"`
|
||||
SecurityOpt []string `json:"SecurityOpt,omitempty" yaml:"SecurityOpt,omitempty"`
|
||||
CgroupParent string `json:"CgroupParent,omitempty" yaml:"CgroupParent,omitempty"`
|
||||
Memory int64 `json:"Memory,omitempty" yaml:"Memory,omitempty"`
|
||||
MemorySwap int64 `json:"MemorySwap,omitempty" yaml:"MemorySwap,omitempty"`
|
||||
MemorySwappiness int64 `json:"MemorySwappiness,omitempty" yaml:"MemorySwappiness,omitempty"`
|
||||
OOMKillDisable bool `json:"OomKillDisable,omitempty" yaml:"OomKillDisable"`
|
||||
CPUShares int64 `json:"CpuShares,omitempty" yaml:"CpuShares,omitempty"`
|
||||
CPUSet string `json:"Cpuset,omitempty" yaml:"Cpuset,omitempty"`
|
||||
CPUSetCPUs string `json:"CpusetCpus,omitempty" yaml:"CpusetCpus,omitempty"`
|
||||
CPUSetMEMs string `json:"CpusetMems,omitempty" yaml:"CpusetMems,omitempty"`
|
||||
CPUQuota int64 `json:"CpuQuota,omitempty" yaml:"CpuQuota,omitempty"`
|
||||
CPUPeriod int64 `json:"CpuPeriod,omitempty" yaml:"CpuPeriod,omitempty"`
|
||||
BlkioWeight int64 `json:"BlkioWeight,omitempty" yaml:"BlkioWeight"`
|
||||
Ulimits []ULimit `json:"Ulimits,omitempty" yaml:"Ulimits,omitempty"`
|
||||
VolumeDriver string `json:"VolumeDriver,omitempty" yaml:"VolumeDriver,omitempty"`
|
||||
OomScoreAdj int `json:"OomScoreAdj,omitempty" yaml:"OomScoreAdj,omitempty"`
|
||||
Binds []string `json:"Binds,omitempty" yaml:"Binds,omitempty"`
|
||||
CapAdd []string `json:"CapAdd,omitempty" yaml:"CapAdd,omitempty"`
|
||||
CapDrop []string `json:"CapDrop,omitempty" yaml:"CapDrop,omitempty"`
|
||||
GroupAdd []string `json:"GroupAdd,omitempty" yaml:"GroupAdd,omitempty"`
|
||||
ContainerIDFile string `json:"ContainerIDFile,omitempty" yaml:"ContainerIDFile,omitempty"`
|
||||
LxcConf []KeyValuePair `json:"LxcConf,omitempty" yaml:"LxcConf,omitempty"`
|
||||
Privileged bool `json:"Privileged,omitempty" yaml:"Privileged,omitempty"`
|
||||
PortBindings map[Port][]PortBinding `json:"PortBindings,omitempty" yaml:"PortBindings,omitempty"`
|
||||
Links []string `json:"Links,omitempty" yaml:"Links,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
|
||||
DNSOptions []string `json:"DnsOptions,omitempty" yaml:"DnsOptions,omitempty"`
|
||||
DNSSearch []string `json:"DnsSearch,omitempty" yaml:"DnsSearch,omitempty"`
|
||||
ExtraHosts []string `json:"ExtraHosts,omitempty" yaml:"ExtraHosts,omitempty"`
|
||||
VolumesFrom []string `json:"VolumesFrom,omitempty" yaml:"VolumesFrom,omitempty"`
|
||||
NetworkMode string `json:"NetworkMode,omitempty" yaml:"NetworkMode,omitempty"`
|
||||
IpcMode string `json:"IpcMode,omitempty" yaml:"IpcMode,omitempty"`
|
||||
PidMode string `json:"PidMode,omitempty" yaml:"PidMode,omitempty"`
|
||||
UTSMode string `json:"UTSMode,omitempty" yaml:"UTSMode,omitempty"`
|
||||
RestartPolicy RestartPolicy `json:"RestartPolicy,omitempty" yaml:"RestartPolicy,omitempty"`
|
||||
Devices []Device `json:"Devices,omitempty" yaml:"Devices,omitempty"`
|
||||
LogConfig LogConfig `json:"LogConfig,omitempty" yaml:"LogConfig,omitempty"`
|
||||
ReadonlyRootfs bool `json:"ReadonlyRootfs,omitempty" yaml:"ReadonlyRootfs,omitempty"`
|
||||
SecurityOpt []string `json:"SecurityOpt,omitempty" yaml:"SecurityOpt,omitempty"`
|
||||
CgroupParent string `json:"CgroupParent,omitempty" yaml:"CgroupParent,omitempty"`
|
||||
Memory int64 `json:"Memory,omitempty" yaml:"Memory,omitempty"`
|
||||
MemorySwap int64 `json:"MemorySwap,omitempty" yaml:"MemorySwap,omitempty"`
|
||||
MemorySwappiness int64 `json:"MemorySwappiness,omitempty" yaml:"MemorySwappiness,omitempty"`
|
||||
OOMKillDisable bool `json:"OomKillDisable,omitempty" yaml:"OomKillDisable"`
|
||||
CPUShares int64 `json:"CpuShares,omitempty" yaml:"CpuShares,omitempty"`
|
||||
CPUSet string `json:"Cpuset,omitempty" yaml:"Cpuset,omitempty"`
|
||||
CPUSetCPUs string `json:"CpusetCpus,omitempty" yaml:"CpusetCpus,omitempty"`
|
||||
CPUSetMEMs string `json:"CpusetMems,omitempty" yaml:"CpusetMems,omitempty"`
|
||||
CPUQuota int64 `json:"CpuQuota,omitempty" yaml:"CpuQuota,omitempty"`
|
||||
CPUPeriod int64 `json:"CpuPeriod,omitempty" yaml:"CpuPeriod,omitempty"`
|
||||
BlkioWeight int64 `json:"BlkioWeight,omitempty" yaml:"BlkioWeight"`
|
||||
BlkioWeightDevice []BlockWeight `json:"BlkioWeightDevice,omitempty" yaml:"BlkioWeightDevice"`
|
||||
BlkioDeviceReadBps []BlockLimit `json:"BlkioDeviceReadBps,omitempty" yaml:"BlkioDeviceReadBps"`
|
||||
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.
|
||||
|
|
|
@ -18,12 +18,38 @@ import (
|
|||
"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 {
|
||||
Status string `json:"Status,omitempty" yaml:"Status,omitempty"`
|
||||
ID string `json:"ID,omitempty" yaml:"ID,omitempty"`
|
||||
From string `json:"From,omitempty" yaml:"From,omitempty"`
|
||||
Time int64 `json:"Time,omitempty" yaml:"Time,omitempty"`
|
||||
// New API Fields in 1.22
|
||||
Action string `json:"action,omitempty"`
|
||||
Type string `json:"type,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 {
|
||||
|
@ -52,6 +78,7 @@ var (
|
|||
|
||||
// EOFEvent is sent when the event listener receives an EOF error.
|
||||
EOFEvent = &APIEvents{
|
||||
Type: "EOF",
|
||||
Status: "EOF",
|
||||
}
|
||||
)
|
||||
|
@ -297,8 +324,47 @@ func (c *Client) eventHijack(startTime int64, eventChan chan *APIEvents, errChan
|
|||
if !c.eventMonitor.isEnabled() {
|
||||
return
|
||||
}
|
||||
transformEvent(&event)
|
||||
eventChan <- &event
|
||||
}
|
||||
}(res, conn)
|
||||
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"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
14
vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/chtimes_unix.go
generated
vendored
Normal file
14
vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/chtimes_unix.go
generated
vendored
Normal 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
|
||||
}
|
27
vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/chtimes_windows.go
generated
vendored
Normal file
27
vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/chtimes_windows.go
generated
vendored
Normal 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)
|
||||
}
|
15
vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/stat_openbsd.go
generated
vendored
Normal file
15
vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/stat_openbsd.go
generated
vendored
Normal 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
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
// +build !linux,!windows,!freebsd,!solaris
|
||||
// +build !linux,!windows,!freebsd,!solaris,!openbsd
|
||||
|
||||
package system
|
||||
|
||||
|
|
12
vendor/github.com/fsouza/go-dockerclient/external/golang.org/x/net/context/context.go
generated
vendored
12
vendor/github.com/fsouza/go-dockerclient/external/golang.org/x/net/context/context.go
generated
vendored
|
@ -210,13 +210,13 @@ type CancelFunc func()
|
|||
// call cancel as soon as the operations running in this Context complete.
|
||||
func WithCancel(parent Context) (ctx Context, cancel CancelFunc) {
|
||||
c := newCancelCtx(parent)
|
||||
propagateCancel(parent, &c)
|
||||
return &c, func() { c.cancel(true, Canceled) }
|
||||
propagateCancel(parent, c)
|
||||
return c, func() { c.cancel(true, Canceled) }
|
||||
}
|
||||
|
||||
// newCancelCtx returns an initialized cancelCtx.
|
||||
func newCancelCtx(parent Context) cancelCtx {
|
||||
return cancelCtx{
|
||||
func newCancelCtx(parent Context) *cancelCtx {
|
||||
return &cancelCtx{
|
||||
Context: parent,
|
||||
done: make(chan struct{}),
|
||||
}
|
||||
|
@ -259,7 +259,7 @@ func parentCancelCtx(parent Context) (*cancelCtx, bool) {
|
|||
case *cancelCtx:
|
||||
return c, true
|
||||
case *timerCtx:
|
||||
return &c.cancelCtx, true
|
||||
return c.cancelCtx, true
|
||||
case *valueCtx:
|
||||
parent = c.Context
|
||||
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
|
||||
// delegating to cancelCtx.cancel.
|
||||
type timerCtx struct {
|
||||
cancelCtx
|
||||
*cancelCtx
|
||||
timer *time.Timer // Under cancelCtx.mu.
|
||||
|
||||
deadline time.Time
|
||||
|
|
|
@ -32,6 +32,7 @@ type APIImages struct {
|
|||
// Image is the type representing a docker image and its various properties
|
||||
type Image struct {
|
||||
ID string `json:"Id" yaml:"Id"`
|
||||
RepoTags []string `json:"RepoTags,omitempty" yaml:"RepoTags,omitempty"`
|
||||
Parent string `json:"Parent,omitempty" yaml:"Parent,omitempty"`
|
||||
Comment string `json:"Comment,omitempty" yaml:"Comment,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
|
||||
ContextDir string `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
|
||||
|
@ -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{
|
||||
setRawTerminal: true,
|
||||
rawJSONStream: opts.RawJSONStream,
|
||||
|
|
|
@ -4,7 +4,10 @@
|
|||
|
||||
package docker
|
||||
|
||||
import "strings"
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Version returns version information about the docker server.
|
||||
//
|
||||
|
@ -22,17 +25,81 @@ func (c *Client) Version() (*Env, error) {
|
|||
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.
|
||||
//
|
||||
// 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{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
var info Env
|
||||
if err := info.Decode(resp.Body); err != nil {
|
||||
var info DockerInfo
|
||||
if err := json.NewDecoder(resp.Body).Decode(&info); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &info, nil
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
package docker
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
@ -26,6 +27,7 @@ type Network struct {
|
|||
IPAM IPAMOptions
|
||||
Containers map[string]Endpoint
|
||||
Options map[string]string
|
||||
Internal bool
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// 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.
|
||||
//
|
||||
// See https://goo.gl/6GugX3 for more details.
|
||||
|
@ -158,14 +185,40 @@ func (c *Client) RemoveNetwork(id string) error {
|
|||
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 {
|
||||
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.
|
||||
func (c *Client) ConnectNetwork(id string, opts NetworkConnectionOptions) error {
|
||||
|
@ -180,7 +233,8 @@ func (c *Client) ConnectNetwork(id string, opts NetworkConnectionOptions) error
|
|||
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.
|
||||
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)
|
||||
}
|
||||
|
||||
// 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 {
|
||||
NetworkID string
|
||||
ContainerID string
|
||||
|
|
Loading…
Reference in New Issue