mirror of
https://github.com/hanzoai/migrate.git
synced 2026-09-30 22:55:10 +00:00
fix(tests): fix Docker imports
This commit is contained in:
@@ -4,11 +4,9 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
import (
|
||||
"github.com/dhui/dktest"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/image"
|
||||
"github.com/docker/docker/client"
|
||||
)
|
||||
|
||||
@@ -36,7 +34,7 @@ func (s *ContainerSpec) Cleanup() (retErr error) {
|
||||
}
|
||||
ctx, timeoutCancelFunc := context.WithTimeout(context.Background(), cleanupTimeout)
|
||||
defer timeoutCancelFunc()
|
||||
if _, err := dc.ImageRemove(ctx, s.ImageName, types.ImageRemoveOptions{Force: true, PruneChildren: true}); err != nil {
|
||||
if _, err := dc.ImageRemove(ctx, s.ImageName, image.RemoveOptions{Force: true, PruneChildren: true}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
+11
-9
@@ -9,16 +9,18 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
dockertypes "github.com/docker/docker/api/types"
|
||||
dockercontainer "github.com/docker/docker/api/types/container"
|
||||
dockernetwork "github.com/docker/docker/api/types/network"
|
||||
dockerclient "github.com/docker/docker/client"
|
||||
"github.com/hashicorp/go-multierror"
|
||||
"io"
|
||||
"math/rand/v2"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
dockertypes "github.com/docker/docker/api/types"
|
||||
dockercontainer "github.com/docker/docker/api/types/container"
|
||||
dockerimage "github.com/docker/docker/api/types/image"
|
||||
dockernetwork "github.com/docker/docker/api/types/network"
|
||||
dockerclient "github.com/docker/docker/client"
|
||||
"github.com/hashicorp/go-multierror"
|
||||
)
|
||||
|
||||
func NewDockerContainer(t testing.TB, image string, env []string, cmd []string) (*DockerContainer, error) {
|
||||
@@ -72,7 +74,7 @@ func (d *DockerContainer) PullImage() (err error) {
|
||||
return errors.New("Cannot pull image on a nil *DockerContainer")
|
||||
}
|
||||
d.t.Logf("Docker: Pull image %v", d.ImageName)
|
||||
r, err := d.client.ImagePull(context.Background(), d.ImageName, dockertypes.ImagePullOptions{})
|
||||
r, err := d.client.ImagePull(context.Background(), d.ImageName, dockerimage.PullOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -125,7 +127,7 @@ func (d *DockerContainer) Start() error {
|
||||
d.ContainerName = containerName
|
||||
|
||||
// then start it
|
||||
if err := d.client.ContainerStart(context.Background(), resp.ID, dockertypes.ContainerStartOptions{}); err != nil {
|
||||
if err := d.client.ContainerStart(context.Background(), resp.ID, dockercontainer.StartOptions{}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -157,7 +159,7 @@ func (d *DockerContainer) Remove() error {
|
||||
return errors.New("missing containerId")
|
||||
}
|
||||
if err := d.client.ContainerRemove(context.Background(), d.ContainerId,
|
||||
dockertypes.ContainerRemoveOptions{
|
||||
dockercontainer.RemoveOptions{
|
||||
Force: true,
|
||||
}); err != nil {
|
||||
d.t.Log(err)
|
||||
@@ -193,7 +195,7 @@ func (d *DockerContainer) Logs() (io.ReadCloser, error) {
|
||||
return nil, errors.New("missing containerId")
|
||||
}
|
||||
|
||||
return d.client.ContainerLogs(context.Background(), d.ContainerId, dockertypes.ContainerLogsOptions{
|
||||
return d.client.ContainerLogs(context.Background(), d.ContainerId, dockercontainer.LogsOptions{
|
||||
ShowStdout: true,
|
||||
ShowStderr: true,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user