Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

Commit

Permalink
Update golang image version
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
  • Loading branch information
vdemeester committed Jul 3, 2017
1 parent a64bde7 commit 9b7aa6f
Show file tree
Hide file tree
Showing 33 changed files with 1,794 additions and 440 deletions.
15 changes: 10 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file describes the standard way to build libcompose, using docker
FROM golang:1.7.5
FROM golang:1.8.3

# virtualenv is necessary to run acceptance tests
RUN apt-get update && \
Expand All @@ -13,18 +13,23 @@ RUN go get github.com/aktau/github-release && \
go get github.com/golang/lint/golint

# Which docker version to test on and what default one to use
ENV DOCKER_VERSIONS 1.9.1 1.10.3 1.11.2 1.12.6 1.13.0
ENV DEFAULT_DOCKER_VERSION 1.10.3
ENV DOCKER_VERSIONS 1.9.1 1.10.3 1.13.1 17.03.2 17.06.0
ENV DEFAULT_DOCKER_VERSION 17.03.2

# Download docker
RUN set -e; \
RUN set -e; set -x; \
for v in $(echo ${DOCKER_VERSIONS} | cut -f1); do \
if test "${v}" = "1.9.1" || test "${v}" = "1.10.3"; then \
mkdir -p /usr/local/bin/docker-${v}/; \
curl https://get.docker.com/builds/Linux/x86_64/docker-${v} -o /usr/local/bin/docker-${v}/docker; \
chmod +x /usr/local/bin/docker-${v}/docker; \
elif test "${v}" = "1.13.1"; then \
curl https://get.docker.com/builds/Linux/x86_64/docker-${v}.tgz -o docker-${v}.tgz; \
tar xzf docker-${v}.tgz -C /usr/local/bin/; \
mv /usr/local/bin/docker /usr/local/bin/docker-${v}; \
rm docker-${v}.tgz; \
else \
curl https://get.docker.com/builds/Linux/x86_64/docker-${v}.tgz -o docker-${v}.tgz; \
curl https://download.docker.com/linux/static/stable/x86_64/docker-${v}-ce.tgz -o docker-${v}.tgz; \
tar xzf docker-${v}.tgz -C /usr/local/bin/; \
mv /usr/local/bin/docker /usr/local/bin/docker-${v}; \
rm docker-${v}.tgz; \
Expand Down
2 changes: 1 addition & 1 deletion docker/auth/auth.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package auth

import (
"github.com/docker/cli/cli/config/configfile"
"github.com/docker/docker/api/types"
"github.com/docker/docker/cli/config/configfile"
"github.com/docker/docker/registry"
)

Expand Down
4 changes: 2 additions & 2 deletions docker/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"strings"

"github.com/Sirupsen/logrus"
"github.com/docker/cli/cli/command/image/build"
"github.com/docker/docker/api/types"
"github.com/docker/docker/builder/dockerignore"
"github.com/docker/docker/cli/command/image/build"
"github.com/docker/docker/client"
"github.com/docker/docker/pkg/archive"
"github.com/docker/docker/pkg/fileutils"
Expand Down Expand Up @@ -75,7 +75,7 @@ func (d *DaemonBuilder) Build(ctx context.Context, imageName string) error {
}

// Setup an upload progress bar
progressOutput := streamformatter.NewStreamFormatter().NewProgressOutput(progBuff, true)
progressOutput := streamformatter.NewProgressOutput(progBuff)

var body io.Reader = progress.NewProgressReader(buildCtx, progressOutput, 0, "", "Sending build context to Docker daemon")

Expand Down
30 changes: 17 additions & 13 deletions docker/builder/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,22 @@ import (
"golang.org/x/net/context"

"github.com/docker/docker/api/types"
"github.com/docker/docker/client"
"github.com/docker/docker/pkg/archive"
"github.com/docker/docker/pkg/jsonmessage"
"github.com/docker/libcompose/test"
"github.com/pkg/errors"
"strings"
)

