Skip to content

Commit

Permalink
Merge pull request #1153 from joschi/fix-docker-imports
Browse files Browse the repository at this point in the history
fix(tests): fix Docker imports
  • Loading branch information
dhui authored Sep 8, 2024
2 parents e40e64c + 6ceb5a9 commit 65a3bd5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
6 changes: 2 additions & 4 deletions dktesting/dktesting.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
Expand Down
20 changes: 11 additions & 9 deletions testing/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
})
Expand Down

0 comments on commit 65a3bd5

Please sign in to comment.