Skip to content

Commit

Permalink
Merge pull request moby#29609 from dnephin/add-compose-file-package
Browse files Browse the repository at this point in the history
Replace the vendored aanand/compose-file with a local copy
  • Loading branch information
tonistiigi authored Dec 29, 2016
2 parents aacc2c8 + 38d08b0 commit edaa3c6
Show file tree
Hide file tree
Showing 41 changed files with 4,362 additions and 465 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ RUN ./contrib/download-frozen-image-v2.sh /docker-frozen-images \
# Please edit hack/dockerfile/install-binaries.sh to update them.
COPY hack/dockerfile/binaries-commits /tmp/binaries-commits
COPY hack/dockerfile/install-binaries.sh /tmp/install-binaries.sh
RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy
RUN /tmp/install-binaries.sh tomlv vndr runc containerd tini proxy bindata

# Wrap all commands in the "docker-in-docker" script to allow nested containers
ENTRYPOINT ["hack/dind"]
Expand Down
4 changes: 2 additions & 2 deletions cli/command/stack/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import (
"github.com/spf13/cobra"
"golang.org/x/net/context"

"github.com/aanand/compose-file/loader"
composetypes "github.com/aanand/compose-file/types"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/cli"
"github.com/docker/docker/cli/command"
"github.com/docker/docker/cli/compose/convert"
"github.com/docker/docker/cli/compose/loader"
composetypes "github.com/docker/docker/cli/compose/types"
dockerclient "github.com/docker/docker/client"
)

Expand Down
2 changes: 1 addition & 1 deletion cli/compose/convert/compose.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package convert

import (
composetypes "github.com/aanand/compose-file/types"
"github.com/docker/docker/api/types"
networktypes "github.com/docker/docker/api/types/network"
composetypes "github.com/docker/docker/cli/compose/types"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion cli/compose/convert/compose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package convert
import (
"testing"

composetypes "github.com/aanand/compose-file/types"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/network"
composetypes "github.com/docker/docker/cli/compose/types"
"github.com/docker/docker/pkg/testutil/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion cli/compose/convert/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"fmt"
"time"

composetypes "github.com/aanand/compose-file/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/swarm"
composetypes "github.com/docker/docker/cli/compose/types"
"github.com/docker/docker/opts"
runconfigopts "github.com/docker/docker/runconfig/opts"
"github.com/docker/go-connections/nat"
Expand Down
2 changes: 1 addition & 1 deletion cli/compose/convert/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"testing"
"time"

composetypes "github.com/aanand/compose-file/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/swarm"
composetypes "github.com/docker/docker/cli/compose/types"
"github.com/docker/docker/pkg/testutil/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion cli/compose/convert/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"strings"

composetypes "github.com/aanand/compose-file/types"
"github.com/docker/docker/api/types/mount"
composetypes "github.com/docker/docker/cli/compose/types"
)

type volumes map[string]composetypes.VolumeConfig
Expand Down
2 changes: 1 addition & 1 deletion cli/compose/convert/volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package convert
import (
"testing"

composetypes "github.com/aanand/compose-file/types"
"github.com/docker/docker/api/types/mount"
composetypes "github.com/docker/docker/cli/compose/types"
"github.com/docker/docker/pkg/testutil/assert"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package interpolation
import (
"fmt"

"github.com/aanand/compose-file/template"
"github.com/aanand/compose-file/types"
"github.com/docker/docker/cli/compose/template"
"github.com/docker/docker/cli/compose/types"
)

// Interpolate replaces variables in a string with the values from a mapping
func Interpolate(config types.Dict, section string, mapping template.Mapping) (types.Dict, error) {
out := types.Dict{}

Expand Down
59 changes: 59 additions & 0 deletions cli/compose/interpolation/interpolation_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package interpolation

import (
"testing"

"github.com/stretchr/testify/assert"

"github.com/docker/docker/cli/compose/types"
)

var defaults = map[string]string{
"USER": "jenny",
"FOO": "bar",
}

func defaultMapping(name string) (string, bool) {
val, ok := defaults[name]
return val, ok
}

func TestInterpolate(t *testing.T) {
services := types.Dict{
"servicea": types.Dict{
"image": "example:${USER}",
"volumes": []interface{}{"$FOO:/target"},
"logging": types.Dict{
"driver": "${FOO}",
"options": types.Dict{
"user": "$USER",
},
},
},
}
expected := types.Dict{
"servicea": types.Dict{
"image": "example:jenny",
"volumes": []interface{}{"bar:/target"},
"logging": types.Dict{
"driver": "bar",
"options": types.Dict{
"user": "jenny",
},
},
},
}
result, err := Interpolate(services, "service", defaultMapping)
assert.NoError(t, err)
assert.Equal(t, expected, result)
}

func TestInvalidInterpolation(t *testing.T) {
services := types.Dict{
"servicea": types.Dict{
"image": "${",
},
}
_, err := Interpolate(services, "service", defaultMapping)
assert.EqualError(t, err, `Invalid interpolation format for "image" option in service "servicea": "${"`)
}
8 changes: 8 additions & 0 deletions cli/compose/loader/example1.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# passed through
FOO=1

# overridden in example2.env
BAR=1

# overridden in full-example.yml
BAZ=1
1 change: 1 addition & 0 deletions cli/compose/loader/example2.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BAR=2
Loading

0 comments on commit edaa3c6

Please sign in to comment.