Skip to content

Commit

Permalink
Merge pull request moby#25721 from cpuguy83/revendor_engine-api
Browse files Browse the repository at this point in the history
revendor engine-api
  • Loading branch information
cpuguy83 authored Aug 16, 2016
2 parents 1225e3e + 9ff0ab7 commit 37302bb
Show file tree
Hide file tree
Showing 42 changed files with 241 additions and 182 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ RUN set -x \
&& rm -rf "$GOPATH"

# Get the "docker-py" source so we can run their integration tests
ENV DOCKER_PY_COMMIT 7befe694bd21e3c54bb1d7825270ea4bd6864c13
ENV DOCKER_PY_COMMIT e2655f658408f9ad1f62abdef3eb6ed43c0cf324
RUN git clone https://github.com/docker/docker-py.git /docker-py \
&& cd /docker-py \
&& git checkout -q $DOCKER_PY_COMMIT \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ RUN set -x \
&& rm -rf "$GOPATH"

# Get the "docker-py" source so we can run their integration tests
ENV DOCKER_PY_COMMIT 7befe694bd21e3c54bb1d7825270ea4bd6864c13
ENV DOCKER_PY_COMMIT e2655f658408f9ad1f62abdef3eb6ed43c0cf324
RUN git clone https://github.com/docker/docker-py.git /docker-py \
&& cd /docker-py \
&& git checkout -q $DOCKER_PY_COMMIT \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.armhf
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ RUN set -x \
&& rm -rf "$GOPATH"

# Get the "docker-py" source so we can run their integration tests
ENV DOCKER_PY_COMMIT 7befe694bd21e3c54bb1d7825270ea4bd6864c13
ENV DOCKER_PY_COMMIT e2655f658408f9ad1f62abdef3eb6ed43c0cf324
RUN git clone https://github.com/docker/docker-py.git /docker-py \
&& cd /docker-py \
&& git checkout -q $DOCKER_PY_COMMIT \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.gccgo
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ RUN set -x \
ENV GOPATH /go:/go/src/github.com/docker/docker/vendor

# Get the "docker-py" source so we can run their integration tests
ENV DOCKER_PY_COMMIT 7befe694bd21e3c54bb1d7825270ea4bd6864c13
ENV DOCKER_PY_COMMIT e2655f658408f9ad1f62abdef3eb6ed43c0cf324
RUN git clone https://github.com/docker/docker-py.git /docker-py \
&& cd /docker-py \
&& git checkout -q $DOCKER_PY_COMMIT
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.ppc64le
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ RUN set -x \
&& rm -rf "$GOPATH"

# Get the "docker-py" source so we can run their integration tests
ENV DOCKER_PY_COMMIT 7befe694bd21e3c54bb1d7825270ea4bd6864c13
ENV DOCKER_PY_COMMIT e2655f658408f9ad1f62abdef3eb6ed43c0cf324
RUN git clone https://github.com/docker/docker-py.git /docker-py \
&& cd /docker-py \
&& git checkout -q $DOCKER_PY_COMMIT \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.s390x
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ RUN set -x \
&& rm -rf "$GOPATH"

