Commit bcc055df authored by Steve Azzopardi's avatar Steve Azzopardi

Fix breaking changes from docker client update

Because of the `github.com/docker/docker` dependency update, there are
some breaking changes on the SDK itself, where an update to our internal
interface had to be made.
parent 7187b1cf
......@@ -2,6 +2,7 @@ package docker
import (
"bytes"
"context"
"errors"
"flag"
"fmt"
......@@ -23,8 +24,6 @@ import (
"gitlab.com/gitlab-org/gitlab-runner/common"
"gitlab.com/gitlab-org/gitlab-runner/helpers"
"gitlab.com/gitlab-org/gitlab-runner/helpers/docker"
"golang.org/x/net/context"
)
func TestMain(m *testing.M) {
......
......@@ -101,7 +101,9 @@ func (t terminalConn) Start(w http.ResponseWriter, r *http.Request, timeoutCh, d
return
}
resp, err := t.client.ContainerExecAttach(t.ctx, exec.ID, execConfig)
execStartCfg := types.ExecStartCheck{Tty: true}
resp, err := t.client.ContainerExecAttach(t.ctx, exec.ID, execStartCfg)
if err != nil {
t.logger.Errorln("Failed to exec attach to container for terminal:", err)
http.Error(w, "failed to attach tty to build container", http.StatusInternalServerError)
......
package docker_helpers
import (
"context"
"io"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/network"
"golang.org/x/net/context"
)
type Client interface {
......@@ -23,7 +23,7 @@ type Client interface {
ContainerRemove(ctx context.Context, containerID string, options types.ContainerRemoveOptions) error
ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error)
ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error)
ContainerExecAttach(ctx context.Context, execID string, config types.ExecConfig) (types.HijackedResponse, error)
ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error)
NetworkDisconnect(ctx context.Context, networkID, containerID string, force bool) error
NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error)
......
......@@ -5,7 +5,7 @@
package docker_helpers
import container "github.com/docker/docker/api/types/container"
import context "golang.org/x/net/context"
import context "context"
import io "io"
import mock "github.com/stretchr/testify/mock"
import network "github.com/docker/docker/api/types/network"
......@@ -73,18 +73,18 @@ func (_m *MockClient) ContainerCreate(ctx context.Context, config *container.Con
}
// ContainerExecAttach provides a mock function with given fields: ctx, execID, config
func (_m *MockClient) ContainerExecAttach(ctx context.Context, execID string, config types.ExecConfig) (types.HijackedResponse, error) {
func (_m *MockClient) ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error) {
ret := _m.Called(ctx, execID, config)
var r0 types.HijackedResponse
if rf, ok := ret.Get(0).(func(context.Context, string, types.ExecConfig) types.HijackedResponse); ok {
if rf, ok := ret.Get(0).(func(context.Context, string, types.ExecStartCheck) types.HijackedResponse); ok {
r0 = rf(ctx, execID, config)
} else {
r0 = ret.Get(0).(types.HijackedResponse)
}
var r1 error
if rf, ok := ret.Get(1).(func(context.Context, string, types.ExecConfig) error); ok {
if rf, ok := ret.Get(1).(func(context.Context, string, types.ExecStartCheck) error); ok {
r1 = rf(ctx, execID, config)
} else {
r1 = ret.Error(1)
......
package docker_helpers
import (
"context"
"fmt"
"io"
"io/ioutil"
......@@ -15,7 +16,6 @@ import (
"github.com/docker/docker/client"
"github.com/docker/go-connections/tlsconfig"
"github.com/sirupsen/logrus"
"golang.org/x/net/context"
)
// The default API version used to create a new docker client.
......@@ -125,7 +125,7 @@ func (c *officialDockerClient) ContainerExecCreate(ctx context.Context, containe
return resp, wrapError("ContainerExecCreate", err, started)
}
func (c *officialDockerClient) ContainerExecAttach(ctx context.Context, execID string, config types.ExecConfig) (types.HijackedResponse, error) {
func (c *officialDockerClient) ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error) {
started := time.Now()
resp, err := c.client.ContainerExecAttach(ctx, execID, config)
return resp, wrapError("ContainerExecAttach", err, started)
......@@ -210,14 +210,14 @@ func New(c DockerCredentials, apiVersion string) (Client, error) {
}
func newHTTPTransport(c DockerCredentials) (*http.Transport, error) {
proto, addr, _, err := client.ParseHost(c.Host)
url, err := client.ParseHostURL(c.Host)
if err != nil {
return nil, err
}
tr := &http.Transport{}
if err := configureTransport(tr, proto, addr); err != nil {
if err := configureTransport(tr, url.Scheme, url.Host); err != nil {
return nil, err
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment