Skip to content

Commit

Permalink
fix: update deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed Jan 24, 2024
1 parent c561e4c commit 69d7c70
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
10 changes: 5 additions & 5 deletions docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (c *DockerContainer) Start(ctx context.Context) error {
return err
}

if err := c.provider.client.ContainerStart(ctx, c.ID, types.ContainerStartOptions{}); err != nil {
if err := c.provider.client.ContainerStart(ctx, c.ID, container.StartOptions{}); err != nil {
return err
}
defer c.provider.Close()
Expand Down Expand Up @@ -263,7 +263,7 @@ func (c *DockerContainer) Terminate(ctx context.Context) error {
return err
}

err = c.provider.client.ContainerRemove(ctx, c.GetContainerID(), types.ContainerRemoveOptions{
err = c.provider.client.ContainerRemove(ctx, c.GetContainerID(), container.RemoveOptions{
RemoveVolumes: true,
Force: true,
})
Expand Down Expand Up @@ -318,7 +318,7 @@ func (c *DockerContainer) inspectContainer(ctx context.Context) (*types.Containe
func (c *DockerContainer) Logs(ctx context.Context) (io.ReadCloser, error) {
const streamHeaderSize = 8

options := types.ContainerLogsOptions{
options := container.LogsOptions{
ShowStdout: true,
ShowStderr: true,
}
Expand Down Expand Up @@ -681,7 +681,7 @@ func (c *DockerContainer) StartLogProducer(ctx context.Context, opts ...LogProdu
since := ""
// if the socket is closed we will make additional logs request with updated Since timestamp
BEGIN:
options := types.ContainerLogsOptions{
options := container.LogsOptions{
ShowStdout: true,
ShowStderr: true,
Follow: true,
Expand Down Expand Up @@ -1162,7 +1162,7 @@ func (p *DockerProvider) findContainerByName(ctx context.Context, name string) (

// Note that, 'name' filter will use regex to find the containers
filter := filters.NewArgs(filters.Arg("name", fmt.Sprintf("^%s$", name)))
containers, err := p.client.ContainerList(ctx, types.ContainerListOptions{Filters: filter})
containers, err := p.client.ContainerList(ctx, container.ListOptions{Filters: filter})
if err != nil {
return nil, err
}
Expand Down
5 changes: 3 additions & 2 deletions docker_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/events"
"github.com/docker/docker/api/types/registry"
"github.com/docker/docker/api/types/system"
"github.com/docker/docker/client"

"github.com/testcontainers/testcontainers-go/internal/core"
Expand All @@ -21,7 +22,7 @@ type DockerClient struct {

var (
// dockerInfo stores the docker info to be reused in the Info method
dockerInfo types.Info
dockerInfo system.Info
dockerInfoSet bool
dockerInfoLock sync.Mutex
)
Expand All @@ -37,7 +38,7 @@ func (c *DockerClient) Events(ctx context.Context, options types.EventsOptions)
// Info returns information about the docker server. The result of Info is cached
// and reused every time Info is called.
// It will also print out the docker server info, and the resolved Docker paths, to the default logger.
func (c *DockerClient) Info(ctx context.Context) (types.Info, error) {
func (c *DockerClient) Info(ctx context.Context) (system.Info, error) {
dockerInfoLock.Lock()
defer dockerInfoLock.Unlock()
if dockerInfoSet {
Expand Down
6 changes: 3 additions & 3 deletions internal/core/docker_host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"path/filepath"
"testing"

"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/system"
"github.com/docker/docker/client"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -276,8 +276,8 @@ type mockCli struct {

// Info returns a mock implementation of types.Info, which is handy for detecting the operating system,
// which is used to determine the default docker socket path.
func (m mockCli) Info(ctx context.Context) (types.Info, error) {
return types.Info{
func (m mockCli) Info(ctx context.Context) (system.Info, error) {
return system.Info{
OperatingSystem: m.OS,
}, nil
}
Expand Down
1 change: 1 addition & 0 deletions network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func WithAttachable() CustomizeNetworkOption {
// WithCheckDuplicate allows to check if a network with the same name already exists.
func WithCheckDuplicate() CustomizeNetworkOption {
return func(original *types.NetworkCreate) {
//nolint:staticcheck
original.CheckDuplicate = true
}
}
Expand Down
3 changes: 1 addition & 2 deletions reaper.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"time"

"github.com/cenkalti/backoff/v4"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/errdefs"
Expand Down Expand Up @@ -96,7 +95,7 @@ func lookUpReaperContainer(ctx context.Context, sessionID string) (*DockerContai
filters.Arg("name", reaperContainerNameFromSessionID(sessionID)),
}

resp, err := dockerClient.ContainerList(ctx, types.ContainerListOptions{
resp, err := dockerClient.ContainerList(ctx, container.ListOptions{
All: true,
Filters: filters.NewArgs(args...),
})
Expand Down

0 comments on commit 69d7c70

Please sign in to comment.