# Get the "docker-py" source so we can run their integration tests
ENV DOCKER_PY_COMMIT 7befe694bd21e3c54bb1d7825270ea4bd6864c13
ENV DOCKER_PY_COMMIT e2655f658408f9ad1f62abdef3eb6ed43c0cf324
RUN git clone https://github.com/docker/docker-py.git /docker-py \
&& cd /docker-py \
&& git checkout -q $DOCKER_PY_COMMIT \
Expand Down
31 changes: 16 additions & 15 deletions api/client/service/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/docker/docker/opts"
runconfigopts "github.com/docker/docker/runconfig/opts"
mounttypes "github.com/docker/engine-api/types/mount"
"github.com/docker/engine-api/types/swarm"
"github.com/docker/go-connections/nat"
units "github.com/docker/go-units"
Expand Down Expand Up @@ -130,7 +131,7 @@ func (i *Uint64Opt) Value() *uint64 {

// MountOpt is a Value type for parsing mounts
type MountOpt struct {
values []swarm.Mount
values []mounttypes.Mount
}

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

mount := swarm.Mount{}
mount := mounttypes.Mount{}

volumeOptions := func() *swarm.VolumeOptions {
volumeOptions := func() *mounttypes.VolumeOptions {
if mount.VolumeOptions == nil {
mount.VolumeOptions = &swarm.VolumeOptions{
mount.VolumeOptions = &mounttypes.VolumeOptions{
Labels: make(map[string]string),
}
}
if mount.VolumeOptions.DriverConfig == nil {
mount.VolumeOptions.DriverConfig = &swarm.Driver{}
mount.VolumeOptions.DriverConfig = &mounttypes.Driver{}
}
return mount.VolumeOptions
}

bindOptions := func() *swarm.BindOptions {
bindOptions := func() *mounttypes.BindOptions {
if mount.BindOptions == nil {
mount.BindOptions = new(swarm.BindOptions)
mount.BindOptions = new(mounttypes.BindOptions)
}
return mount.BindOptions
}
Expand All @@ -171,7 +172,7 @@ func (m *MountOpt) Set(value string) error {
}
}

mount.Type = swarm.MountTypeVolume // default to volume mounts
mount.Type = mounttypes.TypeVolume // default to volume mounts
// Set writable as the default
for _, field := range fields {
parts := strings.SplitN(field, "=", 2)
Expand All @@ -195,7 +196,7 @@ func (m *MountOpt) Set(value string) error {
value := parts[1]
switch key {
case "type":
mount.Type = swarm.MountType(strings.ToLower(value))
mount.Type = mounttypes.Type(strings.ToLower(value))
case "source", "src":
mount.Source = value
case "target", "dst", "destination":
Expand All @@ -206,7 +207,7 @@ func (m *MountOpt) Set(value string) error {
return fmt.Errorf("invalid value for %s: %s", key, value)
}
case "bind-propagation":
bindOptions().Propagation = swarm.MountPropagation(strings.ToLower(value))
bindOptions().Propagation = mounttypes.Propagation(strings.ToLower(value))
case "volume-nocopy":
volumeOptions().NoCopy, err = strconv.ParseBool(value)
if err != nil {
Expand Down Expand Up @@ -238,11 +239,11 @@ func (m *MountOpt) Set(value string) error {
return fmt.Errorf("source is required when specifying volume-* options")
}

if mount.Type == swarm.MountTypeBind && mount.VolumeOptions != nil {
return fmt.Errorf("cannot mix 'volume-*' options with mount type '%s'", swarm.MountTypeBind)
if mount.Type == mounttypes.TypeBind && mount.VolumeOptions != nil {
return fmt.Errorf("cannot mix 'volume-*' options with mount type '%s'", mounttypes.TypeBind)
}
if mount.Type == swarm.MountTypeVolume && mount.BindOptions != nil {
return fmt.Errorf("cannot mix 'bind-*' options with mount type '%s'", swarm.MountTypeVolume)
if mount.Type == mounttypes.TypeVolume && mount.BindOptions != nil {
return fmt.Errorf("cannot mix 'bind-*' options with mount type '%s'", mounttypes.TypeVolume)
}

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

// Value returns the mounts
func (m *MountOpt) Value() []swarm.Mount {
func (m *MountOpt) Value() []mounttypes.Mount {
return m.values
}

Expand Down
14 changes: 7 additions & 7 deletions api/client/service/opts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"time"

"github.com/docker/docker/pkg/testutil/assert"
"github.com/docker/engine-api/types/swarm"
mounttypes "github.com/docker/engine-api/types/mount"
)

func TestMemBytesString(t *testing.T) {
Expand Down Expand Up @@ -59,14 +59,14 @@ func TestUint64OptSetAndValue(t *testing.T) {

func TestMountOptString(t *testing.T) {
mount := MountOpt{
values: []swarm.Mount{
values: []mounttypes.Mount{
{
Type: swarm.MountTypeBind,
Type: mounttypes.TypeBind,
Source: "/home/path",
Target: "/target",
},
{
Type: swarm.MountTypeVolume,
Type: mounttypes.TypeVolume,
Source: "foo",
Target: "/target/foo",
},
Expand All @@ -90,8 +90,8 @@ func TestMountOptSetNoError(t *testing.T) {

mounts := mount.Value()
assert.Equal(t, len(mounts), 1)
assert.Equal(t, mounts[0], swarm.Mount{
Type: swarm.MountTypeBind,
assert.Equal(t, mounts[0], mounttypes.Mount{
Type: mounttypes.TypeBind,
Source: "/source",
Target: "/target",
})
Expand All @@ -103,7 +103,7 @@ func TestMountOptSetNoError(t *testing.T) {
func TestMountOptDefaultType(t *testing.T) {
var mount MountOpt
assert.NilError(t, mount.Set("target=/target,source=/foo"))
assert.Equal(t, mount.values[0].Type, swarm.MountTypeVolume)
assert.Equal(t, mount.values[0].Type, mounttypes.TypeVolume)
}

func TestMountOptSetErrorNoTarget(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions api/client/service/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/docker/docker/opts"
runconfigopts "github.com/docker/docker/runconfig/opts"
"github.com/docker/engine-api/types"
mounttypes "github.com/docker/engine-api/types/mount"
"github.com/docker/engine-api/types/swarm"
"github.com/docker/go-connections/nat"
shlex "github.com/flynn-archive/go-shlex"
Expand Down Expand Up @@ -353,14 +354,14 @@ func removeItems(
return newSeq
}

func updateMounts(flags *pflag.FlagSet, mounts *[]swarm.Mount) {
func updateMounts(flags *pflag.FlagSet, mounts *[]mounttypes.Mount) {
if flags.Changed(flagMountAdd) {
values := flags.Lookup(flagMountAdd).Value.(*MountOpt).Value()
*mounts = append(*mounts, values...)
}
toRemove := buildToRemoveSet(flags, flagMountRemove)

newMounts := []swarm.Mount{}
newMounts := []mounttypes.Mount{}
for _, mount := range *mounts {
if _, exists := toRemove[mount.Target]; !exists {
newMounts = append(newMounts, mount)
Expand Down
7 changes: 4 additions & 3 deletions api/client/service/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"

"github.com/docker/docker/pkg/testutil/assert"
mounttypes "github.com/docker/engine-api/types/mount"
"github.com/docker/engine-api/types/swarm"
)

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

mounts := []swarm.Mount{
{Target: "/toremove", Type: swarm.MountTypeBind},
{Target: "/tokeep", Type: swarm.MountTypeBind},
mounts := []mounttypes.Mount{
{Target: "/toremove", Type: mounttypes.TypeBind},
{Target: "/tokeep", Type: mounttypes.TypeBind},
}

updateMounts(flags, &mounts)
Expand Down
4 changes: 2 additions & 2 deletions api/client/system/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func runInspect(dockerCli *client.DockerCli, opts inspectOptions) error {
}
case "image":
getRefFunc = func(ref string) (interface{}, []byte, error) {
return client.ImageInspectWithRaw(ctx, ref, opts.size)
return client.ImageInspectWithRaw(ctx, ref)
}
case "task":
if opts.size {
Expand All @@ -81,7 +81,7 @@ func inspectAll(ctx context.Context, dockerCli *client.DockerCli, getSize bool)
return c, rawContainer, err
}
// Search for image with that id if a container doesn't exist.
i, rawImage, err := client.ImageInspectWithRaw(ctx, ref, getSize)
i, rawImage, err := client.ImageInspectWithRaw(ctx, ref)
if err == nil || !apiclient.IsErrNotFound(err) {
return i, rawImage, err
}
Expand Down
2 changes: 1 addition & 1 deletion api/client/volume/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func runRemove(dockerCli *client.DockerCli, volumes []string) error {
status := 0

for _, name := range volumes {
if err := client.VolumeRemove(ctx, name); err != nil {
if err := client.VolumeRemove(ctx, name, false); err != nil {
fmt.Fprintf(dockerCli.Err(), "%s\n", err)
status = 1
continue
Expand Down
9 changes: 9 additions & 0 deletions api/server/router/system/system_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/docker/engine-api/types/events"
"github.com/docker/engine-api/types/filters"
timetypes "github.com/docker/engine-api/types/time"
"github.com/docker/engine-api/types/versions"
"golang.org/x/net/context"
)

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

if versions.LessThan("1.25", httputils.VersionFromContext(ctx)) {
// TODO: handle this conversion in engine-api
type oldInfo struct {
*types.Info
ExecutionDriver string
}
return httputils.WriteJSON(w, http.StatusOK, &oldInfo{Info: info, ExecutionDriver: "<not supported>"})
}
return httputils.WriteJSON(w, http.StatusOK, info)
}

Expand Down
8 changes: 4 additions & 4 deletions container/container_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (container *Container) NetworkMounts() []Mount {
Source: container.ResolvConfPath,
Destination: "/etc/resolv.conf",
Writable: writable,
Propagation: volume.DefaultPropagationMode,
Propagation: string(volume.DefaultPropagationMode),
})
}
}
Expand All @@ -148,7 +148,7 @@ func (container *Container) NetworkMounts() []Mount {
Source: container.HostnamePath,
Destination: "/etc/hostname",
Writable: writable,
Propagation: volume.DefaultPropagationMode,
Propagation: string(volume.DefaultPropagationMode),
})
}
}
Expand All @@ -167,7 +167,7 @@ func (container *Container) NetworkMounts() []Mount {
Source: container.HostsPath,
Destination: "/etc/hosts",
Writable: writable,
Propagation: volume.DefaultPropagationMode,
Propagation: string(volume.DefaultPropagationMode),
})
}
}
Expand Down Expand Up @@ -249,7 +249,7 @@ func (container *Container) IpcMounts() []Mount {
Source: container.ShmPath,
Destination: "/dev/shm",
Writable: true,
Propagation: volume.DefaultPropagationMode,
Propagation: string(volume.DefaultPropagationMode),
})
}

Expand Down
13 changes: 7 additions & 6 deletions daemon/cluster/convert/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"strings"

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

// Mounts
for _, m := range c.Mounts {
mount := types.Mount{
mount := mounttypes.Mount{
Target: m.Target,
Source: m.Source,
Type: types.MountType(strings.ToLower(swarmapi.Mount_MountType_name[int32(m.Type)])),
Type: mounttypes.Type(strings.ToLower(swarmapi.Mount_MountType_name[int32(m.Type)])),
ReadOnly: m.ReadOnly,
}

if m.BindOptions != nil {
mount.BindOptions = &types.BindOptions{
Propagation: types.MountPropagation(strings.ToLower(swarmapi.Mount_BindOptions_MountPropagation_name[int32(m.BindOptions.Propagation)])),
mount.BindOptions = &mounttypes.BindOptions{
Propagation: mounttypes.Propagation(strings.ToLower(swarmapi.Mount_BindOptions_MountPropagation_name[int32(m.BindOptions.Propagation)])),
}
}

if m.VolumeOptions != nil {
mount.VolumeOptions = &types.VolumeOptions{
mount.VolumeOptions = &mounttypes.VolumeOptions{
NoCopy: m.VolumeOptions.NoCopy,
Labels: m.VolumeOptions.Labels,
}
if m.VolumeOptions.DriverConfig != nil {
mount.VolumeOptions.DriverConfig = &types.Driver{
mount.VolumeOptions.DriverConfig = &mounttypes.Driver{
Name: m.VolumeOptions.DriverConfig.Name,
Options: m.VolumeOptions.DriverConfig.Options,
}
Expand Down
2 changes: 1 addition & 1 deletion daemon/oci_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ func setMounts(daemon *Daemon, s *specs.Spec, c *container.Container, mounts []c

if m.Source == "tmpfs" {
data := c.HostConfig.Tmpfs[m.Destination]
options := []string{"noexec", "nosuid", "nodev", volume.DefaultPropagationMode}
options := []string{"noexec", "nosuid", "nodev", string(volume.DefaultPropagationMode)}
if data != "" {
options = append(options, strings.Split(data, ",")...)
}
Expand Down
4 changes: 2 additions & 2 deletions daemon/volumes_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ func (daemon *Daemon) setupMounts(c *container.Container) ([]container.Mount, er
Source: path,
Destination: m.Destination,
Writable: m.RW,
Propagation: m.Propagation,
Propagation: string(m.Propagation),
}
if m.Volume != nil {
attributes := map[string]string{
"driver": m.Volume.DriverName(),
"container": c.ID,
"destination": m.Destination,
"read/write": strconv.FormatBool(m.RW),
"propagation": m.Propagation,
"propagation": string(m.Propagation),
}
daemon.LogVolumeEvent(m.Volume.Name(), "mount", attributes)
}
Expand Down
Loading

0 comments on commit 37302bb

Please sign in to comment.