type DaemonClient struct {
test.NopClient
type daemonClient struct {
client.Client
contextDir string
imageName string
changes int
message jsonmessage.JSONMessage
}

func (c *DaemonClient) ImageBuild(ctx context.Context, context io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error) {
func (c *daemonClient) ImageBuild(ctx context.Context, context io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error) {
if c.imageName != "" {
if len(options.Tags) != 1 || options.Tags[0] != c.imageName {
return types.ImageBuildResponse{}, fmt.Errorf("expected image %q, got %v", c.imageName, options.Tags)
Expand Down Expand Up @@ -55,7 +57,9 @@ func (c *DaemonClient) ImageBuild(ctx context.Context, context io.Reader, option
Body: ioutil.NopCloser(bytes.NewReader(b)),
}, nil
}
return c.NopClient.ImageBuild(ctx, context, options)
return types.ImageBuildResponse{
Body: ioutil.NopCloser(strings.NewReader("{}")),
}, errors.New("Engine no longer exists")
}

func TestBuildInvalidContextDirectoryOrDockerfile(t *testing.T) {
Expand Down Expand Up @@ -118,7 +122,7 @@ func TestBuildWithClientBuildError(t *testing.T) {
}

imageName := "image"
client := &DaemonClient{}
client := &daemonClient{}
builder := &DaemonBuilder{
ContextDirectory: tmpDir,
Client: client,
Expand All @@ -144,7 +148,7 @@ func TestBuildWithDefaultDockerfile(t *testing.T) {
}

imageName := "image"
client := &DaemonClient{
client := &daemonClient{
contextDir: tmpDir,
imageName: imageName,
}
Expand Down Expand Up @@ -173,7 +177,7 @@ func TestBuildWithDefaultLowercaseDockerfile(t *testing.T) {
}

imageName := "image"
client := &DaemonClient{
client := &daemonClient{
contextDir: tmpDir,
imageName: imageName,
}
Expand Down Expand Up @@ -202,7 +206,7 @@ func TestBuildWithSpecificDockerfile(t *testing.T) {
}

imageName := "image"
client := &DaemonClient{
client := &daemonClient{
contextDir: tmpDir,
imageName: imageName,
}
Expand Down Expand Up @@ -235,7 +239,7 @@ func TestBuildWithDockerignoreNothing(t *testing.T) {
}

imageName := "image"
client := &DaemonClient{
client := &daemonClient{
contextDir: tmpDir,
imageName: imageName,
}
Expand Down Expand Up @@ -268,7 +272,7 @@ func TestBuildWithDockerignoreDockerfileAndItself(t *testing.T) {
}

imageName := "image"
client := &DaemonClient{
client := &daemonClient{
contextDir: tmpDir,
imageName: imageName,
}
Expand Down Expand Up @@ -301,7 +305,7 @@ func TestBuildWithDockerignoreAfile(t *testing.T) {
}

imageName := "image"
client := &DaemonClient{
client := &daemonClient{
contextDir: tmpDir,
imageName: imageName,
changes: 1,
Expand Down Expand Up @@ -332,7 +336,7 @@ func TestBuildWithErrorJSONMessage(t *testing.T) {
}

imageName := "image"
client := &DaemonClient{
client := &daemonClient{
contextDir: tmpDir,
imageName: imageName,
message: jsonmessage.JSONMessage{
Expand Down
2 changes: 1 addition & 1 deletion docker/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"path/filepath"
"runtime"

cliconfig "github.com/docker/docker/cli/config"
cliconfig "github.com/docker/cli/cli/config"
"github.com/docker/docker/client"
"github.com/docker/docker/pkg/homedir"
"github.com/docker/go-connections/sockets"
Expand Down
9 changes: 5 additions & 4 deletions docker/client/client_factory_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package client

import (
"strings"
"testing"
)

Expand All @@ -18,7 +19,7 @@ func TestFactoryWithEnv(t *testing.T) {
envs: map[string]string{
"DOCKER_CERT_PATH": "invalid/path",
},
expectedError: "Could not load X509 key pair: open invalid/path/cert.pem: no such file or directory. Make sure the key is not encrypted",
expectedError: "Could not load X509 key pair: open invalid/path/cert.pem: no such file or directory",
expectedVersion: "v1.20",
},
{
Expand All @@ -32,7 +33,7 @@ func TestFactoryWithEnv(t *testing.T) {
recoverEnvs := setupEnvs(t, c.envs)
factory, err := NewDefaultFactory(Options{})
if c.expectedError != "" {
if err == nil || err.Error() != c.expectedError {
if err == nil || !strings.Contains(err.Error(), c.expectedError) {
t.Errorf("expected an error %s, got %s, for %v", c.expectedError, err.Error(), c)
}
} else {
Expand All @@ -59,7 +60,7 @@ func TestFactoryWithOptions(t *testing.T) {
options: Options{
Host: "host",
},
expectedError: "unable to parse docker host `host`",
expectedError: "unable to parse docker host",
},
{
options: Options{
Expand All @@ -78,7 +79,7 @@ func TestFactoryWithOptions(t *testing.T) {
for _, c := range cases {
factory, err := NewDefaultFactory(c.options)
if c.expectedError != "" {
if err == nil || err.Error() != c.expectedError {
if err == nil || !strings.Contains(err.Error(), c.expectedError) {
t.Errorf("expected an error %s, got %s, for %v", c.expectedError, err.Error(), c)
}
} else {
Expand Down
23 changes: 12 additions & 11 deletions docker/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package client
import (
"fmt"
"os"
"strings"
"testing"

cliconfig "github.com/docker/docker/cli/config"
cliconfig "github.com/docker/cli/cli/config"
"github.com/docker/go-connections/tlsconfig"
)

Expand All @@ -24,13 +25,13 @@ func TestCreateWithEnv(t *testing.T) {
envs: map[string]string{
"DOCKER_CERT_PATH": "invalid/path",
},
expectedError: "Could not load X509 key pair: open invalid/path/cert.pem: no such file or directory. Make sure the key is not encrypted",
expectedError: "Could not load X509 key pair: open invalid/path/cert.pem: no such file or directory",
},
{
envs: map[string]string{
"DOCKER_HOST": "host",
},
expectedError: "unable to parse docker host `host`",
expectedError: "unable to parse docker host",
},
{
envs: map[string]string{
Expand All @@ -55,8 +56,8 @@ func TestCreateWithEnv(t *testing.T) {
recoverEnvs := setupEnvs(t, c.envs)
apiclient, err := Create(Options{})
if c.expectedError != "" {
if err == nil || err.Error() != c.expectedError {
t.Errorf("expected an error %s, got %s, for %v", c.expectedError, err.Error(), c)
if err == nil || !strings.Contains(err.Error(), c.expectedError) {
t.Errorf("expected an error '%s', got '%s', for %v", c.expectedError, err.Error(), c)
}
} else {
if err != nil {
Expand All @@ -81,7 +82,7 @@ func TestCreateWithOptions(t *testing.T) {
options: Options{
Host: "host",
},
expectedError: "unable to parse docker host `host`",
expectedError: "unable to parse docker host",
},
{
options: Options{
Expand Down Expand Up @@ -109,7 +110,7 @@ func TestCreateWithOptions(t *testing.T) {
TLS: true,
APIVersion: "v1.22",
},
expectedError: fmt.Sprintf("Could not load X509 key pair: open %s/cert.pem: no such file or directory. Make sure the key is not encrypted", cliconfig.Dir()),
expectedError: fmt.Sprintf("Could not load X509 key pair: open %s/cert.pem: no such file or directory", cliconfig.Dir()),
},
{
options: Options{
Expand All @@ -123,7 +124,7 @@ func TestCreateWithOptions(t *testing.T) {
TrustKey: "invalid/trust/key",
APIVersion: "v1.22",
},
expectedError: "Could not load X509 key pair: open invalid/cert/file: no such file or directory. Make sure the key is not encrypted",
expectedError: "Could not load X509 key pair: open invalid/cert/file: no such file or directory",
},
{
options: Options{
Expand All @@ -136,7 +137,7 @@ func TestCreateWithOptions(t *testing.T) {
},
APIVersion: "v1.22",
},
expectedError: "unable to parse docker host `host`",
expectedError: "unable to parse docker host",
},
{
options: Options{
Expand All @@ -155,8 +156,8 @@ func TestCreateWithOptions(t *testing.T) {
for _, c := range cases {
apiclient, err := Create(c.options)
if c.expectedError != "" {
if err == nil || err.Error() != c.expectedError {
t.Errorf("expected an error %s, got %s, for %v", c.expectedError, err.Error(), c)
if err == nil || !strings.Contains(err.Error(), c.expectedError) {
t.Errorf("expected an error '%s', got '%s', for %v", c.expectedError, err.Error(), c)
}
} else {
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions docker/ctx/context.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package ctx

import (
cliconfig "github.com/docker/docker/cli/config"
"github.com/docker/docker/cli/config/configfile"
cliconfig "github.com/docker/cli/cli/config"
"github.com/docker/cli/cli/config/configfile"
"github.com/docker/libcompose/docker/auth"
"github.com/docker/libcompose/docker/client"
"github.com/docker/libcompose/project"
Expand Down
2 changes: 1 addition & 1 deletion docker/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (n *Network) fullName() string {

// Inspect inspect the current network
func (n *Network) Inspect(ctx context.Context) (types.NetworkResource, error) {
return n.client.NetworkInspect(ctx, n.fullName())
return n.client.NetworkInspect(ctx, n.fullName(), false)
}

// Remove removes the current network (from docker engine)
Expand Down
11 changes: 6 additions & 5 deletions docker/network/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import (

"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/client"
"github.com/docker/libcompose/config"
"github.com/docker/libcompose/test"
"github.com/docker/libcompose/yaml"
"github.com/pkg/errors"
)

type networkNotFound struct {
Expand Down Expand Up @@ -218,7 +219,7 @@ func testExpectedContainsNetwork(t *testing.T, index int, expected []*Network, n
}

type networkClient struct {
test.NopClient
client.Client
expectedNetworkCreate types.NetworkCreate
expectedRemoveNetworkID string
expectedName string
Expand All @@ -228,7 +229,7 @@ type networkClient struct {
removeError error
}

func (c *networkClient) NetworkInspect(ctx context.Context, networkID string) (types.NetworkResource, error) {
func (c *networkClient) NetworkInspect(ctx context.Context, networkID string, verbose bool) (types.NetworkResource, error) {
if c.inspectError != nil {
return types.NetworkResource{}, c.inspectError
}
Expand All @@ -254,7 +255,7 @@ func (c *networkClient) NetworkCreate(ctx context.Context, name string, options
ID: c.expectedName,
}, nil
}
return c.NopClient.NetworkCreate(ctx, name, options)
return types.NetworkCreateResponse{}, errors.New("Engine no longer exists")
}

func (c *networkClient) NetworkRemove(ctx context.Context, networkID string) error {
Expand All @@ -264,7 +265,7 @@ func (c *networkClient) NetworkRemove(ctx context.Context, networkID string) err
}
return nil
}
return c.NopClient.NetworkRemove(ctx, networkID)
return errors.New("Engine no longer exists")
}

func TestNetworksInitialize(t *testing.T) {
Expand Down
Loading

0 comments on commit 9b7aa6f

Please sign in to comment.