Browse code

Vendor engine-api 0.1.3.

Signed-off-by: David Calavera <david.calavera@gmail.com>

David Calavera authored on 2016/01/08 09:43:42
Showing 11 changed files
... ...
@@ -22,7 +22,7 @@ clone git github.com/vdemeester/shakers 3c10293ce22b900c27acad7b28656196fcc2f73b
22 22
 clone git golang.org/x/net 47990a1ba55743e6ef1affd3a14e5bac8553615d https://github.com/golang/net.git
23 23
 clone git github.com/docker/go-units 651fc226e7441360384da338d0fd37f2440ffbe3
24 24
 clone git github.com/docker/go-connections v0.1.2
25
-clone git github.com/docker/engine-api v0.1.1
25
+clone git github.com/docker/engine-api v0.1.3
26 26
 
27 27
 #get libnetwork packages
28 28
 clone git github.com/docker/libnetwork 9f0563ea8f430d8828553aac97161cbff4056436
... ...
@@ -7,16 +7,18 @@ import (
7 7
 
8 8
 	"github.com/docker/engine-api/types"
9 9
 	"github.com/docker/engine-api/types/container"
10
+	"github.com/docker/engine-api/types/network"
10 11
 )
11 12
 
12 13
 type configWrapper struct {
13 14
 	*container.Config
14
-	HostConfig *container.HostConfig
15
+	HostConfig       *container.HostConfig
16
+	NetworkingConfig *network.NetworkingConfig
15 17
 }
16 18
 
17 19
 // ContainerCreate creates a new container based in the given configuration.
18 20
 // It can be associated with a name, but it's not mandatory.
