Browse code

Revert "Move Cluster provider back to Moby"

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>

Flavio Crisciani authored on 2017/05/26 02:45:38
Showing 118 changed files
... ...
@@ -11,9 +11,9 @@ import (
11 11
 	"sync"
12 12
 
13 13
 	"github.com/Sirupsen/logrus"
14
-	"github.com/docker/docker/daemon/cluster/provider"
15 14
 	"github.com/docker/docker/pkg/stringid"
16 15
 	"github.com/docker/go-events"
16
+	"github.com/docker/libnetwork/cluster"
17 17
 	"github.com/docker/libnetwork/datastore"
18 18
 	"github.com/docker/libnetwork/discoverapi"
19 19
 	"github.com/docker/libnetwork/driverapi"
... ...
@@ -193,7 +193,7 @@ func (c *controller) handleKeyChange(keys []*types.EncryptionKey) error {
193 193
 	return nil
194 194
 }
195 195
 
196
-func (c *controller) agentSetup(clusterProvider provider.Cluster) error {
196
+func (c *controller) agentSetup(clusterProvider cluster.Provider) error {
197 197
 	agent := c.getAgent()
198 198
 
199 199
 	// If the agent is already present there is no need to try to initilize it again
200 200
new file mode 100644
... ...
@@ -0,0 +1,36 @@
0
+package cluster
1
+
2
+import (
3
+	"github.com/docker/docker/api/types/network"
4
+	"golang.org/x/net/context"
5
+)
6
+
7
+const (
8
+	// EventSocketChange control socket changed
9
+	EventSocketChange = iota
10
+	// EventNodeReady cluster node in ready state
11
+	EventNodeReady
12
+	// EventNodeLeave node is leaving the cluster
13
+	EventNodeLeave
14
+	// EventNetworkKeysAvailable network keys correctly configured in the networking layer
15
+	EventNetworkKeysAvailable
16
+)
17
+
18
+// ConfigEventType type of the event produced by the cluster
19
+type ConfigEventType uint8
20
+
21
+// Provider provides clustering config details
22
+type Provider interface {
23
+	IsManager() bool
24
+	IsAgent() bool
25
+	GetLocalAddress() string
26
+	GetListenAddress() string
27
+	GetAdvertiseAddress() string
28
+	GetDataPathAddress() string
29
+	GetRemoteAddressList() []string
30
+	ListenClusterEvents() <-chan ConfigEventType
31
+	AttachNetwork(string, string, []string) (*network.NetworkingConfig, error)
32
+	DetachNetwork(string, string) error
33
+	UpdateAttachment(string, string, *network.NetworkingConfig) error
34
+	WaitForDetachment(context.Context, string, string, string, string) error
35
+}
... ...
@@ -24,10 +24,10 @@ import (
24 24
 
25 25
 	"github.com/Sirupsen/logrus"
26 26
 	"github.com/docker/docker/api/types/network"
27
-	"github.com/docker/docker/daemon/cluster/provider"
28 27
 	"github.com/docker/docker/pkg/term"
29 28
 	"github.com/docker/libnetwork"
30 29
 	"github.com/docker/libnetwork/api"
30
+	"github.com/docker/libnetwork/cluster"
31 31
 	"github.com/docker/libnetwork/config"
32 32
 	"github.com/docker/libnetwork/datastore"
33 33
 	"github.com/docker/libnetwork/driverapi"
... ...
@@ -235,7 +235,7 @@ type dnetConnection struct {
235 235
 	// addr holds the client address.
236 236
 	addr          string
237 237
 	Orchestration *NetworkOrchestration
238
-	configEvent   chan provider.ClusterConfigEventType
238
+	configEvent   chan cluster.ConfigEventType
239 239
 }
240 240
 
241 241
 // NetworkOrchestration exported
... ...
@@ -276,7 +276,7 @@ func (d *dnetConnection) dnetDaemon(cfgFile string) error {
276 276
 	controller.SetClusterProvider(d)
277 277
 
278 278
 	if d.Orchestration.Agent || d.Orchestration.Manager {
279
-		d.configEvent <- provider.ClusterEventNodeReady
279
+		d.configEvent <- cluster.EventNodeReady
280 280
 	}
281 281
 
282 282
 	createDefaultNetwork(controller)
... ...
@@ -336,7 +336,7 @@ func (d *dnetConnection) GetNetworkKeys() []*types.EncryptionKey {
336 336
 func (d *dnetConnection) SetNetworkKeys([]*types.EncryptionKey) {
337 337
 }
338 338
 
339
-func (d *dnetConnection) ListenClusterEvents() <-chan provider.ClusterConfigEventType {
339
+func (d *dnetConnection) ListenClusterEvents() <-chan cluster.ConfigEventType {
340 340
 	return d.configEvent
341 341
 }
342 342
 
... ...
@@ -439,7 +439,7 @@ func newDnetConnection(val string) (*dnetConnection, error) {
439 439
 		return nil, errors.New("dnet currently only supports tcp transport")
440 440
 	}
441 441
 
442
-	return &dnetConnection{protoAddrParts[0], protoAddrParts[1], &NetworkOrchestration{}, make(chan provider.ClusterConfigEventType, 10)}, nil
442
+	return &dnetConnection{protoAddrParts[0], protoAddrParts[1], &NetworkOrchestration{}, make(chan cluster.ConfigEventType, 10)}, nil
443 443
 }
444 444
 
445 445
 func (d *dnetConnection) httpCall(method, path string, data interface{}, headers map[string][]string) (io.ReadCloser, http.Header, int, error) {
... ...
@@ -5,11 +5,11 @@ import (
5 5
 
6 6
 	"github.com/BurntSushi/toml"
7 7
 	"github.com/Sirupsen/logrus"
8
-	"github.com/docker/docker/daemon/cluster/provider"
9 8
 	"github.com/docker/docker/pkg/discovery"
10 9
 	"github.com/docker/docker/pkg/plugingetter"
11 10
 	"github.com/docker/go-connections/tlsconfig"
12 11
 	"github.com/docker/libkv/store"
12
+	"github.com/docker/libnetwork/cluster"
13 13
 	"github.com/docker/libnetwork/datastore"
14 14
 	"github.com/docker/libnetwork/netlabel"
15 15
 	"github.com/docker/libnetwork/osl"
... ...
@@ -33,7 +33,7 @@ type DaemonCfg struct {
33 33
 	DefaultDriver   string
34 34
 	Labels          []string
35 35
 	DriverCfg       map[string]interface{}
36
-	ClusterProvider provider.Cluster
36
+	ClusterProvider cluster.Provider
37 37
 }
38 38
 
39 39
 // ClusterCfg represents cluster configuration
... ...
@@ -53,12 +53,12 @@ import (
53 53
 	"time"
54 54
 
55 55
 	"github.com/Sirupsen/logrus"
56
-	"github.com/docker/docker/daemon/cluster/provider"
57 56
 	"github.com/docker/docker/pkg/discovery"
58 57
 	"github.com/docker/docker/pkg/locker"
59 58
 	"github.com/docker/docker/pkg/plugingetter"
60 59
 	"github.com/docker/docker/pkg/plugins"
61 60
 	"github.com/docker/docker/pkg/stringid"
61
+	"github.com/docker/libnetwork/cluster"
62 62
 	"github.com/docker/libnetwork/config"
63 63
 	"github.com/docker/libnetwork/datastore"
64 64
 	"github.com/docker/libnetwork/discoverapi"
... ...
@@ -123,7 +123,7 @@ type NetworkController interface {
123 123
 	ReloadConfiguration(cfgOptions ...config.Option) error
124 124
 
125 125
 	// SetClusterProvider sets cluster provider
126
-	SetClusterProvider(provider provider.Cluster)
126
+	SetClusterProvider(provider cluster.Provider)
127 127
 
128 128
 	// Wait for agent initialization complete in libnetwork controller
129 129
 	AgentInitWait()
... ...
@@ -243,7 +243,7 @@ func New(cfgOptions ...config.Option) (NetworkController, error) {
243 243
 	return c, nil
244 244
 }
245 245
 
246
-func (c *controller) SetClusterProvider(provider provider.Cluster) {
246
+func (c *controller) SetClusterProvider(provider cluster.Provider) {
247 247
 	var sameProvider bool
248 248
 	c.Lock()
249 249
 	// Avoids to spawn multiple goroutine for the same cluster provider
... ...
@@ -307,17 +307,17 @@ func (c *controller) clusterAgentInit() {
307 307
 	var keysAvailable bool
308 308
 	for {
309 309
 		eventType := <-clusterProvider.ListenClusterEvents()
310
-		// The events: ClusterEventSocketChange, ClusterEventNodeReady and ClusterEventNetworkKeysAvailable are not ordered
310
+		// The events: EventSocketChange, EventNodeReady and EventNetworkKeysAvailable are not ordered
311 311
 		// when all the condition for the agent initialization are met then proceed with it
312 312
 		switch eventType {
313
-		case provider.ClusterEventNetworkKeysAvailable:
313
+		case cluster.EventNetworkKeysAvailable:
314 314
 			// Validates that the keys are actually available before starting the initialization
315 315
 			// This will handle old spurious messages left on the channel
316 316
 			c.Lock()
317 317
 			keysAvailable = c.keys != nil
318 318
 			c.Unlock()
319 319
 			fallthrough
320
-		case provider.ClusterEventSocketChange, provider.ClusterEventNodeReady:
320
+		case cluster.EventSocketChange, cluster.EventNodeReady:
321 321
 			if keysAvailable && !c.isDistributedControl() {
322 322
 				c.agentOperationStart()
323 323
 				if err := c.agentSetup(clusterProvider); err != nil {
... ...
@@ -326,7 +326,7 @@ func (c *controller) clusterAgentInit() {
326 326
 					c.agentInitComplete()
327 327
 				}
328 328
 			}
329
-		case provider.ClusterEventNodeLeave:
329
+		case cluster.EventNodeLeave:
330 330
 			keysAvailable = false
331 331
 			c.agentOperationStart()
332 332
 			c.Lock()
... ...
@@ -11,7 +11,7 @@ github.com/coreos/etcd 925d1d74cec8c3b169c52fd4b2dc234a35934fce
11 11
 github.com/coreos/go-systemd b4a58d95188dd092ae20072bac14cece0e67c388
12 12
 github.com/deckarep/golang-set ef32fa3046d9f249d399f98ebaf9be944430fd1d
13 13
 
14
-github.com/docker/docker e18f50891a92786c43d467e012a2404edab416d3 https://github.com/fcrisciani/docker
14
+github.com/docker/docker 9c96768eae4b3a65147b47a55c850c103ab8972d
15 15
 github.com/docker/go-connections 34b5052da6b11e27f5f2e357b38b571ddddd3928
16 16
 github.com/docker/go-events 2e7d352816128aa84f4d29b2a21d400133701a0d
17 17
 github.com/docker/go-units 8e2d4523730c73120e10d4652f36ad6010998f4e
... ...
@@ -19,11 +19,11 @@ github.com/docker/libkv 1d8431073ae03cdaedb198a89722f3aab6d418ef
19 19
 
20 20
 github.com/godbus/dbus 5f6efc7ef2759c81b7ba876593971bfce311eab3
21 21
 github.com/gogo/protobuf 8d70fb3182befc465c4a1eac8ad4d38ff49778e2
22
-github.com/golang/protobuf f7137ae6b19afbfd61a94b746fda3b3fe0491874
22
+github.com/golang/protobuf/proto f7137ae6b19afbfd61a94b746fda3b3fe0491874
23 23
 github.com/gorilla/context 215affda49addc4c8ef7e2534915df2c8c35c6cd
24 24
 github.com/gorilla/mux 8096f47503459bcc74d1f4c487b7e6e42e5746b5
25
-github.com/hashicorp/consul 954aec66231b79c161a4122b023fbcad13047f79
26
-github.com/hashicorp/go-msgpack 71c2886f5a673a35f909803f38ece5810165097b
25
+github.com/hashicorp/consul/api 954aec66231b79c161a4122b023fbcad13047f79
26
+github.com/hashicorp/go-msgpack/codec 71c2886f5a673a35f909803f38ece5810165097b
27 27
 github.com/hashicorp/go-multierror 2167c8ec40776024589f483a6b836489e47e1049
28 28
 github.com/hashicorp/memberlist v0.1.0
29 29
 github.com/sean-/seed e2103e2c35297fb7e17febb81e49b312087a2372
... ...
@@ -31,13 +31,11 @@ github.com/hashicorp/go-sockaddr acd314c5781ea706c710d9ea70069fd2e110d61d
31 31
 github.com/hashicorp/serf 598c54895cc5a7b1a24a398d635e8c0ea0959870
32 32
 github.com/mattn/go-shellwords 525bedee691b5a8df547cb5cf9f86b7fb1883e24
33 33
 github.com/miekg/dns d27455715200c7d3e321a1e5cadb27c9ee0b0f02
34
-github.com/opencontainers/runc ba1568de399395774ad84c2ace65937814c542ed
35
-github.com/opencontainers/image-spec 56b55a17598362bd1bf78c9c307738335a2510eb
36
-github.com/opencontainers/go-digest eaa60544f31ccf3b0653b1a118b76d33418ff41b
37
-github.com/samuel/go-zookeeper d0e0d8e11f318e000a8cc434616d69e329edc374
34
+github.com/opencontainers/runc/libcontainer ba1568de399395774ad84c2ace65937814c542ed
35
+github.com/samuel/go-zookeeper/zk d0e0d8e11f318e000a8cc434616d69e329edc374
38 36
 github.com/seccomp/libseccomp-golang 1b506fc7c24eec5a3693cdcbed40d9c226cfc6a1
39 37
 github.com/stretchr/testify dab07ac62d4905d3e48d17dc549c684ac3b7c15a
40
-github.com/syndtr/gocapability 2c00daeb6c3b45114c80ac44119e7b8801fdd852
38
+github.com/syndtr/gocapability/capability 2c00daeb6c3b45114c80ac44119e7b8801fdd852
41 39
 github.com/ugorji/go f1f1a805ed361a0e078bb537e4ea78cd37dcf065
42 40
 github.com/vishvananda/netlink 1e86b2bee5b6a7d377e4c02bb7f98209d6a7297c
43 41
 github.com/vishvananda/netns 604eaf189ee867d8c147fafc28def2394e878d25
... ...
@@ -176,7 +176,7 @@
176 176
 
177 177
    END OF TERMS AND CONDITIONS
178 178
 
179
-   Copyright 2013-2017 Docker, Inc.
179
+   Copyright 2013-2016 Docker, Inc.
180 180
 
181 181
    Licensed under the Apache License, Version 2.0 (the "License");
182 182
    you may not use this file except in compliance with the License.
... ...
@@ -1,5 +1,5 @@
1 1
 Docker
2
-Copyright 2012-2017 Docker, Inc.
2
+Copyright 2012-2016 Docker, Inc.
3 3
 
4 4
 This product includes software developed at Docker, Inc. (https://www.docker.com).
5 5
 
... ...
@@ -1,80 +1,270 @@
1
-### Docker users, see [Moby and Docker](https://mobyproject.org/#moby-and-docker) to clarify the relationship between the projects
1
+Docker: the container engine [![Release](https://img.shields.io/github/release/docker/docker.svg)](https://github.com/docker/docker/releases/latest)
2
+============================
2 3
 
3
-### Docker maintainers and contributors, see [Transitioning to Moby](#transitioning-to-moby) for more details
4
+Docker is an open source project to pack, ship and run any application
5
+as a lightweight container.
4 6
 
5
-The Moby Project
6
-================
7
+Docker containers are both *hardware-agnostic* and *platform-agnostic*.
8
+This means they can run anywhere, from your laptop to the largest
9
+cloud compute instance and everything in between - and they don't require
10
+you to use a particular language, framework or packaging system. That
11
+makes them great building blocks for deploying and scaling web apps,
12
+databases, and backend services without depending on a particular stack
13
+or provider.
7 14
 
8
-![Moby Project logo](docs/static_files/moby-project-logo.png "The Moby Project")
15
+Docker began as an open-source implementation of the deployment engine which
16
+powered [dotCloud](http://web.archive.org/web/20130530031104/https://www.dotcloud.com/),
17
+a popular Platform-as-a-Service. It benefits directly from the experience
18
+accumulated over several years of large-scale operation and support of hundreds
19
+of thousands of applications and databases.
9 20
 
10
-Moby is an open-source project created by Docker to advance the software containerization movement.
11
-It provides a “Lego set” of dozens of components, the framework for assembling them into custom container-based systems, and a place for all container enthusiasts to experiment and exchange ideas.
21
+![Docker logo](docs/static_files/docker-logo-compressed.png "Docker")
12 22
 
13
-# Moby
23
+## Security Disclosure
14 24
 
15
-## Overview
25
+Security is very important to us. If you have any issue regarding security,
26
+please disclose the information responsibly by sending an email to
27
+security@docker.com and not by creating a GitHub issue.
16 28
 
17
-At the core of Moby is a framework to assemble specialized container systems.
18
-It provides:
29
+## Better than VMs
19 30
 
20
-- A library of containerized components for all vital aspects of a container system: OS, container runtime, orchestration, infrastructure management, networking, storage, security, build, image distribution, etc.
21
-- Tools to assemble the components into runnable artifacts for a variety of platforms and architectures: bare metal (both x86 and Arm); executables for Linux, Mac and Windows; VM images for popular cloud and virtualization providers.
22
-- A set of reference assemblies which can be used as-is, modified, or used as inspiration to create your own.
31
+A common method for distributing applications and sandboxing their
32
+execution is to use virtual machines, or VMs. Typical VM formats are
33
+VMware's vmdk, Oracle VirtualBox's vdi, and Amazon EC2's ami. In theory
34
+these formats should allow every developer to automatically package
35
+their application into a "machine" for easy distribution and deployment.
36
+In practice, that almost never happens, for a few reasons:
23 37
 
24
-All Moby components are containers, so creating new components is as easy as building a new OCI-compatible container.
38
+  * *Size*: VMs are very large which makes them impractical to store
39
+     and transfer.
40
+  * *Performance*: running VMs consumes significant CPU and memory,
41
+    which makes them impractical in many scenarios, for example local
42
+    development of multi-tier applications, and large-scale deployment
43
+    of cpu and memory-intensive applications on large numbers of
44
+    machines.
45
+  * *Portability*: competing VM environments don't play well with each
46
+     other. Although conversion tools do exist, they are limited and
47
+     add even more overhead.
48
+  * *Hardware-centric*: VMs were designed with machine operators in
49
+    mind, not software developers. As a result, they offer very
50
+    limited tooling for what developers need most: building, testing
51
+    and running their software. For example, VMs offer no facilities
52
+    for application versioning, monitoring, configuration, logging or
53
+    service discovery.
25 54
 
26
-## Principles
55
+By contrast, Docker relies on a different sandboxing method known as
56
+*containerization*. Unlike traditional virtualization, containerization
57
+takes place at the kernel level. Most modern operating system kernels
58
+now support the primitives necessary for containerization, including
59
+Linux with [openvz](https://openvz.org),
60
+[vserver](http://linux-vserver.org) and more recently
61
+[lxc](https://linuxcontainers.org/), Solaris with
62
+[zones](https://docs.oracle.com/cd/E26502_01/html/E29024/preface-1.html#scrolltoc),
63
+and FreeBSD with
64
+[Jails](https://www.freebsd.org/doc/handbook/jails.html).
27 65
 
28
-Moby is an open project guided by strong principles, but modular, flexible and without too strong an opinion on user experience, so it is open to the community to help set its direction.
29
-The guiding principles are:
66
+Docker builds on top of these low-level primitives to offer developers a
67
+portable format and runtime environment that solves all four problems.
68
+Docker containers are small (and their transfer can be optimized with
69
+layers), they have basically zero memory and cpu overhead, they are
70
+completely portable, and are designed from the ground up with an
71
+application-centric design.
30 72
 
31
-- Batteries included but swappable: Moby includes enough components to build fully featured container system, but its modular architecture ensures that most of the components can be swapped by different implementations.
32
-- Usable security: Moby will provide secure defaults without compromising usability.
33
-- Container centric: Moby is built with containers, for running containers.
73
+Perhaps best of all, because Docker operates at the OS level, it can still be
74
+run inside a VM!
34 75
 
35
-With Moby, you should be able to describe all the components of your distributed application, from the high-level configuration files down to the kernel you would like to use and build and deploy it easily.
76
+## Plays well with others
36 77
 
37
-Moby uses [containerd](https://github.com/containerd/containerd) as the default container runtime.
78
+Docker does not require you to buy into a particular programming
79
+language, framework, packaging system, or configuration language.
38 80
 
39
-## Audience
81
+Is your application a Unix process? Does it use files, tcp connections,
82
+environment variables, standard Unix streams and command-line arguments
83
+as inputs and outputs? Then Docker can run it.
40 84
 
41
-Moby is recommended for anyone who wants to assemble a container-based system. This includes:
85
+Can your application's build be expressed as a sequence of such
86
+commands? Then Docker can build it.
42 87
 
43
-- Hackers who want to customize or patch their Docker build
44
-- System engineers or integrators building a container system
45
-- Infrastructure providers looking to adapt existing container systems to their environment
46
-- Container enthusiasts who want to experiment with the latest container tech
47
-- Open-source developers looking to test their project in a variety of different systems
48
-- Anyone curious about Docker internals and how it’s built
88
+## Escape dependency hell
49 89
 
50
-Moby is NOT recommended for:
90
+A common problem for developers is the difficulty of managing all
91
+their application's dependencies in a simple and automated way.
51 92
 
52
-- Application developers looking for an easy way to run their applications in containers. We recommend Docker CE instead.
53
-- Enterprise IT and development teams looking for a ready-to-use, commercially supported container platform. We recommend Docker EE instead.
54
-- Anyone curious about containers and looking for an easy way to learn. We recommend the docker.com website instead.
93
+This is usually difficult for several reasons:
55 94
 
56
-# Transitioning to Moby
95
+  * *Cross-platform dependencies*. Modern applications often depend on
96
+    a combination of system libraries and binaries, language-specific
97
+    packages, framework-specific modules, internal components
98
+    developed for another project, etc. These dependencies live in
99
+    different "worlds" and require different tools - these tools
100
+    typically don't work well with each other, requiring awkward
101
+    custom integrations.
57 102
 
58
-Docker is transitioning all of its open source collaborations to the Moby project going forward.
59
-During the transition, all open source activity should continue as usual.
103
+  * *Conflicting dependencies*. Different applications may depend on
104
+    different versions of the same dependency. Packaging tools handle
105
+    these situations with various degrees of ease - but they all
106
+    handle them in different and incompatible ways, which again forces
107
+    the developer to do extra work.
60 108
 
61
-We are proposing the following list of changes:
109
+  * *Custom dependencies*. A developer may need to prepare a custom
110
+    version of their application's dependency. Some packaging systems
111
+    can handle custom versions of a dependency, others can't - and all
112
+    of them handle it differently.
62 113
 
63
-- splitting up the engine into more open components
64
-- removing the docker UI, SDK etc to keep them in the Docker org
65
-- clarifying that the project is not limited to the engine, but to the assembly of all the individual components of the Docker platform
66
-- open-source new tools & components which we currently use to assemble the Docker product, but could benefit the community
67
-- defining an open, community-centric governance inspired by the Fedora project (a very successful example of balancing the needs of the community with the constraints of the primary corporate sponsor)
68 114
 
115
+Docker solves the problem of dependency hell by giving the developer a simple
116
+way to express *all* their application's dependencies in one place, while
117
+streamlining the process of assembling them. If this makes you think of
118
+[XKCD 927](https://xkcd.com/927/), don't worry. Docker doesn't
119
+*replace* your favorite packaging systems. It simply orchestrates
120
+their use in a simple and repeatable way. How does it do that? With
121
+layers.
69 122
 
70
-Legal
71
-=====
123
+Docker defines a build as running a sequence of Unix commands, one
124
+after the other, in the same container. Build commands modify the
125
+contents of the container (usually by installing new files on the
126
+filesystem), the next command modifies it some more, etc. Since each
127
+build command inherits the result of the previous commands, the
128
+*order* in which the commands are executed expresses *dependencies*.
129
+
130
+Here's a typical Docker build process:
131
+
132
+```bash
133
+FROM ubuntu:12.04
134
+RUN apt-get update && apt-get install -y python python-pip curl
135
+RUN curl -sSL https://github.com/shykes/helloflask/archive/master.tar.gz | tar -xzv
136
+RUN cd helloflask-master && pip install -r requirements.txt
137
+```
138
+
139
+Note that Docker doesn't care *how* dependencies are built - as long
140
+as they can be built by running a Unix command in a container.
141
+
142
+
143
+Getting started
144
+===============
145
+
146
+Docker can be installed either on your computer for building applications or
147
+on servers for running them. To get started, [check out the installation
148
+instructions in the
149
+documentation](https://docs.docker.com/engine/installation/).
150
+
151
+Usage examples
152
+==============
153
+
154
+Docker can be used to run short-lived commands, long-running daemons
155
+(app servers, databases, etc.), interactive shell sessions, etc.
156
+
157
+You can find a [list of real-world
158
+examples](https://docs.docker.com/engine/examples/) in the
159
+documentation.
160
+
161
+Under the hood
162
+--------------
163
+
164
+Under the hood, Docker is built on the following components:
165
+
166
+* The
167
+  [cgroups](https://www.kernel.org/doc/Documentation/cgroup-v1/cgroups.txt)
168
+  and
169
+  [namespaces](http://man7.org/linux/man-pages/man7/namespaces.7.html)
170
+  capabilities of the Linux kernel
171
+* The [Go](https://golang.org) programming language
172
+* The [Docker Image Specification](https://github.com/docker/docker/blob/master/image/spec/v1.md)
173
+* The [Libcontainer Specification](https://github.com/opencontainers/runc/blob/master/libcontainer/SPEC.md)
174
+
175
+Contributing to Docker [![GoDoc](https://godoc.org/github.com/docker/docker?status.svg)](https://godoc.org/github.com/docker/docker)
176
+======================
177
+
178
+| **Master** (Linux) | **Experimental** (Linux) | **Windows** | **FreeBSD** |
179
+|------------------|----------------------|---------|---------|
180
+| [![Jenkins Build Status](https://jenkins.dockerproject.org/view/Docker/job/Docker%20Master/badge/icon)](https://jenkins.dockerproject.org/view/Docker/job/Docker%20Master/) | [![Jenkins Build Status](https://jenkins.dockerproject.org/view/Docker/job/Docker%20Master%20%28experimental%29/badge/icon)](https://jenkins.dockerproject.org/view/Docker/job/Docker%20Master%20%28experimental%29/) | [![Build Status](http://jenkins.dockerproject.org/job/Docker%20Master%20(windows)/badge/icon)](http://jenkins.dockerproject.org/job/Docker%20Master%20(windows)/) | [![Build Status](http://jenkins.dockerproject.org/job/Docker%20Master%20(freebsd)/badge/icon)](http://jenkins.dockerproject.org/job/Docker%20Master%20(freebsd)/) |
181
+
182
+Want to hack on Docker? Awesome! We have [instructions to help you get
183
+started contributing code or documentation](https://docs.docker.com/opensource/project/who-written-for/).
184
+
185
+These instructions are probably not perfect, please let us know if anything
186
+feels wrong or incomplete. Better yet, submit a PR and improve them yourself.
187
+
188
+Getting the development builds
189
+==============================
190
+
191
+Want to run Docker from a master build? You can download
192
+master builds at [master.dockerproject.org](https://master.dockerproject.org).
193
+They are updated with each commit merged into the master branch.
194
+
195
+Don't know how to use that super cool new feature in the master build? Check
196
+out the master docs at
197
+[docs.master.dockerproject.org](http://docs.master.dockerproject.org).
198
+
199
+How the project is run
200
+======================
201
+
202
+Docker is a very, very active project. If you want to learn more about how it is run,
203
+or want to get more involved, the best place to start is [the project directory](https://github.com/docker/docker/tree/master/project).
204
+
205
+We are always open to suggestions on process improvements, and are always looking for more maintainers.
206
+
207
+### Talking to other Docker users and contributors
208
+
209
+<table class="tg">
210
+  <col width="45%">
211
+  <col width="65%">
212
+  <tr>
213
+    <td>Internet&nbsp;Relay&nbsp;Chat&nbsp;(IRC)</td>
214
+    <td>
215
+      <p>
216
+        IRC is a direct line to our most knowledgeable Docker users; we have
217
+        both the  <code>#docker</code> and <code>#docker-dev</code> group on
218
+        <strong>irc.freenode.net</strong>.
219
+        IRC is a rich chat protocol but it can overwhelm new users. You can search
220
+        <a href="https://botbot.me/freenode/docker/#" target="_blank">our chat archives</a>.
221
+      </p>
222
+      Read our <a href="https://docs.docker.com/opensource/get-help/#/irc-quickstart" target="_blank">IRC quickstart guide</a> for an easy way to get started.
223
+    </td>
224
+  </tr>
225
+  <tr>
226
+    <td>Docker Community Forums</td>
227
+    <td>
228
+      The <a href="https://forums.docker.com/c/open-source-projects/de" target="_blank">Docker Engine</a>
229
+      group is for users of the Docker Engine project.
230
+    </td>
231
+  </tr>
232
+  <tr>
233
+    <td>Google Groups</td>
234
+    <td>
235
+      The <a href="https://groups.google.com/forum/#!forum/docker-dev"
236
+      target="_blank">docker-dev</a> group is for contributors and other people
237
+      contributing to the Docker project.  You can join this group without a
238
+      Google account by sending an email to <a
239
+      href="mailto:docker-dev+subscribe@googlegroups.com">docker-dev+subscribe@googlegroups.com</a>.
240
+      You'll receive a join-request message; simply reply to the message to
241
+      confirm your subscription.
242
+    </td>
243
+  </tr>
244
+  <tr>
245
+    <td>Twitter</td>
246
+    <td>
247
+      You can follow <a href="https://twitter.com/docker/" target="_blank">Docker's Twitter feed</a>
248
+      to get updates on our products. You can also tweet us questions or just
249
+      share blogs or stories.
250
+    </td>
251
+  </tr>
252
+  <tr>
253
+    <td>Stack Overflow</td>
254
+    <td>
255
+      Stack Overflow has over 7000 Docker questions listed. We regularly
256
+      monitor <a href="https://stackoverflow.com/search?tab=newest&q=docker" target="_blank">Docker questions</a>
257
+      and so do many other knowledgeable Docker users.
258
+    </td>
259
+  </tr>
260
+</table>
261
+
262
+### Legal
72 263
 
73 264
 *Brought to you courtesy of our legal counsel. For more context,
74
-please see the [NOTICE](https://github.com/moby/moby/blob/master/NOTICE) document in this repo.*
265
+please see the [NOTICE](https://github.com/docker/docker/blob/master/NOTICE) document in this repo.*
75 266
 
76
-Use and transfer of Moby may be subject to certain restrictions by the
267
+Use and transfer of Docker may be subject to certain restrictions by the
77 268
 United States and other governments.
78 269
 
79 270
 It is your responsibility to ensure that your use and/or transfer does not
... ...
@@ -85,6 +275,30 @@ For more information, please see https://www.bis.doc.gov
85 85
 
86 86
 Licensing
87 87
 =========
88
-Moby is licensed under the Apache License, Version 2.0. See
89
-[LICENSE](https://github.com/moby/moby/blob/master/LICENSE) for the full
88
+Docker is licensed under the Apache License, Version 2.0. See
89
+[LICENSE](https://github.com/docker/docker/blob/master/LICENSE) for the full
90 90
 license text.
91
+
92
+Other Docker Related Projects
93
+=============================
94
+There are a number of projects under development that are based on Docker's
95
+core technology. These projects expand the tooling built around the
96
+Docker platform to broaden its application and utility.
97
+
98
+* [Docker Registry](https://github.com/docker/distribution): Registry
99
+server for Docker (hosting/delivery of repositories and images)
100
+* [Docker Machine](https://github.com/docker/machine): Machine management
101
+for a container-centric world
102
+* [Docker Swarm](https://github.com/docker/swarm): A Docker-native clustering
103
+system
104
+* [Docker Compose](https://github.com/docker/compose) (formerly Fig):
105
+Define and run multi-container apps
106
+* [Kitematic](https://github.com/docker/kitematic): The easiest way to use
107
+Docker on Mac and Windows
108
+
109
+If you know of another project underway that should be listed here, please help
110
+us keep this list up-to-date by submitting a PR.
111
+
112
+Awesome-Docker
113
+==============
114
+You can find more projects, tools and articles related to Docker on the [awesome-docker list](https://github.com/veggiemonk/awesome-docker). Add your project there.
... ...
@@ -14,8 +14,8 @@ It consists of various components in this repository:
14 14
 
15 15
 The API is defined by the [Swagger](http://swagger.io/specification/) definition in `api/swagger.yaml`. This definition can be used to:
16 16
 
17
-1. Automatically generate documentation.
18
-2. Automatically generate the Go server and client. (A work-in-progress.)
17
+1. To automatically generate documentation.
18
+2. To automatically generate the Go server and client. (A work-in-progress.)
19 19
 3. Provide a machine readable version of the API for introspecting what it can do, automatically generating clients for other languages, etc.
20 20
 
21 21
 ## Updating the API documentation
... ...
@@ -4,6 +4,7 @@ import (
4 4
 	"bufio"
5 5
 	"io"
6 6
 	"net"
7
+	"os"
7 8
 
8 9
 	"github.com/docker/docker/api/types/container"
9 10
 	"github.com/docker/docker/api/types/filters"
... ...
@@ -97,7 +98,6 @@ type ContainerStartOptions struct {
97 97
 // about files to copy into a container
98 98
 type CopyToContainerOptions struct {
99 99
 	AllowOverwriteDirWithFile bool
100
-	CopyUIDGID                bool
101 100
 }
102 101
 
103 102
 // EventsOptions holds parameters to filter events with.
... ...
@@ -160,10 +160,9 @@ type ImageBuildOptions struct {
160 160
 	ShmSize        int64
161 161
 	Dockerfile     string
162 162
 	Ulimits        []*units.Ulimit
163
-	// BuildArgs needs to be a *string instead of just a string so that
164
-	// we can tell the difference between "" (empty string) and no value
165
-	// at all (nil). See the parsing of buildArgs in
166
-	// api/server/router/build/build_routes.go for even more info.
163
+	// See the parsing of buildArgs in api/server/router/build/build_routes.go
164
+	// for an explaination of why BuildArgs needs to use *string instead of
165
+	// just a string
167 166
 	BuildArgs   map[string]*string
168 167
 	AuthConfigs map[string]AuthConfig
169 168
 	Context     io.Reader
... ...
@@ -176,8 +175,6 @@ type ImageBuildOptions struct {
176 176
 	// specified here do not need to have a valid parent chain to match cache.
177 177
 	CacheFrom   []string
178 178
 	SecurityOpt []string
179
-	ExtraHosts  []string // List of extra hosts
180
-	Target      string
181 179
 }
182 180
 
183 181
 // ImageBuildResponse holds information
... ...
@@ -195,8 +192,8 @@ type ImageCreateOptions struct {
195 195
 
196 196
 // ImageImportSource holds source information for ImageImport
197 197
 type ImageImportSource struct {
198
-	Source     io.Reader // Source is the data to send to the server to create this image from. You must set SourceName to "-" to leverage this.
199
-	SourceName string    // SourceName is the name of the image to pull. Set to "-" to leverage the Source attribute.
198
+	Source     io.Reader // Source is the data to send to the server to create this image from (mutually exclusive with SourceName)
199
+	SourceName string    // SourceName is the name of the image to pull (mutually exclusive with Source)
200 200
 }
201 201
 
202 202
 // ImageImportOptions holds information to import images from the client host.
... ...
@@ -259,6 +256,18 @@ type ResizeOptions struct {
259 259
 	Width  uint
260 260
 }
261 261
 
262
+// VersionResponse holds version information for the client and the server
263
+type VersionResponse struct {
264
+	Client *Version
265
+	Server *Version
266
+}
267
+
268
+// ServerOK returns true when the client could connect to the docker server
269
+// and parse the information received. It returns false otherwise.
270
+func (v VersionResponse) ServerOK() bool {
271
+	return v.Server != nil
272
+}
273
+
262 274
 // NodeListOptions holds parameters to list nodes with.
263 275
 type NodeListOptions struct {
264 276
 	Filters filters.Args
... ...
@@ -276,12 +285,6 @@ type ServiceCreateOptions struct {
276 276
 	//
277 277
 	// This field follows the format of the X-Registry-Auth header.
278 278
 	EncodedRegistryAuth string
279
-
280
-	// QueryRegistry indicates whether the service update requires
281
-	// contacting a registry. A registry may be contacted to retrieve
282
-	// the image digest and manifest, which in turn can be used to update
283
-	// platform or other information about the service.
284
-	QueryRegistry bool
285 279
 }
286 280
 
287 281
 // ServiceCreateResponse contains the information returned to a client
... ...
@@ -315,32 +318,14 @@ type ServiceUpdateOptions struct {
315 315
 	// credentials if they are not given in EncodedRegistryAuth. Valid
316 316
 	// values are "spec" and "previous-spec".
317 317
 	RegistryAuthFrom string
318
-
319
-	// Rollback indicates whether a server-side rollback should be
320
-	// performed. When this is set, the provided spec will be ignored.
321
-	// The valid values are "previous" and "none". An empty value is the
322
-	// same as "none".
323
-	Rollback string
324
-
325
-	// QueryRegistry indicates whether the service update requires
326
-	// contacting a registry. A registry may be contacted to retrieve
327
-	// the image digest and manifest, which in turn can be used to update
328
-	// platform or other information about the service.
329
-	QueryRegistry bool
330 318
 }
331 319
 
332
-// ServiceListOptions holds parameters to list services with.
320
+// ServiceListOptions holds parameters to list  services with.
333 321
 type ServiceListOptions struct {
334 322
 	Filters filters.Args
335 323
 }
336 324
 
337
-// ServiceInspectOptions holds parameters related to the "service inspect"
338
-// operation.
339
-type ServiceInspectOptions struct {
340
-	InsertDefaults bool
341
-}
342
-
343
-// TaskListOptions holds parameters to list tasks with.
325
+// TaskListOptions holds parameters to list  tasks with.
344 326
 type TaskListOptions struct {
345 327
 	Filters filters.Args
346 328
 }
... ...
@@ -371,6 +356,15 @@ type PluginInstallOptions struct {
371 371
 	Args                  []string
372 372
 }
373 373
 
374
+// SecretRequestOption is a type for requesting secrets
375
+type SecretRequestOption struct {
376
+	Source string
377
+	Target string
378
+	UID    string
379
+	GID    string
380
+	Mode   os.FileMode
381
+}
382
+
374 383
 // SwarmUnlockKeyResponse contains the response for Engine API:
375 384
 // GET /swarm/unlockkey
376 385
 type SwarmUnlockKeyResponse struct {
... ...
@@ -7,12 +7,6 @@ import (
7 7
 	"github.com/docker/go-connections/nat"
8 8
 )
9 9
 
10
-// MinimumDuration puts a minimum on user configured duration.
11
-// This is to prevent API error on time unit. For example, API may
12
-// set 3 as healthcheck interval with intention of 3 seconds, but
13
-// Docker interprets it as 3 nanoseconds.
14
-const MinimumDuration = 1 * time.Millisecond
15
-
16 10
 // HealthConfig holds configuration settings for the HEALTHCHECK feature.
17 11
 type HealthConfig struct {
18 12
 	// Test is the test to perform to check that the container is healthy.
... ...
@@ -25,9 +19,8 @@ type HealthConfig struct {
25 25
 	Test []string `json:",omitempty"`
26 26
 
27 27
 	// Zero means to inherit. Durations are expressed as integer nanoseconds.
28
-	Interval    time.Duration `json:",omitempty"` // Interval is the time to wait between checks.
29
-	Timeout     time.Duration `json:",omitempty"` // Timeout is the time to wait before considering the check to have hung.
30
-	StartPeriod time.Duration `json:",omitempty"` // The start period for the container to initialize before the retries starts to count down.
28
+	Interval time.Duration `json:",omitempty"` // Interval is the time to wait between checks.
29
+	Timeout  time.Duration `json:",omitempty"` // Timeout is the time to wait before considering the check to have hung.
31 30
 
32 31
 	// Retries is the number of consecutive failures needed to consider a container as unhealthy.
33 32
 	// Zero means inherit.
34 33
deleted file mode 100644
... ...
@@ -1,21 +0,0 @@
1
-package container
2
-
3
-// ----------------------------------------------------------------------------
4
-// DO NOT EDIT THIS FILE
5
-// This file was generated by `swagger generate operation`
6
-//
7
-// See hack/generate-swagger-api.sh
8
-// ----------------------------------------------------------------------------
9
-
10
-// ContainerChangeResponseItem container change response item
11
-// swagger:model ContainerChangeResponseItem
12
-type ContainerChangeResponseItem struct {
13
-
14
-	// Kind of change
15
-	// Required: true
16
-	Kind uint8 `json:"Kind"`
17
-
18
-	// Path to file that has changed
19
-	// Required: true
20
-	Path string `json:"Path"`
21
-}
22 1
deleted file mode 100644
... ...
@@ -1,21 +0,0 @@
1
-package container
2
-
3
-// ----------------------------------------------------------------------------
4
-// DO NOT EDIT THIS FILE
5
-// This file was generated by `swagger generate operation`
6
-//
7
-// See hack/generate-swagger-api.sh
8
-// ----------------------------------------------------------------------------
9
-
10
-// ContainerTopOKBody container top o k body
11
-// swagger:model ContainerTopOKBody
12
-type ContainerTopOKBody struct {
13
-
14
-	// Each process running in the container, where each is process is an array of values corresponding to the titles
15
-	// Required: true
16
-	Processes [][]string `json:"Processes"`
17
-
18
-	// The ps column titles
19
-	// Required: true
20
-	Titles []string `json:"Titles"`
21
-}
... ...
@@ -10,6 +10,9 @@ import (
10 10
 	"github.com/docker/go-units"
11 11
 )
12 12
 
13
+// NetworkMode represents the container network stack.
14
+type NetworkMode string
15
+
13 16
 // Isolation represents the isolation technology of a container. The supported
14 17
 // values are platform specific
15 18
 type Isolation string
... ...
@@ -63,47 +66,6 @@ func (n IpcMode) Container() string {
63 63
 	return ""
64 64
 }
65 65
 
66
-// NetworkMode represents the container network stack.
67
-type NetworkMode string
68
-
69
-// IsNone indicates whether container isn't using a network stack.
70
-func (n NetworkMode) IsNone() bool {
71
-	return n == "none"
72
-}
73
-
74
-// IsDefault indicates whether container uses the default network stack.
75
-func (n NetworkMode) IsDefault() bool {
76
-	return n == "default"
77
-}
78
-
79
-// IsPrivate indicates whether container uses its private network stack.
80
-func (n NetworkMode) IsPrivate() bool {
81
-	return !(n.IsHost() || n.IsContainer())
82
-}
83
-
84
-// IsContainer indicates whether container uses a container network stack.
85
-func (n NetworkMode) IsContainer() bool {
86
-	parts := strings.SplitN(string(n), ":", 2)
87
-	return len(parts) > 1 && parts[0] == "container"
88
-}
89
-
90
-// ConnectedContainer is the id of the container which network this container is connected to.
91
-func (n NetworkMode) ConnectedContainer() string {
92
-	parts := strings.SplitN(string(n), ":", 2)
93
-	if len(parts) > 1 {
94
-		return parts[1]
95
-	}
96
-	return ""
97
-}
98
-
99
-//UserDefined indicates user-created network
100
-func (n NetworkMode) UserDefined() string {
101
-	if n.IsUserDefined() {
102
-		return string(n)
103
-	}
104
-	return ""
105
-}
106
-
107 66
 // UsernsMode represents userns mode in the container.
108 67
 type UsernsMode string
109 68
 
... ...
@@ -261,17 +223,6 @@ func (rp *RestartPolicy) IsSame(tp *RestartPolicy) bool {
261 261
 	return rp.Name == tp.Name && rp.MaximumRetryCount == tp.MaximumRetryCount
262 262
 }
263 263
 
264
-// LogMode is a type to define the available modes for logging
265
-// These modes affect how logs are handled when log messages start piling up.
266
-type LogMode string
267
-
268
-// Available logging modes
269
-const (
270
-	LogModeUnset            = ""
271
-	LogModeBlocking LogMode = "blocking"
272
-	LogModeNonBlock LogMode = "non-blocking"
273
-)
274
-
275 264
 // LogConfig represents the logging configuration of the container.
276 265
 type LogConfig struct {
277 266
 	Type   string
... ...
@@ -300,7 +251,6 @@ type Resources struct {
300 300
 	CpusetCpus           string          // CpusetCpus 0-2, 0,1
301 301
 	CpusetMems           string          // CpusetMems 0-2, 0,1
302 302
 	Devices              []DeviceMapping // List of devices to map inside the container
303
-	DeviceCgroupRules    []string        // List of rule to be added to the device cgroup
304 303
 	DiskQuota            int64           // Disk limit (in bytes)
305 304
 	KernelMemory         int64           // Kernel memory limit (in bytes)
306 305
 	MemoryReservation    int64           // Memory soft limit (in bytes)
... ...
@@ -377,4 +327,7 @@ type HostConfig struct {
377 377
 
378 378
 	// Run a custom init inside the container, if null, use the daemon's configured settings
379 379
 	Init *bool `json:",omitempty"`
380
+
381
+	// Custom init path
382
+	InitPath string `json:",omitempty"`
380 383
 }
... ...
@@ -2,11 +2,23 @@
2 2
 
3 3
 package container
4 4
 
5
+import "strings"
6
+
5 7
 // IsValid indicates if an isolation technology is valid
6 8
 func (i Isolation) IsValid() bool {
7 9
 	return i.IsDefault()
8 10
 }
9 11
 
12
+// IsPrivate indicates whether container uses its private network stack.
13
+func (n NetworkMode) IsPrivate() bool {
14
+	return !(n.IsHost() || n.IsContainer())
15
+}
16
+
17
+// IsDefault indicates whether container uses the default network stack.
18
+func (n NetworkMode) IsDefault() bool {
19
+	return n == "default"
20
+}
21
+
10 22
 // NetworkName returns the name of the network stack.
11 23
 func (n NetworkMode) NetworkName() string {
12 24
 	if n.IsBridge() {
... ...
@@ -35,7 +47,35 @@ func (n NetworkMode) IsHost() bool {
35 35
 	return n == "host"
36 36
 }
37 37
 
38
+// IsContainer indicates whether container uses a container network stack.
39
+func (n NetworkMode) IsContainer() bool {
40
+	parts := strings.SplitN(string(n), ":", 2)
41
+	return len(parts) > 1 && parts[0] == "container"
42
+}
43
+
44
+// IsNone indicates whether container isn't using a network stack.
45
+func (n NetworkMode) IsNone() bool {
46
+	return n == "none"
47
+}
48
+
49
+// ConnectedContainer is the id of the container which network this container is connected to.
50
+func (n NetworkMode) ConnectedContainer() string {
51
+	parts := strings.SplitN(string(n), ":", 2)
52
+	if len(parts) > 1 {
53
+		return parts[1]
54
+	}
55
+	return ""
56
+}
57
+
38 58
 // IsUserDefined indicates user-created network
39 59
 func (n NetworkMode) IsUserDefined() bool {
40 60
 	return !n.IsDefault() && !n.IsBridge() && !n.IsHost() && !n.IsNone() && !n.IsContainer()
41 61
 }
62
+
63
+//UserDefined indicates user-created network
64
+func (n NetworkMode) UserDefined() string {
65
+	if n.IsUserDefined() {
66
+		return string(n)
67
+	}
68
+	return ""
69
+}
... ...
@@ -4,6 +4,22 @@ import (
4 4
 	"strings"
5 5
 )
6 6
 
7
+// IsDefault indicates whether container uses the default network stack.
8
+func (n NetworkMode) IsDefault() bool {
9
+	return n == "default"
10
+}
11
+
12
+// IsNone indicates whether container isn't using a network stack.
13
+func (n NetworkMode) IsNone() bool {
14
+	return n == "none"
15
+}
16
+
17
+// IsContainer indicates whether container uses a container network stack.
18
+// Returns false as windows doesn't support this mode
19
+func (n NetworkMode) IsContainer() bool {
20
+	return false
21
+}
22
+
7 23
 // IsBridge indicates whether container uses the bridge network stack
8 24
 // in windows it is given the name NAT
9 25
 func (n NetworkMode) IsBridge() bool {
... ...
@@ -16,9 +32,20 @@ func (n NetworkMode) IsHost() bool {
16 16
 	return false
17 17
 }
18 18
 
19
+// IsPrivate indicates whether container uses its private network stack.
20
+func (n NetworkMode) IsPrivate() bool {
21
+	return !(n.IsHost() || n.IsContainer())
22
+}
23
+
24
+// ConnectedContainer is the id of the container which network this container is connected to.
25
+// Returns blank string on windows
26
+func (n NetworkMode) ConnectedContainer() string {
27
+	return ""
28
+}
29
+
19 30
 // IsUserDefined indicates user-created network
20 31
 func (n NetworkMode) IsUserDefined() bool {
21
-	return !n.IsDefault() && !n.IsNone() && !n.IsBridge() && !n.IsContainer()
32
+	return !n.IsDefault() && !n.IsNone() && !n.IsBridge()
22 33
 }
23 34
 
24 35
 // IsHyperV indicates the use of a Hyper-V partition for isolation
... ...
@@ -44,11 +71,17 @@ func (n NetworkMode) NetworkName() string {
44 44
 		return "nat"
45 45
 	} else if n.IsNone() {
46 46
 		return "none"
47
-	} else if n.IsContainer() {
48
-		return "container"
49 47
 	} else if n.IsUserDefined() {
50 48
 		return n.UserDefined()
51 49
 	}
52 50
 
53 51
 	return ""
54 52
 }
53
+
54
+//UserDefined indicates user-created network
55
+func (n NetworkMode) UserDefined() string {
56
+	if n.IsUserDefined() {
57
+		return string(n)
58
+	}
59
+	return ""
60
+}
55 61
deleted file mode 100644
... ...
@@ -1,22 +0,0 @@
1
-package container
2
-
3
-// WaitCondition is a type used to specify a container state for which
4
-// to wait.
5
-type WaitCondition string
6
-
7
-// Possible WaitCondition Values.
8
-//
9
-// WaitConditionNotRunning (default) is used to wait for any of the non-running
10
-// states: "created", "exited", "dead", "removing", or "removed".
11
-//
12
-// WaitConditionNextExit is used to wait for the next time the state changes
13
-// to a non-running state. If the state is currently "created" or "exited",
14
-// this would cause Wait() to block until either the container runs and exits
15
-// or is removed.
16
-//
17
-// WaitConditionRemoved is used to wait for the container to be removed.
18
-const (
19
-	WaitConditionNotRunning WaitCondition = "not-running"
20
-	WaitConditionNextExit   WaitCondition = "next-exit"
21
-	WaitConditionRemoved    WaitCondition = "removed"
22
-)
... ...
@@ -79,8 +79,8 @@ func ToParamWithVersion(version string, a Args) (string, error) {
79 79
 	}
80 80
 
81 81
 	// for daemons older than v1.10, filter must be of the form map[string][]string
82
-	var buf []byte
83
-	var err error
82
+	buf := []byte{}
83
+	err := errors.New("")
84 84
 	if version != "" && versions.LessThan(version, "1.22") {
85 85
 		buf, err = json.Marshal(convertArgsToSlice(a.fields))
86 86
 	} else {
87 87
deleted file mode 100644
... ...
@@ -1,17 +0,0 @@
1
-package types
2
-
3
-// This file was generated by the swagger tool.
4
-// Editing this file might prove futile when you re-run the swagger generate command
5
-
6
-// GraphDriverData Information about a container's graph driver.
7
-// swagger:model GraphDriverData
8
-type GraphDriverData struct {
9
-
10
-	// data
11
-	// Required: true
12
-	Data map[string]string `json:"Data"`
13
-
14
-	// name
15
-	// Required: true
16
-	Name string `json:"Name"`
17
-}
18 1
deleted file mode 100644
... ...
@@ -1,15 +0,0 @@
1
-package types
2
-
3
-// This file was generated by the swagger tool.
4
-// Editing this file might prove futile when you re-run the swagger generate command
5
-
6
-// ImageDeleteResponseItem image delete response item
7
-// swagger:model ImageDeleteResponseItem
8
-type ImageDeleteResponseItem struct {
9
-
10
-	// The image ID of an image that was deleted
11
-	Deleted string `json:"Deleted,omitempty"`
12
-
13
-	// The image ID of an image that was untagged
14
-	Untagged string `json:"Untagged,omitempty"`
15
-}
... ...
@@ -23,10 +23,9 @@ type Mount struct {
23 23
 	// Source specifies the name of the mount. Depending on mount type, this
24 24
 	// may be a volume name or a host path, or even ignored.
25 25
 	// Source is not supported for tmpfs (must be an empty value)
26
-	Source      string      `json:",omitempty"`
27
-	Target      string      `json:",omitempty"`
28
-	ReadOnly    bool        `json:",omitempty"`
29
-	Consistency Consistency `json:",omitempty"`
26
+	Source   string `json:",omitempty"`
27
+	Target   string `json:",omitempty"`
28
+	ReadOnly bool   `json:",omitempty"`
30 29
 
31 30
 	BindOptions   *BindOptions   `json:",omitempty"`
32 31
 	VolumeOptions *VolumeOptions `json:",omitempty"`
... ...
@@ -61,20 +60,6 @@ var Propagations = []Propagation{
61 61
 	PropagationSlave,
62 62
 }
63 63
 
64
-// Consistency represents the consistency requirements of a mount.
65
-type Consistency string
66
-
67
-const (
68
-	// ConsistencyFull guarantees bind-mount-like consistency
69
-	ConsistencyFull Consistency = "consistent"
70
-	// ConsistencyCached mounts can cache read data and FS structure
71
-	ConsistencyCached Consistency = "cached"
72
-	// ConsistencyDelegated mounts can cache read and written data and structure
73
-	ConsistencyDelegated Consistency = "delegated"
74
-	// ConsistencyDefault provides "consistent" behavior unless overridden
75
-	ConsistencyDefault Consistency = "default"
76
-)
77
-
78 64
 // BindOptions defines options specific to mounts of type "bind".
79 65
 type BindOptions struct {
80 66
 	Propagation Propagation `json:",omitempty"`
... ...
@@ -98,7 +83,7 @@ type TmpfsOptions struct {
98 98
 	// Size sets the size of the tmpfs, in bytes.
99 99
 	//
100 100
 	// This will be converted to an operating system specific value
101
-	// depending on the host. For example, on linux, it will be converted to
101
+	// depending on the host. For example, on linux, it will be convered to
102 102
 	// use a 'k', 'm' or 'g' syntax. BSD, though not widely supported with
103 103
 	// docker, uses a straight byte value.
104 104
 	//
... ...
@@ -28,14 +28,6 @@ type EndpointIPAMConfig struct {
28 28
 	LinkLocalIPs []string `json:",omitempty"`
29 29
 }
30 30
 
31
-// Copy makes a copy of the endpoint ipam config
32
-func (cfg *EndpointIPAMConfig) Copy() *EndpointIPAMConfig {
33
-	cfgCopy := *cfg
34
-	cfgCopy.LinkLocalIPs = make([]string, 0, len(cfg.LinkLocalIPs))
35
-	cfgCopy.LinkLocalIPs = append(cfgCopy.LinkLocalIPs, cfg.LinkLocalIPs...)
36
-	return &cfgCopy
37
-}
38
-
39 31
 // PeerInfo represents one peer of an overlay network
40 32
 type PeerInfo struct {
41 33
 	Name string
... ...
@@ -58,42 +50,6 @@ type EndpointSettings struct {
58 58
 	GlobalIPv6Address   string
59 59
 	GlobalIPv6PrefixLen int
60 60
 	MacAddress          string
61
-	DriverOpts          map[string]string
62
-}
63
-
64
-// Task carries the information about one backend task
65
-type Task struct {
66
-	Name       string
67
-	EndpointID string
68
-	EndpointIP string
69
-	Info       map[string]string
70
-}
71
-
72
-// ServiceInfo represents service parameters with the list of service's tasks
73
-type ServiceInfo struct {
74
-	VIP          string
75
-	Ports        []string
76
-	LocalLBIndex int
77
-	Tasks        []Task
78
-}
79
-
80
-// Copy makes a deep copy of `EndpointSettings`
81
-func (es *EndpointSettings) Copy() *EndpointSettings {
82
-	epCopy := *es
83
-	if es.IPAMConfig != nil {
84
-		epCopy.IPAMConfig = es.IPAMConfig.Copy()
85
-	}
86
-
87
-	if es.Links != nil {
88
-		links := make([]string, 0, len(es.Links))
89
-		epCopy.Links = append(links, es.Links...)
90
-	}
91
-
92
-	if es.Aliases != nil {
93
-		aliases := make([]string, 0, len(es.Aliases))
94
-		epCopy.Aliases = append(aliases, es.Aliases...)
95
-	}
96
-	return &epCopy
97 61
 }
98 62
 
99 63
 // NetworkingConfig represents the container's networking configuration for each of its interfaces
... ...
@@ -101,8 +57,3 @@ func (es *EndpointSettings) Copy() *EndpointSettings {
101 101
 type NetworkingConfig struct {
102 102
 	EndpointsConfig map[string]*EndpointSettings // Endpoint configs for each connecting network
103 103
 }
104
-
105
-// ConfigReference specifies the source which provides a network's configuration
106
-type ConfigReference struct {
107
-	Network string
108
-}
... ...
@@ -22,9 +22,6 @@ type Plugin struct {
22 22
 	// Required: true
23 23
 	Name string `json:"Name"`
24 24
 
25
-	// plugin remote reference used to push/pull the plugin
26
-	PluginReference string `json:"PluginReference,omitempty"`
27
-
28 25
 	// settings
29 26
 	// Required: true
30 27
 	Settings PluginSettings `json:"Settings"`
... ...
@@ -42,9 +39,6 @@ type PluginConfig struct {
42 42
 	// Required: true
43 43
 	Description string `json:"Description"`
44 44
 
45
-	// Docker Version used to create the plugin
46
-	DockerVersion string `json:"DockerVersion,omitempty"`
47
-
48 45
 	// documentation
49 46
 	// Required: true
50 47
 	Documentation string `json:"Documentation"`
... ...
@@ -61,10 +55,6 @@ type PluginConfig struct {
61 61
 	// Required: true
62 62
 	Interface PluginConfigInterface `json:"Interface"`
63 63
 
64
-	// ipc host
65
-	// Required: true
66
-	IpcHost bool `json:"IpcHost"`
67
-
68 64
 	// linux
69 65
 	// Required: true
70 66
 	Linux PluginConfigLinux `json:"Linux"`
... ...
@@ -77,10 +67,6 @@ type PluginConfig struct {
77 77
 	// Required: true
78 78
 	Network PluginConfigNetwork `json:"Network"`
79 79
 
80
-	// pid host
81
-	// Required: true
82
-	PidHost bool `json:"PidHost"`
83
-
84 80
 	// propagated mount
85 81
 	// Required: true
86 82
 	PropagatedMount string `json:"PropagatedMount"`
... ...
@@ -134,14 +120,14 @@ type PluginConfigInterface struct {
134 134
 // swagger:model PluginConfigLinux
135 135
 type PluginConfigLinux struct {
136 136
 
137
-	// allow all devices
138
-	// Required: true
139
-	AllowAllDevices bool `json:"AllowAllDevices"`
140
-
141 137
 	// capabilities
142 138
 	// Required: true
143 139
 	Capabilities []string `json:"Capabilities"`
144 140
 
141
+	// device creation
142
+	// Required: true
143
+	DeviceCreation bool `json:"DeviceCreation"`
144
+
145 145
 	// devices
146 146
 	// Required: true
147 147
 	Devices []PluginDevice `json:"Devices"`
... ...
@@ -3,7 +3,6 @@ package types
3 3
 import (
4 4
 	"encoding/json"
5 5
 	"fmt"
6
-	"sort"
7 6
 )
8 7
 
9 8
 // PluginsListResponse contains the response for the Engine API
... ...
@@ -63,17 +62,3 @@ type PluginPrivilege struct {
63 63
 
64 64
 // PluginPrivileges is a list of PluginPrivilege
65 65
 type PluginPrivileges []PluginPrivilege
66
-
67
-func (s PluginPrivileges) Len() int {
68
-	return len(s)
69
-}
70
-
71
-func (s PluginPrivileges) Less(i, j int) bool {
72
-	return s[i].Name < s[j].Name
73
-}
74
-
75
-func (s PluginPrivileges) Swap(i, j int) {
76
-	sort.Strings(s[i].Value)
77
-	sort.Strings(s[j].Value)
78
-	s[i], s[j] = s[j], s[i]
79
-}
... ...
@@ -3,17 +3,13 @@ package registry
3 3
 import (
4 4
 	"encoding/json"
5 5
 	"net"
6
-
7
-	"github.com/opencontainers/image-spec/specs-go/v1"
8 6
 )
9 7
 
10 8
 // ServiceConfig stores daemon registry services configuration.
11 9
 type ServiceConfig struct {
12
-	AllowNondistributableArtifactsCIDRs     []*NetIPNet
13
-	AllowNondistributableArtifactsHostnames []string
14
-	InsecureRegistryCIDRs                   []*NetIPNet           `json:"InsecureRegistryCIDRs"`
15
-	IndexConfigs                            map[string]*IndexInfo `json:"IndexConfigs"`
16
-	Mirrors                                 []string
10
+	InsecureRegistryCIDRs []*NetIPNet           `json:"InsecureRegistryCIDRs"`
11
+	IndexConfigs          map[string]*IndexInfo `json:"IndexConfigs"`
12
+	Mirrors               []string
17 13
 }
18 14
 
19 15
 // NetIPNet is the net.IPNet type, which can be marshalled and
... ...
@@ -106,14 +102,3 @@ type SearchResults struct {
106 106
 	// Results is a slice containing the actual results for the search
107 107
 	Results []SearchResult `json:"results"`
108 108
 }
109
-
110
-// DistributionInspect describes the result obtained from contacting the
111
-// registry to retrieve image metadata
112
-type DistributionInspect struct {
113
-	// Descriptor contains information about the manifest, including
114
-	// the content addressable digest
115
-	Descriptor v1.Descriptor
116
-	// Platforms contains the list of platforms supported by the image,
117
-	// obtained by parsing the manifest
118
-	Platforms []v1.Platform
119
-}
... ...
@@ -47,9 +47,6 @@ type CPUStats struct {
47 47
 	// System Usage. Linux only.
48 48
 	SystemUsage uint64 `json:"system_cpu_usage,omitempty"`
49 49
 
50
-	// Online CPUs. Linux only.
51
-	OnlineCPUs uint32 `json:"online_cpus,omitempty"`
52
-
53 50
 	// Throttling Data. Linux only.
54 51
 	ThrottlingData ThrottlingData `json:"throttling_data,omitempty"`
55 52
 }
... ...
@@ -17,7 +17,7 @@ type Meta struct {
17 17
 // Annotations represents how to describe an object.
18 18
 type Annotations struct {
19 19
 	Name   string            `json:",omitempty"`
20
-	Labels map[string]string `json:"Labels"`
20
+	Labels map[string]string `json:",omitempty"`
21 21
 }
22 22
 
23 23
 // Driver represents a driver (network, logging).
... ...
@@ -25,16 +25,3 @@ type Driver struct {
25 25
 	Name    string            `json:",omitempty"`
26 26
 	Options map[string]string `json:",omitempty"`
27 27
 }
28
-
29
-// TLSInfo represents the TLS information about what CA certificate is trusted,
30
-// and who the issuer for a TLS certificate is
31
-type TLSInfo struct {
32
-	// TrustRoot is the trusted CA root certificate in PEM format
33
-	TrustRoot string `json:",omitempty"`
34
-
35
-	// CertIssuer is the raw subject bytes of the issuer
36
-	CertIssuerSubject []byte `json:",omitempty"`
37
-
38
-	// CertIssuerPublicKey is the raw public key bytes of the issuer
39
-	CertIssuerPublicKey []byte `json:",omitempty"`
40
-}
41 28
deleted file mode 100644
... ...
@@ -1,31 +0,0 @@
1
-package swarm
2
-
3
-import "os"
4
-
5
-// Config represents a config.
6
-type Config struct {
7
-	ID string
8
-	Meta
9
-	Spec ConfigSpec
10
-}
11
-
12
-// ConfigSpec represents a config specification from a config in swarm
13
-type ConfigSpec struct {
14
-	Annotations
15
-	Data []byte `json:",omitempty"`
16
-}
17
-
18
-// ConfigReferenceFileTarget is a file target in a config reference
19
-type ConfigReferenceFileTarget struct {
20
-	Name string
21
-	UID  string
22
-	GID  string
23
-	Mode os.FileMode
24
-}
25
-
26
-// ConfigReference is a reference to a config in swarm
27
-type ConfigReference struct {
28
-	File       *ConfigReferenceFileTarget
29
-	ConfigID   string
30
-	ConfigName string
31
-}
... ...
@@ -21,28 +21,6 @@ type DNSConfig struct {
21 21
 	Options []string `json:",omitempty"`
22 22
 }
23 23
 
24
-// SELinuxContext contains the SELinux labels of the container.
25
-type SELinuxContext struct {
26
-	Disable bool
27
-
28
-	User  string
29
-	Role  string
30
-	Type  string
31
-	Level string
32
-}
33
-
34
-// CredentialSpec for managed service account (Windows only)
35
-type CredentialSpec struct {
36
-	File     string
37
-	Registry string
38
-}
39
-
40
-// Privileges defines the security options for the container.
41
-type Privileges struct {
42
-	CredentialSpec *CredentialSpec
43
-	SELinuxContext *SELinuxContext
44
-}
45
-
46 24
 // ContainerSpec represents the spec of a container.
47 25
 type ContainerSpec struct {
48 26
 	Image           string                  `json:",omitempty"`
... ...
@@ -54,11 +32,8 @@ type ContainerSpec struct {
54 54
 	Dir             string                  `json:",omitempty"`
55 55
 	User            string                  `json:",omitempty"`
56 56
 	Groups          []string                `json:",omitempty"`
57
-	Privileges      *Privileges             `json:",omitempty"`
58
-	StopSignal      string                  `json:",omitempty"`
59 57
 	TTY             bool                    `json:",omitempty"`
60 58
 	OpenStdin       bool                    `json:",omitempty"`
61
-	ReadOnly        bool                    `json:",omitempty"`
62 59
 	Mounts          []mount.Mount           `json:",omitempty"`
63 60
 	StopGracePeriod *time.Duration          `json:",omitempty"`
64 61
 	Healthcheck     *container.HealthConfig `json:",omitempty"`
... ...
@@ -68,5 +43,4 @@ type ContainerSpec struct {
68 68
 	Hosts     []string           `json:",omitempty"`
69 69
 	DNSConfig *DNSConfig         `json:",omitempty"`
70 70
 	Secrets   []*SecretReference `json:",omitempty"`
71
-	Configs   []*ConfigReference `json:",omitempty"`
72 71
 }
... ...
@@ -1,9 +1,5 @@
1 1
 package swarm
2 2
 
3
-import (
4
-	"github.com/docker/docker/api/types/network"
5
-)
6
-
7 3
 // Endpoint represents an endpoint.
8 4
 type Endpoint struct {
9 5
 	Spec       EndpointSpec        `json:",omitempty"`
... ...
@@ -82,21 +78,17 @@ type Network struct {
82 82
 // NetworkSpec represents the spec of a network.
83 83
 type NetworkSpec struct {
84 84
 	Annotations
85
-	DriverConfiguration *Driver                  `json:",omitempty"`
86
-	IPv6Enabled         bool                     `json:",omitempty"`
87
-	Internal            bool                     `json:",omitempty"`
88
-	Attachable          bool                     `json:",omitempty"`
89
-	Ingress             bool                     `json:",omitempty"`
90
-	IPAMOptions         *IPAMOptions             `json:",omitempty"`
91
-	ConfigFrom          *network.ConfigReference `json:",omitempty"`
92
-	Scope               string                   `json:",omitempty"`
85
+	DriverConfiguration *Driver      `json:",omitempty"`
86
+	IPv6Enabled         bool         `json:",omitempty"`
87
+	Internal            bool         `json:",omitempty"`
88
+	Attachable          bool         `json:",omitempty"`
89
+	IPAMOptions         *IPAMOptions `json:",omitempty"`
93 90
 }
94 91
 
95 92
 // NetworkAttachmentConfig represents the configuration of a network attachment.
96 93
 type NetworkAttachmentConfig struct {
97
-	Target     string            `json:",omitempty"`
98
-	Aliases    []string          `json:",omitempty"`
99
-	DriverOpts map[string]string `json:",omitempty"`
94
+	Target  string   `json:",omitempty"`
95
+	Aliases []string `json:",omitempty"`
100 96
 }
101 97
 
102 98
 // NetworkAttachment represents a network attachment.
... ...
@@ -52,7 +52,6 @@ type NodeDescription struct {
52 52
 	Platform  Platform          `json:",omitempty"`
53 53
 	Resources Resources         `json:",omitempty"`
54 54
 	Engine    EngineDescription `json:",omitempty"`
55
-	TLSInfo   TLSInfo           `json:",omitempty"`
56 55
 }
57 56
 
58 57
 // Platform represents the platform (Arch/OS).
59 58
deleted file mode 100644
... ...
@@ -1,19 +0,0 @@
1
-package swarm
2
-
3
-// RuntimeType is the type of runtime used for the TaskSpec
4
-type RuntimeType string
5
-
6
-// RuntimeURL is the proto type url
7
-type RuntimeURL string
8
-
9
-const (
10
-	// RuntimeContainer is the container based runtime
11
-	RuntimeContainer RuntimeType = "container"
12
-	// RuntimePlugin is the plugin based runtime
13
-	RuntimePlugin RuntimeType = "plugin"
14
-
15
-	// RuntimeURLContainer is the proto url for the container type
16
-	RuntimeURLContainer RuntimeURL = "types.docker.com/RuntimeContainer"
17
-	// RuntimeURLPlugin is the proto url for the plugin type
18
-	RuntimeURLPlugin RuntimeURL = "types.docker.com/RuntimePlugin"
19
-)
... ...
@@ -18,10 +18,9 @@ type ServiceSpec struct {
18 18
 
19 19
 	// TaskTemplate defines how the service should construct new tasks when
20 20
 	// orchestrating this service.
21
-	TaskTemplate   TaskSpec      `json:",omitempty"`
22
-	Mode           ServiceMode   `json:",omitempty"`
23
-	UpdateConfig   *UpdateConfig `json:",omitempty"`
24
-	RollbackConfig *UpdateConfig `json:",omitempty"`
21
+	TaskTemplate TaskSpec      `json:",omitempty"`
22
+	Mode         ServiceMode   `json:",omitempty"`
23
+	UpdateConfig *UpdateConfig `json:",omitempty"`
25 24
 
26 25
 	// Networks field in ServiceSpec is deprecated. The
27 26
 	// same field in TaskSpec should be used instead.
... ...
@@ -46,12 +45,6 @@ const (
46 46
 	UpdateStatePaused UpdateState = "paused"
47 47
 	// UpdateStateCompleted is the completed state.
48 48
 	UpdateStateCompleted UpdateState = "completed"
49
-	// UpdateStateRollbackStarted is the state with a rollback in progress.
50
-	UpdateStateRollbackStarted UpdateState = "rollback_started"
51
-	// UpdateStateRollbackPaused is the state with a rollback in progress.
52
-	UpdateStateRollbackPaused UpdateState = "rollback_paused"
53
-	// UpdateStateRollbackCompleted is the state with a rollback in progress.
54
-	UpdateStateRollbackCompleted UpdateState = "rollback_completed"
55 49
 )
56 50
 
57 51
 // UpdateStatus reports the status of a service update.
... ...
@@ -75,13 +68,6 @@ const (
75 75
 	UpdateFailureActionPause = "pause"
76 76
 	// UpdateFailureActionContinue CONTINUE
77 77
 	UpdateFailureActionContinue = "continue"
78
-	// UpdateFailureActionRollback ROLLBACK
79
-	UpdateFailureActionRollback = "rollback"
80
-
81
-	// UpdateOrderStopFirst STOP_FIRST
82
-	UpdateOrderStopFirst = "stop-first"
83
-	// UpdateOrderStartFirst START_FIRST
84
-	UpdateOrderStartFirst = "start-first"
85 78
 )
86 79
 
87 80
 // UpdateConfig represents the update configuration.
... ...
@@ -116,9 +102,4 @@ type UpdateConfig struct {
116 116
 	// If the failure action is PAUSE, no more tasks will be updated until
117 117
 	// another update is started.
118 118
 	MaxFailureRatio float32
119
-
120
-	// Order indicates the order of operations when rolling out an updated
121
-	// task. Either the old task is shut down before the new task is
122
-	// started, or the new task is started before the old task is shut down.
123
-	Order string
124 119
 }
... ...
@@ -7,9 +7,7 @@ import "time"
7 7
 type ClusterInfo struct {
8 8
 	ID string
9 9
 	Meta
10
-	Spec                   Spec
11
-	TLSInfo                TLSInfo
12
-	RootRotationInProgress bool
10
+	Spec Spec
13 11
 }
14 12
 
15 13
 // Swarm represents a swarm.
... ...
@@ -109,16 +107,6 @@ type CAConfig struct {
109 109
 	// ExternalCAs is a list of CAs to which a manager node will make
110 110
 	// certificate signing requests for node certificates.
111 111
 	ExternalCAs []*ExternalCA `json:",omitempty"`
112
-
113
-	// SigningCACert and SigningCAKey specify the desired signing root CA and
114
-	// root CA key for the swarm.  When inspecting the cluster, the key will
115
-	// be redacted.
116
-	SigningCACert string `json:",omitempty"`
117
-	SigningCAKey  string `json:",omitempty"`
118
-
119
-	// If this value changes, and there is no specified signing cert and key,
120
-	// then the swarm is forced to generate a new root certificate ane key.
121
-	ForceRotate uint64 `json:",omitempty"`
122 112
 }
123 113
 
124 114
 // ExternalCAProtocol represents type of external CA.
... ...
@@ -138,31 +126,23 @@ type ExternalCA struct {
138 138
 	// Options is a set of additional key/value pairs whose interpretation
139 139
 	// depends on the specified CA type.
140 140
 	Options map[string]string `json:",omitempty"`
141
-
142
-	// CACert specifies which root CA is used by this external CA.  This certificate must
143
-	// be in PEM format.
144
-	CACert string
145 141
 }
146 142
 
147 143
 // InitRequest is the request used to init a swarm.
148 144
 type InitRequest struct {
149 145
 	ListenAddr       string
150 146
 	AdvertiseAddr    string
151
-	DataPathAddr     string
152 147
 	ForceNewCluster  bool
153 148
 	Spec             Spec
154 149
 	AutoLockManagers bool
155
-	Availability     NodeAvailability
156 150
 }
157 151
 
158 152
 // JoinRequest is the request used to join a swarm.
159 153
 type JoinRequest struct {
160 154
 	ListenAddr    string
161 155
 	AdvertiseAddr string
162
-	DataPathAddr  string
163 156
 	RemoteAddrs   []string
164 157
 	JoinToken     string // accept by secret
165
-	Availability  NodeAvailability
166 158
 }
167 159
 
168 160
 // UnlockRequest is the request used to unlock a swarm.
... ...
@@ -197,10 +177,10 @@ type Info struct {
197 197
 	Error            string
198 198
 
199 199
 	RemoteManagers []Peer
200
-	Nodes          int `json:",omitempty"`
201
-	Managers       int `json:",omitempty"`
200
+	Nodes          int
201
+	Managers       int
202 202
 
203
-	Cluster *ClusterInfo `json:",omitempty"`
203
+	Cluster ClusterInfo
204 204
 }
205 205
 
206 206
 // Peer represents a peer.
... ...
@@ -65,8 +65,6 @@ type TaskSpec struct {
65 65
 	// ForceUpdate is a counter that triggers an update even if no relevant
66 66
 	// parameters have been changed.
67 67
 	ForceUpdate uint64
68
-
69
-	Runtime RuntimeType `json:",omitempty"`
70 68
 }
71 69
 
72 70
 // Resources represents resources (CPU/Memory).
... ...
@@ -83,26 +81,7 @@ type ResourceRequirements struct {
83 83
 
84 84
 // Placement represents orchestration parameters.
85 85
 type Placement struct {
86
-	Constraints []string              `json:",omitempty"`
87
-	Preferences []PlacementPreference `json:",omitempty"`
88
-
89
-	// Platforms stores all the platforms that the image can run on.
90
-	// This field is used in the platform filter for scheduling. If empty,
91
-	// then the platform filter is off, meaning there are no scheduling restrictions.
92
-	Platforms []Platform `json:",omitempty"`
93
-}
94
-
95
-// PlacementPreference provides a way to make the scheduler aware of factors
96
-// such as topology.
97
-type PlacementPreference struct {
98
-	Spread *SpreadOver
99
-}
100
-
101
-// SpreadOver is a scheduling preference that instructs the scheduler to spread
102
-// tasks evenly over groups of nodes identified by labels.
103
-type SpreadOver struct {
104
-	// label descriptor, such as engine.labels.az
105
-	SpreadDescriptor string
86
+	Constraints []string `json:",omitempty"`
106 87
 }
107 88
 
108 89
 // RestartPolicy represents the restart policy.
... ...
@@ -17,6 +17,38 @@ import (
17 17
 	"github.com/docker/go-connections/nat"
18 18
 )
19 19
 
20
+// ContainerChange contains response of Engine API:
21
+// GET "/containers/{name:.*}/changes"
22
+type ContainerChange struct {
23
+	Kind int
24
+	Path string
25
+}
26
+
27
+// ImageHistory contains response of Engine API:
28
+// GET "/images/{name:.*}/history"
29
+type ImageHistory struct {
30
+	ID        string `json:"Id"`
31
+	Created   int64
32
+	CreatedBy string
33
+	Tags      []string
34
+	Size      int64
35
+	Comment   string
36
+}
37
+
38
+// ImageDelete contains response of Engine API:
39
+// DELETE "/images/{name:.*}"
40
+type ImageDelete struct {
41
+	Untagged string `json:",omitempty"`
42
+	Deleted  string `json:",omitempty"`
43
+}
44
+
45
+// GraphDriverData returns Image's graph driver config info
46
+// when calling inspect command
47
+type GraphDriverData struct {
48
+	Name string
49
+	Data map[string]string
50
+}
51
+
20 52
 // RootFS returns Image's RootFS description including the layer IDs.
21 53
 type RootFS struct {
22 54
 	Type      string
... ...
@@ -93,11 +125,17 @@ type ContainerStats struct {
93 93
 	OSType string        `json:"ostype"`
94 94
 }
95 95
 
96
+// ContainerProcessList contains response of Engine API:
97
+// GET "/containers/{name:.*}/top"
98
+type ContainerProcessList struct {
99
+	Processes [][]string
100
+	Titles    []string
101
+}
102
+
96 103
 // Ping contains response of Engine API:
97 104
 // GET "/_ping"
98 105
 type Ping struct {
99 106
 	APIVersion   string
100
-	OSType       string
101 107
 	Experimental bool
102 108
 }
103 109
 
... ...
@@ -238,8 +276,6 @@ type PluginsInfo struct {
238 238
 	Network []string
239 239
 	// List of Authorization plugins registered
240 240
 	Authorization []string
241
-	// List of Log plugins registered
242
-	Log []string
243 241
 }
244 242
 
245 243
 // ExecStartCheck is a temp struct used by execStart
... ...
@@ -277,7 +313,7 @@ type Health struct {
277 277
 // ContainerState stores container's running state
278 278
 // it's part of ContainerJSONBase and will return by "inspect" command
279 279
 type ContainerState struct {
280
-	Status     string // String representation of the container state. Can be one of "created", "running", "paused", "restarting", "removing", "exited", or "dead"
280
+	Status     string
281 281
 	Running    bool
282 282
 	Paused     bool
283 283
 	Restarting bool
... ...
@@ -393,23 +429,19 @@ type MountPoint struct {
393 393
 
394 394
 // NetworkResource is the body of the "get network" http response message
395 395
 type NetworkResource struct {
396
-	Name       string                         // Name is the requested name of the network
397
-	ID         string                         `json:"Id"` // ID uniquely identifies a network on a single machine
398
-	Created    time.Time                      // Created is the time the network created
399
-	Scope      string                         // Scope describes the level at which the network exists (e.g. `swarm` for cluster-wide or `local` for machine level)
400
-	Driver     string                         // Driver is the Driver name used to create the network (e.g. `bridge`, `overlay`)
401
-	EnableIPv6 bool                           // EnableIPv6 represents whether to enable IPv6
402
-	IPAM       network.IPAM                   // IPAM is the network's IP Address Management
403
-	Internal   bool                           // Internal represents if the network is used internal only
404
-	Attachable bool                           // Attachable represents if the global scope is manually attachable by regular containers from workers in swarm mode.
405
-	Ingress    bool                           // Ingress indicates the network is providing the routing-mesh for the swarm cluster.
406
-	ConfigFrom network.ConfigReference        // ConfigFrom specifies the source which will provide the configuration for this network.
407
-	ConfigOnly bool                           // ConfigOnly networks are place-holder networks for network configurations to be used by other networks. ConfigOnly networks cannot be used directly to run containers or services.
408
-	Containers map[string]EndpointResource    // Containers contains endpoints belonging to the network
409
-	Options    map[string]string              // Options holds the network specific options to use for when creating the network
410
-	Labels     map[string]string              // Labels holds metadata specific to the network being created
411
-	Peers      []network.PeerInfo             `json:",omitempty"` // List of peer nodes for an overlay network
412
-	Services   map[string]network.ServiceInfo `json:",omitempty"`
396
+	Name       string                      // Name is the requested name of the network
397
+	ID         string                      `json:"Id"` // ID uniquely identifies a network on a single machine
398
+	Created    time.Time                   // Created is the time the network created
399
+	Scope      string                      // Scope describes the level at which the network exists (e.g. `global` for cluster-wide or `local` for machine level)
400
+	Driver     string                      // Driver is the Driver name used to create the network (e.g. `bridge`, `overlay`)
401
+	EnableIPv6 bool                        // EnableIPv6 represents whether to enable IPv6
402
+	IPAM       network.IPAM                // IPAM is the network's IP Address Management
403
+	Internal   bool                        // Internal represents if the network is used internal only
404
+	Attachable bool                        // Attachable represents if the global scope is manually attachable by regular containers from workers in swarm mode.
405
+	Containers map[string]EndpointResource // Containers contains endpoints belonging to the network
406
+	Options    map[string]string           // Options holds the network specific options to use for when creating the network
407
+	Labels     map[string]string           // Labels holds metadata specific to the network being created
408
+	Peers      []network.PeerInfo          `json:",omitempty"` // List of peer nodes for an overlay network
413 409
 }
414 410
 
415 411
 // EndpointResource contains network resources allocated and used for a container in a network
... ...
@@ -423,23 +455,12 @@ type EndpointResource struct {
423 423
 
424 424
 // NetworkCreate is the expected body of the "create network" http request message
425 425
 type NetworkCreate struct {
426
-	// Check for networks with duplicate names.
427
-	// Network is primarily keyed based on a random ID and not on the name.
428
-	// Network name is strictly a user-friendly alias to the network
429
-	// which is uniquely identified using ID.
430
-	// And there is no guaranteed way to check for duplicates.
431
-	// Option CheckDuplicate is there to provide a best effort checking of any networks
432
-	// which has the same name but it is not guaranteed to catch all name collisions.
433 426
 	CheckDuplicate bool
434 427
 	Driver         string
435
-	Scope          string
436 428
 	EnableIPv6     bool
437 429
 	IPAM           *network.IPAM
438 430
 	Internal       bool
439 431
 	Attachable     bool
440
-	Ingress        bool
441
-	ConfigOnly     bool
442
-	ConfigFrom     *network.ConfigReference
443 432
 	Options        map[string]string
444 433
 	Labels         map[string]string
445 434
 }
... ...
@@ -505,7 +526,7 @@ type VolumesPruneReport struct {
505 505
 // ImagesPruneReport contains the response for Engine API:
506 506
 // POST "/images/prune"
507 507
 type ImagesPruneReport struct {
508
-	ImagesDeleted  []ImageDeleteResponseItem
508
+	ImagesDeleted  []ImageDelete
509 509
 	SpaceReclaimed uint64
510 510
 }
511 511
 
... ...
@@ -527,18 +548,6 @@ type SecretListOptions struct {
527 527
 	Filters filters.Args
528 528
 }
529 529
 
530
-// ConfigCreateResponse contains the information returned to a client
531
-// on the creation of a new config.
532
-type ConfigCreateResponse struct {
533
-	// ID is the id of the created config.
534
-	ID string
535
-}
536
-
537
-// ConfigListOptions holds parameters to list configs
538
-type ConfigListOptions struct {
539
-	Filters filters.Args
540
-}
541
-
542 530
 // PushResult contains the tag, manifest digest, and manifest size from the
543 531
 // push. It's used to signal this information to the trust code in the client
544 532
 // so it can sign the manifest if necessary.
... ...
@@ -547,8 +556,3 @@ type PushResult struct {
547 547
 	Digest string
548 548
 	Size   int
549 549
 }
550
-
551
-// BuildResult contains the image id of a successful build
552
-type BuildResult struct {
553
-	ID string
554
-}
555 550
deleted file mode 100644
... ...
@@ -1,36 +0,0 @@
1
-package provider
2
-
3
-import (
4
-	"github.com/docker/docker/api/types/network"
5
-	"golang.org/x/net/context"
6
-)
7
-
8
-const (
9
-	// ClusterEventSocketChange control socket changed
10
-	ClusterEventSocketChange = iota
11
-	// ClusterEventNodeReady cluster node in ready state
12
-	ClusterEventNodeReady
13
-	// ClusterEventNodeLeave node is leaving the cluster
14
-	ClusterEventNodeLeave
15
-	// ClusterEventNetworkKeysAvailable network keys correctly configured in the networking layer
16
-	ClusterEventNetworkKeysAvailable
17
-)
18
-
19
-// ClusterConfigEventType type of the event produced by the cluster
20
-type ClusterConfigEventType uint8
21
-
22
-// Cluster provides clustering config details
23
-type Cluster interface {
24
-	IsManager() bool
25
-	IsAgent() bool
26
-	GetLocalAddress() string
27
-	GetListenAddress() string
28
-	GetAdvertiseAddress() string
29
-	GetDataPathAddress() string
30
-	GetRemoteAddressList() []string
31
-	ListenClusterEvents() <-chan ClusterConfigEventType
32
-	AttachNetwork(string, string, []string) (*network.NetworkingConfig, error)
33
-	DetachNetwork(string, string) error
34
-	UpdateAttachment(string, string, *network.NetworkingConfig) error
35
-	WaitForDetachment(context.Context, string, string, string, string) error
36
-}
37 1
deleted file mode 100644
... ...
@@ -1,37 +0,0 @@
1
-package provider
2
-
3
-import "github.com/docker/docker/api/types"
4
-
5
-// NetworkCreateRequest is a request when creating a network.
6
-type NetworkCreateRequest struct {
7
-	ID string
8
-	types.NetworkCreateRequest
9
-}
10
-
11
-// NetworkCreateResponse is a response when creating a network.
12
-type NetworkCreateResponse struct {
13
-	ID string `json:"Id"`
14
-}
15
-
16
-// VirtualAddress represents a virtual address.
17
-type VirtualAddress struct {
18
-	IPv4 string
19
-	IPv6 string
20
-}
21
-
22
-// PortConfig represents a port configuration.
23
-type PortConfig struct {
24
-	Name          string
25
-	Protocol      int32
26
-	TargetPort    uint32
27
-	PublishedPort uint32
28
-}
29
-
30
-// ServiceConfig represents a service configuration.
31
-type ServiceConfig struct {
32
-	ID               string
33
-	Name             string
34
-	Aliases          map[string][]string
35
-	VirtualAddresses map[string]*VirtualAddress
36
-	ExposedPorts     []*PortConfig
37
-}
38 1
deleted file mode 100644
... ...
@@ -1,68 +0,0 @@
1
-## About
2
-
3
-This directory contains a collection of scripts used to build and manage this
4
-repository. If there are any issues regarding the intention of a particular
5
-script (or even part of a certain script), please reach out to us.
6
-It may help us either refine our current scripts, or add on new ones
7
-that are appropriate for a given use case.
8
-
9
-## DinD (dind.sh)
10
-
11
-DinD is a wrapper script which allows Docker to be run inside a Docker
12
-container. DinD requires the container to
13
-be run with privileged mode enabled.
14
-
15
-## Generate Authors (generate-authors.sh)
16
-
17
-Generates AUTHORS; a file with all the names and corresponding emails of
18
-individual contributors. AUTHORS can be found in the home directory of
19
-this repository.
20
-
21
-## Install (install.sh)
22
-
23
-Executable install script for installing Docker. If updates to this are
24
-desired, please use hack/release.sh during a normal release. The following
25
-one-liner may be used for script hotfixes:
26
-
27
-- `aws s3 cp --acl public-read hack/install.sh s3://get.docker.com/index`
28
-
29
-## Make
30
-
31
-There are two make files, each with different extensions. Neither are supposed
32
-to be called directly; only invoke `make`. Both scripts run inside a Docker
33
-container.
34
-
35
-### make.ps1
36
-
37
-- The Windows native build script that uses PowerShell semantics; it is limited
38
-unlike `hack\make.sh` since it does not provide support for the full set of
39
-operations provided by the Linux counterpart, `make.sh`. However, `make.ps1`
40
-does provide support for local Windows development and Windows to Windows CI.
41
-More information is found within `make.ps1` by the author, @jhowardmsft
42
-
43
-### make.sh
44
-
45
-- Referenced via `make test` when running tests on a local machine,
46
-or directly referenced when running tests inside a Docker development container.  
47
-- When running on a local machine, `make test` to run all tests found in
48
-`test`, `test-unit`, `test-integration-cli`, and `test-docker-py` on
49
-your local machine. The default timeout is set in `make.sh` to 60 minutes
50
-(`${TIMEOUT:=60m}`), since it currently takes up to an hour to run
51
-all of the tests.
52
-- When running inside a Docker development container, `hack/make.sh` does
53
-not have a single target that runs all the tests. You need to provide a
54
-single command line with multiple targets that performs the same thing.
55
-An example referenced from [Run targets inside a development container](https://docs.docker.com/opensource/project/test-and-docs/#run-targets-inside-a-development-container): `root@5f8630b873fe:/go/src/github.com/moby/moby# hack/make.sh dynbinary binary cross test-unit test-integration-cli test-docker-py`
56
-- For more information related to testing outside the scope of this README,
57
-refer to
58
-[Run tests and test documentation](https://docs.docker.com/opensource/project/test-and-docs/)
59
-
60
-## Release (release.sh)
61
-
62
-Releases any bundles built by `make` on a public AWS S3 bucket.
63
-For information regarding configuration, please view `release.sh`.
64
-
65
-## Vendor (vendor.sh)
66
-
67
-A shell script that is a wrapper around Vndr. For information on how to use
68
-this, please refer to [vndr's README](https://github.com/LK4D4/vndr/blob/master/README.md)
69 1
deleted file mode 100644
... ...
@@ -1,69 +0,0 @@
1
-# Integration Testing on Swarm
2
-
3
-IT on Swarm allows you to execute integration test in parallel across a Docker Swarm cluster
4
-
5
-## Architecture
6
-
7
-### Master service
8
-
9
-  - Works as a funker caller
10
-  - Calls a worker funker (`-worker-service`) with a chunk of `-check.f` filter strings (passed as a file via `-input` flag, typically `/mnt/input`)
11
-
12
-### Worker service
13
-
14
-  - Works as a funker callee
15
-  - Executes an equivalent of `TESTFLAGS=-check.f TestFoo|TestBar|TestBaz ... make test-integration-cli` using the bind-mounted API socket (`docker.sock`)
16
-
17
-### Client
18
-
19
-  - Controls master and workers via `docker stack`
20
-  - No need to have a local daemon
21
-
22
-Typically, the master and workers are supposed to be running on a cloud environment,
23
-while the client is supposed to be running on a laptop, e.g. Docker for Mac/Windows.
24
-
25
-## Requirement
26
-
27
-  - Docker daemon 1.13 or later
28
-  - Private registry for distributed execution with multiple nodes
29
-
30
-## Usage
31
-
32
-### Step 1: Prepare images
33
-
34
-    $ make build-integration-cli-on-swarm
35
-
36
-Following environment variables are known to work in this step:
37
-
38
- - `BUILDFLAGS`
39
- - `DOCKER_INCREMENTAL_BINARY`
40
-
41
-Note: during the transition into Moby Project, you might need to create a symbolic link `$GOPATH/src/github.com/docker/docker` to `$GOPATH/src/github.com/moby/moby`. 
42
-
43
-### Step 2: Execute tests
44
-
45
-    $ ./hack/integration-cli-on-swarm/integration-cli-on-swarm -replicas 40 -push-worker-image YOUR_REGISTRY.EXAMPLE.COM/integration-cli-worker:latest 
46
-
47
-Following environment variables are known to work in this step:
48
-
49
- - `DOCKER_GRAPHDRIVER`
50
- - `DOCKER_EXPERIMENTAL`
51
-
52
-#### Flags
53
-
54
-Basic flags:
55
-
56
- - `-replicas N`: the number of worker service replicas. i.e. degree of parallelism.
57
- - `-chunks N`: the number of chunks. By default, `chunks` == `replicas`.
58
- - `-push-worker-image REGISTRY/IMAGE:TAG`: push the worker image to the registry. Note that if you have only single node and hence you do not need a private registry, you do not need to specify `-push-worker-image`.
59
-
60
-Experimental flags for mitigating makespan nonuniformity:
61
-
62
- - `-shuffle`: Shuffle the test filter strings
63
-
64
-Flags for debugging IT on Swarm itself:
65
-
66
- - `-rand-seed N`: the random seed. This flag is useful for deterministic replaying. By default(0), the timestamp is used.
67
- - `-filters-file FILE`: the file contains `-check.f` strings. By default, the file is automatically generated.
68
- - `-dry-run`: skip the actual workload
69
- - `keep-executor`: do not auto-remove executor containers, which is used for running privileged programs on Swarm
70 1
deleted file mode 100644
... ...
@@ -1,2 +0,0 @@
1
-# dependencies specific to worker (i.e. github.com/docker/docker/...) are not vendored here
2
-github.com/bfirsh/funker-go eaa0a2e06f30e72c9a0b7f858951e581e26ef773
3 1
new file mode 100644
... ...
@@ -0,0 +1,171 @@
0
+package opts
1
+
2
+import (
3
+	"encoding/csv"
4
+	"fmt"
5
+	"os"
6
+	"strconv"
7
+	"strings"
8
+
9
+	mounttypes "github.com/docker/docker/api/types/mount"
10
+	"github.com/docker/go-units"
11
+)
12
+
13
+// MountOpt is a Value type for parsing mounts
14
+type MountOpt struct {
15
+	values []mounttypes.Mount
16
+}
17
+
18
+// Set a new mount value
19
+func (m *MountOpt) Set(value string) error {
20
+	csvReader := csv.NewReader(strings.NewReader(value))
21
+	fields, err := csvReader.Read()
22
+	if err != nil {
23
+		return err
24
+	}
25
+
26
+	mount := mounttypes.Mount{}
27
+
28
+	volumeOptions := func() *mounttypes.VolumeOptions {
29
+		if mount.VolumeOptions == nil {
30
+			mount.VolumeOptions = &mounttypes.VolumeOptions{
31
+				Labels: make(map[string]string),
32
+			}
33
+		}
34
+		if mount.VolumeOptions.DriverConfig == nil {
35
+			mount.VolumeOptions.DriverConfig = &mounttypes.Driver{}
36
+		}
37
+		return mount.VolumeOptions
38
+	}
39
+
40
+	bindOptions := func() *mounttypes.BindOptions {
41
+		if mount.BindOptions == nil {
42
+			mount.BindOptions = new(mounttypes.BindOptions)
43
+		}
44
+		return mount.BindOptions
45
+	}
46
+
47
+	tmpfsOptions := func() *mounttypes.TmpfsOptions {
48
+		if mount.TmpfsOptions == nil {
49
+			mount.TmpfsOptions = new(mounttypes.TmpfsOptions)
50
+		}
51
+		return mount.TmpfsOptions
52
+	}
53
+
54
+	setValueOnMap := func(target map[string]string, value string) {
55
+		parts := strings.SplitN(value, "=", 2)
56
+		if len(parts) == 1 {
57
+			target[value] = ""
58
+		} else {
59
+			target[parts[0]] = parts[1]
60
+		}
61
+	}
62
+
63
+	mount.Type = mounttypes.TypeVolume // default to volume mounts
64
+	// Set writable as the default
65
+	for _, field := range fields {
66
+		parts := strings.SplitN(field, "=", 2)
67
+		key := strings.ToLower(parts[0])
68
+
69
+		if len(parts) == 1 {
70
+			switch key {
71
+			case "readonly", "ro":
72
+				mount.ReadOnly = true
73
+				continue
74
+			case "volume-nocopy":
75
+				volumeOptions().NoCopy = true
76
+				continue
77
+			}
78
+		}
79
+
80
+		if len(parts) != 2 {
81
+			return fmt.Errorf("invalid field '%s' must be a key=value pair", field)
82
+		}
83
+
84
+		value := parts[1]
85
+		switch key {
86
+		case "type":
87
+			mount.Type = mounttypes.Type(strings.ToLower(value))
88
+		case "source", "src":
89
+			mount.Source = value
90
+		case "target", "dst", "destination":
91
+			mount.Target = value
92
+		case "readonly", "ro":
93
+			mount.ReadOnly, err = strconv.ParseBool(value)
94
+			if err != nil {
95
+				return fmt.Errorf("invalid value for %s: %s", key, value)
96
+			}
97
+		case "bind-propagation":
98
+			bindOptions().Propagation = mounttypes.Propagation(strings.ToLower(value))
99
+		case "volume-nocopy":
100
+			volumeOptions().NoCopy, err = strconv.ParseBool(value)
101
+			if err != nil {
102
+				return fmt.Errorf("invalid value for populate: %s", value)
103
+			}
104
+		case "volume-label":
105
+			setValueOnMap(volumeOptions().Labels, value)
106
+		case "volume-driver":
107
+			volumeOptions().DriverConfig.Name = value
108
+		case "volume-opt":
109
+			if volumeOptions().DriverConfig.Options == nil {
110
+				volumeOptions().DriverConfig.Options = make(map[string]string)
111
+			}
112
+			setValueOnMap(volumeOptions().DriverConfig.Options, value)
113
+		case "tmpfs-size":
114
+			sizeBytes, err := units.RAMInBytes(value)
115
+			if err != nil {
116
+				return fmt.Errorf("invalid value for %s: %s", key, value)
117
+			}
118
+			tmpfsOptions().SizeBytes = sizeBytes
119
+		case "tmpfs-mode":
120
+			ui64, err := strconv.ParseUint(value, 8, 32)
121
+			if err != nil {
122
+				return fmt.Errorf("invalid value for %s: %s", key, value)
123
+			}
124
+			tmpfsOptions().Mode = os.FileMode(ui64)
125
+		default:
126
+			return fmt.Errorf("unexpected key '%s' in '%s'", key, field)
127
+		}
128
+	}
129
+
130
+	if mount.Type == "" {
131
+		return fmt.Errorf("type is required")
132
+	}
133
+
134
+	if mount.Target == "" {
135
+		return fmt.Errorf("target is required")
136
+	}
137
+
138
+	if mount.VolumeOptions != nil && mount.Type != mounttypes.TypeVolume {
139
+		return fmt.Errorf("cannot mix 'volume-*' options with mount type '%s'", mount.Type)
140
+	}
141
+	if mount.BindOptions != nil && mount.Type != mounttypes.TypeBind {
142
+		return fmt.Errorf("cannot mix 'bind-*' options with mount type '%s'", mount.Type)
143
+	}
144
+	if mount.TmpfsOptions != nil && mount.Type != mounttypes.TypeTmpfs {
145
+		return fmt.Errorf("cannot mix 'tmpfs-*' options with mount type '%s'", mount.Type)
146
+	}
147
+
148
+	m.values = append(m.values, mount)
149
+	return nil
150
+}
151
+
152
+// Type returns the type of this option
153
+func (m *MountOpt) Type() string {
154
+	return "mount"
155
+}
156
+
157
+// String returns a string repr of this option
158
+func (m *MountOpt) String() string {
159
+	mounts := []string{}
160
+	for _, mount := range m.values {
161
+		repr := fmt.Sprintf("%s %s %s", mount.Type, mount.Source, mount.Target)
162
+		mounts = append(mounts, repr)
163
+	}
164
+	return strings.Join(mounts, ", ")
165
+}
166
+
167
+// Value returns the mounts
168
+func (m *MountOpt) Value() []mounttypes.Mount {
169
+	return m.values
170
+}
... ...
@@ -2,12 +2,13 @@ package opts
2 2
 
3 3
 import (
4 4
 	"fmt"
5
+	"math/big"
5 6
 	"net"
6 7
 	"path"
7 8
 	"regexp"
8 9
 	"strings"
9 10
 
10
-	units "github.com/docker/go-units"
11
+	"github.com/docker/docker/api/types/filters"
11 12
 )
12 13
 
13 14
 var (
... ...
@@ -36,10 +37,7 @@ func NewListOptsRef(values *[]string, validator ValidatorFctType) *ListOpts {
36 36
 }
37 37
 
38 38
 func (opts *ListOpts) String() string {
39
-	if len(*opts.values) == 0 {
40
-		return ""
41
-	}
42
-	return fmt.Sprintf("%v", *opts.values)
39
+	return fmt.Sprintf("%v", []string((*opts.values)))
43 40
 }
44 41
 
45 42
 // Set validates if needed the input value and adds it to the
... ...
@@ -234,6 +232,15 @@ func ValidateIPAddress(val string) (string, error) {
234 234
 	return "", fmt.Errorf("%s is not an ip address", val)
235 235
 }
236 236
 
237
+// ValidateMACAddress validates a MAC address.
238
+func ValidateMACAddress(val string) (string, error) {
239
+	_, err := net.ParseMAC(strings.TrimSpace(val))
240
+	if err != nil {
241
+		return "", err
242
+	}
243
+	return val, nil
244
+}
245
+
237 246
 // ValidateDNSSearch validates domain for resolvconf search configuration.
238 247
 // A zero length domain is represented by a dot (.).
239 248
 func ValidateDNSSearch(val string) (string, error) {
... ...
@@ -263,6 +270,111 @@ func ValidateLabel(val string) (string, error) {
263 263
 	return val, nil
264 264
 }
265 265
 
266
+// ValidateSysctl validates a sysctl and returns it.
267
+func ValidateSysctl(val string) (string, error) {
268
+	validSysctlMap := map[string]bool{
269
+		"kernel.msgmax":          true,
270
+		"kernel.msgmnb":          true,
271
+		"kernel.msgmni":          true,
272
+		"kernel.sem":             true,
273
+		"kernel.shmall":          true,
274
+		"kernel.shmmax":          true,
275
+		"kernel.shmmni":          true,
276
+		"kernel.shm_rmid_forced": true,
277
+	}
278
+	validSysctlPrefixes := []string{
279
+		"net.",
280
+		"fs.mqueue.",
281
+	}
282
+	arr := strings.Split(val, "=")
283
+	if len(arr) < 2 {
284
+		return "", fmt.Errorf("sysctl '%s' is not whitelisted", val)
285
+	}
286
+	if validSysctlMap[arr[0]] {
287
+		return val, nil
288
+	}
289
+
290
+	for _, vp := range validSysctlPrefixes {
291
+		if strings.HasPrefix(arr[0], vp) {
292
+			return val, nil
293
+		}
294
+	}
295
+	return "", fmt.Errorf("sysctl '%s' is not whitelisted", val)
296
+}
297
+
298
+// FilterOpt is a flag type for validating filters
299
+type FilterOpt struct {
300
+	filter filters.Args
301
+}
302
+
303
+// NewFilterOpt returns a new FilterOpt
304
+func NewFilterOpt() FilterOpt {
305
+	return FilterOpt{filter: filters.NewArgs()}
306
+}
307
+
308
+func (o *FilterOpt) String() string {
309
+	repr, err := filters.ToParam(o.filter)
310
+	if err != nil {
311
+		return "invalid filters"
312
+	}
313
+	return repr
314
+}
315
+
316
+// Set sets the value of the opt by parsing the command line value
317
+func (o *FilterOpt) Set(value string) error {
318
+	var err error
319
+	o.filter, err = filters.ParseFlag(value, o.filter)
320
+	return err
321
+}
322
+
323
+// Type returns the option type
324
+func (o *FilterOpt) Type() string {
325
+	return "filter"
326
+}
327
+
328
+// Value returns the value of this option
329
+func (o *FilterOpt) Value() filters.Args {
330
+	return o.filter
331
+}
332
+
333
+// NanoCPUs is a type for fixed point fractional number.
334
+type NanoCPUs int64
335
+
336
+// String returns the string format of the number
337
+func (c *NanoCPUs) String() string {
338
+	return big.NewRat(c.Value(), 1e9).FloatString(3)
339
+}
340
+
341
+// Set sets the value of the NanoCPU by passing a string
342
+func (c *NanoCPUs) Set(value string) error {
343
+	cpus, err := ParseCPUs(value)
344
+	*c = NanoCPUs(cpus)
345
+	return err
346
+}
347
+
348
+// Type returns the type
349
+func (c *NanoCPUs) Type() string {
350
+	return "decimal"
351
+}
352
+
353
+// Value returns the value in int64
354
+func (c *NanoCPUs) Value() int64 {
355
+	return int64(*c)
356
+}
357
+
358
+// ParseCPUs takes a string ratio and returns an integer value of nano cpus
359
+func ParseCPUs(value string) (int64, error) {
360
+	cpu, ok := new(big.Rat).SetString(value)
361
+	if !ok {
362
+		return 0, fmt.Errorf("failed to parse %v as a rational number", value)
363
+	}
364
+	nano := cpu.Mul(cpu, big.NewRat(1e9, 1))
365
+	if !nano.IsInt() {
366
+		return 0, fmt.Errorf("value is too precise")
367
+	}
368
+	return nano.Num().Int64(), nil
369
+}
370
+
266 371
 // ParseLink parses and validates the specified string as a link format (name:alias)
267 372
 func ParseLink(val string) (string, string, error) {
268 373
 	if val == "" {
... ...
@@ -285,43 +397,8 @@ func ParseLink(val string) (string, string, error) {
285 285
 	return arr[0], arr[1], nil
286 286
 }
287 287
 
288
-// MemBytes is a type for human readable memory bytes (like 128M, 2g, etc)
289
-type MemBytes int64
290
-
291
-// String returns the string format of the human readable memory bytes
292
-func (m *MemBytes) String() string {
293
-	// NOTE: In spf13/pflag/flag.go, "0" is considered as "zero value" while "0 B" is not.
294
-	// We return "0" in case value is 0 here so that the default value is hidden.
295
-	// (Sometimes "default 0 B" is actually misleading)
296
-	if m.Value() != 0 {
297
-		return units.BytesSize(float64(m.Value()))
298
-	}
299
-	return "0"
300
-}
301
-
302
-// Set sets the value of the MemBytes by passing a string
303
-func (m *MemBytes) Set(value string) error {
304
-	val, err := units.RAMInBytes(value)
305
-	*m = MemBytes(val)
306
-	return err
307
-}
308
-
309
-// Type returns the type
310
-func (m *MemBytes) Type() string {
311
-	return "bytes"
312
-}
313
-
314
-// Value returns the value in int64
315
-func (m *MemBytes) Value() int64 {
316
-	return int64(*m)
317
-}
318
-
319
-// UnmarshalJSON is the customized unmarshaler for MemBytes
320
-func (m *MemBytes) UnmarshalJSON(s []byte) error {
321
-	if len(s) <= 2 || s[0] != '"' || s[len(s)-1] != '"' {
322
-		return fmt.Errorf("invalid size: %q", s)
323
-	}
324
-	val, err := units.RAMInBytes(string(s[1 : len(s)-1]))
325
-	*m = MemBytes(val)
326
-	return err
288
+// ValidateLink validates that the specified string has a valid link format (containerName:alias).
289
+func ValidateLink(val string) (string, error) {
290
+	_, _, err := ParseLink(val)
291
+	return val, err
327 292
 }
328 293
new file mode 100644
... ...
@@ -0,0 +1,146 @@
0
+package opts
1
+
2
+import (
3
+	"encoding/csv"
4
+	"fmt"
5
+	"regexp"
6
+	"strconv"
7
+	"strings"
8
+
9
+	"github.com/docker/docker/api/types/swarm"
10
+	"github.com/docker/go-connections/nat"
11
+)
12
+
13
+const (
14
+	portOptTargetPort    = "target"
15
+	portOptPublishedPort = "published"
16
+	portOptProtocol      = "protocol"
17
+	portOptMode          = "mode"
18
+)
19
+
20
+// PortOpt represents a port config in swarm mode.
21
+type PortOpt struct {
22
+	ports []swarm.PortConfig
23
+}
24
+
25
+// Set a new port value
26
+func (p *PortOpt) Set(value string) error {
27
+	longSyntax, err := regexp.MatchString(`\w+=\w+(,\w+=\w+)*`, value)
28
+	if err != nil {
29
+		return err
30
+	}
31
+	if longSyntax {
32
+		csvReader := csv.NewReader(strings.NewReader(value))
33
+		fields, err := csvReader.Read()
34
+		if err != nil {
35
+			return err
36
+		}
37
+
38
+		pConfig := swarm.PortConfig{}
39
+		for _, field := range fields {
40
+			parts := strings.SplitN(field, "=", 2)
41
+			if len(parts) != 2 {
42
+				return fmt.Errorf("invalid field %s", field)
43
+			}
44
+
45
+			key := strings.ToLower(parts[0])
46
+			value := strings.ToLower(parts[1])
47
+
48
+			switch key {
49
+			case portOptProtocol:
50
+				if value != string(swarm.PortConfigProtocolTCP) && value != string(swarm.PortConfigProtocolUDP) {
51
+					return fmt.Errorf("invalid protocol value %s", value)
52
+				}
53
+
54
+				pConfig.Protocol = swarm.PortConfigProtocol(value)
55
+			case portOptMode:
56
+				if value != string(swarm.PortConfigPublishModeIngress) && value != string(swarm.PortConfigPublishModeHost) {
57
+					return fmt.Errorf("invalid publish mode value %s", value)
58
+				}
59
+
60
+				pConfig.PublishMode = swarm.PortConfigPublishMode(value)
61
+			case portOptTargetPort:
62
+				tPort, err := strconv.ParseUint(value, 10, 16)
63
+				if err != nil {
64
+					return err
65
+				}
66
+
67
+				pConfig.TargetPort = uint32(tPort)
68
+			case portOptPublishedPort:
69
+				pPort, err := strconv.ParseUint(value, 10, 16)
70
+				if err != nil {
71
+					return err
72
+				}
73
+
74
+				pConfig.PublishedPort = uint32(pPort)
75
+			default:
76
+				return fmt.Errorf("invalid field key %s", key)
77
+			}
78
+		}
79
+
80
+		if pConfig.TargetPort == 0 {
81
+			return fmt.Errorf("missing mandatory field %q", portOptTargetPort)
82
+		}
83
+
84
+		if pConfig.PublishMode == "" {
85
+			pConfig.PublishMode = swarm.PortConfigPublishModeIngress
86
+		}
87
+
88
+		if pConfig.Protocol == "" {
89
+			pConfig.Protocol = swarm.PortConfigProtocolTCP
90
+		}
91
+
92
+		p.ports = append(p.ports, pConfig)
93
+	} else {
94
+		// short syntax
95
+		portConfigs := []swarm.PortConfig{}
96
+		// We can ignore errors because the format was already validated by ValidatePort
97
+		ports, portBindings, _ := nat.ParsePortSpecs([]string{value})
98
+
99
+		for port := range ports {
100
+			portConfigs = append(portConfigs, ConvertPortToPortConfig(port, portBindings)...)
101
+		}
102
+		p.ports = append(p.ports, portConfigs...)
103
+	}
104
+	return nil
105
+}
106
+
107
+// Type returns the type of this option
108
+func (p *PortOpt) Type() string {
109
+	return "port"
110
+}
111
+
112
+// String returns a string repr of this option
113
+func (p *PortOpt) String() string {
114
+	ports := []string{}
115
+	for _, port := range p.ports {
116
+		repr := fmt.Sprintf("%v:%v/%s/%s", port.PublishedPort, port.TargetPort, port.Protocol, port.PublishMode)
117
+		ports = append(ports, repr)
118
+	}
119
+	return strings.Join(ports, ", ")
120
+}
121
+
122
+// Value returns the ports
123
+func (p *PortOpt) Value() []swarm.PortConfig {
124
+	return p.ports
125
+}
126
+
127
+// ConvertPortToPortConfig converts ports to the swarm type
128
+func ConvertPortToPortConfig(
129
+	port nat.Port,
130
+	portBindings map[nat.Port][]nat.PortBinding,
131
+) []swarm.PortConfig {
132
+	ports := []swarm.PortConfig{}
133
+
134
+	for _, binding := range portBindings[port] {
135
+		hostPort, _ := strconv.ParseUint(binding.HostPort, 10, 16)
136
+		ports = append(ports, swarm.PortConfig{
137
+			//TODO Name: ?
138
+			Protocol:      swarm.PortConfigProtocol(strings.ToLower(port.Proto())),
139
+			TargetPort:    uint32(port.Int()),
140
+			PublishedPort: uint32(hostPort),
141
+			PublishMode:   swarm.PortConfigPublishModeIngress,
142
+		})
143
+	}
144
+	return ports
145
+}
0 146
new file mode 100644
... ...
@@ -0,0 +1,107 @@
0
+package opts
1
+
2
+import (
3
+	"encoding/csv"
4
+	"fmt"
5
+	"os"
6
+	"path/filepath"
7
+	"strconv"
8
+	"strings"
9
+
10
+	"github.com/docker/docker/api/types"
11
+)
12
+
13
+// SecretOpt is a Value type for parsing secrets
14
+type SecretOpt struct {
15
+	values []*types.SecretRequestOption
16
+}
17
+
18
+// Set a new secret value
19
+func (o *SecretOpt) Set(value string) error {
20
+	csvReader := csv.NewReader(strings.NewReader(value))
21
+	fields, err := csvReader.Read()
22
+	if err != nil {
23
+		return err
24
+	}
25
+
26
+	options := &types.SecretRequestOption{
27
+		Source: "",
28
+		Target: "",
29
+		UID:    "0",
30
+		GID:    "0",
31
+		Mode:   0444,
32
+	}
33
+
34
+	// support a simple syntax of --secret foo
35
+	if len(fields) == 1 {
36
+		options.Source = fields[0]
37
+		options.Target = fields[0]
38
+		o.values = append(o.values, options)
39
+		return nil
40
+	}
41
+
42
+	for _, field := range fields {
43
+		parts := strings.SplitN(field, "=", 2)
44
+		key := strings.ToLower(parts[0])
45
+
46
+		if len(parts) != 2 {
47
+			return fmt.Errorf("invalid field '%s' must be a key=value pair", field)
48
+		}
49
+
50
+		value := parts[1]
51
+		switch key {
52
+		case "source":
53
+			options.Source = value
54
+		case "target":
55
+			tDir, _ := filepath.Split(value)
56
+			if tDir != "" {
57
+				return fmt.Errorf("target must not be a path")
58
+			}
59
+			options.Target = value
60
+		case "uid":
61
+			options.UID = value
62
+		case "gid":
63
+			options.GID = value
64
+		case "mode":
65
+			m, err := strconv.ParseUint(value, 0, 32)
66
+			if err != nil {
67
+				return fmt.Errorf("invalid mode specified: %v", err)
68
+			}
69
+
70
+			options.Mode = os.FileMode(m)
71
+		default:
72
+			if len(fields) == 1 && value == "" {
73
+
74
+			} else {
75
+				return fmt.Errorf("invalid field in secret request: %s", key)
76
+			}
77
+		}
78
+	}
79
+
80
+	if options.Source == "" {
81
+		return fmt.Errorf("source is required")
82
+	}
83
+
84
+	o.values = append(o.values, options)
85
+	return nil
86
+}
87
+
88
+// Type returns the type of this option
89
+func (o *SecretOpt) Type() string {
90
+	return "secret"
91
+}
92
+
93
+// String returns a string repr of this option
94
+func (o *SecretOpt) String() string {
95
+	secrets := []string{}
96
+	for _, secret := range o.values {
97
+		repr := fmt.Sprintf("%s -> %s", secret.Source, secret.Target)
98
+		secrets = append(secrets, repr)
99
+	}
100
+	return strings.Join(secrets, ", ")
101
+}
102
+
103
+// Value returns the secret requests
104
+func (o *SecretOpt) Value() []*types.SecretRequestOption {
105
+	return o.values
106
+}
0 107
new file mode 100644
... ...
@@ -0,0 +1,111 @@
0
+package opts
1
+
2
+import (
3
+	"fmt"
4
+	"strconv"
5
+	"strings"
6
+
7
+	"github.com/docker/docker/api/types/blkiodev"
8
+	"github.com/docker/go-units"
9
+)
10
+
11
+// ValidatorThrottleFctType defines a validator function that returns a validated struct and/or an error.
12
+type ValidatorThrottleFctType func(val string) (*blkiodev.ThrottleDevice, error)
13
+
14
+// ValidateThrottleBpsDevice validates that the specified string has a valid device-rate format.
15
+func ValidateThrottleBpsDevice(val string) (*blkiodev.ThrottleDevice, error) {
16
+	split := strings.SplitN(val, ":", 2)
17
+	if len(split) != 2 {
18
+		return nil, fmt.Errorf("bad format: %s", val)
19
+	}
20
+	if !strings.HasPrefix(split[0], "/dev/") {
21
+		return nil, fmt.Errorf("bad format for device path: %s", val)
22
+	}
23
+	rate, err := units.RAMInBytes(split[1])
24
+	if err != nil {
25
+		return nil, fmt.Errorf("invalid rate for device: %s. The correct format is <device-path>:<number>[<unit>]. Number must be a positive integer. Unit is optional and can be kb, mb, or gb", val)
26
+	}
27
+	if rate < 0 {
28
+		return nil, fmt.Errorf("invalid rate for device: %s. The correct format is <device-path>:<number>[<unit>]. Number must be a positive integer. Unit is optional and can be kb, mb, or gb", val)
29
+	}
30
+
31
+	return &blkiodev.ThrottleDevice{
32
+		Path: split[0],
33
+		Rate: uint64(rate),
34
+	}, nil
35
+}
36
+
37
+// ValidateThrottleIOpsDevice validates that the specified string has a valid device-rate format.
38
+func ValidateThrottleIOpsDevice(val string) (*blkiodev.ThrottleDevice, error) {
39
+	split := strings.SplitN(val, ":", 2)
40
+	if len(split) != 2 {
41
+		return nil, fmt.Errorf("bad format: %s", val)
42
+	}
43
+	if !strings.HasPrefix(split[0], "/dev/") {
44
+		return nil, fmt.Errorf("bad format for device path: %s", val)
45
+	}
46
+	rate, err := strconv.ParseUint(split[1], 10, 64)
47
+	if err != nil {
48
+		return nil, fmt.Errorf("invalid rate for device: %s. The correct format is <device-path>:<number>. Number must be a positive integer", val)
49
+	}
50
+	if rate < 0 {
51
+		return nil, fmt.Errorf("invalid rate for device: %s. The correct format is <device-path>:<number>. Number must be a positive integer", val)
52
+	}
53
+
54
+	return &blkiodev.ThrottleDevice{
55
+		Path: split[0],
56
+		Rate: uint64(rate),
57
+	}, nil
58
+}
59
+
60
+// ThrottledeviceOpt defines a map of ThrottleDevices
61
+type ThrottledeviceOpt struct {
62
+	values    []*blkiodev.ThrottleDevice
63
+	validator ValidatorThrottleFctType
64
+}
65
+
66
+// NewThrottledeviceOpt creates a new ThrottledeviceOpt
67
+func NewThrottledeviceOpt(validator ValidatorThrottleFctType) ThrottledeviceOpt {
68
+	values := []*blkiodev.ThrottleDevice{}
69
+	return ThrottledeviceOpt{
70
+		values:    values,
71
+		validator: validator,
72
+	}
73
+}
74
+
75
+// Set validates a ThrottleDevice and sets its name as a key in ThrottledeviceOpt
76
+func (opt *ThrottledeviceOpt) Set(val string) error {
77
+	var value *blkiodev.ThrottleDevice
78
+	if opt.validator != nil {
79
+		v, err := opt.validator(val)
80
+		if err != nil {
81
+			return err
82
+		}
83
+		value = v
84
+	}
85
+	(opt.values) = append((opt.values), value)
86
+	return nil
87
+}
88
+
89
+// String returns ThrottledeviceOpt values as a string.
90
+func (opt *ThrottledeviceOpt) String() string {
91
+	var out []string
92
+	for _, v := range opt.values {
93
+		out = append(out, v.String())
94
+	}
95
+
96
+	return fmt.Sprintf("%v", out)
97
+}
98
+
99
+// GetList returns a slice of pointers to ThrottleDevices.
100
+func (opt *ThrottledeviceOpt) GetList() []*blkiodev.ThrottleDevice {
101
+	var throttledevice []*blkiodev.ThrottleDevice
102
+	throttledevice = append(throttledevice, opt.values...)
103
+
104
+	return throttledevice
105
+}
106
+
107
+// Type returns the option type
108
+func (opt *ThrottledeviceOpt) Type() string {
109
+	return "list"
110
+}
0 111
new file mode 100644
... ...
@@ -0,0 +1,89 @@
0
+package opts
1
+
2
+import (
3
+	"fmt"
4
+	"strconv"
5
+	"strings"
6
+
7
+	"github.com/docker/docker/api/types/blkiodev"
8
+)
9
+
10
+// ValidatorWeightFctType defines a validator function that returns a validated struct and/or an error.
11
+type ValidatorWeightFctType func(val string) (*blkiodev.WeightDevice, error)
12
+
13
+// ValidateWeightDevice validates that the specified string has a valid device-weight format.
14
+func ValidateWeightDevice(val string) (*blkiodev.WeightDevice, error) {
15
+	split := strings.SplitN(val, ":", 2)
16
+	if len(split) != 2 {
17
+		return nil, fmt.Errorf("bad format: %s", val)
18
+	}
19
+	if !strings.HasPrefix(split[0], "/dev/") {
20
+		return nil, fmt.Errorf("bad format for device path: %s", val)
21
+	}
22
+	weight, err := strconv.ParseUint(split[1], 10, 0)
23
+	if err != nil {
24
+		return nil, fmt.Errorf("invalid weight for device: %s", val)
25
+	}
26
+	if weight > 0 && (weight < 10 || weight > 1000) {
27
+		return nil, fmt.Errorf("invalid weight for device: %s", val)
28
+	}
29
+
30
+	return &blkiodev.WeightDevice{
31
+		Path:   split[0],
32
+		Weight: uint16(weight),
33
+	}, nil
34
+}
35
+
36
+// WeightdeviceOpt defines a map of WeightDevices
37
+type WeightdeviceOpt struct {
38
+	values    []*blkiodev.WeightDevice
39
+	validator ValidatorWeightFctType
40
+}
41
+
42
+// NewWeightdeviceOpt creates a new WeightdeviceOpt
43
+func NewWeightdeviceOpt(validator ValidatorWeightFctType) WeightdeviceOpt {
44
+	values := []*blkiodev.WeightDevice{}
45
+	return WeightdeviceOpt{
46
+		values:    values,
47
+		validator: validator,
48
+	}
49
+}
50
+
51
+// Set validates a WeightDevice and sets its name as a key in WeightdeviceOpt
52
+func (opt *WeightdeviceOpt) Set(val string) error {
53
+	var value *blkiodev.WeightDevice
54
+	if opt.validator != nil {
55
+		v, err := opt.validator(val)
56
+		if err != nil {
57
+			return err
58
+		}
59
+		value = v
60
+	}
61
+	(opt.values) = append((opt.values), value)
62
+	return nil
63
+}
64
+
65
+// String returns WeightdeviceOpt values as a string.
66
+func (opt *WeightdeviceOpt) String() string {
67
+	var out []string
68
+	for _, v := range opt.values {
69
+		out = append(out, v.String())
70
+	}
71
+
72
+	return fmt.Sprintf("%v", out)
73
+}
74
+
75
+// GetList returns a slice of pointers to WeightDevices.
76
+func (opt *WeightdeviceOpt) GetList() []*blkiodev.WeightDevice {
77
+	var weightdevice []*blkiodev.WeightDevice
78
+	for _, v := range opt.values {
79
+		weightdevice = append(weightdevice, v)
80
+	}
81
+
82
+	return weightdevice
83
+}
84
+
85
+// Type returns the option type
86
+func (opt *WeightdeviceOpt) Type() string {
87
+	return "list"
88
+}
0 89
new file mode 100644
... ...
@@ -0,0 +1,22 @@
0
+package ioutils
1
+
2
+import (
3
+	"fmt"
4
+	"io"
5
+)
6
+
7
+// FprintfIfNotEmpty prints the string value if it's not empty
8
+func FprintfIfNotEmpty(w io.Writer, format, value string) (int, error) {
9
+	if value != "" {
10
+		return fmt.Fprintf(w, format, value)
11
+	}
12
+	return 0, nil
13
+}
14
+
15
+// FprintfIfTrue prints the boolean value if it's true
16
+func FprintfIfTrue(w io.Writer, format string, ok bool) (int, error) {
17
+	if ok {
18
+		return fmt.Fprintf(w, format, ok)
19
+	}
20
+	return 0, nil
21
+}
... ...
@@ -152,8 +152,7 @@ func (r *multiReadSeeker) getOffsetToReader(rdr io.ReadSeeker) (int64, error) {
152 152
 
153 153
 func (r *multiReadSeeker) Read(b []byte) (int, error) {
154 154
 	if r.pos == nil {
155
-		// make sure all readers are at 0
156
-		r.Seek(0, os.SEEK_SET)
155
+		r.pos = &pos{0, 0}
157 156
 	}
158 157
 
159 158
 	bLen := int64(len(b))
... ...
@@ -45,5 +45,4 @@ const (
45 45
 	RELATIME    = 0
46 46
 	REMOUNT     = 0
47 47
 	STRICTATIME = 0
48
-	mntDetach   = 0
49 48
 )
... ...
@@ -82,6 +82,4 @@ const (
82 82
 	// it possible for the kernel to default to relatime or noatime but still
83 83
 	// allow userspace to override it.
84 84
 	STRICTATIME = syscall.MS_STRICTATIME
85
-
86
-	mntDetach = syscall.MNT_DETACH
87 85
 )
... ...
@@ -27,5 +27,4 @@ const (
27 27
 	STRICTATIME = 0
28 28
 	SYNCHRONOUS = 0
29 29
 	RDONLY      = 0
30
-	mntDetach   = 0
31 30
 )
... ...
@@ -1,8 +1,7 @@
1 1
 package mount
2 2
 
3 3
 import (
4
-	"sort"
5
-	"strings"
4
+	"time"
6 5
 )
7 6
 
8 7
 // GetMounts retrieves a list of mounts for the current running process.
... ...
@@ -47,40 +46,29 @@ func Mount(device, target, mType, options string) error {
47 47
 // flags.go for supported option flags.
48 48
 func ForceMount(device, target, mType, options string) error {
49 49
 	flag, data := parseOptions(options)
50
-	return mount(device, target, mType, uintptr(flag), data)
50
+	if err := mount(device, target, mType, uintptr(flag), data); err != nil {
51
+		return err
52
+	}
53
+	return nil
51 54
 }
52 55
 
53
-// Unmount lazily unmounts a filesystem on supported platforms, otherwise
54
-// does a normal unmount.
56
+// Unmount will unmount the target filesystem, so long as it is mounted.
55 57
 func Unmount(target string) error {
56 58
 	if mounted, err := Mounted(target); err != nil || !mounted {
57 59
 		return err
58 60
 	}
59
-	return unmount(target, mntDetach)
61
+	return ForceUnmount(target)
60 62
 }
61 63
 
62
-// RecursiveUnmount unmounts the target and all mounts underneath, starting with
63
-// the deepsest mount first.
64
-func RecursiveUnmount(target string) error {
65
-	mounts, err := GetMounts()
66
-	if err != nil {
67
-		return err
68
-	}
69
-
70
-	// Make the deepest mount be first
71
-	sort.Sort(sort.Reverse(byMountpoint(mounts)))
72
-
73
-	for i, m := range mounts {
74
-		if !strings.HasPrefix(m.Mountpoint, target) {
75
-			continue
76
-		}
77
-		if err := Unmount(m.Mountpoint); err != nil && i == len(mounts)-1 {
78
-			if mounted, err := Mounted(m.Mountpoint); err != nil || mounted {
79
-				return err
80
-			}
81
-			// Ignore errors for submounts and continue trying to unmount others
82
-			// The final unmount should fail if there ane any submounts remaining
64
+// ForceUnmount will force an unmount of the target filesystem, regardless if
65
+// it is mounted or not.
66
+func ForceUnmount(target string) (err error) {
67
+	// Simple retry logic for unmount
68
+	for i := 0; i < 10; i++ {
69
+		if err = unmount(target, 0); err == nil {
70
+			return nil
83 71
 		}
72
+		time.Sleep(100 * time.Millisecond)
84 73
 	}
85
-	return nil
74
+	return
86 75
 }
... ...
@@ -4,50 +4,15 @@ import (
4 4
 	"syscall"
5 5
 )
6 6
 
7
-const (
8
-	// ptypes is the set propagation types.
9
-	ptypes = syscall.MS_SHARED | syscall.MS_PRIVATE | syscall.MS_SLAVE | syscall.MS_UNBINDABLE
10
-
11
-	// pflags is the full set valid flags for a change propagation call.
12
-	pflags = ptypes | syscall.MS_REC | syscall.MS_SILENT
13
-
14
-	// broflags is the combination of bind and read only
15
-	broflags = syscall.MS_BIND | syscall.MS_RDONLY
16
-)
17
-
18
-// isremount returns true if either device name or flags identify a remount request, false otherwise.
19
-func isremount(device string, flags uintptr) bool {
20
-	switch {
21
-	// We treat device "" and "none" as a remount request to provide compatibility with
22
-	// requests that don't explicitly set MS_REMOUNT such as those manipulating bind mounts.
23
-	case flags&syscall.MS_REMOUNT != 0, device == "", device == "none":
24
-		return true
25
-	default:
26
-		return false
27
-	}
28
-}
29
-
30
-func mount(device, target, mType string, flags uintptr, data string) error {
31
-	oflags := flags &^ ptypes
32
-	if !isremount(device, flags) {
33
-		// Initial call applying all non-propagation flags.
34
-		if err := syscall.Mount(device, target, mType, oflags, data); err != nil {
35
-			return err
36
-		}
7
+func mount(device, target, mType string, flag uintptr, data string) error {
8
+	if err := syscall.Mount(device, target, mType, flag, data); err != nil {
9
+		return err
37 10
 	}
38 11
 
39
-	if flags&ptypes != 0 {
40
-		// Change the propagation type.
41
-		if err := syscall.Mount("", target, "", flags&pflags, ""); err != nil {
42
-			return err
43
-		}
12
+	// If we have a bind mount or remount, remount...
13
+	if flag&syscall.MS_BIND == syscall.MS_BIND && flag&syscall.MS_RDONLY == syscall.MS_RDONLY {
14
+		return syscall.Mount(device, target, mType, flag|syscall.MS_REMOUNT, data)
44 15
 	}
45
-
46
-	if oflags&broflags == broflags {
47
-		// Remount the bind to apply read only.
48
-		return syscall.Mount("", target, "", oflags|syscall.MS_REMOUNT, "")
49
-	}
50
-
51 16
 	return nil
52 17
 }
53 18
 
... ...
@@ -38,17 +38,3 @@ type Info struct {
38 38
 	// VfsOpts represents per super block options.
39 39
 	VfsOpts string
40 40
 }
41
-
42
-type byMountpoint []*Info
43
-
44
-func (by byMountpoint) Len() int {
45
-	return len(by)
46
-}
47
-
48
-func (by byMountpoint) Less(i, j int) bool {
49
-	return by[i].Mountpoint < by[j].Mountpoint
50
-}
51
-
52
-func (by byMountpoint) Swap(i, j int) {
53
-	by[i], by[j] = by[j], by[i]
54
-}
... ...
@@ -1,4 +1,4 @@
1
-// +build linux freebsd solaris openbsd
1
+// +build linux freebsd solaris
2 2
 
3 3
 // Package kernel provides helper function to get, parse and compare kernel
4 4
 // versions for different platforms.
... ...
@@ -78,6 +78,12 @@ type Plugin struct {
78 78
 	handlersRun bool
79 79
 }
80 80
 
81
+// BasePath returns the path to which all paths returned by the plugin are relative to.
82
+// For v1 plugins, this always returns the host's root directory.
83
+func (p *Plugin) BasePath() string {
84
+	return "/"
85
+}
86
+
81 87
 // Name returns the name of the plugin.
82 88
 func (p *Plugin) Name() string {
83 89
 	return p.name
... ...
@@ -169,7 +175,7 @@ func (p *Plugin) activateWithLock() error {
169 169
 
170 170
 func (p *Plugin) waitActive() error {
171 171
 	p.activateWait.L.Lock()
172
-	for !p.activated() && p.activateErr == nil {
172
+	for !p.activated() {
173 173
 		p.activateWait.Wait()
174 174
 	}
175 175
 	p.activateWait.L.Unlock()
176 176
deleted file mode 100644
... ...
@@ -1,9 +0,0 @@
1
-// +build !windows
2
-
3
-package plugins
4
-
5
-// BasePath returns the path to which all paths returned by the plugin are relative to.
6
-// For v1 plugins, this always returns the host's root directory.
7
-func (p *Plugin) BasePath() string {
8
-	return "/"
9
-}
10 1
deleted file mode 100644
... ...
@@ -1,8 +0,0 @@
1
-package plugins
2
-
3
-// BasePath returns the path to which all paths returned by the plugin are relative to.
4
-// For Windows v1 plugins, this returns an empty string, since the plugin is already aware
5
-// of the absolute path of the mount.
6
-func (p *Plugin) BasePath() string {
7
-	return ""
8
-}
... ...
@@ -176,7 +176,7 @@
176 176
 
177 177
    END OF TERMS AND CONDITIONS
178 178
 
179
-   Copyright 2014-2017 Docker, Inc.
179
+   Copyright 2014-2016 Docker, Inc.
180 180
 
181 181
    Licensed under the Apache License, Version 2.0 (the "License");
182 182
    you may not use this file except in compliance with the License.
... ...
@@ -1,4 +1,4 @@
1
-Copyright (c) 2014-2017 The Docker & Go Authors. All rights reserved.
1
+Copyright (c) 2014-2016 The Docker & Go Authors. All rights reserved.
2 2
 
3 3
 Redistribution and use in source and binary forms, with or without
4 4
 modification, are permitted provided that the following conditions are
... ...
@@ -3,7 +3,6 @@
3 3
 package system
4 4
 
5 5
 import (
6
-	"io/ioutil"
7 6
 	"os"
8 7
 	"path/filepath"
9 8
 )
... ...
@@ -25,7 +24,7 @@ func IsAbs(path string) bool {
25 25
 	return filepath.IsAbs(path)
26 26
 }
27 27
 
28
-// The functions below here are wrappers for the equivalents in the os and ioutils packages.
28
+// The functions below here are wrappers for the equivalents in the os package.
29 29
 // They are passthrough on Unix platforms, and only relevant on Windows.
30 30
 
31 31
 // CreateSequential creates the named file with mode 0666 (before umask), truncating
... ...
@@ -53,16 +52,3 @@ func OpenSequential(name string) (*os.File, error) {
53 53
 func OpenFileSequential(name string, flag int, perm os.FileMode) (*os.File, error) {
54 54
 	return os.OpenFile(name, flag, perm)
55 55
 }
56
-
57
-// TempFileSequential creates a new temporary file in the directory dir
58
-// with a name beginning with prefix, opens the file for reading
59
-// and writing, and returns the resulting *os.File.
60
-// If dir is the empty string, TempFile uses the default directory
61
-// for temporary files (see os.TempDir).
62
-// Multiple programs calling TempFile simultaneously
63
-// will not choose the same file. The caller can use f.Name()
64
-// to find the pathname of the file. It is the caller's responsibility
65
-// to remove the file when no longer needed.
66
-func TempFileSequential(dir, prefix string) (f *os.File, err error) {
67
-	return ioutil.TempFile(dir, prefix)
68
-}
... ...
@@ -6,11 +6,8 @@ import (
6 6
 	"os"
7 7
 	"path/filepath"
8 8
 	"regexp"
9
-	"strconv"
10 9
 	"strings"
11
-	"sync"
12 10
 	"syscall"
13
-	"time"
14 11
 	"unsafe"
15 12
 
16 13
 	winio "github.com/Microsoft/go-winio"
... ...
@@ -237,55 +234,3 @@ func syscallOpenSequential(path string, mode int, _ uint32) (fd syscall.Handle,
237 237
 	h, e := syscall.CreateFile(pathp, access, sharemode, sa, createmode, fileFlagSequentialScan, 0)
238 238
 	return h, e
239 239
 }
240
-
241
-// Helpers for TempFileSequential
242
-var rand uint32
243
-var randmu sync.Mutex
244
-
245
-func reseed() uint32 {
246
-	return uint32(time.Now().UnixNano() + int64(os.Getpid()))
247
-}
248
-func nextSuffix() string {
249
-	randmu.Lock()
250
-	r := rand
251
-	if r == 0 {
252
-		r = reseed()
253
-	}
254
-	r = r*1664525 + 1013904223 // constants from Numerical Recipes
255
-	rand = r
256
-	randmu.Unlock()
257
-	return strconv.Itoa(int(1e9 + r%1e9))[1:]
258
-}
259
-
260
-// TempFileSequential is a copy of ioutil.TempFile, modified to use sequential
261
-// file access. Below is the original comment from golang:
262
-// TempFile creates a new temporary file in the directory dir
263
-// with a name beginning with prefix, opens the file for reading
264
-// and writing, and returns the resulting *os.File.
265
-// If dir is the empty string, TempFile uses the default directory
266
-// for temporary files (see os.TempDir).
267
-// Multiple programs calling TempFile simultaneously
268
-// will not choose the same file. The caller can use f.Name()
269
-// to find the pathname of the file. It is the caller's responsibility
270
-// to remove the file when no longer needed.
271
-func TempFileSequential(dir, prefix string) (f *os.File, err error) {
272
-	if dir == "" {
273
-		dir = os.TempDir()
274
-	}
275
-
276
-	nconflict := 0
277
-	for i := 0; i < 10000; i++ {
278
-		name := filepath.Join(dir, prefix+nextSuffix())
279
-		f, err = OpenFileSequential(name, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0600)
280
-		if os.IsExist(err) {
281
-			if nconflict++; nconflict > 10 {
282
-				randmu.Lock()
283
-				rand = reseed()
284
-				randmu.Unlock()
285
-			}
286
-			continue
287
-		}
288
-		break
289
-	}
290
-	return
291
-}
292 240
new file mode 100644
... ...
@@ -0,0 +1,19 @@
0
+// +build !windows
1
+
2
+package system
3
+
4
+import (
5
+	"syscall"
6
+)
7
+
8
+// Lstat takes a path to a file and returns
9
+// a system.StatT type pertaining to that file.
10
+//
11
+// Throws an error if the file does not exist
12
+func Lstat(path string) (*StatT, error) {
13
+	s := &syscall.Stat_t{}
14
+	if err := syscall.Lstat(path, s); err != nil {
15
+		return nil, err
16
+	}
17
+	return fromStatT(s)
18
+}
0 19
deleted file mode 100644
... ...
@@ -1,17 +0,0 @@
1
-// +build !windows
2
-
3
-package system
4
-
5
-import "syscall"
6
-
7
-// Lstat takes a path to a file and returns
8
-// a system.StatT type pertaining to that file.
9
-//
10
-// Throws an error if the file does not exist
11
-func Lstat(path string) (*StatT, error) {
12
-	s := &syscall.Stat_t{}
13
-	if err := syscall.Lstat(path, s); err != nil {
14
-		return nil, err
15
-	}
16
-	return fromStatT(s)
17
-}
... ...
@@ -1,14 +1,25 @@
1
+// +build windows
2
+
1 3
 package system
2 4
 
3
-import "os"
5
+import (
6
+	"os"
7
+)
4 8
 
5 9
 // Lstat calls os.Lstat to get a fileinfo interface back.
6 10
 // This is then copied into our own locally defined structure.
11
+// Note the Linux version uses fromStatT to do the copy back,
12
+// but that not strictly necessary when already in an OS specific module.
7 13
 func Lstat(path string) (*StatT, error) {
8 14
 	fi, err := os.Lstat(path)
9 15
 	if err != nil {
10 16
 		return nil, err
11 17
 	}
12 18
 
13
-	return fromStatT(&fi)
19
+	return &StatT{
20
+		name:    fi.Name(),
21
+		size:    fi.Size(),
22
+		mode:    fi.Mode(),
23
+		modTime: fi.ModTime(),
24
+		isDir:   fi.IsDir()}, nil
14 25
 }
... ...
@@ -7,7 +7,6 @@ import (
7 7
 	"unsafe"
8 8
 )
9 9
 
10
-// #cgo CFLAGS: -std=c99
11 10
 // #cgo LDFLAGS: -lkstat
12 11
 // #include <unistd.h>
13 12
 // #include <stdlib.h>
14 13
new file mode 100644
... ...
@@ -0,0 +1,20 @@
0
+package system
1
+
2
+// IsProcessAlive returns true if process with a given pid is running.
3
+func IsProcessAlive(pid int) bool {
4
+	// TODO Windows containerd. Not sure this is needed
5
+	//	p, err := os.FindProcess(pid)
6
+	//	if err == nil {
7
+	//		return true
8
+	//	}
9
+	return false
10
+}
11
+
12
+// KillProcess force-stops a process.
13
+func KillProcess(pid int) {
14
+	// TODO Windows containerd. Not sure this is needed
15
+	//	p, err := os.FindProcess(pid)
16
+	//	if err == nil {
17
+	//		p.Kill()
18
+	//	}
19
+}
0 20
deleted file mode 100644
... ...
@@ -1,80 +0,0 @@
1
-package system
2
-
3
-import (
4
-	"os"
5
-	"syscall"
6
-	"time"
7
-
8
-	"github.com/docker/docker/pkg/mount"
9
-	"github.com/pkg/errors"
10
-)
11
-
12
-// EnsureRemoveAll wraps `os.RemoveAll` to check for specific errors that can
13
-// often be remedied.
14
-// Only use `EnsureRemoveAll` if you really want to make every effort to remove
15
-// a directory.
16
-//
17
-// Because of the way `os.Remove` (and by extension `os.RemoveAll`) works, there
18
-// can be a race between reading directory entries and then actually attempting
19
-// to remove everything in the directory.
20
-// These types of errors do not need to be returned since it's ok for the dir to
21
-// be gone we can just retry the remove operation.
22
-//
23
-// This should not return a `os.ErrNotExist` kind of error under any cirucmstances
24
-func EnsureRemoveAll(dir string) error {
25
-	notExistErr := make(map[string]bool)
26
-
27
-	// track retries
28
-	exitOnErr := make(map[string]int)
29
-	maxRetry := 5
30
-
31
-	// Attempt to unmount anything beneath this dir first
32
-	mount.RecursiveUnmount(dir)
33
-
34
-	for {
35
-		err := os.RemoveAll(dir)
36
-		if err == nil {
37
-			return err
38
-		}
39
-
40
-		pe, ok := err.(*os.PathError)
41
-		if !ok {
42
-			return err
43
-		}
44
-
45
-		if os.IsNotExist(err) {
46
-			if notExistErr[pe.Path] {
47
-				return err
48
-			}
49
-			notExistErr[pe.Path] = true
50
-
51
-			// There is a race where some subdir can be removed but after the parent
52
-			//   dir entries have been read.
53
-			// So the path could be from `os.Remove(subdir)`
54
-			// If the reported non-existent path is not the passed in `dir` we
55
-			// should just retry, but otherwise return with no error.
56
-			if pe.Path == dir {
57
-				return nil
58
-			}
59
-			continue
60
-		}
61
-
62
-		if pe.Err != syscall.EBUSY {
63
-			return err
64
-		}
65
-
66
-		if mounted, _ := mount.Mounted(pe.Path); mounted {
67
-			if e := mount.Unmount(pe.Path); e != nil {
68
-				if mounted, _ := mount.Mounted(pe.Path); mounted {
69
-					return errors.Wrapf(e, "error while removing %s", dir)
70
-				}
71
-			}
72
-		}
73
-
74
-		if exitOnErr[pe.Path] == maxRetry {
75
-			return err
76
-		}
77
-		exitOnErr[pe.Path]++
78
-		time.Sleep(100 * time.Millisecond)
79
-	}
80
-}
81 1
new file mode 100644
... ...
@@ -0,0 +1,53 @@
0
+// +build !windows
1
+
2
+package system
3
+
4
+import (
5
+	"syscall"
6
+)
7
+
8
+// StatT type contains status of a file. It contains metadata
9
+// like permission, owner, group, size, etc about a file.
10
+type StatT struct {
11
+	mode uint32
12
+	uid  uint32
13
+	gid  uint32
14
+	rdev uint64
15
+	size int64
16
+	mtim syscall.Timespec
17
+}
18
+
19
+// Mode returns file's permission mode.
20
+func (s StatT) Mode() uint32 {
21
+	return s.mode
22
+}
23
+
24
+// UID returns file's user id of owner.
25
+func (s StatT) UID() uint32 {
26
+	return s.uid
27
+}
28
+
29
+// GID returns file's group id of owner.
30
+func (s StatT) GID() uint32 {
31
+	return s.gid
32
+}
33
+
34
+// Rdev returns file's device ID (if it's special file).
35
+func (s StatT) Rdev() uint64 {
36
+	return s.rdev
37
+}
38
+
39
+// Size returns file's size.
40
+func (s StatT) Size() int64 {
41
+	return s.size
42
+}
43
+
44
+// Mtim returns file's last modification time.
45
+func (s StatT) Mtim() syscall.Timespec {
46
+	return s.mtim
47
+}
48
+
49
+// GetLastModification returns file's last modification time.
50
+func (s StatT) GetLastModification() syscall.Timespec {
51
+	return s.Mtim()
52
+}
... ...
@@ -1,8 +1,10 @@
1 1
 package system
2 2
 
3
-import "syscall"
3
+import (
4
+	"syscall"
5
+)
4 6
 
5
-// fromStatT converts a syscall.Stat_t type to a system.Stat_t type
7
+// fromStatT creates a system.StatT type from a syscall.Stat_t type
6 8
 func fromStatT(s *syscall.Stat_t) (*StatT, error) {
7 9
 	return &StatT{size: s.Size,
8 10
 		mode: uint32(s.Mode),
... ...
@@ -11,3 +13,20 @@ func fromStatT(s *syscall.Stat_t) (*StatT, error) {
11 11
 		rdev: uint64(s.Rdev),
12 12
 		mtim: s.Mtimespec}, nil
13 13
 }
14
+
15
+// FromStatT loads a system.StatT from a syscall.Stat_t.
16
+func FromStatT(s *syscall.Stat_t) (*StatT, error) {
17
+	return fromStatT(s)
18
+}
19
+
20
+// Stat takes a path to a file and returns
21
+// a system.StatT type pertaining to that file.
22
+//
23
+// Throws an error if the file does not exist
24
+func Stat(path string) (*StatT, error) {
25
+	s := &syscall.Stat_t{}
26
+	if err := syscall.Stat(path, s); err != nil {
27
+		return nil, err
28
+	}
29
+	return fromStatT(s)
30
+}
... ...
@@ -1,6 +1,8 @@
1 1
 package system
2 2
 
3
-import "syscall"
3
+import (
4
+	"syscall"
5
+)
4 6
 
5 7
 // fromStatT converts a syscall.Stat_t type to a system.Stat_t type
6 8
 func fromStatT(s *syscall.Stat_t) (*StatT, error) {
... ...
@@ -11,3 +13,15 @@ func fromStatT(s *syscall.Stat_t) (*StatT, error) {
11 11
 		rdev: uint64(s.Rdev),
12 12
 		mtim: s.Mtimespec}, nil
13 13
 }
14
+
15
+// Stat takes a path to a file and returns
16
+// a system.Stat_t type pertaining to that file.
17
+//
18
+// Throws an error if the file does not exist
19
+func Stat(path string) (*StatT, error) {
20
+	s := &syscall.Stat_t{}
21
+	if err := syscall.Stat(path, s); err != nil {
22
+		return nil, err
23
+	}
24
+	return fromStatT(s)
25
+}
... ...
@@ -1,19 +1,33 @@
1 1
 package system
2 2
 
3
-import "syscall"
3
+import (
4
+	"syscall"
5
+)
4 6
 
5 7
 // fromStatT converts a syscall.Stat_t type to a system.Stat_t type
6 8
 func fromStatT(s *syscall.Stat_t) (*StatT, error) {
7 9
 	return &StatT{size: s.Size,
8
-		mode: uint32(s.Mode),
10
+		mode: s.Mode,
9 11
 		uid:  s.Uid,
10 12
 		gid:  s.Gid,
11
-		rdev: uint64(s.Rdev),
13
+		rdev: s.Rdev,
12 14
 		mtim: s.Mtim}, nil
13 15
 }
14 16
 
15
-// FromStatT converts a syscall.Stat_t type to a system.Stat_t type
16
-// This is exposed on Linux as pkg/archive/changes uses it.
17
+// FromStatT exists only on linux, and loads a system.StatT from a
18
+// syscal.Stat_t.
17 19
 func FromStatT(s *syscall.Stat_t) (*StatT, error) {
18 20
 	return fromStatT(s)
19 21
 }
22
+
23
+// Stat takes a path to a file and returns
24
+// a system.StatT type pertaining to that file.
25
+//
26
+// Throws an error if the file does not exist
27
+func Stat(path string) (*StatT, error) {
28
+	s := &syscall.Stat_t{}
29
+	if err := syscall.Stat(path, s); err != nil {
30
+		return nil, err
31
+	}
32
+	return fromStatT(s)
33
+}
... ...
@@ -1,8 +1,10 @@
1 1
 package system
2 2
 
3
-import "syscall"
3
+import (
4
+	"syscall"
5
+)
4 6
 
5
-// fromStatT converts a syscall.Stat_t type to a system.Stat_t type
7
+// fromStatT creates a system.StatT type from a syscall.Stat_t type
6 8
 func fromStatT(s *syscall.Stat_t) (*StatT, error) {
7 9
 	return &StatT{size: s.Size,
8 10
 		mode: uint32(s.Mode),
... ...
@@ -1,8 +1,12 @@
1
+// +build solaris
2
+
1 3
 package system
2 4
 
3
-import "syscall"
5
+import (
6
+	"syscall"
7
+)
4 8
 
5
-// fromStatT converts a syscall.Stat_t type to a system.Stat_t type
9
+// fromStatT creates a system.StatT type from a syscall.Stat_t type
6 10
 func fromStatT(s *syscall.Stat_t) (*StatT, error) {
7 11
 	return &StatT{size: s.Size,
8 12
 		mode: uint32(s.Mode),
... ...
@@ -11,3 +15,20 @@ func fromStatT(s *syscall.Stat_t) (*StatT, error) {
11 11
 		rdev: uint64(s.Rdev),
12 12
 		mtim: s.Mtim}, nil
13 13
 }
14
+
15
+// FromStatT loads a system.StatT from a syscal.Stat_t.
16
+func FromStatT(s *syscall.Stat_t) (*StatT, error) {
17
+	return fromStatT(s)
18
+}
19
+
20
+// Stat takes a path to a file and returns
21
+// a system.StatT type pertaining to that file.
22
+//
23
+// Throws an error if the file does not exist
24
+func Stat(path string) (*StatT, error) {
25
+	s := &syscall.Stat_t{}
26
+	if err := syscall.Stat(path, s); err != nil {
27
+		return nil, err
28
+	}
29
+	return fromStatT(s)
30
+}
14 31
deleted file mode 100644
... ...
@@ -1,58 +0,0 @@
1
-// +build !windows
2
-
3
-package system
4
-
5
-import "syscall"
6
-
7
-// StatT type contains status of a file. It contains metadata
8
-// like permission, owner, group, size, etc about a file.
9
-type StatT struct {
10
-	mode uint32
11
-	uid  uint32
12
-	gid  uint32
13
-	rdev uint64
14
-	size int64
15
-	mtim syscall.Timespec
16
-}
17
-
18
-// Mode returns file's permission mode.
19
-func (s StatT) Mode() uint32 {
20
-	return s.mode
21
-}
22
-
23
-// UID returns file's user id of owner.
24
-func (s StatT) UID() uint32 {
25
-	return s.uid
26
-}
27
-
28
-// GID returns file's group id of owner.
29
-func (s StatT) GID() uint32 {
30
-	return s.gid
31
-}
32
-
33
-// Rdev returns file's device ID (if it's special file).
34
-func (s StatT) Rdev() uint64 {
35
-	return s.rdev
36
-}
37
-
38
-// Size returns file's size.
39
-func (s StatT) Size() int64 {
40
-	return s.size
41
-}
42
-
43
-// Mtim returns file's last modification time.
44
-func (s StatT) Mtim() syscall.Timespec {
45
-	return s.mtim
46
-}
47
-
48
-// Stat takes a path to a file and returns
49
-// a system.StatT type pertaining to that file.
50
-//
51
-// Throws an error if the file does not exist
52
-func Stat(path string) (*StatT, error) {
53
-	s := &syscall.Stat_t{}
54
-	if err := syscall.Stat(path, s); err != nil {
55
-		return nil, err
56
-	}
57
-	return fromStatT(s)
58
-}
59 1
new file mode 100644
... ...
@@ -0,0 +1,17 @@
0
+// +build !linux,!windows,!freebsd,!solaris,!openbsd,!darwin
1
+
2
+package system
3
+
4
+import (
5
+	"syscall"
6
+)
7
+
8
+// fromStatT creates a system.StatT type from a syscall.Stat_t type
9
+func fromStatT(s *syscall.Stat_t) (*StatT, error) {
10
+	return &StatT{size: s.Size,
11
+		mode: uint32(s.Mode),
12
+		uid:  s.Uid,
13
+		gid:  s.Gid,
14
+		rdev: uint64(s.Rdev),
15
+		mtim: s.Mtimespec}, nil
16
+}
... ...
@@ -1,3 +1,5 @@
1
+// +build windows
2
+
1 3
 package system
2 4
 
3 5
 import (
... ...
@@ -6,11 +8,18 @@ import (
6 6
 )
7 7
 
8 8
 // StatT type contains status of a file. It contains metadata
9
-// like permission, size, etc about a file.
9
+// like name, permission, size, etc about a file.
10 10
 type StatT struct {
11
-	mode os.FileMode
12
-	size int64
13
-	mtim time.Time
11
+	name    string
12
+	size    int64
13
+	mode    os.FileMode
14
+	modTime time.Time
15
+	isDir   bool
16
+}
17
+
18
+// Name returns file's name.
19
+func (s StatT) Name() string {
20
+	return s.name
14 21
 }
15 22
 
16 23
 // Size returns file's size.
... ...
@@ -20,30 +29,15 @@ func (s StatT) Size() int64 {
20 20
 
21 21
 // Mode returns file's permission mode.
22 22
 func (s StatT) Mode() os.FileMode {
23
-	return os.FileMode(s.mode)
24
-}
25
-
26
-// Mtim returns file's last modification time.
27
-func (s StatT) Mtim() time.Time {
28
-	return time.Time(s.mtim)
23
+	return s.mode
29 24
 }
30 25
 
31
-// Stat takes a path to a file and returns
32
-// a system.StatT type pertaining to that file.
33
-//
34
-// Throws an error if the file does not exist
35
-func Stat(path string) (*StatT, error) {
36
-	fi, err := os.Stat(path)
37
-	if err != nil {
38
-		return nil, err
39
-	}
40
-	return fromStatT(&fi)
26
+// ModTime returns file's last modification time.
27
+func (s StatT) ModTime() time.Time {
28
+	return s.modTime
41 29
 }
42 30
 
43
-// fromStatT converts a os.FileInfo type to a system.StatT type
44
-func fromStatT(fi *os.FileInfo) (*StatT, error) {
45
-	return &StatT{
46
-		size: (*fi).Size(),
47
-		mode: (*fi).Mode(),
48
-		mtim: (*fi).ModTime()}, nil
31
+// IsDir returns whether file is actually a directory.
32
+func (s StatT) IsDir() bool {
33
+	return s.isDir
49 34
 }
50 35
deleted file mode 100644
... ...
@@ -1,74 +0,0 @@
1
-package term
2
-
3
-import (
4
-	"io"
5
-)
6
-
7
-// EscapeError is special error which returned by a TTY proxy reader's Read()
8
-// method in case its detach escape sequence is read.
9
-type EscapeError struct{}
10
-
11
-func (EscapeError) Error() string {
12
-	return "read escape sequence"
13
-}
14
-
15
-// escapeProxy is used only for attaches with a TTY. It is used to proxy
16
-// stdin keypresses from the underlying reader and look for the passed in
17
-// escape key sequence to signal a detach.
18
-type escapeProxy struct {
19
-	escapeKeys   []byte
20
-	escapeKeyPos int
21
-	r            io.Reader
22
-}
23
-
24
-// NewEscapeProxy returns a new TTY proxy reader which wraps the given reader
25
-// and detects when the specified escape keys are read, in which case the Read
26
-// method will return an error of type EscapeError.
27
-func NewEscapeProxy(r io.Reader, escapeKeys []byte) io.Reader {
28
-	return &escapeProxy{
29
-		escapeKeys: escapeKeys,
30
-		r:          r,
31
-	}
32
-}
33
-
34
-func (r *escapeProxy) Read(buf []byte) (int, error) {
35
-	nr, err := r.r.Read(buf)
36
-
37
-	preserve := func() {
38
-		// this preserves the original key presses in the passed in buffer
39
-		nr += r.escapeKeyPos
40
-		preserve := make([]byte, 0, r.escapeKeyPos+len(buf))
41
-		preserve = append(preserve, r.escapeKeys[:r.escapeKeyPos]...)
42
-		preserve = append(preserve, buf...)
43
-		r.escapeKeyPos = 0
44
-		copy(buf[0:nr], preserve)
45
-	}
46
-
47
-	if nr != 1 || err != nil {
48
-		if r.escapeKeyPos > 0 {
49
-			preserve()
50
-		}
51
-		return nr, err
52
-	}
53
-
54
-	if buf[0] != r.escapeKeys[r.escapeKeyPos] {
55
-		if r.escapeKeyPos > 0 {
56
-			preserve()
57
-		}
58
-		return nr, nil
59
-	}
60
-
61
-	if r.escapeKeyPos == len(r.escapeKeys)-1 {
62
-		return 0, EscapeError{}
63
-	}
64
-
65
-	// Looks like we've got an escape key, but we need to match again on the next
66
-	// read.
67
-	// Store the current escape key we found so we can look for the next one on
68
-	// the next read.
69
-	// Since this is an escape key, make sure we don't let the caller read it
70
-	// If later on we find that this is not the escape sequence, we'll add the
71
-	// keys back
72
-	r.escapeKeyPos++
73
-	return nr - r.escapeKeyPos, nil
74
-}
75 1
deleted file mode 100644
... ...
@@ -1,21 +0,0 @@
1
-// +build !windows
2
-// +build !solaris !cgo
3
-
4
-package term
5
-
6
-import (
7
-	"syscall"
8
-	"unsafe"
9
-
10
-	"golang.org/x/sys/unix"
11
-)
12
-
13
-func tcget(fd uintptr, p *Termios) syscall.Errno {
14
-	_, _, err := unix.Syscall(unix.SYS_IOCTL, fd, uintptr(getTermios), uintptr(unsafe.Pointer(p)))
15
-	return err
16
-}
17
-
18
-func tcset(fd uintptr, p *Termios) syscall.Errno {
19
-	_, _, err := unix.Syscall(unix.SYS_IOCTL, fd, setTermios, uintptr(unsafe.Pointer(p)))
20
-	return err
21
-}
22 1
new file mode 100644
... ...
@@ -0,0 +1,50 @@
0
+// +build linux,cgo
1
+
2
+package term
3
+
4
+import (
5
+	"syscall"
6
+	"unsafe"
7
+)
8
+
9
+// #include <termios.h>
10
+import "C"
11
+
12
+// Termios is the Unix API for terminal I/O.
13
+// It is passthrough for syscall.Termios in order to make it portable with
14
+// other platforms where it is not available or handled differently.
15
+type Termios syscall.Termios
16
+
17
+// MakeRaw put the terminal connected to the given file descriptor into raw
18
+// mode and returns the previous state of the terminal so that it can be
19
+// restored.
20
+func MakeRaw(fd uintptr) (*State, error) {
21
+	var oldState State
22
+	if err := tcget(fd, &oldState.termios); err != 0 {
23
+		return nil, err
24
+	}
25
+
26
+	newState := oldState.termios
27
+
28
+	C.cfmakeraw((*C.struct_termios)(unsafe.Pointer(&newState)))
29
+	if err := tcset(fd, &newState); err != 0 {
30
+		return nil, err
31
+	}
32
+	return &oldState, nil
33
+}
34
+
35
+func tcget(fd uintptr, p *Termios) syscall.Errno {
36
+	ret, err := C.tcgetattr(C.int(fd), (*C.struct_termios)(unsafe.Pointer(p)))
37
+	if ret != 0 {
38
+		return err.(syscall.Errno)
39
+	}
40
+	return 0
41
+}
42
+
43
+func tcset(fd uintptr, p *Termios) syscall.Errno {
44
+	ret, err := C.tcsetattr(C.int(fd), C.TCSANOW, (*C.struct_termios)(unsafe.Pointer(p)))
45
+	if ret != 0 {
46
+		return err.(syscall.Errno)
47
+	}
48
+	return 0
49
+}
0 50
new file mode 100644
... ...
@@ -0,0 +1,20 @@
0
+// +build !windows
1
+// +build !linux !cgo
2
+// +build !solaris !cgo
3
+
4
+package term
5
+
6
+import (
7
+	"syscall"
8
+	"unsafe"
9
+)
10
+
11
+func tcget(fd uintptr, p *Termios) syscall.Errno {
12
+	_, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(getTermios), uintptr(unsafe.Pointer(p)))
13
+	return err
14
+}
15
+
16
+func tcset(fd uintptr, p *Termios) syscall.Errno {
17
+	_, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, setTermios, uintptr(unsafe.Pointer(p)))
18
+	return err
19
+}
... ...
@@ -5,17 +5,15 @@ package term
5 5
 import (
6 6
 	"syscall"
7 7
 	"unsafe"
8
-
9
-	"golang.org/x/sys/unix"
10 8
 )
11 9
 
12 10
 // #include <termios.h>
13 11
 import "C"
14 12
 
15 13
 // Termios is the Unix API for terminal I/O.
16
-// It is passthrough for unix.Termios in order to make it portable with
14
+// It is passthrough for syscall.Termios in order to make it portable with
17 15
 // other platforms where it is not available or handled differently.
18
-type Termios unix.Termios
16
+type Termios syscall.Termios
19 17
 
20 18
 // MakeRaw put the terminal connected to the given file descriptor into raw
21 19
 // mode and returns the previous state of the terminal so that it can be
... ...
@@ -28,11 +26,11 @@ func MakeRaw(fd uintptr) (*State, error) {
28 28
 
29 29
 	newState := oldState.termios
30 30
 
31
-	newState.Iflag &^= (unix.IGNBRK | unix.BRKINT | unix.PARMRK | unix.ISTRIP | unix.INLCR | unix.IGNCR | unix.ICRNL | unix.IXON | unix.IXANY)
32
-	newState.Oflag &^= unix.OPOST
33
-	newState.Lflag &^= (unix.ECHO | unix.ECHONL | unix.ICANON | unix.ISIG | unix.IEXTEN)
34
-	newState.Cflag &^= (unix.CSIZE | unix.PARENB)
35
-	newState.Cflag |= unix.CS8
31
+	newState.Iflag &^= (syscall.IGNBRK | syscall.BRKINT | syscall.PARMRK | syscall.ISTRIP | syscall.INLCR | syscall.IGNCR | syscall.ICRNL | syscall.IXON | syscall.IXANY)
32
+	newState.Oflag &^= syscall.OPOST
33
+	newState.Lflag &^= (syscall.ECHO | syscall.ECHONL | syscall.ICANON | syscall.ISIG | syscall.IEXTEN)
34
+	newState.Cflag &^= (syscall.CSIZE | syscall.PARENB)
35
+	newState.Cflag |= syscall.CS8
36 36
 
37 37
 	/*
38 38
 		VMIN is the minimum number of characters that needs to be read in non-canonical mode for it to be returned
... ...
@@ -10,8 +10,7 @@ import (
10 10
 	"io"
11 11
 	"os"
12 12
 	"os/signal"
13
-
14
-	"golang.org/x/sys/unix"
13
+	"syscall"
15 14
 )
16 15
 
17 16
 var (
... ...
@@ -32,7 +31,7 @@ type Winsize struct {
32 32
 	y      uint16
33 33
 }
34 34
 
35
-// StdStreams returns the standard streams (stdin, stdout, stderr).
35
+// StdStreams returns the standard streams (stdin, stdout, stedrr).
36 36
 func StdStreams() (stdIn io.ReadCloser, stdOut, stdErr io.Writer) {
37 37
 	return os.Stdin, os.Stdout, os.Stderr
38 38
 }
... ...
@@ -80,7 +79,7 @@ func SaveState(fd uintptr) (*State, error) {
80 80
 // descriptor, with echo disabled.
81 81
 func DisableEcho(fd uintptr, state *State) error {
82 82
 	newState := state.termios
83
-	newState.Lflag &^= unix.ECHO
83
+	newState.Lflag &^= syscall.ECHO
84 84
 
85 85
 	if err := tcset(fd, &newState); err != 0 {
86 86
 		return err
87 87
new file mode 100644
... ...
@@ -0,0 +1,41 @@
0
+// +build solaris
1
+
2
+package term
3
+
4
+import (
5
+	"syscall"
6
+	"unsafe"
7
+)
8
+
9
+/*
10
+#include <unistd.h>
11
+#include <stropts.h>
12
+#include <termios.h>
13
+
14
+// Small wrapper to get rid of variadic args of ioctl()
15
+int my_ioctl(int fd, int cmd, struct winsize *ws) {
16
+	return ioctl(fd, cmd, ws);
17
+}
18
+*/
19
+import "C"
20
+
21
+// GetWinsize returns the window size based on the specified file descriptor.
22
+func GetWinsize(fd uintptr) (*Winsize, error) {
23
+	ws := &Winsize{}
24
+	ret, err := C.my_ioctl(C.int(fd), C.int(syscall.TIOCGWINSZ), (*C.struct_winsize)(unsafe.Pointer(ws)))
25
+	// Skip retval = 0
26
+	if ret == 0 {
27
+		return ws, nil
28
+	}
29
+	return ws, err
30
+}
31
+
32
+// SetWinsize tries to set the specified window size for the specified file descriptor.
33
+func SetWinsize(fd uintptr, ws *Winsize) error {
34
+	ret, err := C.my_ioctl(C.int(fd), C.int(syscall.TIOCSWINSZ), (*C.struct_winsize)(unsafe.Pointer(ws)))
35
+	// Skip retval = 0
36
+	if ret == 0 {
37
+		return nil
38
+	}
39
+	return err
40
+}
0 41
new file mode 100644
... ...
@@ -0,0 +1,29 @@
0
+// +build !solaris,!windows
1
+
2
+package term
3
+
4
+import (
5
+	"syscall"
6
+	"unsafe"
7
+)
8
+
9
+// GetWinsize returns the window size based on the specified file descriptor.
10
+func GetWinsize(fd uintptr) (*Winsize, error) {
11
+	ws := &Winsize{}
12
+	_, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(syscall.TIOCGWINSZ), uintptr(unsafe.Pointer(ws)))
13
+	// Skipp errno = 0
14
+	if err == 0 {
15
+		return ws, nil
16
+	}
17
+	return ws, err
18
+}
19
+
20
+// SetWinsize tries to set the specified window size for the specified file descriptor.
21
+func SetWinsize(fd uintptr, ws *Winsize) error {
22
+	_, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(syscall.TIOCSWINSZ), uintptr(unsafe.Pointer(ws)))
23
+	// Skipp errno = 0
24
+	if err == 0 {
25
+		return nil
26
+	}
27
+	return err
28
+}
... ...
@@ -6,10 +6,10 @@ import (
6 6
 	"io"
7 7
 	"os"
8 8
 	"os/signal"
9
+	"syscall"
9 10
 
10 11
 	"github.com/Azure/go-ansiterm/winterm"
11 12
 	"github.com/docker/docker/pkg/term/windows"
12
-	"golang.org/x/sys/windows"
13 13
 )
14 14
 
15 15
 // State holds the console mode for the terminal.
... ...
@@ -33,7 +33,7 @@ const (
33 33
 // vtInputSupported is true if enableVirtualTerminalInput is supported by the console
34 34
 var vtInputSupported bool
35 35
 
36
-// StdStreams returns the standard streams (stdin, stdout, stderr).
36
+// StdStreams returns the standard streams (stdin, stdout, stedrr).
37 37
 func StdStreams() (stdIn io.ReadCloser, stdOut, stdErr io.Writer) {
38 38
 	// Turn on VT handling on all std handles, if possible. This might
39 39
 	// fail, in which case we will fall back to terminal emulation.
... ...
@@ -79,19 +79,19 @@ func StdStreams() (stdIn io.ReadCloser, stdOut, stdErr io.Writer) {
79 79
 	}
80 80
 
81 81
 	if emulateStdin {
82
-		stdIn = windowsconsole.NewAnsiReader(windows.STD_INPUT_HANDLE)
82
+		stdIn = windows.NewAnsiReader(syscall.STD_INPUT_HANDLE)
83 83
 	} else {
84 84
 		stdIn = os.Stdin
85 85
 	}
86 86
 
87 87
 	if emulateStdout {
88
-		stdOut = windowsconsole.NewAnsiWriter(windows.STD_OUTPUT_HANDLE)
88
+		stdOut = windows.NewAnsiWriter(syscall.STD_OUTPUT_HANDLE)
89 89
 	} else {
90 90
 		stdOut = os.Stdout
91 91
 	}
92 92
 
93 93
 	if emulateStderr {
94
-		stdErr = windowsconsole.NewAnsiWriter(windows.STD_ERROR_HANDLE)
94
+		stdErr = windows.NewAnsiWriter(syscall.STD_ERROR_HANDLE)
95 95
 	} else {
96 96
 		stdErr = os.Stderr
97 97
 	}
... ...
@@ -101,7 +101,7 @@ func StdStreams() (stdIn io.ReadCloser, stdOut, stdErr io.Writer) {
101 101
 
102 102
 // GetFdInfo returns the file descriptor for an os.File and indicates whether the file represents a terminal.
103 103
 func GetFdInfo(in interface{}) (uintptr, bool) {
104
-	return windowsconsole.GetHandleInfo(in)
104
+	return windows.GetHandleInfo(in)
105 105
 }
106 106
 
107 107
 // GetWinsize returns the window size based on the specified file descriptor.
... ...
@@ -121,7 +121,7 @@ func GetWinsize(fd uintptr) (*Winsize, error) {
121 121
 
122 122
 // IsTerminal returns true if the given file descriptor is a terminal.
123 123
 func IsTerminal(fd uintptr) bool {
124
-	return windowsconsole.IsConsole(fd)
124
+	return windows.IsConsole(fd)
125 125
 }
126 126
 
127 127
 // RestoreTerminal restores the terminal connected to the given file descriptor
128 128
deleted file mode 100644
... ...
@@ -1,42 +0,0 @@
1
-// +build darwin freebsd openbsd
2
-
3
-package term
4
-
5
-import (
6
-	"unsafe"
7
-
8
-	"golang.org/x/sys/unix"
9
-)
10
-
11
-const (
12
-	getTermios = unix.TIOCGETA
13
-	setTermios = unix.TIOCSETA
14
-)
15
-
16
-// Termios is the Unix API for terminal I/O.
17
-type Termios unix.Termios
18
-
19
-// MakeRaw put the terminal connected to the given file descriptor into raw
20
-// mode and returns the previous state of the terminal so that it can be
21
-// restored.
22
-func MakeRaw(fd uintptr) (*State, error) {
23
-	var oldState State
24
-	if _, _, err := unix.Syscall(unix.SYS_IOCTL, fd, getTermios, uintptr(unsafe.Pointer(&oldState.termios))); err != 0 {
25
-		return nil, err
26
-	}
27
-
28
-	newState := oldState.termios
29
-	newState.Iflag &^= (unix.IGNBRK | unix.BRKINT | unix.PARMRK | unix.ISTRIP | unix.INLCR | unix.IGNCR | unix.ICRNL | unix.IXON)
30
-	newState.Oflag &^= unix.OPOST
31
-	newState.Lflag &^= (unix.ECHO | unix.ECHONL | unix.ICANON | unix.ISIG | unix.IEXTEN)
32
-	newState.Cflag &^= (unix.CSIZE | unix.PARENB)
33
-	newState.Cflag |= unix.CS8
34
-	newState.Cc[unix.VMIN] = 1
35
-	newState.Cc[unix.VTIME] = 0
36
-
37
-	if _, _, err := unix.Syscall(unix.SYS_IOCTL, fd, setTermios, uintptr(unsafe.Pointer(&newState))); err != 0 {
38
-		return nil, err
39
-	}
40
-
41
-	return &oldState, nil
42
-}
43 1
new file mode 100644
... ...
@@ -0,0 +1,69 @@
0
+package term
1
+
2
+import (
3
+	"syscall"
4
+	"unsafe"
5
+)
6
+
7
+const (
8
+	getTermios = syscall.TIOCGETA
9
+	setTermios = syscall.TIOCSETA
10
+)
11
+
12
+// Termios magic numbers, passthrough to the ones defined in syscall.
13
+const (
14
+	IGNBRK = syscall.IGNBRK
15
+	PARMRK = syscall.PARMRK
16
+	INLCR  = syscall.INLCR
17
+	IGNCR  = syscall.IGNCR
18
+	ECHONL = syscall.ECHONL
19
+	CSIZE  = syscall.CSIZE
20
+	ICRNL  = syscall.ICRNL
21
+	ISTRIP = syscall.ISTRIP
22
+	PARENB = syscall.PARENB
23
+	ECHO   = syscall.ECHO
24
+	ICANON = syscall.ICANON
25
+	ISIG   = syscall.ISIG
26
+	IXON   = syscall.IXON
27
+	BRKINT = syscall.BRKINT
28
+	INPCK  = syscall.INPCK
29
+	OPOST  = syscall.OPOST
30
+	CS8    = syscall.CS8
31
+	IEXTEN = syscall.IEXTEN
32
+)
33
+
34
+// Termios is the Unix API for terminal I/O.
35
+type Termios struct {
36
+	Iflag  uint64
37
+	Oflag  uint64
38
+	Cflag  uint64
39
+	Lflag  uint64
40
+	Cc     [20]byte
41
+	Ispeed uint64
42
+	Ospeed uint64
43
+}
44
+
45
+// MakeRaw put the terminal connected to the given file descriptor into raw
46
+// mode and returns the previous state of the terminal so that it can be
47
+// restored.
48
+func MakeRaw(fd uintptr) (*State, error) {
49
+	var oldState State
50
+	if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(getTermios), uintptr(unsafe.Pointer(&oldState.termios))); err != 0 {
51
+		return nil, err
52
+	}
53
+
54
+	newState := oldState.termios
55
+	newState.Iflag &^= (IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON)
56
+	newState.Oflag &^= OPOST
57
+	newState.Lflag &^= (ECHO | ECHONL | ICANON | ISIG | IEXTEN)
58
+	newState.Cflag &^= (CSIZE | PARENB)
59
+	newState.Cflag |= CS8
60
+	newState.Cc[syscall.VMIN] = 1
61
+	newState.Cc[syscall.VTIME] = 0
62
+
63
+	if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(setTermios), uintptr(unsafe.Pointer(&newState))); err != 0 {
64
+		return nil, err
65
+	}
66
+
67
+	return &oldState, nil
68
+}
0 69
new file mode 100644
... ...
@@ -0,0 +1,69 @@
0
+package term
1
+
2
+import (
3
+	"syscall"
4
+	"unsafe"
5
+)
6
+
7
+const (
8
+	getTermios = syscall.TIOCGETA
9
+	setTermios = syscall.TIOCSETA
10
+)
11
+
12
+// Termios magic numbers, passthrough to the ones defined in syscall.
13
+const (
14
+	IGNBRK = syscall.IGNBRK
15
+	PARMRK = syscall.PARMRK
16
+	INLCR  = syscall.INLCR
17
+	IGNCR  = syscall.IGNCR
18
+	ECHONL = syscall.ECHONL
19
+	CSIZE  = syscall.CSIZE
20
+	ICRNL  = syscall.ICRNL
21
+	ISTRIP = syscall.ISTRIP
22
+	PARENB = syscall.PARENB
23
+	ECHO   = syscall.ECHO
24
+	ICANON = syscall.ICANON
25
+	ISIG   = syscall.ISIG
26
+	IXON   = syscall.IXON
27
+	BRKINT = syscall.BRKINT
28
+	INPCK  = syscall.INPCK
29
+	OPOST  = syscall.OPOST
30
+	CS8    = syscall.CS8
31
+	IEXTEN = syscall.IEXTEN
32
+)
33
+
34
+// Termios is the Unix API for terminal I/O.
35
+type Termios struct {
36
+	Iflag  uint32
37
+	Oflag  uint32
38
+	Cflag  uint32
39
+	Lflag  uint32
40
+	Cc     [20]byte
41
+	Ispeed uint32
42
+	Ospeed uint32
43
+}
44
+
45
+// MakeRaw put the terminal connected to the given file descriptor into raw
46
+// mode and returns the previous state of the terminal so that it can be
47
+// restored.
48
+func MakeRaw(fd uintptr) (*State, error) {
49
+	var oldState State
50
+	if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(getTermios), uintptr(unsafe.Pointer(&oldState.termios))); err != 0 {
51
+		return nil, err
52
+	}
53
+
54
+	newState := oldState.termios
55
+	newState.Iflag &^= (IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON)
56
+	newState.Oflag &^= OPOST
57
+	newState.Lflag &^= (ECHO | ECHONL | ICANON | ISIG | IEXTEN)
58
+	newState.Cflag &^= (CSIZE | PARENB)
59
+	newState.Cflag |= CS8
60
+	newState.Cc[syscall.VMIN] = 1
61
+	newState.Cc[syscall.VTIME] = 0
62
+
63
+	if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(setTermios), uintptr(unsafe.Pointer(&newState))); err != 0 {
64
+		return nil, err
65
+	}
66
+
67
+	return &oldState, nil
68
+}
... ...
@@ -1,37 +1,46 @@
1
+// +build !cgo
2
+
1 3
 package term
2 4
 
3 5
 import (
6
+	"syscall"
4 7
 	"unsafe"
5
-
6
-	"golang.org/x/sys/unix"
7 8
 )
8 9
 
9 10
 const (
10
-	getTermios = unix.TCGETS
11
-	setTermios = unix.TCSETS
11
+	getTermios = syscall.TCGETS
12
+	setTermios = syscall.TCSETS
12 13
 )
13 14
 
14 15
 // Termios is the Unix API for terminal I/O.
15
-type Termios unix.Termios
16
+type Termios struct {
17
+	Iflag  uint32
18
+	Oflag  uint32
19
+	Cflag  uint32
20
+	Lflag  uint32
21
+	Cc     [20]byte
22
+	Ispeed uint32
23
+	Ospeed uint32
24
+}
16 25
 
17 26
 // MakeRaw put the terminal connected to the given file descriptor into raw
18 27
 // mode and returns the previous state of the terminal so that it can be
19 28
 // restored.
20 29
 func MakeRaw(fd uintptr) (*State, error) {
21 30
 	var oldState State
22
-	if _, _, err := unix.Syscall(unix.SYS_IOCTL, fd, getTermios, uintptr(unsafe.Pointer(&oldState.termios))); err != 0 {
31
+	if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, getTermios, uintptr(unsafe.Pointer(&oldState.termios))); err != 0 {
23 32
 		return nil, err
24 33
 	}
25 34
 
26 35
 	newState := oldState.termios
27 36
 
28
-	newState.Iflag &^= (unix.IGNBRK | unix.BRKINT | unix.PARMRK | unix.ISTRIP | unix.INLCR | unix.IGNCR | unix.ICRNL | unix.IXON)
29
-	newState.Oflag |= unix.OPOST
30
-	newState.Lflag &^= (unix.ECHO | unix.ECHONL | unix.ICANON | unix.ISIG | unix.IEXTEN)
31
-	newState.Cflag &^= (unix.CSIZE | unix.PARENB)
32
-	newState.Cflag |= unix.CS8
37
+	newState.Iflag &^= (syscall.IGNBRK | syscall.BRKINT | syscall.PARMRK | syscall.ISTRIP | syscall.INLCR | syscall.IGNCR | syscall.ICRNL | syscall.IXON)
38
+	newState.Oflag &^= syscall.OPOST
39
+	newState.Lflag &^= (syscall.ECHO | syscall.ECHONL | syscall.ICANON | syscall.ISIG | syscall.IEXTEN)
40
+	newState.Cflag &^= (syscall.CSIZE | syscall.PARENB)
41
+	newState.Cflag |= syscall.CS8
33 42
 
34
-	if _, _, err := unix.Syscall(unix.SYS_IOCTL, fd, setTermios, uintptr(unsafe.Pointer(&newState))); err != 0 {
43
+	if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, setTermios, uintptr(unsafe.Pointer(&newState))); err != 0 {
35 44
 		return nil, err
36 45
 	}
37 46
 	return &oldState, nil
38 47
new file mode 100644
... ...
@@ -0,0 +1,69 @@
0
+package term
1
+
2
+import (
3
+	"syscall"
4
+	"unsafe"
5
+)
6
+
7
+const (
8
+	getTermios = syscall.TIOCGETA
9
+	setTermios = syscall.TIOCSETA
10
+)
11
+
12
+// Termios magic numbers, passthrough to the ones defined in syscall.
13
+const (
14
+	IGNBRK = syscall.IGNBRK
15
+	PARMRK = syscall.PARMRK
16
+	INLCR  = syscall.INLCR
17
+	IGNCR  = syscall.IGNCR
18
+	ECHONL = syscall.ECHONL
19
+	CSIZE  = syscall.CSIZE
20
+	ICRNL  = syscall.ICRNL
21
+	ISTRIP = syscall.ISTRIP
22
+	PARENB = syscall.PARENB
23
+	ECHO   = syscall.ECHO
24
+	ICANON = syscall.ICANON
25
+	ISIG   = syscall.ISIG
26
+	IXON   = syscall.IXON
27
+	BRKINT = syscall.BRKINT
28
+	INPCK  = syscall.INPCK
29
+	OPOST  = syscall.OPOST
30
+	CS8    = syscall.CS8
31
+	IEXTEN = syscall.IEXTEN
32
+)
33
+
34
+// Termios is the Unix API for terminal I/O.
35
+type Termios struct {
36
+	Iflag  uint32
37
+	Oflag  uint32
38
+	Cflag  uint32
39
+	Lflag  uint32
40
+	Cc     [20]byte
41
+	Ispeed uint32
42
+	Ospeed uint32
43
+}
44
+
45
+// MakeRaw put the terminal connected to the given file descriptor into raw
46
+// mode and returns the previous state of the terminal so that it can be
47
+// restored.
48
+func MakeRaw(fd uintptr) (*State, error) {
49
+	var oldState State
50
+	if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(getTermios), uintptr(unsafe.Pointer(&oldState.termios))); err != 0 {
51
+		return nil, err
52
+	}
53
+
54
+	newState := oldState.termios
55
+	newState.Iflag &^= (IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON)
56
+	newState.Oflag &^= OPOST
57
+	newState.Lflag &^= (ECHO | ECHONL | ICANON | ISIG | IEXTEN)
58
+	newState.Cflag &^= (CSIZE | PARENB)
59
+	newState.Cflag |= CS8
60
+	newState.Cc[syscall.VMIN] = 1
61
+	newState.Cc[syscall.VTIME] = 0
62
+
63
+	if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(setTermios), uintptr(unsafe.Pointer(&newState))); err != 0 {
64
+		return nil, err
65
+	}
66
+
67
+	return &oldState, nil
68
+}
... ...
@@ -1,6 +1,6 @@
1 1
 // +build windows
2 2
 
3
-package windowsconsole
3
+package windows
4 4
 
5 5
 import (
6 6
 	"bytes"
... ...
@@ -1,6 +1,6 @@
1 1
 // +build windows
2 2
 
3
-package windowsconsole
3
+package windows
4 4
 
5 5
 import (
6 6
 	"io"
... ...
@@ -1,6 +1,6 @@
1 1
 // +build windows
2 2
 
3
-package windowsconsole
3
+package windows
4 4
 
5 5
 import (
6 6
 	"os"
... ...
@@ -2,7 +2,7 @@
2 2
 // When asked for the set of standard streams (e.g., stdin, stdout, stderr), the code will create
3 3
 // and return pseudo-streams that convert ANSI sequences to / from Windows Console API calls.
4 4
 
5
-package windowsconsole
5
+package windows
6 6
 
7 7
 import (
8 8
 	"io/ioutil"
9 9
deleted file mode 100644
... ...
@@ -1,30 +0,0 @@
1
-// +build !solaris,!windows
2
-
3
-package term
4
-
5
-import (
6
-	"unsafe"
7
-
8
-	"golang.org/x/sys/unix"
9
-)
10
-
11
-// GetWinsize returns the window size based on the specified file descriptor.
12
-func GetWinsize(fd uintptr) (*Winsize, error) {
13
-	ws := &Winsize{}
14
-	_, _, err := unix.Syscall(unix.SYS_IOCTL, fd, uintptr(unix.TIOCGWINSZ), uintptr(unsafe.Pointer(ws)))
15
-	// Skipp errno = 0
16
-	if err == 0 {
17
-		return ws, nil
18
-	}
19
-	return ws, err
20
-}
21
-
22
-// SetWinsize tries to set the specified window size for the specified file descriptor.
23
-func SetWinsize(fd uintptr, ws *Winsize) error {
24
-	_, _, err := unix.Syscall(unix.SYS_IOCTL, fd, uintptr(unix.TIOCSWINSZ), uintptr(unsafe.Pointer(ws)))
25
-	// Skipp errno = 0
26
-	if err == 0 {
27
-		return nil
28
-	}
29
-	return err
30
-}
31 1
deleted file mode 100644
... ...
@@ -1,42 +0,0 @@
1
-// +build solaris,cgo
2
-
3
-package term
4
-
5
-import (
6
-	"unsafe"
7
-
8
-	"golang.org/x/sys/unix"
9
-)
10
-
11
-/*
12
-#include <unistd.h>
13
-#include <stropts.h>
14
-#include <termios.h>
15
-
16
-// Small wrapper to get rid of variadic args of ioctl()
17
-int my_ioctl(int fd, int cmd, struct winsize *ws) {
18
-	return ioctl(fd, cmd, ws);
19
-}
20
-*/
21
-import "C"
22
-
23
-// GetWinsize returns the window size based on the specified file descriptor.
24
-func GetWinsize(fd uintptr) (*Winsize, error) {
25
-	ws := &Winsize{}
26
-	ret, err := C.my_ioctl(C.int(fd), C.int(unix.TIOCGWINSZ), (*C.struct_winsize)(unsafe.Pointer(ws)))
27
-	// Skip retval = 0
28
-	if ret == 0 {
29
-		return ws, nil
30
-	}
31
-	return ws, err
32
-}
33
-
34
-// SetWinsize tries to set the specified window size for the specified file descriptor.
35
-func SetWinsize(fd uintptr, ws *Winsize) error {
36
-	ret, err := C.my_ioctl(C.int(fd), C.int(unix.TIOCSWINSZ), (*C.struct_winsize)(unsafe.Pointer(ws)))
37
-	// Skip retval = 0
38
-	if ret == 0 {
39
-		return nil
40
-	}
41
-	return err
42
-}
43 1
deleted file mode 100644
... ...
@@ -1,136 +0,0 @@
1
-# the following lines are in sorted order, FYI
2
-github.com/Azure/go-ansiterm 388960b655244e76e24c75f48631564eaefade62
3
-github.com/Microsoft/hcsshim v0.5.17
4
-github.com/Microsoft/go-winio v0.4.1
5
-github.com/Sirupsen/logrus v0.11.0
6
-github.com/davecgh/go-spew 346938d642f2ec3594ed81d874461961cd0faa76
7
-github.com/docker/libtrust 9cbd2a1374f46905c68a4eb3694a130610adc62a
8
-github.com/go-check/check 4ed411733c5785b40214c70bce814c3a3a689609 https://github.com/cpuguy83/check.git
9
-github.com/gorilla/context v1.1
10
-github.com/gorilla/mux v1.1
11
-github.com/kr/pty 5cf931ef8f
12
-github.com/mattn/go-shellwords v1.0.3
13
-github.com/tchap/go-patricia v2.2.6
14
-github.com/vdemeester/shakers 24d7f1d6a71aa5d9cbe7390e4afb66b7eef9e1b3
15
-# forked golang.org/x/net package includes a patch for lazy loading trace templates
16
-golang.org/x/net c427ad74c6d7a814201695e9ffde0c5d400a7674
17
-golang.org/x/sys 8f0908ab3b2457e2e15403d3697c9ef5cb4b57a9
18
-github.com/docker/go-units 9e638d38cf6977a37a8ea0078f3ee75a7cdb2dd1
19
-github.com/docker/go-connections e15c02316c12de00874640cd76311849de2aeed5
20
-golang.org/x/text f72d8390a633d5dfb0cc84043294db9f6c935756
21
-github.com/stretchr/testify 4d4bfba8f1d1027c4fdbe371823030df51419987
22
-github.com/pmezard/go-difflib v1.0.0
23
-
24
-github.com/RackSec/srslog 456df3a81436d29ba874f3590eeeee25d666f8a5
25
-github.com/imdario/mergo 0.2.1
26
-golang.org/x/sync de49d9dcd27d4f764488181bea099dfe6179bcf0
27
-
28
-#get libnetwork packages
29
-github.com/docker/libnetwork fd9cf1bc88ac6d54f3d0313da8c2660f128a360b https://github.com/fcrisciani/libnetwork
30
-github.com/docker/go-events 18b43f1bc85d9cdd42c05a6cd2d444c7a200a894
31
-github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80
32
-github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec
33
-github.com/hashicorp/go-msgpack 71c2886f5a673a35f909803f38ece5810165097b
34
-github.com/hashicorp/memberlist v0.1.0
35
-github.com/sean-/seed e2103e2c35297fb7e17febb81e49b312087a2372
36
-github.com/hashicorp/go-sockaddr acd314c5781ea706c710d9ea70069fd2e110d61d
37
-github.com/hashicorp/go-multierror fcdddc395df1ddf4247c69bd436e84cfa0733f7e
38
-github.com/hashicorp/serf 598c54895cc5a7b1a24a398d635e8c0ea0959870
39
-github.com/docker/libkv 1d8431073ae03cdaedb198a89722f3aab6d418ef
40
-github.com/vishvananda/netns 604eaf189ee867d8c147fafc28def2394e878d25
41
-github.com/vishvananda/netlink 1e86b2bee5b6a7d377e4c02bb7f98209d6a7297c
42
-github.com/BurntSushi/toml f706d00e3de6abe700c994cdd545a1a4915af060
43
-github.com/samuel/go-zookeeper d0e0d8e11f318e000a8cc434616d69e329edc374
44
-github.com/deckarep/golang-set ef32fa3046d9f249d399f98ebaf9be944430fd1d
45
-github.com/coreos/etcd ea5389a79f40206170582c1ea076191b8622cb8e https://github.com/aaronlehmann/etcd # for https://github.com/coreos/etcd/pull/7830
46
-github.com/ugorji/go f1f1a805ed361a0e078bb537e4ea78cd37dcf065
47
-github.com/hashicorp/consul v0.5.2
48
-github.com/boltdb/bolt fff57c100f4dea1905678da7e90d92429dff2904
49
-github.com/miekg/dns 75e6e86cc601825c5dbcd4e0c209eab180997cd7
50
-
51
-# get graph and distribution packages
52
-github.com/docker/distribution b38e5838b7b2f2ad48e06ec4b500011976080621
53
-github.com/vbatts/tar-split v0.10.1
54
-github.com/opencontainers/go-digest a6d0ee40d4207ea02364bd3b9e8e77b9159ba1eb
55
-
56
-# get go-zfs packages
57
-github.com/mistifyio/go-zfs 22c9b32c84eb0d0c6f4043b6e90fc94073de92fa
58
-github.com/pborman/uuid v1.0
59
-
60
-google.golang.org/grpc v1.0.4
61
-github.com/miekg/pkcs11 df8ae6ca730422dba20c768ff38ef7d79077a59f
62
-
63
-# When updating, also update RUNC_COMMIT in hack/dockerfile/binaries-commits accordingly
64
-github.com/opencontainers/runc 992a5be178a62e026f4069f443c6164912adbf09
65
-github.com/opencontainers/image-spec f03dbe35d449c54915d235f1a3cf8f585a24babe
66
-github.com/opencontainers/runtime-spec d42f1eb741e6361e858d83fc75aa6893b66292c4 # specs
67
-
68
-github.com/seccomp/libseccomp-golang 32f571b70023028bd57d9288c20efbcb237f3ce0
69
-
70
-# libcontainer deps (see src/github.com/opencontainers/runc/Godeps/Godeps.json)
71
-github.com/coreos/go-systemd v4
72
-github.com/godbus/dbus v4.0.0
73
-github.com/syndtr/gocapability 2c00daeb6c3b45114c80ac44119e7b8801fdd852
74
-github.com/golang/protobuf 8ee79997227bf9b34611aee7946ae64735e6fd93
75
-
76
-# gelf logging driver deps
77
-github.com/Graylog2/go-gelf 7029da823dad4ef3a876df61065156acb703b2ea
78
-
79
-github.com/fluent/fluent-logger-golang v1.2.1
80
-# fluent-logger-golang deps
81
-github.com/philhofer/fwd 98c11a7a6ec829d672b03833c3d69a7fae1ca972
82
-github.com/tinylib/msgp 75ee40d2601edf122ef667e2a07d600d4c44490c
83
-
84
-# fsnotify
85
-github.com/fsnotify/fsnotify v1.2.11
86
-
87
-# awslogs deps
88
-github.com/aws/aws-sdk-go v1.4.22
89
-github.com/go-ini/ini 060d7da055ba6ec5ea7a31f116332fe5efa04ce0
90
-github.com/jmespath/go-jmespath 0b12d6b521d83fc7f755e7cfc1b1fbdd35a01a74
91
-
92
-# logentries
93
-github.com/bsphere/le_go 7a984a84b5492ae539b79b62fb4a10afc63c7bcf
94
-
95
-# gcplogs deps
96
-golang.org/x/oauth2 96382aa079b72d8c014eb0c50f6c223d1e6a2de0
97
-google.golang.org/api 3cc2e591b550923a2c5f0ab5a803feda924d5823
98
-cloud.google.com/go 9d965e63e8cceb1b5d7977a202f0fcb8866d6525
99
-github.com/googleapis/gax-go da06d194a00e19ce00d9011a13931c3f6f6887c7
100
-google.golang.org/genproto b3e7c2fb04031add52c4817f53f43757ccbf9c18
101
-
102
-# containerd
103
-github.com/containerd/containerd 3addd840653146c90a254301d6c3a663c7fd6429
104
-github.com/tonistiigi/fifo 1405643975692217d6720f8b54aeee1bf2cd5cf4
105
-
106
-# cluster
107
-github.com/docker/swarmkit 1a3e510517be82d18ac04380b5f71eddf06c2fc0
108
-github.com/gogo/protobuf v0.4
109
-github.com/cloudflare/cfssl 7fb22c8cba7ecaf98e4082d22d65800cf45e042a
110
-github.com/google/certificate-transparency d90e65c3a07988180c5b1ece71791c0b6506826e
111
-golang.org/x/crypto 3fbbcd23f1cb824e69491a5930cfeff09b12f4d2
112
-golang.org/x/time a4bde12657593d5e90d0533a3e4fd95e635124cb
113
-github.com/hashicorp/go-memdb cb9a474f84cc5e41b273b20c6927680b2a8776ad
114
-github.com/hashicorp/go-immutable-radix 8e8ed81f8f0bf1bdd829593fdd5c29922c1ea990
115
-github.com/hashicorp/golang-lru a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4
116
-github.com/coreos/pkg fa29b1d70f0beaddd4c7021607cc3c3be8ce94b8
117
-github.com/pivotal-golang/clock 3fd3c1944c59d9742e1cd333672181cd1a6f9fa0
118
-github.com/prometheus/client_golang 52437c81da6b127a9925d17eb3a382a2e5fd395e
119
-github.com/beorn7/perks 4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9
120
-github.com/prometheus/client_model fa8ad6fec33561be4280a8f0514318c79d7f6cb6
121
-github.com/prometheus/common ebdfc6da46522d58825777cf1f90490a5b1ef1d8
122
-github.com/prometheus/procfs abf152e5f3e97f2fafac028d2cc06c1feb87ffa5
123
-github.com/matttproud/golang_protobuf_extensions v1.0.0
124
-github.com/pkg/errors 839d9e913e063e28dfd0e6c7b7512793e0a48be9
125
-github.com/grpc-ecosystem/go-grpc-prometheus 6b7015e65d366bf3f19b2b2a000a831940f0f7e0
126
-
127
-# cli
128
-github.com/spf13/cobra v1.5.1 https://github.com/dnephin/cobra.git
129
-github.com/spf13/pflag 9ff6c6923cfffbcd502984b8e0c80539a94968b7
130
-github.com/inconshreveable/mousetrap 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75
131
-github.com/Nvveen/Gotty a8b993ba6abdb0e0c12b0125c603323a71c7790c https://github.com/ijc25/Gotty
132
-
133
-# metrics
134
-github.com/docker/go-metrics d466d4f6fd960e01820085bd7e1a24426ee7ef18
135
-
136
-github.com/opencontainers/selinux v1.0.0-rc1
137 1
deleted file mode 100644
... ...
@@ -1,191 +0,0 @@
1
-
2
-                                 Apache License
3
-                           Version 2.0, January 2004
4
-                        https://www.apache.org/licenses/
5
-
6
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
-
8
-   1. Definitions.
9
-
10
-      "License" shall mean the terms and conditions for use, reproduction,
11
-      and distribution as defined by Sections 1 through 9 of this document.
12
-
13
-      "Licensor" shall mean the copyright owner or entity authorized by
14
-      the copyright owner that is granting the License.
15
-
16
-      "Legal Entity" shall mean the union of the acting entity and all
17
-      other entities that control, are controlled by, or are under common
18
-      control with that entity. For the purposes of this definition,
19
-      "control" means (i) the power, direct or indirect, to cause the
20
-      direction or management of such entity, whether by contract or
21
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
-      outstanding shares, or (iii) beneficial ownership of such entity.
23
-
24
-      "You" (or "Your") shall mean an individual or Legal Entity
25
-      exercising permissions granted by this License.
26
-
27
-      "Source" form shall mean the preferred form for making modifications,
28
-      including but not limited to software source code, documentation
29
-      source, and configuration files.
30
-
31
-      "Object" form shall mean any form resulting from mechanical
32
-      transformation or translation of a Source form, including but
33
-      not limited to compiled object code, generated documentation,
34
-      and conversions to other media types.
35
-
36
-      "Work" shall mean the work of authorship, whether in Source or
37
-      Object form, made available under the License, as indicated by a
38
-      copyright notice that is included in or attached to the work
39
-      (an example is provided in the Appendix below).
40
-
41
-      "Derivative Works" shall mean any work, whether in Source or Object
42
-      form, that is based on (or derived from) the Work and for which the
43
-      editorial revisions, annotations, elaborations, or other modifications
44
-      represent, as a whole, an original work of authorship. For the purposes
45
-      of this License, Derivative Works shall not include works that remain
46
-      separable from, or merely link (or bind by name) to the interfaces of,
47
-      the Work and Derivative Works thereof.
48
-
49
-      "Contribution" shall mean any work of authorship, including
50
-      the original version of the Work and any modifications or additions
51
-      to that Work or Derivative Works thereof, that is intentionally
52
-      submitted to Licensor for inclusion in the Work by the copyright owner
53
-      or by an individual or Legal Entity authorized to submit on behalf of
54
-      the copyright owner. For the purposes of this definition, "submitted"
55
-      means any form of electronic, verbal, or written communication sent
56
-      to the Licensor or its representatives, including but not limited to
57
-      communication on electronic mailing lists, source code control systems,
58
-      and issue tracking systems that are managed by, or on behalf of, the
59
-      Licensor for the purpose of discussing and improving the Work, but
60
-      excluding communication that is conspicuously marked or otherwise
61
-      designated in writing by the copyright owner as "Not a Contribution."
62
-
63
-      "Contributor" shall mean Licensor and any individual or Legal Entity
64
-      on behalf of whom a Contribution has been received by Licensor and
65
-      subsequently incorporated within the Work.
66
-
67
-   2. Grant of Copyright License. Subject to the terms and conditions of
68
-      this License, each Contributor hereby grants to You a perpetual,
69
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
-      copyright license to reproduce, prepare Derivative Works of,
71
-      publicly display, publicly perform, sublicense, and distribute the
72
-      Work and such Derivative Works in Source or Object form.
73
-
74
-   3. Grant of Patent License. Subject to the terms and conditions of
75
-      this License, each Contributor hereby grants to You a perpetual,
76
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
-      (except as stated in this section) patent license to make, have made,
78
-      use, offer to sell, sell, import, and otherwise transfer the Work,
79
-      where such license applies only to those patent claims licensable
80
-      by such Contributor that are necessarily infringed by their
81
-      Contribution(s) alone or by combination of their Contribution(s)
82
-      with the Work to which such Contribution(s) was submitted. If You
83
-      institute patent litigation against any entity (including a
84
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
85
-      or a Contribution incorporated within the Work constitutes direct
86
-      or contributory patent infringement, then any patent licenses
87
-      granted to You under this License for that Work shall terminate
88
-      as of the date such litigation is filed.
89
-
90
-   4. Redistribution. You may reproduce and distribute copies of the
91
-      Work or Derivative Works thereof in any medium, with or without
92
-      modifications, and in Source or Object form, provided that You
93
-      meet the following conditions:
94
-
95
-      (a) You must give any other recipients of the Work or
96
-          Derivative Works a copy of this License; and
97
-
98
-      (b) You must cause any modified files to carry prominent notices
99
-          stating that You changed the files; and
100
-
101
-      (c) You must retain, in the Source form of any Derivative Works
102
-          that You distribute, all copyright, patent, trademark, and
103
-          attribution notices from the Source form of the Work,
104
-          excluding those notices that do not pertain to any part of
105
-          the Derivative Works; and
106
-
107
-      (d) If the Work includes a "NOTICE" text file as part of its
108
-          distribution, then any Derivative Works that You distribute must
109
-          include a readable copy of the attribution notices contained
110
-          within such NOTICE file, excluding those notices that do not
111
-          pertain to any part of the Derivative Works, in at least one
112
-          of the following places: within a NOTICE text file distributed
113
-          as part of the Derivative Works; within the Source form or
114
-          documentation, if provided along with the Derivative Works; or,
115
-          within a display generated by the Derivative Works, if and
116
-          wherever such third-party notices normally appear. The contents
117
-          of the NOTICE file are for informational purposes only and
118
-          do not modify the License. You may add Your own attribution
119
-          notices within Derivative Works that You distribute, alongside
120
-          or as an addendum to the NOTICE text from the Work, provided
121
-          that such additional attribution notices cannot be construed
122
-          as modifying the License.
123
-
124
-      You may add Your own copyright statement to Your modifications and
125
-      may provide additional or different license terms and conditions
126
-      for use, reproduction, or distribution of Your modifications, or
127
-      for any such Derivative Works as a whole, provided Your use,
128
-      reproduction, and distribution of the Work otherwise complies with
129
-      the conditions stated in this License.
130
-
131
-   5. Submission of Contributions. Unless You explicitly state otherwise,
132
-      any Contribution intentionally submitted for inclusion in the Work
133
-      by You to the Licensor shall be under the terms and conditions of
134
-      this License, without any additional terms or conditions.
135
-      Notwithstanding the above, nothing herein shall supersede or modify
136
-      the terms of any separate license agreement you may have executed
137
-      with Licensor regarding such Contributions.
138
-
139
-   6. Trademarks. This License does not grant permission to use the trade
140
-      names, trademarks, service marks, or product names of the Licensor,
141
-      except as required for reasonable and customary use in describing the
142
-      origin of the Work and reproducing the content of the NOTICE file.
143
-
144
-   7. Disclaimer of Warranty. Unless required by applicable law or
145
-      agreed to in writing, Licensor provides the Work (and each
146
-      Contributor provides its Contributions) on an "AS IS" BASIS,
147
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
-      implied, including, without limitation, any warranties or conditions
149
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
-      PARTICULAR PURPOSE. You are solely responsible for determining the
151
-      appropriateness of using or redistributing the Work and assume any
152
-      risks associated with Your exercise of permissions under this License.
153
-
154
-   8. Limitation of Liability. In no event and under no legal theory,
155
-      whether in tort (including negligence), contract, or otherwise,
156
-      unless required by applicable law (such as deliberate and grossly
157
-      negligent acts) or agreed to in writing, shall any Contributor be
158
-      liable to You for damages, including any direct, indirect, special,
159
-      incidental, or consequential damages of any character arising as a
160
-      result of this License or out of the use or inability to use the
161
-      Work (including but not limited to damages for loss of goodwill,
162
-      work stoppage, computer failure or malfunction, or any and all
163
-      other commercial damages or losses), even if such Contributor
164
-      has been advised of the possibility of such damages.
165
-
166
-   9. Accepting Warranty or Additional Liability. While redistributing
167
-      the Work or Derivative Works thereof, You may choose to offer,
168
-      and charge a fee for, acceptance of support, warranty, indemnity,
169
-      or other liability obligations and/or rights consistent with this
170
-      License. However, in accepting such obligations, You may act only
171
-      on Your own behalf and on Your sole responsibility, not on behalf
172
-      of any other Contributor, and only if You agree to indemnify,
173
-      defend, and hold each Contributor harmless for any liability
174
-      incurred by, or claims asserted against, such Contributor by reason
175
-      of your accepting any such warranty or additional liability.
176
-
177
-   END OF TERMS AND CONDITIONS
178
-
179
-   Copyright 2016 Docker, Inc.
180
-
181
-   Licensed under the Apache License, Version 2.0 (the "License");
182
-   you may not use this file except in compliance with the License.
183
-   You may obtain a copy of the License at
184
-
185
-       https://www.apache.org/licenses/LICENSE-2.0
186
-
187
-   Unless required by applicable law or agreed to in writing, software
188
-   distributed under the License is distributed on an "AS IS" BASIS,
189
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
-   See the License for the specific language governing permissions and
191
-   limitations under the License.
192 1
deleted file mode 100644
... ...
@@ -1,425 +0,0 @@
1
-Attribution-ShareAlike 4.0 International
2
-
3
-=======================================================================
4
-
5
-Creative Commons Corporation ("Creative Commons") is not a law firm and
6
-does not provide legal services or legal advice. Distribution of
7
-Creative Commons public licenses does not create a lawyer-client or
8
-other relationship. Creative Commons makes its licenses and related
9
-information available on an "as-is" basis. Creative Commons gives no
10
-warranties regarding its licenses, any material licensed under their
11
-terms and conditions, or any related information. Creative Commons
12
-disclaims all liability for damages resulting from their use to the
13
-fullest extent possible.
14
-
15
-Using Creative Commons Public Licenses
16
-
17
-Creative Commons public licenses provide a standard set of terms and
18
-conditions that creators and other rights holders may use to share
19
-original works of authorship and other material subject to copyright
20
-and certain other rights specified in the public license below. The
21
-following considerations are for informational purposes only, are not
22
-exhaustive, and do not form part of our licenses.
23
-
24
-     Considerations for licensors: Our public licenses are
25
-     intended for use by those authorized to give the public
26
-     permission to use material in ways otherwise restricted by
27
-     copyright and certain other rights. Our licenses are
28
-     irrevocable. Licensors should read and understand the terms
29
-     and conditions of the license they choose before applying it.
30
-     Licensors should also secure all rights necessary before
31
-     applying our licenses so that the public can reuse the
32
-     material as expected. Licensors should clearly mark any
33
-     material not subject to the license. This includes other CC-
34
-     licensed material, or material used under an exception or
35
-     limitation to copyright. More considerations for licensors:
36
-	wiki.creativecommons.org/Considerations_for_licensors
37
-
38
-     Considerations for the public: By using one of our public
39
-     licenses, a licensor grants the public permission to use the
40
-     licensed material under specified terms and conditions. If
41
-     the licensor's permission is not necessary for any reason--for
42
-     example, because of any applicable exception or limitation to
43
-     copyright--then that use is not regulated by the license. Our
44
-     licenses grant only permissions under copyright and certain
45
-     other rights that a licensor has authority to grant. Use of
46
-     the licensed material may still be restricted for other
47
-     reasons, including because others have copyright or other
48
-     rights in the material. A licensor may make special requests,
49
-     such as asking that all changes be marked or described.
50
-     Although not required by our licenses, you are encouraged to
51
-     respect those requests where reasonable. More_considerations
52
-     for the public:
53
-	wiki.creativecommons.org/Considerations_for_licensees
54
-
55
-=======================================================================
56
-
57
-Creative Commons Attribution-ShareAlike 4.0 International Public
58
-License
59
-
60
-By exercising the Licensed Rights (defined below), You accept and agree
61
-to be bound by the terms and conditions of this Creative Commons
62
-Attribution-ShareAlike 4.0 International Public License ("Public
63
-License"). To the extent this Public License may be interpreted as a
64
-contract, You are granted the Licensed Rights in consideration of Your
65
-acceptance of these terms and conditions, and the Licensor grants You
66
-such rights in consideration of benefits the Licensor receives from
67
-making the Licensed Material available under these terms and
68
-conditions.
69
-
70
-
71
-Section 1 -- Definitions.
72
-
73
-  a. Adapted Material means material subject to Copyright and Similar
74
-     Rights that is derived from or based upon the Licensed Material
75
-     and in which the Licensed Material is translated, altered,
76
-     arranged, transformed, or otherwise modified in a manner requiring
77
-     permission under the Copyright and Similar Rights held by the
78
-     Licensor. For purposes of this Public License, where the Licensed
79
-     Material is a musical work, performance, or sound recording,
80
-     Adapted Material is always produced where the Licensed Material is
81
-     synched in timed relation with a moving image.
82
-
83
-  b. Adapter's License means the license You apply to Your Copyright
84
-     and Similar Rights in Your contributions to Adapted Material in
85
-     accordance with the terms and conditions of this Public License.
86
-
87
-  c. BY-SA Compatible License means a license listed at
88
-     creativecommons.org/compatiblelicenses, approved by Creative
89
-     Commons as essentially the equivalent of this Public License.
90
-
91
-  d. Copyright and Similar Rights means copyright and/or similar rights
92
-     closely related to copyright including, without limitation,
93
-     performance, broadcast, sound recording, and Sui Generis Database
94
-     Rights, without regard to how the rights are labeled or
95
-     categorized. For purposes of this Public License, the rights
96
-     specified in Section 2(b)(1)-(2) are not Copyright and Similar
97
-     Rights.
98
-
99
-  e. Effective Technological Measures means those measures that, in the
100
-     absence of proper authority, may not be circumvented under laws
101
-     fulfilling obligations under Article 11 of the WIPO Copyright
102
-     Treaty adopted on December 20, 1996, and/or similar international
103
-     agreements.
104
-
105
-  f. Exceptions and Limitations means fair use, fair dealing, and/or
106
-     any other exception or limitation to Copyright and Similar Rights
107
-     that applies to Your use of the Licensed Material.
108
-
109
-  g. License Elements means the license attributes listed in the name
110
-     of a Creative Commons Public License. The License Elements of this
111
-     Public License are Attribution and ShareAlike.
112
-
113
-  h. Licensed Material means the artistic or literary work, database,
114
-     or other material to which the Licensor applied this Public
115
-     License.
116
-
117
-  i. Licensed Rights means the rights granted to You subject to the
118
-     terms and conditions of this Public License, which are limited to
119
-     all Copyright and Similar Rights that apply to Your use of the
120
-     Licensed Material and that the Licensor has authority to license.
121
-
122
-  j. Licensor means the individual(s) or entity(ies) granting rights
123
-     under this Public License.
124
-
125
-  k. Share means to provide material to the public by any means or
126
-     process that requires permission under the Licensed Rights, such
127
-     as reproduction, public display, public performance, distribution,
128
-     dissemination, communication, or importation, and to make material
129
-     available to the public including in ways that members of the
130
-     public may access the material from a place and at a time
131
-     individually chosen by them.
132
-
133
-  l. Sui Generis Database Rights means rights other than copyright
134
-     resulting from Directive 96/9/EC of the European Parliament and of
135
-     the Council of 11 March 1996 on the legal protection of databases,
136
-     as amended and/or succeeded, as well as other essentially
137
-     equivalent rights anywhere in the world.
138
-
139
-  m. You means the individual or entity exercising the Licensed Rights
140
-     under this Public License. Your has a corresponding meaning.
141
-
142
-
143
-Section 2 -- Scope.
144
-
145
-  a. License grant.
146
-
147
-       1. Subject to the terms and conditions of this Public License,
148
-          the Licensor hereby grants You a worldwide, royalty-free,
149
-          non-sublicensable, non-exclusive, irrevocable license to
150
-          exercise the Licensed Rights in the Licensed Material to:
151
-
152
-            a. reproduce and Share the Licensed Material, in whole or
153
-               in part; and
154
-
155
-            b. produce, reproduce, and Share Adapted Material.
156
-
157
-       2. Exceptions and Limitations. For the avoidance of doubt, where
158
-          Exceptions and Limitations apply to Your use, this Public
159
-          License does not apply, and You do not need to comply with
160
-          its terms and conditions.
161
-
162
-       3. Term. The term of this Public License is specified in Section
163
-          6(a).
164
-
165
-       4. Media and formats; technical modifications allowed. The
166
-          Licensor authorizes You to exercise the Licensed Rights in
167
-          all media and formats whether now known or hereafter created,
168
-          and to make technical modifications necessary to do so. The
169
-          Licensor waives and/or agrees not to assert any right or
170
-          authority to forbid You from making technical modifications
171
-          necessary to exercise the Licensed Rights, including
172
-          technical modifications necessary to circumvent Effective
173
-          Technological Measures. For purposes of this Public License,
174
-          simply making modifications authorized by this Section 2(a)
175
-          (4) never produces Adapted Material.
176
-
177
-       5. Downstream recipients.
178
-
179
-            a. Offer from the Licensor -- Licensed Material. Every
180
-               recipient of the Licensed Material automatically
181
-               receives an offer from the Licensor to exercise the
182
-               Licensed Rights under the terms and conditions of this
183
-               Public License.
184
-
185
-            b. Additional offer from the Licensor -- Adapted Material.
186
-               Every recipient of Adapted Material from You
187
-               automatically receives an offer from the Licensor to
188
-               exercise the Licensed Rights in the Adapted Material
189
-               under the conditions of the Adapter's License You apply.
190
-
191
-            c. No downstream restrictions. You may not offer or impose
192
-               any additional or different terms or conditions on, or
193
-               apply any Effective Technological Measures to, the
194
-               Licensed Material if doing so restricts exercise of the
195
-               Licensed Rights by any recipient of the Licensed
196
-               Material.
197
-
198
-       6. No endorsement. Nothing in this Public License constitutes or
199
-          may be construed as permission to assert or imply that You
200
-          are, or that Your use of the Licensed Material is, connected
201
-          with, or sponsored, endorsed, or granted official status by,
202
-          the Licensor or others designated to receive attribution as
203
-          provided in Section 3(a)(1)(A)(i).
204
-
205
-  b. Other rights.
206
-
207
-       1. Moral rights, such as the right of integrity, are not
208
-          licensed under this Public License, nor are publicity,
209
-          privacy, and/or other similar personality rights; however, to
210
-          the extent possible, the Licensor waives and/or agrees not to
211
-          assert any such rights held by the Licensor to the limited
212
-          extent necessary to allow You to exercise the Licensed
213
-          Rights, but not otherwise.
214
-
215
-       2. Patent and trademark rights are not licensed under this
216
-          Public License.
217
-
218
-       3. To the extent possible, the Licensor waives any right to
219
-          collect royalties from You for the exercise of the Licensed
220
-          Rights, whether directly or through a collecting society
221
-          under any voluntary or waivable statutory or compulsory
222
-          licensing scheme. In all other cases the Licensor expressly
223
-          reserves any right to collect such royalties.
224
-
225
-
226
-Section 3 -- License Conditions.
227
-
228
-Your exercise of the Licensed Rights is expressly made subject to the
229
-following conditions.
230
-
231
-  a. Attribution.
232
-
233
-       1. If You Share the Licensed Material (including in modified
234
-          form), You must:
235
-
236
-            a. retain the following if it is supplied by the Licensor
237
-               with the Licensed Material:
238
-
239
-                 i. identification of the creator(s) of the Licensed
240
-                    Material and any others designated to receive
241
-                    attribution, in any reasonable manner requested by
242
-                    the Licensor (including by pseudonym if
243
-                    designated);
244
-
245
-                ii. a copyright notice;
246
-
247
-               iii. a notice that refers to this Public License;
248
-
249
-                iv. a notice that refers to the disclaimer of
250
-                    warranties;
251
-
252
-                 v. a URI or hyperlink to the Licensed Material to the
253
-                    extent reasonably practicable;
254
-
255
-            b. indicate if You modified the Licensed Material and
256
-               retain an indication of any previous modifications; and
257
-
258
-            c. indicate the Licensed Material is licensed under this
259
-               Public License, and include the text of, or the URI or
260
-               hyperlink to, this Public License.
261
-
262
-       2. You may satisfy the conditions in Section 3(a)(1) in any
263
-          reasonable manner based on the medium, means, and context in
264
-          which You Share the Licensed Material. For example, it may be
265
-          reasonable to satisfy the conditions by providing a URI or
266
-          hyperlink to a resource that includes the required
267
-          information.
268
-
269
-       3. If requested by the Licensor, You must remove any of the
270
-          information required by Section 3(a)(1)(A) to the extent
271
-          reasonably practicable.
272
-
273
-  b. ShareAlike.
274
-
275
-     In addition to the conditions in Section 3(a), if You Share
276
-     Adapted Material You produce, the following conditions also apply.
277
-
278
-       1. The Adapter's License You apply must be a Creative Commons
279
-          license with the same License Elements, this version or
280
-          later, or a BY-SA Compatible License.
281
-
282
-       2. You must include the text of, or the URI or hyperlink to, the
283
-          Adapter's License You apply. You may satisfy this condition
284
-          in any reasonable manner based on the medium, means, and
285
-          context in which You Share Adapted Material.
286
-
287
-       3. You may not offer or impose any additional or different terms
288
-          or conditions on, or apply any Effective Technological
289
-          Measures to, Adapted Material that restrict exercise of the
290
-          rights granted under the Adapter's License You apply.
291
-
292
-
293
-Section 4 -- Sui Generis Database Rights.
294
-
295
-Where the Licensed Rights include Sui Generis Database Rights that
296
-apply to Your use of the Licensed Material:
297
-
298
-  a. for the avoidance of doubt, Section 2(a)(1) grants You the right
299
-     to extract, reuse, reproduce, and Share all or a substantial
300
-     portion of the contents of the database;
301
-
302
-  b. if You include all or a substantial portion of the database
303
-     contents in a database in which You have Sui Generis Database
304
-     Rights, then the database in which You have Sui Generis Database
305
-     Rights (but not its individual contents) is Adapted Material,
306
-
307
-     including for purposes of Section 3(b); and
308
-  c. You must comply with the conditions in Section 3(a) if You Share
309
-     all or a substantial portion of the contents of the database.
310
-
311
-For the avoidance of doubt, this Section 4 supplements and does not
312
-replace Your obligations under this Public License where the Licensed
313
-Rights include other Copyright and Similar Rights.
314
-
315
-
316
-Section 5 -- Disclaimer of Warranties and Limitation of Liability.
317
-
318
-  a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
319
-     EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
320
-     AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
321
-     ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
322
-     IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
323
-     WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
324
-     PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
325
-     ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
326
-     KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
327
-     ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
328
-
329
-  b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
330
-     TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
331
-     NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
332
-     INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
333
-     COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
334
-     USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
335
-     ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
336
-     DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
337
-     IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
338
-
339
-  c. The disclaimer of warranties and limitation of liability provided
340
-     above shall be interpreted in a manner that, to the extent
341
-     possible, most closely approximates an absolute disclaimer and
342
-     waiver of all liability.
343
-
344
-
345
-Section 6 -- Term and Termination.
346
-
347
-  a. This Public License applies for the term of the Copyright and
348
-     Similar Rights licensed here. However, if You fail to comply with
349
-     this Public License, then Your rights under this Public License
350
-     terminate automatically.
351
-
352
-  b. Where Your right to use the Licensed Material has terminated under
353
-     Section 6(a), it reinstates:
354
-
355
-       1. automatically as of the date the violation is cured, provided
356
-          it is cured within 30 days of Your discovery of the
357
-          violation; or
358
-
359
-       2. upon express reinstatement by the Licensor.
360
-
361
-     For the avoidance of doubt, this Section 6(b) does not affect any
362
-     right the Licensor may have to seek remedies for Your violations
363
-     of this Public License.
364
-
365
-  c. For the avoidance of doubt, the Licensor may also offer the
366
-     Licensed Material under separate terms or conditions or stop
367
-     distributing the Licensed Material at any time; however, doing so
368
-     will not terminate this Public License.
369
-
370
-  d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
371
-     License.
372
-
373
-
374
-Section 7 -- Other Terms and Conditions.
375
-
376
-  a. The Licensor shall not be bound by any additional or different
377
-     terms or conditions communicated by You unless expressly agreed.
378
-
379
-  b. Any arrangements, understandings, or agreements regarding the
380
-     Licensed Material not stated herein are separate from and
381
-     independent of the terms and conditions of this Public License.
382
-
383
-
384
-Section 8 -- Interpretation.
385
-
386
-  a. For the avoidance of doubt, this Public License does not, and
387
-     shall not be interpreted to, reduce, limit, restrict, or impose
388
-     conditions on any use of the Licensed Material that could lawfully
389
-     be made without permission under this Public License.
390
-
391
-  b. To the extent possible, if any provision of this Public License is
392
-     deemed unenforceable, it shall be automatically reformed to the
393
-     minimum extent necessary to make it enforceable. If the provision
394
-     cannot be reformed, it shall be severed from this Public License
395
-     without affecting the enforceability of the remaining terms and
396
-     conditions.
397
-
398
-  c. No term or condition of this Public License will be waived and no
399
-     failure to comply consented to unless expressly agreed to by the
400
-     Licensor.
401
-
402
-  d. Nothing in this Public License constitutes or may be interpreted
403
-     as a limitation upon, or waiver of, any privileges and immunities
404
-     that apply to the Licensor or You, including from the legal
405
-     processes of any jurisdiction or authority.
406
-
407
-
408
-=======================================================================
409
-
410
-Creative Commons is not a party to its public licenses.
411
-Notwithstanding, Creative Commons may elect to apply one of its public
412
-licenses to material it publishes and in those instances will be
413
-considered the "Licensor." Except for the limited purpose of indicating
414
-that material is shared under a Creative Commons public license or as
415
-otherwise permitted by the Creative Commons policies published at
416
-creativecommons.org/policies, Creative Commons does not authorize the
417
-use of the trademark "Creative Commons" or any other trademark or logo
418
-of Creative Commons without its prior written consent including,
419
-without limitation, in connection with any unauthorized modifications
420
-to any of its public licenses or any other arrangements,
421
-understandings, or agreements concerning use of licensed material. For
422
-the avoidance of doubt, this paragraph does not form part of the public
423
-licenses.
424
-
425
-Creative Commons may be contacted at creativecommons.org.
426 1
deleted file mode 100644
... ...
@@ -1,104 +0,0 @@
1
-# go-digest
2
-
3
-[![GoDoc](https://godoc.org/github.com/opencontainers/go-digest?status.svg)](https://godoc.org/github.com/opencontainers/go-digest) [![Go Report Card](https://goreportcard.com/badge/github.com/opencontainers/go-digest)](https://goreportcard.com/report/github.com/opencontainers/go-digest) [![Build Status](https://travis-ci.org/opencontainers/go-digest.svg?branch=master)](https://travis-ci.org/opencontainers/go-digest)
4
-
5
-Common digest package used across the container ecosystem.
6
-
7
-Please see the [godoc](https://godoc.org/github.com/opencontainers/go-digest) for more information.
8
-
9
-# What is a digest?
10
-
11
-A digest is just a hash.
12
-
13
-The most common use case for a digest is to create a content
14
-identifier for use in [Content Addressable Storage](https://en.wikipedia.org/wiki/Content-addressable_storage)
15
-systems:
16
-
17
-```go
18
-id := digest.FromBytes([]byte("my content"))
19
-```
20
-
21
-In the example above, the id can be used to uniquely identify 
22
-the byte slice "my content". This allows two disparate applications
23
-to agree on a verifiable identifier without having to trust one
24
-another.
25
-
26
-An identifying digest can be verified, as follows:
27
-
28
-```go
29
-if id != digest.FromBytes([]byte("my content")) {
30
-  return errors.New("the content has changed!")
31
-}
32
-```
33
-
34
-A `Verifier` type can be used to handle cases where an `io.Reader`
35
-makes more sense:
36
-
37
-```go
38
-rd := getContent()
39
-verifier := id.Verifier()
40
-io.Copy(verifier, rd)
41
-
42
-if !verifier.Verified() {
43
-  return errors.New("the content has changed!")
44
-}
45
-```
46
-
47
-Using [Merkle DAGs](https://en.wikipedia.org/wiki/Merkle_tree), this
48
-can power a rich, safe, content distribution system.
49
-
50
-# Usage
51
-
52
-While the [godoc](https://godoc.org/github.com/opencontainers/go-digest) is
53
-considered the best resource, a few important items need to be called 
54
-out when using this package.
55
-
56
-1. Make sure to import the hash implementations into your application
57
-    or the package will panic. You should have something like the 
58
-    following in the main (or other entrypoint) of your application:
59
-   
60
-    ```go
61
-    import (
62
-        _ "crypto/sha256"
63
-   	    _ "crypto/sha512"
64
-    )
65
-    ```
66
-    This may seem inconvenient but it allows you replace the hash 
67
-    implementations with others, such as https://github.com/stevvooe/resumable.
68
- 
69
-2. Even though `digest.Digest` may be assemable as a string, _always_ 
70
-    verify your input with `digest.Parse` or use `Digest.Validate`
71
-    when accepting untrusted input. While there are measures to 
72
-    avoid common problems, this will ensure you have valid digests
73
-    in the rest of your application.
74
-
75
-# Stability
76
-
77
-The Go API, at this stage, is considered stable, unless otherwise noted.
78
-
79
-As always, before using a package export, read the [godoc](https://godoc.org/github.com/opencontainers/go-digest).
80
-
81
-# Contributing
82
-
83
-This package is considered fairly complete. It has been in production
84
-in thousands (millions?) of deployments and is fairly battle-hardened.
85
-New additions will be met with skepticism. If you think there is a 
86
-missing feature, please file a bug clearly describing the problem and 
87
-the alternatives you tried before submitting a PR.
88
-
89
-# Reporting security issues
90
-
91
-Please DO NOT file a public issue, instead send your report privately to
92
-security@opencontainers.org.
93
-
94
-The maintainers take security seriously. If you discover a security issue,
95
-please bring it to their attention right away!
96
-
97
-If you are reporting a security issue, do not create an issue or file a pull
98
-request on GitHub. Instead, disclose the issue responsibly by sending an email
99
-to security@opencontainers.org (which is inhabited only by the maintainers of
100
-the various OCI projects).
101
-
102
-# Copyright and license
103
-
104
-Copyright © 2016 Docker, Inc. All rights reserved, except as follows. Code is released under the [Apache 2.0 license](LICENSE.code). This `README.md` file and the [`CONTRIBUTING.md`](CONTRIBUTING.md) file are licensed under the Creative Commons Attribution 4.0 International License under the terms and conditions set forth in the file [`LICENSE.docs`](LICENSE.docs). You may obtain a duplicate copy of the same license, titled CC BY-SA 4.0, at http://creativecommons.org/licenses/by-sa/4.0/.
105 1
deleted file mode 100644
... ...
@@ -1,166 +0,0 @@
1
-// Copyright 2017 Docker, Inc.
2
-//
3
-// Licensed under the Apache License, Version 2.0 (the "License");
4
-// you may not use this file except in compliance with the License.
5
-// You may obtain a copy of the License at
6
-//
7
-//     https://www.apache.org/licenses/LICENSE-2.0
8
-//
9
-// Unless required by applicable law or agreed to in writing, software
10
-// distributed under the License is distributed on an "AS IS" BASIS,
11
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
-// See the License for the specific language governing permissions and
13
-// limitations under the License.
14
-
15
-package digest
16
-
17
-import (
18
-	"crypto"
19
-	"fmt"
20
-	"hash"
21
-	"io"
22
-)
23
-
24
-// Algorithm identifies and implementation of a digester by an identifier.
25
-// Note the that this defines both the hash algorithm used and the string
26
-// encoding.
27
-type Algorithm string
28
-
29
-// supported digest types
30
-const (
31
-	SHA256 Algorithm = "sha256" // sha256 with hex encoding
32
-	SHA384 Algorithm = "sha384" // sha384 with hex encoding
33
-	SHA512 Algorithm = "sha512" // sha512 with hex encoding
34
-
35
-	// Canonical is the primary digest algorithm used with the distribution
36
-	// project. Other digests may be used but this one is the primary storage
37
-	// digest.
38
-	Canonical = SHA256
39
-)
40
-
41
-var (
42
-	// TODO(stevvooe): Follow the pattern of the standard crypto package for
43
-	// registration of digests. Effectively, we are a registerable set and
44
-	// common symbol access.
45
-
46
-	// algorithms maps values to hash.Hash implementations. Other algorithms
47
-	// may be available but they cannot be calculated by the digest package.
48
-	algorithms = map[Algorithm]crypto.Hash{
49
-		SHA256: crypto.SHA256,
50
-		SHA384: crypto.SHA384,
51
-		SHA512: crypto.SHA512,
52
-	}
53
-)
54
-
55
-// Available returns true if the digest type is available for use. If this
56
-// returns false, Digester and Hash will return nil.
57
-func (a Algorithm) Available() bool {
58
-	h, ok := algorithms[a]
59
-	if !ok {
60
-		return false
61
-	}
62
-
63
-	// check availability of the hash, as well
64
-	return h.Available()
65
-}
66
-
67
-func (a Algorithm) String() string {
68
-	return string(a)
69
-}
70
-
71
-// Size returns number of bytes returned by the hash.
72
-func (a Algorithm) Size() int {
73
-	h, ok := algorithms[a]
74
-	if !ok {
75
-		return 0
76
-	}
77
-	return h.Size()
78
-}
79
-
80
-// Set implemented to allow use of Algorithm as a command line flag.
81
-func (a *Algorithm) Set(value string) error {
82
-	if value == "" {
83
-		*a = Canonical
84
-	} else {
85
-		// just do a type conversion, support is queried with Available.
86
-		*a = Algorithm(value)
87
-	}
88
-
89
-	if !a.Available() {
90
-		return ErrDigestUnsupported
91
-	}
92
-
93
-	return nil
94
-}
95
-
96
-// Digester returns a new digester for the specified algorithm. If the algorithm
97
-// does not have a digester implementation, nil will be returned. This can be
98
-// checked by calling Available before calling Digester.
99
-func (a Algorithm) Digester() Digester {
100
-	return &digester{
101
-		alg:  a,
102
-		hash: a.Hash(),
103
-	}
104
-}
105
-
106
-// Hash returns a new hash as used by the algorithm. If not available, the
107
-// method will panic. Check Algorithm.Available() before calling.
108
-func (a Algorithm) Hash() hash.Hash {
109
-	if !a.Available() {
110
-		// Empty algorithm string is invalid
111
-		if a == "" {
112
-			panic(fmt.Sprintf("empty digest algorithm, validate before calling Algorithm.Hash()"))
113
-		}
114
-
115
-		// NOTE(stevvooe): A missing hash is usually a programming error that
116
-		// must be resolved at compile time. We don't import in the digest
117
-		// package to allow users to choose their hash implementation (such as
118
-		// when using stevvooe/resumable or a hardware accelerated package).
119
-		//
120
-		// Applications that may want to resolve the hash at runtime should
121
-		// call Algorithm.Available before call Algorithm.Hash().
122
-		panic(fmt.Sprintf("%v not available (make sure it is imported)", a))
123
-	}
124
-
125
-	return algorithms[a].New()
126
-}
127
-
128
-// Encode encodes the raw bytes of a digest, typically from a hash.Hash, into
129
-// the encoded portion of the digest.
130
-func (a Algorithm) Encode(d []byte) string {
131
-	// TODO(stevvooe): Currently, all algorithms use a hex encoding. When we
132
-	// add support for back registration, we can modify this accordingly.
133
-	return fmt.Sprintf("%x", d)
134
-}
135
-
136
-// FromReader returns the digest of the reader using the algorithm.
137
-func (a Algorithm) FromReader(rd io.Reader) (Digest, error) {
138
-	digester := a.Digester()
139
-
140
-	if _, err := io.Copy(digester.Hash(), rd); err != nil {
141
-		return "", err
142
-	}
143
-
144
-	return digester.Digest(), nil
145
-}
146
-
147
-// FromBytes digests the input and returns a Digest.
148
-func (a Algorithm) FromBytes(p []byte) Digest {
149
-	digester := a.Digester()
150
-
151
-	if _, err := digester.Hash().Write(p); err != nil {
152
-		// Writes to a Hash should never fail. None of the existing
153
-		// hash implementations in the stdlib or hashes vendored
154
-		// here can return errors from Write. Having a panic in this
155
-		// condition instead of having FromBytes return an error value
156
-		// avoids unnecessary error handling paths in all callers.
157
-		panic("write to hash function returned error: " + err.Error())
158
-	}
159
-
160
-	return digester.Digest()
161
-}
162
-
163
-// FromString digests the string input and returns a Digest.
164
-func (a Algorithm) FromString(s string) Digest {
165
-	return a.FromBytes([]byte(s))
166
-}
167 1
deleted file mode 100644
... ...
@@ -1,164 +0,0 @@
1
-// Copyright 2017 Docker, Inc.
2
-//
3
-// Licensed under the Apache License, Version 2.0 (the "License");
4
-// you may not use this file except in compliance with the License.
5
-// You may obtain a copy of the License at
6
-//
7
-//     https://www.apache.org/licenses/LICENSE-2.0
8
-//
9
-// Unless required by applicable law or agreed to in writing, software
10
-// distributed under the License is distributed on an "AS IS" BASIS,
11
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
-// See the License for the specific language governing permissions and
13
-// limitations under the License.
14
-
15
-package digest
16
-
17
-import (
18
-	"fmt"
19
-	"hash"
20
-	"io"
21
-	"regexp"
22
-	"strings"
23
-)
24
-
25
-// Digest allows simple protection of hex formatted digest strings, prefixed
26
-// by their algorithm. Strings of type Digest have some guarantee of being in
27
-// the correct format and it provides quick access to the components of a
28
-// digest string.
29
-//
30
-// The following is an example of the contents of Digest types:
31
-//
32
-// 	sha256:7173b809ca12ec5dee4506cd86be934c4596dd234ee82c0662eac04a8c2c71dc
33
-//
34
-// This allows to abstract the digest behind this type and work only in those
35
-// terms.
36
-type Digest string
37
-
38
-// NewDigest returns a Digest from alg and a hash.Hash object.
39
-func NewDigest(alg Algorithm, h hash.Hash) Digest {
40
-	return NewDigestFromBytes(alg, h.Sum(nil))
41
-}
42
-
43
-// NewDigestFromBytes returns a new digest from the byte contents of p.
44
-// Typically, this can come from hash.Hash.Sum(...) or xxx.SumXXX(...)
45
-// functions. This is also useful for rebuilding digests from binary
46
-// serializations.
47
-func NewDigestFromBytes(alg Algorithm, p []byte) Digest {
48
-	return NewDigestFromEncoded(alg, alg.Encode(p))
49
-}
50
-
51
-// NewDigestFromHex is deprecated. Please use NewDigestFromEncoded.
52
-func NewDigestFromHex(alg, hex string) Digest {
53
-	return NewDigestFromEncoded(Algorithm(alg), hex)
54
-}
55
-
56
-// NewDigestFromEncoded returns a Digest from alg and the encoded digest.
57
-func NewDigestFromEncoded(alg Algorithm, encoded string) Digest {
58
-	return Digest(fmt.Sprintf("%s:%s", alg, encoded))
59
-}
60
-
61
-// DigestRegexp matches valid digest types.
62
-var DigestRegexp = regexp.MustCompile(`[a-z0-9]+(?:[.+_-][a-z0-9]+)*:[a-zA-Z0-9=_-]+`)
63
-
64
-// DigestRegexpAnchored matches valid digest types, anchored to the start and end of the match.
65
-var DigestRegexpAnchored = regexp.MustCompile(`^` + DigestRegexp.String() + `$`)
66
-
67
-var (
68
-	// ErrDigestInvalidFormat returned when digest format invalid.
69
-	ErrDigestInvalidFormat = fmt.Errorf("invalid checksum digest format")
70
-
71
-	// ErrDigestInvalidLength returned when digest has invalid length.
72
-	ErrDigestInvalidLength = fmt.Errorf("invalid checksum digest length")
73
-
74
-	// ErrDigestUnsupported returned when the digest algorithm is unsupported.
75
-	ErrDigestUnsupported = fmt.Errorf("unsupported digest algorithm")
76
-)
77
-
78
-// Parse parses s and returns the validated digest object. An error will
79
-// be returned if the format is invalid.
80
-func Parse(s string) (Digest, error) {
81
-	d := Digest(s)
82
-	return d, d.Validate()
83
-}
84
-
85
-// FromReader consumes the content of rd until io.EOF, returning canonical digest.
86
-func FromReader(rd io.Reader) (Digest, error) {
87
-	return Canonical.FromReader(rd)
88
-}
89
-
90
-// FromBytes digests the input and returns a Digest.
91
-func FromBytes(p []byte) Digest {
92
-	return Canonical.FromBytes(p)
93
-}
94
-
95
-// FromString digests the input and returns a Digest.
96
-func FromString(s string) Digest {
97
-	return Canonical.FromString(s)
98
-}
99
-
100
-// Validate checks that the contents of d is a valid digest, returning an
101
-// error if not.
102
-func (d Digest) Validate() error {
103
-	s := string(d)
104
-
105
-	i := strings.Index(s, ":")
106
-
107
-	// validate i then run through regexp
108
-	if i < 0 || i+1 == len(s) || !DigestRegexpAnchored.MatchString(s) {
109
-		return ErrDigestInvalidFormat
110
-	}
111
-
112
-	algorithm := Algorithm(s[:i])
113
-	if !algorithm.Available() {
114
-		return ErrDigestUnsupported
115
-	}
116
-
117
-	// Digests much always be hex-encoded, ensuring that their hex portion will
118
-	// always be size*2
119
-	if algorithm.Size()*2 != len(s[i+1:]) {
120
-		return ErrDigestInvalidLength
121
-	}
122
-
123
-	return nil
124
-}
125
-
126
-// Algorithm returns the algorithm portion of the digest. This will panic if
127
-// the underlying digest is not in a valid format.
128
-func (d Digest) Algorithm() Algorithm {
129
-	return Algorithm(d[:d.sepIndex()])
130
-}
131
-
132
-// Verifier returns a writer object that can be used to verify a stream of
133
-// content against the digest. If the digest is invalid, the method will panic.
134
-func (d Digest) Verifier() Verifier {
135
-	return hashVerifier{
136
-		hash:   d.Algorithm().Hash(),
137
-		digest: d,
138
-	}
139
-}
140
-
141
-// Encoded returns the encoded portion of the digest. This will panic if the
142
-// underlying digest is not in a valid format.
143
-func (d Digest) Encoded() string {
144
-	return string(d[d.sepIndex()+1:])
145
-}
146
-
147
-// Hex is deprecated. Please use Digest.Encoded.
148
-func (d Digest) Hex() string {
149
-	return d.Encoded()
150
-}
151
-
152
-func (d Digest) String() string {
153
-	return string(d)
154
-}
155
-
156
-func (d Digest) sepIndex() int {
157
-	i := strings.Index(string(d), ":")
158
-
159
-	if i < 0 {
160
-		panic(fmt.Sprintf("no ':' separator in digest %q", d))
161
-	}
162
-
163
-	return i
164
-}
165 1
deleted file mode 100644
... ...
@@ -1,39 +0,0 @@
1
-// Copyright 2017 Docker, Inc.
2
-//
3
-// Licensed under the Apache License, Version 2.0 (the "License");
4
-// you may not use this file except in compliance with the License.
5
-// You may obtain a copy of the License at
6
-//
7
-//     https://www.apache.org/licenses/LICENSE-2.0
8
-//
9
-// Unless required by applicable law or agreed to in writing, software
10
-// distributed under the License is distributed on an "AS IS" BASIS,
11
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
-// See the License for the specific language governing permissions and
13
-// limitations under the License.
14
-
15
-package digest
16
-
17
-import "hash"
18
-
19
-// Digester calculates the digest of written data. Writes should go directly
20
-// to the return value of Hash, while calling Digest will return the current
21
-// value of the digest.
22
-type Digester interface {
23
-	Hash() hash.Hash // provides direct access to underlying hash instance.
24
-	Digest() Digest
25
-}
26
-
27
-// digester provides a simple digester definition that embeds a hasher.
28
-type digester struct {
29
-	alg  Algorithm
30
-	hash hash.Hash
31
-}
32
-
33
-func (d *digester) Hash() hash.Hash {
34
-	return d.hash
35
-}
36
-
37
-func (d *digester) Digest() Digest {
38
-	return NewDigest(d.alg, d.hash)
39
-}
40 1
deleted file mode 100644
... ...
@@ -1,56 +0,0 @@
1
-// Copyright 2017 Docker, Inc.
2
-//
3
-// Licensed under the Apache License, Version 2.0 (the "License");
4
-// you may not use this file except in compliance with the License.
5
-// You may obtain a copy of the License at
6
-//
7
-//     https://www.apache.org/licenses/LICENSE-2.0
8
-//
9
-// Unless required by applicable law or agreed to in writing, software
10
-// distributed under the License is distributed on an "AS IS" BASIS,
11
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
-// See the License for the specific language governing permissions and
13
-// limitations under the License.
14
-
15
-// Package digest provides a generalized type to opaquely represent message
16
-// digests and their operations within the registry. The Digest type is
17
-// designed to serve as a flexible identifier in a content-addressable system.
18
-// More importantly, it provides tools and wrappers to work with
19
-// hash.Hash-based digests with little effort.
20
-//
21
-// Basics
22
-//
23
-// The format of a digest is simply a string with two parts, dubbed the
24
-// "algorithm" and the "digest", separated by a colon:
25
-//
26
-// 	<algorithm>:<digest>
27
-//
28
-// An example of a sha256 digest representation follows:
29
-//
30
-// 	sha256:7173b809ca12ec5dee4506cd86be934c4596dd234ee82c0662eac04a8c2c71dc
31
-//
32
-// In this case, the string "sha256" is the algorithm and the hex bytes are
33
-// the "digest".
34
-//
35
-// Because the Digest type is simply a string, once a valid Digest is
36
-// obtained, comparisons are cheap, quick and simple to express with the
37
-// standard equality operator.
38
-//
39
-// Verification
40
-//
41
-// The main benefit of using the Digest type is simple verification against a
42
-// given digest. The Verifier interface, modeled after the stdlib hash.Hash
43
-// interface, provides a common write sink for digest verification. After
44
-// writing is complete, calling the Verifier.Verified method will indicate
45
-// whether or not the stream of bytes matches the target digest.
46
-//
47
-// Missing Features
48
-//
49
-// In addition to the above, we intend to add the following features to this
50
-// package:
51
-//
52
-// 1. A Digester type that supports write sink digest calculation.
53
-//
54
-// 2. Suspend and resume of ongoing digest calculations to support efficient digest verification in the registry.
55
-//
56
-package digest
57 1
deleted file mode 100644
... ...
@@ -1,45 +0,0 @@
1
-// Copyright 2017 Docker, Inc.
2
-//
3
-// Licensed under the Apache License, Version 2.0 (the "License");
4
-// you may not use this file except in compliance with the License.
5
-// You may obtain a copy of the License at
6
-//
7
-//     https://www.apache.org/licenses/LICENSE-2.0
8
-//
9
-// Unless required by applicable law or agreed to in writing, software
10
-// distributed under the License is distributed on an "AS IS" BASIS,
11
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
-// See the License for the specific language governing permissions and
13
-// limitations under the License.
14
-
15
-package digest
16
-
17
-import (
18
-	"hash"
19
-	"io"
20
-)
21
-
22
-// Verifier presents a general verification interface to be used with message
23
-// digests and other byte stream verifications. Users instantiate a Verifier
24
-// from one of the various methods, write the data under test to it then check
25
-// the result with the Verified method.
26
-type Verifier interface {
27
-	io.Writer
28
-
29
-	// Verified will return true if the content written to Verifier matches
30
-	// the digest.
31
-	Verified() bool
32
-}
33
-
34
-type hashVerifier struct {
35
-	digest Digest
36
-	hash   hash.Hash
37
-}
38
-
39
-func (hv hashVerifier) Write(p []byte) (n int, err error) {
40
-	return hv.hash.Write(p)
41
-}
42
-
43
-func (hv hashVerifier) Verified() bool {
44
-	return hv.digest == NewDigest(hv.digest.Algorithm(), hv.hash)
45
-}
46 1
deleted file mode 100644
... ...
@@ -1,191 +0,0 @@
1
-
2
-                                 Apache License
3
-                           Version 2.0, January 2004
4
-                        http://www.apache.org/licenses/
5
-
6
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
-
8
-   1. Definitions.
9
-
10
-      "License" shall mean the terms and conditions for use, reproduction,
11
-      and distribution as defined by Sections 1 through 9 of this document.
12
-
13
-      "Licensor" shall mean the copyright owner or entity authorized by
14
-      the copyright owner that is granting the License.
15
-
16
-      "Legal Entity" shall mean the union of the acting entity and all
17
-      other entities that control, are controlled by, or are under common
18
-      control with that entity. For the purposes of this definition,
19
-      "control" means (i) the power, direct or indirect, to cause the
20
-      direction or management of such entity, whether by contract or
21
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
-      outstanding shares, or (iii) beneficial ownership of such entity.
23
-
24
-      "You" (or "Your") shall mean an individual or Legal Entity
25
-      exercising permissions granted by this License.
26
-
27
-      "Source" form shall mean the preferred form for making modifications,
28
-      including but not limited to software source code, documentation
29
-      source, and configuration files.
30
-
31
-      "Object" form shall mean any form resulting from mechanical
32
-      transformation or translation of a Source form, including but
33
-      not limited to compiled object code, generated documentation,
34
-      and conversions to other media types.
35
-
36
-      "Work" shall mean the work of authorship, whether in Source or
37
-      Object form, made available under the License, as indicated by a
38
-      copyright notice that is included in or attached to the work
39
-      (an example is provided in the Appendix below).
40
-
41
-      "Derivative Works" shall mean any work, whether in Source or Object
42
-      form, that is based on (or derived from) the Work and for which the
43
-      editorial revisions, annotations, elaborations, or other modifications
44
-      represent, as a whole, an original work of authorship. For the purposes
45
-      of this License, Derivative Works shall not include works that remain
46
-      separable from, or merely link (or bind by name) to the interfaces of,
47
-      the Work and Derivative Works thereof.
48
-
49
-      "Contribution" shall mean any work of authorship, including
50
-      the original version of the Work and any modifications or additions
51
-      to that Work or Derivative Works thereof, that is intentionally
52
-      submitted to Licensor for inclusion in the Work by the copyright owner
53
-      or by an individual or Legal Entity authorized to submit on behalf of
54
-      the copyright owner. For the purposes of this definition, "submitted"
55
-      means any form of electronic, verbal, or written communication sent
56
-      to the Licensor or its representatives, including but not limited to
57
-      communication on electronic mailing lists, source code control systems,
58
-      and issue tracking systems that are managed by, or on behalf of, the
59
-      Licensor for the purpose of discussing and improving the Work, but
60
-      excluding communication that is conspicuously marked or otherwise
61
-      designated in writing by the copyright owner as "Not a Contribution."
62
-
63
-      "Contributor" shall mean Licensor and any individual or Legal Entity
64
-      on behalf of whom a Contribution has been received by Licensor and
65
-      subsequently incorporated within the Work.
66
-
67
-   2. Grant of Copyright License. Subject to the terms and conditions of
68
-      this License, each Contributor hereby grants to You a perpetual,
69
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
-      copyright license to reproduce, prepare Derivative Works of,
71
-      publicly display, publicly perform, sublicense, and distribute the
72
-      Work and such Derivative Works in Source or Object form.
73
-
74
-   3. Grant of Patent License. Subject to the terms and conditions of
75
-      this License, each Contributor hereby grants to You a perpetual,
76
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
-      (except as stated in this section) patent license to make, have made,
78
-      use, offer to sell, sell, import, and otherwise transfer the Work,
79
-      where such license applies only to those patent claims licensable
80
-      by such Contributor that are necessarily infringed by their
81
-      Contribution(s) alone or by combination of their Contribution(s)
82
-      with the Work to which such Contribution(s) was submitted. If You
83
-      institute patent litigation against any entity (including a
84
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
85
-      or a Contribution incorporated within the Work constitutes direct
86
-      or contributory patent infringement, then any patent licenses
87
-      granted to You under this License for that Work shall terminate
88
-      as of the date such litigation is filed.
89
-
90
-   4. Redistribution. You may reproduce and distribute copies of the
91
-      Work or Derivative Works thereof in any medium, with or without
92
-      modifications, and in Source or Object form, provided that You
93
-      meet the following conditions:
94
-
95
-      (a) You must give any other recipients of the Work or
96
-          Derivative Works a copy of this License; and
97
-
98
-      (b) You must cause any modified files to carry prominent notices
99
-          stating that You changed the files; and
100
-
101
-      (c) You must retain, in the Source form of any Derivative Works
102
-          that You distribute, all copyright, patent, trademark, and
103
-          attribution notices from the Source form of the Work,
104
-          excluding those notices that do not pertain to any part of
105
-          the Derivative Works; and
106
-
107
-      (d) If the Work includes a "NOTICE" text file as part of its
108
-          distribution, then any Derivative Works that You distribute must
109
-          include a readable copy of the attribution notices contained
110
-          within such NOTICE file, excluding those notices that do not
111
-          pertain to any part of the Derivative Works, in at least one
112
-          of the following places: within a NOTICE text file distributed
113
-          as part of the Derivative Works; within the Source form or
114
-          documentation, if provided along with the Derivative Works; or,
115
-          within a display generated by the Derivative Works, if and
116
-          wherever such third-party notices normally appear. The contents
117
-          of the NOTICE file are for informational purposes only and
118
-          do not modify the License. You may add Your own attribution
119
-          notices within Derivative Works that You distribute, alongside
120
-          or as an addendum to the NOTICE text from the Work, provided
121
-          that such additional attribution notices cannot be construed
122
-          as modifying the License.
123
-
124
-      You may add Your own copyright statement to Your modifications and
125
-      may provide additional or different license terms and conditions
126
-      for use, reproduction, or distribution of Your modifications, or
127
-      for any such Derivative Works as a whole, provided Your use,
128
-      reproduction, and distribution of the Work otherwise complies with
129
-      the conditions stated in this License.
130
-
131
-   5. Submission of Contributions. Unless You explicitly state otherwise,
132
-      any Contribution intentionally submitted for inclusion in the Work
133
-      by You to the Licensor shall be under the terms and conditions of
134
-      this License, without any additional terms or conditions.
135
-      Notwithstanding the above, nothing herein shall supersede or modify
136
-      the terms of any separate license agreement you may have executed
137
-      with Licensor regarding such Contributions.
138
-
139
-   6. Trademarks. This License does not grant permission to use the trade
140
-      names, trademarks, service marks, or product names of the Licensor,
141
-      except as required for reasonable and customary use in describing the
142
-      origin of the Work and reproducing the content of the NOTICE file.
143
-
144
-   7. Disclaimer of Warranty. Unless required by applicable law or
145
-      agreed to in writing, Licensor provides the Work (and each
146
-      Contributor provides its Contributions) on an "AS IS" BASIS,
147
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
-      implied, including, without limitation, any warranties or conditions
149
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
-      PARTICULAR PURPOSE. You are solely responsible for determining the
151
-      appropriateness of using or redistributing the Work and assume any
152
-      risks associated with Your exercise of permissions under this License.
153
-
154
-   8. Limitation of Liability. In no event and under no legal theory,
155
-      whether in tort (including negligence), contract, or otherwise,
156
-      unless required by applicable law (such as deliberate and grossly
157
-      negligent acts) or agreed to in writing, shall any Contributor be
158
-      liable to You for damages, including any direct, indirect, special,
159
-      incidental, or consequential damages of any character arising as a
160
-      result of this License or out of the use or inability to use the
161
-      Work (including but not limited to damages for loss of goodwill,
162
-      work stoppage, computer failure or malfunction, or any and all
163
-      other commercial damages or losses), even if such Contributor
164
-      has been advised of the possibility of such damages.
165
-
166
-   9. Accepting Warranty or Additional Liability. While redistributing
167
-      the Work or Derivative Works thereof, You may choose to offer,
168
-      and charge a fee for, acceptance of support, warranty, indemnity,
169
-      or other liability obligations and/or rights consistent with this
170
-      License. However, in accepting such obligations, You may act only
171
-      on Your own behalf and on Your sole responsibility, not on behalf
172
-      of any other Contributor, and only if You agree to indemnify,
173
-      defend, and hold each Contributor harmless for any liability
174
-      incurred by, or claims asserted against, such Contributor by reason
175
-      of your accepting any such warranty or additional liability.
176
-
177
-   END OF TERMS AND CONDITIONS
178
-
179
-   Copyright 2016 The Linux Foundation.
180
-
181
-   Licensed under the Apache License, Version 2.0 (the "License");
182
-   you may not use this file except in compliance with the License.
183
-   You may obtain a copy of the License at
184
-
185
-       http://www.apache.org/licenses/LICENSE-2.0
186
-
187
-   Unless required by applicable law or agreed to in writing, software
188
-   distributed under the License is distributed on an "AS IS" BASIS,
189
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
-   See the License for the specific language governing permissions and
191
-   limitations under the License.
192 1
deleted file mode 100644
... ...
@@ -1,167 +0,0 @@
1
-# OCI Image Format Specification
2
-<div>
3
-<a href="https://travis-ci.org/opencontainers/image-spec">
4
-<img src="https://travis-ci.org/opencontainers/image-spec.svg?branch=master"></img>
5
-</a>
6
-</div>
7
-
8
-The OCI Image Format project creates and maintains the software shipping container image format spec (OCI Image Format).
9
-
10
-**[The specification can be found here](spec.md).**
11
-
12
-This repository also provides [Go types](specs-go), [intra-blob validation tooling, and JSON Schema](schema).
13
-The Go types and validation should be compatible with the current Go release; earlier Go releases are not supported.
14
-
15
-Additional documentation about how this group operates:
16
-
17
-- [Code of Conduct](https://github.com/opencontainers/tob/blob/d2f9d68c1332870e40693fe077d311e0742bc73d/code-of-conduct.md)
18
-- [Roadmap](#roadmap)
19
-- [Releases](RELEASES.md)
20
-- [Project Documentation](project.md)
21
-
22
-The _optional_ and _base_ layers of all OCI projects are tracked in the [OCI Scope Table](https://www.opencontainers.org/about/oci-scope-table).
23
-
24
-## Running an OCI Image
25
-
26
-The OCI Image Format partner project is the [OCI Runtime Spec project](https://github.com/opencontainers/runtime-spec).
27
-The Runtime Specification outlines how to run a "[filesystem bundle](https://github.com/opencontainers/runtime-spec/blob/master/bundle.md)" that is unpacked on disk.
28
-At a high-level an OCI implementation would download an OCI Image then unpack that image into an OCI Runtime filesystem bundle.
29
-At this point the OCI Runtime Bundle would be run by an OCI Runtime.
30
-
31
-This entire workflow supports the UX that users have come to expect from container engines like Docker and rkt: primarily, the ability to run an image with no additional arguments:
32
-
33
-* docker run example.com/org/app:v1.0.0
34
-* rkt run example.com/org/app,version=v1.0.0
35
-
36
-To support this UX the OCI Image Format contains sufficient information to launch the application on the target platform (e.g. command, arguments, environment variables, etc).
37
-
38
-## FAQ
39
-
40
-**Q: Why doesn't this project mention distribution?**
41
-
42
-A: Distribution, for example using HTTP as both Docker v2.2 and AppC do today, is currently out of scope on the [OCI Scope Table](https://www.opencontainers.org/about/oci-scope-table).
43
-There has been [some discussion on the TOB mailing list](https://groups.google.com/a/opencontainers.org/d/msg/tob/A3JnmI-D-6Y/tLuptPDHAgAJ) to make distribution an optional layer, but this topic is a work in progress.
44
-
45
-**Q: What happens to AppC or Docker Image Formats?**
46
-
47
-A: Existing formats can continue to be a proving ground for technologies, as needed.
48
-The OCI Image Format project strives to provide a dependable open specification that can be shared between different tools and be evolved for years or decades of compatibility; as the deb and rpm format have.
49
-
50
-Find more [FAQ on the OCI site](https://www.opencontainers.org/faq).
51
-
52
-## Roadmap
53
-
54
-The [GitHub milestones](https://github.com/opencontainers/image-spec/milestones) lay out the path to the OCI v1.0.0 release in late 2016.
55
-
56
-# Contributing
57
-
58
-Development happens on GitHub for the spec.
59
-Issues are used for bugs and actionable items and longer discussions can happen on the [mailing list](#mailing-list).
60
-
61
-The specification and code is licensed under the Apache 2.0 license found in the `LICENSE` file of this repository.
62
-
63
-## Discuss your design
64
-
65
-The project welcomes submissions, but please let everyone know what you are working on.
66
-
67
-Before undertaking a nontrivial change to this specification, send mail to the [mailing list](#mailing-list) to discuss what you plan to do.
68
-This gives everyone a chance to validate the design, helps prevent duplication of effort, and ensures that the idea fits.
69
-It also guarantees that the design is sound before code is written; a GitHub pull-request is not the place for high-level discussions.
70
-
71
-Typos and grammatical errors can go straight to a pull-request.
72
-When in doubt, start on the [mailing-list](#mailing-list).
73
-
74
-## Weekly Call
75
-
76
-The contributors and maintainers of all OCI projects have a weekly meeting Wednesdays at 2:00 PM (USA Pacific).
77
-Everyone is welcome to participate via [UberConference web][UberConference] or audio-only: +1-415-968-0849 (no PIN needed).
78
-An initial agenda will be posted to the [mailing list](#mailing-list) earlier in the week, and everyone is welcome to propose additional topics or suggest other agenda alterations there.
79
-Minutes are posted to the [mailing list](#mailing-list) and minutes from past calls are archived [here][minutes].
80
-
81
-## Mailing List
82
-
83
-You can subscribe and join the mailing list on [Google Groups](https://groups.google.com/a/opencontainers.org/forum/#!forum/dev).
84
-
85
-## IRC
86
-
87
-OCI discussion happens on #opencontainers on Freenode ([logs][irc-logs]).
88
-
89
-## Markdown style
90
-
91
-To keep consistency throughout the Markdown files in the Open Container spec all files should be formatted one sentence per line.
92
-This fixes two things: it makes diffing easier with git and it resolves fights about line wrapping length.
93
-For example, this paragraph will span three lines in the Markdown source.
94
-
95
-## Git commit
96
-
97
-### Sign your work
98
-
99
-The sign-off is a simple line at the end of the explanation for the patch, which certifies that you wrote it or otherwise have the right to pass it on as an open-source patch.
100
-The rules are pretty simple: if you can certify the below (from [developercertificate.org](http://developercertificate.org/)):
101
-
102
-```
103
-Developer Certificate of Origin
104
-Version 1.1
105
-
106
-Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
107
-660 York Street, Suite 102,
108
-San Francisco, CA 94110 USA
109
-
110
-Everyone is permitted to copy and distribute verbatim copies of this
111
-license document, but changing it is not allowed.
112
-
113
-
114
-Developer's Certificate of Origin 1.1
115
-
116
-By making a contribution to this project, I certify that:
117
-
118
-(a) The contribution was created in whole or in part by me and I
119
-    have the right to submit it under the open source license
120
-    indicated in the file; or
121
-
122
-(b) The contribution is based upon previous work that, to the best
123
-    of my knowledge, is covered under an appropriate open source
124
-    license and I have the right under that license to submit that
125
-    work with modifications, whether created in whole or in part
126
-    by me, under the same open source license (unless I am
127
-    permitted to submit under a different license), as indicated
128
-    in the file; or
129
-
130
-(c) The contribution was provided directly to me by some other
131
-    person who certified (a), (b) or (c) and I have not modified
132
-    it.
133
-
134
-(d) I understand and agree that this project and the contribution
135
-    are public and that a record of the contribution (including all
136
-    personal information I submit with it, including my sign-off) is
137
-    maintained indefinitely and may be redistributed consistent with
138
-    this project or the open source license(s) involved.
139
-```
140
-
141
-then you just add a line to every git commit message:
142
-
143
-    Signed-off-by: Joe Smith <joe@gmail.com>
144
-
145
-using your real name (sorry, no pseudonyms or anonymous contributions.)
146
-
147
-You can add the sign off when creating the git commit via `git commit -s`.
148
-
149
-### Commit Style
150
-
151
-Simple house-keeping for clean git history.
152
-Read more on [How to Write a Git Commit Message](http://chris.beams.io/posts/git-commit/) or the Discussion section of [`git-commit(1)`](http://git-scm.com/docs/git-commit).
153
-
154
-1. Separate the subject from body with a blank line
155
-2. Limit the subject line to 50 characters
156
-3. Capitalize the subject line
157
-4. Do not end the subject line with a period
158
-5. Use the imperative mood in the subject line
159
-6. Wrap the body at 72 characters
160
-7. Use the body to explain what and why vs. how
161
-  * If there was important/useful/essential conversation or information, copy or include a reference
162
-8. When possible, one keyword to scope the change in the subject (i.e. "README: ...", "runtime: ...")
163
-
164
-
165
-[UberConference]: https://www.uberconference.com/opencontainers
166
-[irc-logs]: http://ircbot.wl.linuxfoundation.org/eavesdrop/%23opencontainers/
167
-[minutes]: http://ircbot.wl.linuxfoundation.org/meetings/opencontainers/
168 1
deleted file mode 100644
... ...
@@ -1,103 +0,0 @@
1
-// Copyright 2016 The Linux Foundation
2
-//
3
-// Licensed under the Apache License, Version 2.0 (the "License");
4
-// you may not use this file except in compliance with the License.
5
-// You may obtain a copy of the License at
6
-//
7
-//     http://www.apache.org/licenses/LICENSE-2.0
8
-//
9
-// Unless required by applicable law or agreed to in writing, software
10
-// distributed under the License is distributed on an "AS IS" BASIS,
11
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
-// See the License for the specific language governing permissions and
13
-// limitations under the License.
14
-
15
-package v1
16
-
17
-import (
18
-	"time"
19
-
20
-	digest "github.com/opencontainers/go-digest"
21
-)
22
-
23
-// ImageConfig defines the execution parameters which should be used as a base when running a container using an image.
24
-type ImageConfig struct {
25
-	// User defines the username or UID which the process in the container should run as.
26
-	User string `json:"User,omitempty"`
27
-
28
-	// ExposedPorts a set of ports to expose from a container running this image.
29
-	ExposedPorts map[string]struct{} `json:"ExposedPorts,omitempty"`
30
-
31
-	// Env is a list of environment variables to be used in a container.
32
-	Env []string `json:"Env,omitempty"`
33
-
34
-	// Entrypoint defines a list of arguments to use as the command to execute when the container starts.
35
-	Entrypoint []string `json:"Entrypoint,omitempty"`
36
-
37
-	// Cmd defines the default arguments to the entrypoint of the container.
38
-	Cmd []string `json:"Cmd,omitempty"`
39
-
40
-	// Volumes is a set of directories which should be created as data volumes in a container running this image.
41
-	Volumes map[string]struct{} `json:"Volumes,omitempty"`
42
-
43
-	// WorkingDir sets the current working directory of the entrypoint process in the container.
44
-	WorkingDir string `json:"WorkingDir,omitempty"`
45
-
46
-	// Labels contains arbitrary metadata for the container.
47
-	Labels map[string]string `json:"Labels,omitempty"`
48
-
49
-	// StopSignal contains the system call signal that will be sent to the container to exit.
50
-	StopSignal string `json:"StopSignal,omitempty"`
51
-}
52
-
53
-// RootFS describes a layer content addresses
54
-type RootFS struct {
55
-	// Type is the type of the rootfs.
56
-	Type string `json:"type"`
57
-
58
-	// DiffIDs is an array of layer content hashes (DiffIDs), in order from bottom-most to top-most.
59
-	DiffIDs []digest.Digest `json:"diff_ids"`
60
-}
61
-
62
-// History describes the history of a layer.
63
-type History struct {
64
-	// Created is the combined date and time at which the layer was created, formatted as defined by RFC 3339, section 5.6.
65
-	Created *time.Time `json:"created,omitempty"`
66
-
67
-	// CreatedBy is the command which created the layer.
68
-	CreatedBy string `json:"created_by,omitempty"`
69
-
70
-	// Author is the author of the build point.
71
-	Author string `json:"author,omitempty"`
72
-
73
-	// Comment is a custom message set when creating the layer.
74
-	Comment string `json:"comment,omitempty"`
75
-
76
-	// EmptyLayer is used to mark if the history item created a filesystem diff.
77
-	EmptyLayer bool `json:"empty_layer,omitempty"`
78
-}
79
-
80
-// Image is the JSON structure which describes some basic information about the image.
81
-// This provides the `application/vnd.oci.image.config.v1+json` mediatype when marshalled to JSON.
82
-type Image struct {
83
-	// Created is the combined date and time at which the image was created, formatted as defined by RFC 3339, section 5.6.
84
-	Created *time.Time `json:"created,omitempty"`
85
-
86
-	// Author defines the name and/or email address of the person or entity which created and is responsible for maintaining the image.
87
-	Author string `json:"author,omitempty"`
88
-
89
-	// Architecture is the CPU architecture which the binaries in this image are built to run on.
90
-	Architecture string `json:"architecture"`
91
-
92
-	// OS is the name of the operating system which the image is built to run on.
93
-	OS string `json:"os"`
94
-
95
-	// Config defines the execution parameters which should be used as a base when running a container using the image.
96
-	Config ImageConfig `json:"config,omitempty"`
97
-
98
-	// RootFS references the layer content addresses used by the image.
99
-	RootFS RootFS `json:"rootfs"`
100
-
101
-	// History describes the history of each layer.
102
-	History []History `json:"history,omitempty"`
103
-}
104 1
deleted file mode 100644
... ...
@@ -1,64 +0,0 @@
1
-// Copyright 2016 The Linux Foundation
2
-//
3
-// Licensed under the Apache License, Version 2.0 (the "License");
4
-// you may not use this file except in compliance with the License.
5
-// You may obtain a copy of the License at
6
-//
7
-//     http://www.apache.org/licenses/LICENSE-2.0
8
-//
9
-// Unless required by applicable law or agreed to in writing, software
10
-// distributed under the License is distributed on an "AS IS" BASIS,
11
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
-// See the License for the specific language governing permissions and
13
-// limitations under the License.
14
-
15
-package v1
16
-
17
-import digest "github.com/opencontainers/go-digest"
18
-
19
-// Descriptor describes the disposition of targeted content.
20
-// This structure provides `application/vnd.oci.descriptor.v1+json` mediatype
21
-// when marshalled to JSON.
22
-type Descriptor struct {
23
-	// MediaType is the media type of the object this schema refers to.
24
-	MediaType string `json:"mediaType,omitempty"`
25
-
26
-	// Digest is the digest of the targeted content.
27
-	Digest digest.Digest `json:"digest"`
28
-
29
-	// Size specifies the size in bytes of the blob.
30
-	Size int64 `json:"size"`
31
-
32
-	// URLs specifies a list of URLs from which this object MAY be downloaded
33
-	URLs []string `json:"urls,omitempty"`
34
-
35
-	// Annotations contains arbitrary metadata relating to the targeted content.
36
-	Annotations map[string]string `json:"annotations,omitempty"`
37
-
38
-	// Platform describes the platform which the image in the manifest runs on.
39
-	//
40
-	// This should only be used when referring to a manifest.
41
-	Platform *Platform `json:"platform,omitempty"`
42
-}
43
-
44
-// Platform describes the platform which the image in the manifest runs on.
45
-type Platform struct {
46
-	// Architecture field specifies the CPU architecture, for example
47
-	// `amd64` or `ppc64`.
48
-	Architecture string `json:"architecture"`
49
-
50
-	// OS specifies the operating system, for example `linux` or `windows`.
51
-	OS string `json:"os"`
52
-
53
-	// OSVersion is an optional field specifying the operating system
54
-	// version, for example on Windows `10.0.14393.1066`.
55
-	OSVersion string `json:"os.version,omitempty"`
56
-
57
-	// OSFeatures is an optional field specifying an array of strings,
58
-	// each listing a required OS feature (for example on Windows `win32k`).
59
-	OSFeatures []string `json:"os.features,omitempty"`
60
-
61
-	// Variant is an optional field specifying a variant of the CPU, for
62
-	// example `v7` to specify ARMv7 when architecture is `arm`.
63
-	Variant string `json:"variant,omitempty"`
64
-}
65 1
deleted file mode 100644
... ...
@@ -1,29 +0,0 @@
1
-// Copyright 2016 The Linux Foundation
2
-//
3
-// Licensed under the Apache License, Version 2.0 (the "License");
4
-// you may not use this file except in compliance with the License.
5
-// You may obtain a copy of the License at
6
-//
7
-//     http://www.apache.org/licenses/LICENSE-2.0
8
-//
9
-// Unless required by applicable law or agreed to in writing, software
10
-// distributed under the License is distributed on an "AS IS" BASIS,
11
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
-// See the License for the specific language governing permissions and
13
-// limitations under the License.
14
-
15
-package v1
16
-
17
-import "github.com/opencontainers/image-spec/specs-go"
18
-
19
-// Index references manifests for various platforms.
20
-// This structure provides `application/vnd.oci.image.index.v1+json` mediatype when marshalled to JSON.
21
-type Index struct {
22
-	specs.Versioned
23
-
24
-	// Manifests references platform specific manifests.
25
-	Manifests []Descriptor `json:"manifests"`
26
-
27
-	// Annotations contains arbitrary metadata for the image index.
28
-	Annotations map[string]string `json:"annotations,omitempty"`
29
-}
30 1
deleted file mode 100644
... ...
@@ -1,28 +0,0 @@
1
-// Copyright 2016 The Linux Foundation
2
-//
3
-// Licensed under the Apache License, Version 2.0 (the "License");
4
-// you may not use this file except in compliance with the License.
5
-// You may obtain a copy of the License at
6
-//
7
-//     http://www.apache.org/licenses/LICENSE-2.0
8
-//
9
-// Unless required by applicable law or agreed to in writing, software
10
-// distributed under the License is distributed on an "AS IS" BASIS,
11
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
-// See the License for the specific language governing permissions and
13
-// limitations under the License.
14
-
15
-package v1
16
-
17
-const (
18
-	// ImageLayoutFile is the file name of oci image layout file
19
-	ImageLayoutFile = "oci-layout"
20
-	// ImageLayoutVersion is the version of ImageLayout
21
-	ImageLayoutVersion = "1.0.0"
22
-)
23
-
24
-// ImageLayout is the structure in the "oci-layout" file, found in the root
25
-// of an OCI Image-layout directory.
26
-type ImageLayout struct {
27
-	Version string `json:"imageLayoutVersion"`
28
-}
29 1
deleted file mode 100644
... ...
@@ -1,32 +0,0 @@
1
-// Copyright 2016 The Linux Foundation
2
-//
3
-// Licensed under the Apache License, Version 2.0 (the "License");
4
-// you may not use this file except in compliance with the License.
5
-// You may obtain a copy of the License at
6
-//
7
-//     http://www.apache.org/licenses/LICENSE-2.0
8
-//
9
-// Unless required by applicable law or agreed to in writing, software
10
-// distributed under the License is distributed on an "AS IS" BASIS,
11
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
-// See the License for the specific language governing permissions and
13
-// limitations under the License.
14
-
15
-package v1
16
-
17
-import "github.com/opencontainers/image-spec/specs-go"
18
-
19
-// Manifest provides `application/vnd.oci.image.manifest.v1+json` mediatype structure when marshalled to JSON.
20
-type Manifest struct {
21
-	specs.Versioned
22
-
23
-	// Config references a configuration object for a container, by digest.
24
-	// The referenced configuration object is a JSON blob that the runtime uses to set up the container.
25
-	Config Descriptor `json:"config"`
26
-
27
-	// Layers is an indexed list of layers referenced by the manifest.
28
-	Layers []Descriptor `json:"layers"`
29
-
30
-	// Annotations contains arbitrary metadata for the image manifest.
31
-	Annotations map[string]string `json:"annotations,omitempty"`
32
-}
33 1
deleted file mode 100644
... ...
@@ -1,48 +0,0 @@
1
-// Copyright 2016 The Linux Foundation
2
-//
3
-// Licensed under the Apache License, Version 2.0 (the "License");
4
-// you may not use this file except in compliance with the License.
5
-// You may obtain a copy of the License at
6
-//
7
-//     http://www.apache.org/licenses/LICENSE-2.0
8
-//
9
-// Unless required by applicable law or agreed to in writing, software
10
-// distributed under the License is distributed on an "AS IS" BASIS,
11
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
-// See the License for the specific language governing permissions and
13
-// limitations under the License.
14
-
15
-package v1
16
-
17
-const (
18
-	// MediaTypeDescriptor specifies the media type for a content descriptor.
19
-	MediaTypeDescriptor = "application/vnd.oci.descriptor.v1+json"
20
-
21
-	// MediaTypeLayoutHeader specifies the media type for the oci-layout.
22
-	MediaTypeLayoutHeader = "application/vnd.oci.layout.header.v1+json"
23
-
24
-	// MediaTypeImageManifest specifies the media type for an image manifest.
25
-	MediaTypeImageManifest = "application/vnd.oci.image.manifest.v1+json"
26
-
27
-	// MediaTypeImageIndex specifies the media type for an image index.
28
-	MediaTypeImageIndex = "application/vnd.oci.image.index.v1+json"
29
-
30
-	// MediaTypeImageLayer is the media type used for layers referenced by the manifest.
31
-	MediaTypeImageLayer = "application/vnd.oci.image.layer.v1.tar"
32
-
33
-	// MediaTypeImageLayerGzip is the media type used for gzipped layers
34
-	// referenced by the manifest.
35
-	MediaTypeImageLayerGzip = "application/vnd.oci.image.layer.v1.tar+gzip"
36
-
37
-	// MediaTypeImageLayerNonDistributable is the media type for layers referenced by
38
-	// the manifest but with distribution restrictions.
39
-	MediaTypeImageLayerNonDistributable = "application/vnd.oci.image.layer.nondistributable.v1.tar"
40
-
41
-	// MediaTypeImageLayerNonDistributableGzip is the media type for
42
-	// gzipped layers referenced by the manifest but with distribution
43
-	// restrictions.
44
-	MediaTypeImageLayerNonDistributableGzip = "application/vnd.oci.image.layer.nondistributable.v1.tar+gzip"
45
-
46
-	// MediaTypeImageConfig specifies the media type for the image configuration.
47
-	MediaTypeImageConfig = "application/vnd.oci.image.config.v1+json"
48
-)
49 1
deleted file mode 100644
... ...
@@ -1,32 +0,0 @@
1
-// Copyright 2016 The Linux Foundation
2
-//
3
-// Licensed under the Apache License, Version 2.0 (the "License");
4
-// you may not use this file except in compliance with the License.
5
-// You may obtain a copy of the License at
6
-//
7
-//     http://www.apache.org/licenses/LICENSE-2.0
8
-//
9
-// Unless required by applicable law or agreed to in writing, software
10
-// distributed under the License is distributed on an "AS IS" BASIS,
11
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
-// See the License for the specific language governing permissions and
13
-// limitations under the License.
14
-
15
-package specs
16
-
17
-import "fmt"
18
-
19
-const (
20
-	// VersionMajor is for an API incompatible changes
21
-	VersionMajor = 1
22
-	// VersionMinor is for functionality in a backwards-compatible manner
23
-	VersionMinor = 0
24
-	// VersionPatch is for backwards-compatible bug fixes
25
-	VersionPatch = 0
26
-
27
-	// VersionDev indicates development branch. Releases will be empty string.
28
-	VersionDev = "-rc6-dev"
29
-)
30
-
31
-// Version is the specification version that the package types support.
32
-var Version = fmt.Sprintf("%d.%d.%d%s", VersionMajor, VersionMinor, VersionPatch, VersionDev)
33 1
deleted file mode 100644
... ...
@@ -1,23 +0,0 @@
1
-// Copyright 2016 The Linux Foundation
2
-//
3
-// Licensed under the Apache License, Version 2.0 (the "License");
4
-// you may not use this file except in compliance with the License.
5
-// You may obtain a copy of the License at
6
-//
7
-//     http://www.apache.org/licenses/LICENSE-2.0
8
-//
9
-// Unless required by applicable law or agreed to in writing, software
10
-// distributed under the License is distributed on an "AS IS" BASIS,
11
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
-// See the License for the specific language governing permissions and
13
-// limitations under the License.
14
-
15
-package specs
16
-
17
-// Versioned provides a struct with the manifest schemaVersion and mediaType.
18
-// Incoming content with unknown schema version can be decoded against this
19
-// struct to check the version.
20
-type Versioned struct {
21
-	// SchemaVersion is the image manifest schema that this image follows
22
-	SchemaVersion int `json:"schemaVersion"`
23
-}