Skip to content

Commit 6d98e34

Browse files
committed
revendor engine-api
Signed-off-by: Brian Goff <[email protected]>
1 parent e4a88b3 commit 6d98e34

36 files changed

Lines changed: 235 additions & 176 deletions

api/client/service/opts.go

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"github.com/docker/docker/opts"
1212
runconfigopts "github.com/docker/docker/runconfig/opts"
13+
mounttypes "github.com/docker/engine-api/types/mount"
1314
"github.com/docker/engine-api/types/swarm"
1415
"github.com/docker/go-connections/nat"
1516
units "github.com/docker/go-units"
@@ -130,7 +131,7 @@ func (i *Uint64Opt) Value() *uint64 {
130131

131132
// MountOpt is a Value type for parsing mounts
132133
type MountOpt struct {
133-
values []swarm.Mount
134+
values []mounttypes.Mount
134135
}
135136

136137
// Set a new mount value
@@ -141,23 +142,23 @@ func (m *MountOpt) Set(value string) error {
141142
return err
142143
}
143144

144-
mount := swarm.Mount{}
145+
mount := mounttypes.Mount{}
145146

146-
volumeOptions := func() *swarm.VolumeOptions {
147+
volumeOptions := func() *mounttypes.VolumeOptions {
147148
if mount.VolumeOptions == nil {
148-
mount.VolumeOptions = &swarm.VolumeOptions{
149+
mount.VolumeOptions = &mounttypes.VolumeOptions{
149150
Labels: make(map[string]string),
150151
}
151152
}
152153
if mount.VolumeOptions.DriverConfig == nil {
153-
mount.VolumeOptions.DriverConfig = &swarm.Driver{}
154+
mount.VolumeOptions.DriverConfig = &mounttypes.Driver{}
154155
}
155156
return mount.VolumeOptions
156157
}
157158

158-
bindOptions := func() *swarm.BindOptions {
159+
bindOptions := func() *mounttypes.BindOptions {
159160
if mount.BindOptions == nil {
160-
mount.BindOptions = new(swarm.BindOptions)
161+
mount.BindOptions = new(mounttypes.BindOptions)
161162
}
162163
return mount.BindOptions
163164
}
@@ -171,7 +172,7 @@ func (m *MountOpt) Set(value string) error {
171172
}
172173
}
173174

174-
mount.Type = swarm.MountTypeVolume // default to volume mounts
175+
mount.Type = mounttypes.TypeVolume // default to volume mounts
175176
// Set writable as the default
176177
for _, field := range fields {
177178
parts := strings.SplitN(field, "=", 2)
@@ -195,7 +196,7 @@ func (m *MountOpt) Set(value string) error {
195196
value := parts[1]
196197
switch key {
197198
case "type":
198-
mount.Type = swarm.MountType(strings.ToLower(value))
199+
mount.Type = mounttypes.Type(strings.ToLower(value))
199200
case "source", "src":
200201
mount.Source = value
201202
case "target", "dst", "destination":
@@ -206,7 +207,7 @@ func (m *MountOpt) Set(value string) error {
206207
return fmt.Errorf("invalid value for %s: %s", key, value)
207208
}
208209
case "bind-propagation":
209-
bindOptions().Propagation = swarm.MountPropagation(strings.ToLower(value))
210+
bindOptions().Propagation = mounttypes.Propagation(strings.ToLower(value))
210211
case "volume-nocopy":
211212
volumeOptions().NoCopy, err = strconv.ParseBool(value)
212213
if err != nil {
@@ -238,11 +239,11 @@ func (m *MountOpt) Set(value string) error {
238239
return fmt.Errorf("source is required when specifying volume-* options")
239240
}
240241

241-
if mount.Type == swarm.MountTypeBind && mount.VolumeOptions != nil {
242-
return fmt.Errorf("cannot mix 'volume-*' options with mount type '%s'", swarm.MountTypeBind)
242+
if mount.Type == mounttypes.TypeBind && mount.VolumeOptions != nil {
243+
return fmt.Errorf("cannot mix 'volume-*' options with mount type '%s'", mounttypes.TypeBind)
243244
}
244-
if mount.Type == swarm.MountTypeVolume && mount.BindOptions != nil {
245-
return fmt.Errorf("cannot mix 'bind-*' options with mount type '%s'", swarm.MountTypeVolume)
245+
if mount.Type == mounttypes.TypeVolume && mount.BindOptions != nil {
246+
return fmt.Errorf("cannot mix 'bind-*' options with mount type '%s'", mounttypes.TypeVolume)
246247
}
247248

248249
m.values = append(m.values, mount)
@@ -265,7 +266,7 @@ func (m *MountOpt) String() string {
265266
}
266267

267268
// Value returns the mounts
268-
func (m *MountOpt) Value() []swarm.Mount {
269+
func (m *MountOpt) Value() []mounttypes.Mount {
269270
return m.values
270271
}
271272

api/client/service/opts_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"time"
66

77
"github.com/docker/docker/pkg/testutil/assert"
8-
"github.com/docker/engine-api/types/swarm"
8+
mounttypes "github.com/docker/engine-api/types/mount"
99
)
1010

1111
func TestMemBytesString(t *testing.T) {
@@ -59,14 +59,14 @@ func TestUint64OptSetAndValue(t *testing.T) {
5959

6060
func TestMountOptString(t *testing.T) {
6161
mount := MountOpt{
62-
values: []swarm.Mount{
62+
values: []mounttypes.Mount{
6363
{
64-
Type: swarm.MountTypeBind,
64+
Type: mounttypes.TypeBind,
6565
Source: "/home/path",
6666
Target: "/target",
6767
},
6868
{
69-
Type: swarm.MountTypeVolume,
69+
Type: mounttypes.TypeVolume,
7070
Source: "foo",
7171
Target: "/target/foo",
7272
},
@@ -90,8 +90,8 @@ func TestMountOptSetNoError(t *testing.T) {
9090

9191
mounts := mount.Value()
9292
assert.Equal(t, len(mounts), 1)
93-
assert.Equal(t, mounts[0], swarm.Mount{
94-
Type: swarm.MountTypeBind,
93+
assert.Equal(t, mounts[0], mounttypes.Mount{
94+
Type: mounttypes.TypeBind,
9595
Source: "/source",
9696
Target: "/target",
9797
})
@@ -103,7 +103,7 @@ func TestMountOptSetNoError(t *testing.T) {
103103
func TestMountOptDefaultType(t *testing.T) {
104104
var mount MountOpt
105105
assert.NilError(t, mount.Set("target=/target,source=/foo"))
106-
assert.Equal(t, mount.values[0].Type, swarm.MountTypeVolume)
106+
assert.Equal(t, mount.values[0].Type, mounttypes.TypeVolume)
107107
}
108108

109109
func TestMountOptSetErrorNoTarget(t *testing.T) {

api/client/service/update.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/docker/docker/opts"
1313
runconfigopts "github.com/docker/docker/runconfig/opts"
1414
"github.com/docker/engine-api/types"
15+
mounttypes "github.com/docker/engine-api/types/mount"
1516
"github.com/docker/engine-api/types/swarm"
1617
"github.com/docker/go-connections/nat"
1718
shlex "github.com/flynn-archive/go-shlex"
@@ -353,14 +354,14 @@ func removeItems(
353354
return newSeq
354355
}
355356

356-
func updateMounts(flags *pflag.FlagSet, mounts *[]swarm.Mount) {
357+
func updateMounts(flags *pflag.FlagSet, mounts *[]mounttypes.Mount) {
357358
if flags.Changed(flagMountAdd) {
358359
values := flags.Lookup(flagMountAdd).Value.(*MountOpt).Value()
359360
*mounts = append(*mounts, values...)
360361
}
361362
toRemove := buildToRemoveSet(flags, flagMountRemove)
362363

363-
newMounts := []swarm.Mount{}
364+
newMounts := []mounttypes.Mount{}
364365
for _, mount := range *mounts {
365366
if _, exists := toRemove[mount.Target]; !exists {
366367
newMounts = append(newMounts, mount)

api/client/service/update_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"testing"
66

77
"github.com/docker/docker/pkg/testutil/assert"
8+
mounttypes "github.com/docker/engine-api/types/mount"
89
"github.com/docker/engine-api/types/swarm"
910
)
1011

@@ -104,9 +105,9 @@ func TestUpdateMounts(t *testing.T) {
104105
flags.Set("mount-add", "type=volume,target=/toadd")
105106
flags.Set("mount-rm", "/toremove")
106107

107-
mounts := []swarm.Mount{
108-
{Target: "/toremove", Type: swarm.MountTypeBind},
109-
{Target: "/tokeep", Type: swarm.MountTypeBind},
108+
mounts := []mounttypes.Mount{
109+
{Target: "/toremove", Type: mounttypes.TypeBind},
110+
{Target: "/tokeep", Type: mounttypes.TypeBind},
110111
}
111112

112113
updateMounts(flags, &mounts)

api/client/system/inspect.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func runInspect(dockerCli *client.DockerCli, opts inspectOptions) error {
5454
}
5555
case "image":
5656
getRefFunc = func(ref string) (interface{}, []byte, error) {
57-
return client.ImageInspectWithRaw(ctx, ref, opts.size)
57+
return client.ImageInspectWithRaw(ctx, ref)
5858
}
5959
case "task":
6060
if opts.size {
@@ -81,7 +81,7 @@ func inspectAll(ctx context.Context, dockerCli *client.DockerCli, getSize bool)
8181
return c, rawContainer, err
8282
}
8383
// Search for image with that id if a container doesn't exist.
84-
i, rawImage, err := client.ImageInspectWithRaw(ctx, ref, getSize)
84+
i, rawImage, err := client.ImageInspectWithRaw(ctx, ref)
8585
if err == nil || !apiclient.IsErrNotFound(err) {
8686
return i, rawImage, err
8787
}

api/client/volume/remove.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func runRemove(dockerCli *client.DockerCli, volumes []string) error {
3030
status := 0
3131

3232
for _, name := range volumes {
33-
if err := client.VolumeRemove(ctx, name); err != nil {
33+
if err := client.VolumeRemove(ctx, name, false); err != nil {
3434
fmt.Fprintf(dockerCli.Err(), "%s\n", err)
3535
status = 1
3636
continue

api/server/router/system/system_routes.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/docker/engine-api/types/events"
1616
"github.com/docker/engine-api/types/filters"
1717
timetypes "github.com/docker/engine-api/types/time"
18+
"github.com/docker/engine-api/types/versions"
1819
"golang.org/x/net/context"
1920
)
2021

@@ -37,6 +38,14 @@ func (s *systemRouter) getInfo(ctx context.Context, w http.ResponseWriter, r *ht
3738
info.Swarm = s.clusterProvider.Info()
3839
}
3940

41+
if versions.LessThan("1.25", httputils.VersionFromContext(ctx)) {
42+
// TODO: handle this conversion in engine-api
43+
type oldInfo struct {
44+
*types.Info
45+
ExecutionDriver string
46+
}
47+
return httputils.WriteJSON(w, http.StatusOK, &oldInfo{Info: info, ExecutionDriver: "<not supported>"})
48+
}
4049
return httputils.WriteJSON(w, http.StatusOK, info)
4150
}
4251

container/container_unix.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func (container *Container) NetworkMounts() []Mount {
129129
Source: container.ResolvConfPath,
130130
Destination: "/etc/resolv.conf",
131131
Writable: writable,
132-
Propagation: volume.DefaultPropagationMode,
132+
Propagation: string(volume.DefaultPropagationMode),
133133
})
134134
}
135135
}
@@ -148,7 +148,7 @@ func (container *Container) NetworkMounts() []Mount {
148148
Source: container.HostnamePath,
149149
Destination: "/etc/hostname",
150150
Writable: writable,
151-
Propagation: volume.DefaultPropagationMode,
151+
Propagation: string(volume.DefaultPropagationMode),
152152
})
153153
}
154154
}
@@ -167,7 +167,7 @@ func (container *Container) NetworkMounts() []Mount {
167167
Source: container.HostsPath,
168168
Destination: "/etc/hosts",
169169
Writable: writable,
170-
Propagation: volume.DefaultPropagationMode,
170+
Propagation: string(volume.DefaultPropagationMode),
171171
})
172172
}
173173
}
@@ -249,7 +249,7 @@ func (container *Container) IpcMounts() []Mount {
249249
Source: container.ShmPath,
250250
Destination: "/dev/shm",
251251
Writable: true,
252-
Propagation: volume.DefaultPropagationMode,
252+
Propagation: string(volume.DefaultPropagationMode),
253253
})
254254
}
255255

daemon/cluster/convert/container.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"strings"
66

7+
mounttypes "github.com/docker/engine-api/types/mount"
78
types "github.com/docker/engine-api/types/swarm"
89
swarmapi "github.com/docker/swarmkit/api"
910
"github.com/docker/swarmkit/protobuf/ptypes"
@@ -22,26 +23,26 @@ func containerSpecFromGRPC(c *swarmapi.ContainerSpec) types.ContainerSpec {
2223

2324
// Mounts
2425
for _, m := range c.Mounts {
25-
mount := types.Mount{
26+
mount := mounttypes.Mount{
2627
Target: m.Target,
2728
Source: m.Source,
28-
Type: types.MountType(strings.ToLower(swarmapi.Mount_MountType_name[int32(m.Type)])),
29+
Type: mounttypes.Type(strings.ToLower(swarmapi.Mount_MountType_name[int32(m.Type)])),
2930
ReadOnly: m.ReadOnly,
3031
}
3132

3233
if m.BindOptions != nil {
33-
mount.BindOptions = &types.BindOptions{
34-
Propagation: types.MountPropagation(strings.ToLower(swarmapi.Mount_BindOptions_MountPropagation_name[int32(m.BindOptions.Propagation)])),
34+
mount.BindOptions = &mounttypes.BindOptions{
35+
Propagation: mounttypes.Propagation(strings.ToLower(swarmapi.Mount_BindOptions_MountPropagation_name[int32(m.BindOptions.Propagation)])),
3536
}
3637
}
3738

3839
if m.VolumeOptions != nil {
39-
mount.VolumeOptions = &types.VolumeOptions{
40+
mount.VolumeOptions = &mounttypes.VolumeOptions{
4041
NoCopy: m.VolumeOptions.NoCopy,
4142
Labels: m.VolumeOptions.Labels,
4243
}
4344
if m.VolumeOptions.DriverConfig != nil {
44-
mount.VolumeOptions.DriverConfig = &types.Driver{
45+
mount.VolumeOptions.DriverConfig = &mounttypes.Driver{
4546
Name: m.VolumeOptions.DriverConfig.Name,
4647
Options: m.VolumeOptions.DriverConfig.Options,
4748
}

daemon/oci_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ func setMounts(daemon *Daemon, s *specs.Spec, c *container.Container, mounts []c
481481

482482
if m.Source == "tmpfs" {
483483
data := c.HostConfig.Tmpfs[m.Destination]
484-
options := []string{"noexec", "nosuid", "nodev", volume.DefaultPropagationMode}
484+
options := []string{"noexec", "nosuid", "nodev", string(volume.DefaultPropagationMode)}
485485
if data != "" {
486486
options = append(options, strings.Split(data, ",")...)
487487
}

0 commit comments

Comments
 (0)