19
-func (cli *Client) ContainerCreate(config *container.Config, hostConfig *container.HostConfig, containerName string) (types.ContainerCreateResponse, error) {
21
+func (cli *Client) ContainerCreate(config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (types.ContainerCreateResponse, error) {
20 22
 	var response types.ContainerCreateResponse
21 23
 	query := url.Values{}
22 24
 	if containerName != "" {
... ...
@@ -24,8 +26,9 @@ func (cli *Client) ContainerCreate(config *container.Config, hostConfig *contain
24 24
 	}
25 25
 
26 26
 	body := configWrapper{
27
-		Config:     config,
28
-		HostConfig: hostConfig,
27
+		Config:           config,
28
+		HostConfig:       hostConfig,
29
+		NetworkingConfig: networkingConfig,
29 30
 	}
30 31
 
31 32
 	serverResp, err := cli.post("/containers/create", query, body, nil)
... ...
@@ -5,8 +5,8 @@ import (
5 5
 )
6 6
 
7 7
 // ContainerUpdate updates resources of a container
8
-func (cli *Client) ContainerUpdate(containerID string, hostConfig container.HostConfig) error {
9
-	resp, err := cli.post("/containers/"+containerID+"/update", nil, hostConfig, nil)
8
+func (cli *Client) ContainerUpdate(containerID string, updateConfig container.UpdateConfig) error {
9
+	resp, err := cli.post("/containers/"+containerID+"/update", nil, updateConfig, nil)
10 10
 	ensureReaderClosed(resp)
11 11
 	return err
12 12
 }
13 13
new file mode 100644
... ...
@@ -0,0 +1,76 @@
0
+package client
1
+
2
+import (
3
+	"io"
4
+
5
+	"github.com/docker/engine-api/types"
6
+	"github.com/docker/engine-api/types/container"
7
+	"github.com/docker/engine-api/types/filters"
8
+	"github.com/docker/engine-api/types/network"
9
+	"github.com/docker/engine-api/types/registry"
10
+)
11
+
12
+// APIClient is an interface that clients that talk with a docker server must implement.
13
+type APIClient interface {
14
+	ClientVersion() string
15
+	ContainerAttach(options types.ContainerAttachOptions) (types.HijackedResponse, error)
16
+	ContainerCommit(options types.ContainerCommitOptions) (types.ContainerCommitResponse, error)
17
+	ContainerCreate(config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (types.ContainerCreateResponse, error)
18
+	ContainerDiff(containerID string) ([]types.ContainerChange, error)
19
+	ContainerExecAttach(execID string, config types.ExecConfig) (types.HijackedResponse, error)
20
+	ContainerExecCreate(config types.ExecConfig) (types.ContainerExecCreateResponse, error)
21
+	ContainerExecInspect(execID string) (types.ContainerExecInspect, error)
22
+	ContainerExecResize(options types.ResizeOptions) error
23
+	ContainerExecStart(execID string, config types.ExecStartCheck) error
24
+	ContainerExport(containerID string) (io.ReadCloser, error)
25
+	ContainerInspect(containerID string) (types.ContainerJSON, error)
26
+	ContainerInspectWithRaw(containerID string, getSize bool) (types.ContainerJSON, []byte, error)
27
+	ContainerKill(containerID, signal string) error
28
+	ContainerList(options types.ContainerListOptions) ([]types.Container, error)
29
+	ContainerLogs(options types.ContainerLogsOptions) (io.ReadCloser, error)
30
+	ContainerPause(containerID string) error
31
+	ContainerRemove(options types.ContainerRemoveOptions) error
32
+	ContainerRename(containerID, newContainerName string) error
33
+	ContainerResize(options types.ResizeOptions) error
34
+	ContainerRestart(containerID string, timeout int) error
35
+	ContainerStatPath(containerID, path string) (types.ContainerPathStat, error)
36
+	ContainerStats(containerID string, stream bool) (io.ReadCloser, error)
37
+	ContainerStart(containerID string) error
38
+	ContainerStop(containerID string, timeout int) error
39
+	ContainerTop(containerID string, arguments []string) (types.ContainerProcessList, error)
40
+	ContainerUnpause(containerID string) error
41
+	ContainerUpdate(containerID string, updateConfig container.UpdateConfig) error
42
+	ContainerWait(containerID string) (int, error)
43
+	CopyFromContainer(containerID, srcPath string) (io.ReadCloser, types.ContainerPathStat, error)
44
+	CopyToContainer(options types.CopyToContainerOptions) error
45
+	Events(options types.EventsOptions) (io.ReadCloser, error)
46
+	ImageBuild(options types.ImageBuildOptions) (types.ImageBuildResponse, error)
47
+	ImageCreate(options types.ImageCreateOptions) (io.ReadCloser, error)
48
+	ImageHistory(imageID string) ([]types.ImageHistory, error)
49
+	ImageImport(options types.ImageImportOptions) (io.ReadCloser, error)
50
+	ImageInspectWithRaw(imageID string, getSize bool) (types.ImageInspect, []byte, error)
51
+	ImageList(options types.ImageListOptions) ([]types.Image, error)
52
+	ImageLoad(input io.Reader) (types.ImageLoadResponse, error)
53
+	ImagePull(options types.ImagePullOptions, privilegeFunc RequestPrivilegeFunc) (io.ReadCloser, error)
54
+	ImagePush(options types.ImagePushOptions, privilegeFunc RequestPrivilegeFunc) (io.ReadCloser, error)
55
+	ImageRemove(options types.ImageRemoveOptions) ([]types.ImageDelete, error)
56
+	ImageSearch(options types.ImageSearchOptions, privilegeFunc RequestPrivilegeFunc) ([]registry.SearchResult, error)
57
+	ImageSave(imageIDs []string) (io.ReadCloser, error)
58
+	ImageTag(options types.ImageTagOptions) error
59
+	Info() (types.Info, error)
60
+	NetworkConnect(networkID, containerID string, config *network.EndpointSettings) error
61
+	NetworkCreate(options types.NetworkCreate) (types.NetworkCreateResponse, error)
62
+	NetworkDisconnect(networkID, containerID string) error
63
+	NetworkInspect(networkID string) (types.NetworkResource, error)
64
+	NetworkList(options types.NetworkListOptions) ([]types.NetworkResource, error)
65
+	NetworkRemove(networkID string) error
66
+	RegistryLogin(auth types.AuthConfig) (types.AuthResponse, error)
67
+	ServerVersion() (types.Version, error)
68
+	VolumeCreate(options types.VolumeCreateRequest) (types.Volume, error)
69
+	VolumeInspect(volumeID string) (types.Volume, error)
70
+	VolumeList(filter filters.Args) (types.VolumesListResponse, error)
71
+	VolumeRemove(volumeID string) error
72
+}
73
+
74
+// Ensure that Client always implements APIClient.
75
+var _ APIClient = &Client{}
... ...
@@ -7,6 +7,7 @@ import (
7 7
 
8 8
 	"github.com/docker/engine-api/types"
9 9
 	"github.com/docker/engine-api/types/filters"
10
+	"github.com/docker/engine-api/types/network"
10 11
 )
11 12
 
12 13
 // NetworkCreate creates a new network in the docker host.
... ...
@@ -30,8 +31,11 @@ func (cli *Client) NetworkRemove(networkID string) error {
30 30
 }
31 31
 
32 32
 // NetworkConnect connects a container to an existent network in the docker host.
33
-func (cli *Client) NetworkConnect(networkID, containerID string) error {
34
-	nc := types.NetworkConnect{Container: containerID}
33
+func (cli *Client) NetworkConnect(networkID, containerID string, config *network.EndpointSettings) error {
34
+	nc := types.NetworkConnect{
35
+		Container:      containerID,
36
+		EndpointConfig: config,
37
+	}
35 38
 	resp, err := cli.post("/networks/"+networkID+"/connect", nil, nc, nil)
36 39
 	ensureReaderClosed(resp)
37 40
 	return err
... ...
@@ -1,6 +1,9 @@
1 1
 package types
2 2
 
3
-import "github.com/docker/engine-api/types/container"
3
+import (
4
+	"github.com/docker/engine-api/types/container"
5
+	"github.com/docker/engine-api/types/network"
6
+)
4 7
 
5 8
 // configs holds structs used for internal communication between the
6 9
 // frontend (such as an http server) and the backend (such as the
... ...
@@ -8,10 +11,11 @@ import "github.com/docker/engine-api/types/container"
8 8
 
9 9
 // ContainerCreateConfig is the parameter set to ContainerCreate()
10 10
 type ContainerCreateConfig struct {
11
-	Name            string
12
-	Config          *container.Config
13
-	HostConfig      *container.HostConfig
14
-	AdjustCPUShares bool
11
+	Name             string
12
+	Config           *container.Config
13
+	HostConfig       *container.HostConfig
14
+	NetworkingConfig *network.NetworkingConfig
15
+	AdjustCPUShares  bool
15 16
 }
16 17
 
17 18
 // ContainerRmConfig holds arguments for the container remove
... ...
@@ -181,9 +181,17 @@ type Resources struct {
181 181
 	MemorySwap           int64           // Total memory usage (memory + swap); set `-1` to disable swap
182 182
 	MemorySwappiness     *int64          // Tuning container memory swappiness behaviour
183 183
 	OomKillDisable       bool            // Whether to disable OOM Killer or not
184
+	PidsLimit            int64           // Setting pids limit for a container
184 185
 	Ulimits              []*units.Ulimit // List of ulimits to be set in the container
185 186
 }
186 187
 
188
+// UpdateConfig holds the mutable attributes of a Container.
189
+// Those attributes can be updated at runtime.
190
+type UpdateConfig struct {
191
+	// Contains container's resources (cgroups, ulimits)
192
+	Resources
193
+}
194
+
187 195
 // HostConfig the non-portable Config structure of a container.
188 196
 // Here, "non-portable" means "dependent of the host we are running on".
189 197
 // Portable information *should* appear in Config.
... ...
@@ -214,6 +222,7 @@ type HostConfig struct {
214 214
 	PublishAllPorts bool               // Should docker publish all exposed port for the container
215 215
 	ReadonlyRootfs  bool               // Is the container root filesystem in read-only
216 216
 	SecurityOpt     []string           // List of string values to customize labels for MLS systems, such as SELinux.
217
+	StorageOpt      []string           // Graph storage options per container
217 218
 	Tmpfs           map[string]string  `json:",omitempty"` // List of tmpfs (mounts) used for the container
218 219
 	UTSMode         UTSMode            // UTS namespace to use for the container
219 220
 	ShmSize         int64              // Total shm memory usage
... ...
@@ -10,6 +10,16 @@ func (n NetworkMode) IsDefault() bool {
10 10
 	return n == "default"
11 11
 }
12 12
 
13
+// IsNone indicates whether container isn't using a network stack.
14
+func (n NetworkMode) IsNone() bool {
15
+	return n == "none"
16
+}
17
+
18
+// IsUserDefined indicates user-created network
19
+func (n NetworkMode) IsUserDefined() bool {
20
+	return !n.IsDefault() && !n.IsNone()
21
+}
22
+
13 23
 // IsHyperV indicates the use of a Hyper-V partition for isolation
14 24
 func (i IsolationLevel) IsHyperV() bool {
15 25
 	return strings.ToLower(string(i)) == "hyperv"
... ...
@@ -20,8 +20,17 @@ type IPAMConfig struct {
20 20
 	AuxAddress map[string]string `json:"AuxiliaryAddresses,omitempty"`
21 21
 }
22 22
 
23
+// EndpointIPAMConfig represents IPAM configurations for the endpoint
24
+type EndpointIPAMConfig struct {
25
+	IPv4Address string `json:",omitempty"`
26
+	IPv6Address string `json:",omitempty"`
27
+}
28
+
23 29
 // EndpointSettings stores the network endpoint details
24 30
 type EndpointSettings struct {
31
+	// Configurations
32
+	IPAMConfig *EndpointIPAMConfig
33
+	// Operational data
25 34
 	EndpointID          string
26 35
 	Gateway             string
27 36
 	IPAddress           string
... ...
@@ -31,3 +40,9 @@ type EndpointSettings struct {
31 31
 	GlobalIPv6PrefixLen int
32 32
 	MacAddress          string
33 33
 }
34
+
35
+// NetworkingConfig represents the container's networking configuration for each of its interfaces
36
+// Carries the networink configs specified in the `docker run` and `docker network connect` commands
37
+type NetworkingConfig struct {
38
+	EndpointsConfig map[string]*EndpointSettings // Endpoint configs for each conencting network
39
+}
... ...
@@ -87,6 +87,12 @@ type NetworkStats struct {
87 87
 	TxDropped uint64 `json:"tx_dropped"`
88 88
 }
89 89
 
90
+// PidsStats contains the stats of a container's pids
91
+type PidsStats struct {
92
+	// Current is the number of pids in the cgroup
93
+	Current uint64 `json:"current,omitempty"`
94
+}
95
+
90 96
 // Stats is Ultimate struct aggregating all types of stats of one container
91 97
 type Stats struct {
92 98
 	Read        time.Time   `json:"read"`
... ...
@@ -94,6 +100,7 @@ type Stats struct {
94 94
 	CPUStats    CPUStats    `json:"cpu_stats,omitempty"`
95 95
 	MemoryStats MemoryStats `json:"memory_stats,omitempty"`
96 96
 	BlkioStats  BlkioStats  `json:"blkio_stats,omitempty"`
97
+	PidsStats   PidsStats   `json:"pids_stats,omitempty"`
97 98
 }
98 99
 
99 100
 // StatsJSON is newly used Networks
... ...
@@ -415,7 +415,8 @@ type NetworkCreateResponse struct {
415 415
 
416 416
 // NetworkConnect represents the data to be used to connect a container to the network
417 417
 type NetworkConnect struct {
418
-	Container string
418
+	Container      string
419
+	EndpointConfig *network.EndpointSettings `json:"endpoint_config"`
419 420
 }
420 421
 
421 422
 // NetworkDisconnect represents the data to be used to disconnect a container from the network