From 69d7c70a45011a4ec89cafb62bfa090cd9d2185d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Wed, 24 Jan 2024 14:25:01 +0100 Subject: [PATCH] fix: update deprecations --- docker.go | 10 +++++----- docker_client.go | 5 +++-- internal/core/docker_host_test.go | 6 +++--- network/network.go | 1 + reaper.go | 3 +-- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/docker.go b/docker.go index 4c79b43322..9657f28f55 100644 --- a/docker.go +++ b/docker.go @@ -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() @@ -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, }) @@ -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, } @@ -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, @@ -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 } diff --git a/docker_client.go b/docker_client.go index e2db4c3a81..eb719cf25e 100644 --- a/docker_client.go +++ b/docker_client.go @@ -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" @@ -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 ) @@ -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 { diff --git a/internal/core/docker_host_test.go b/internal/core/docker_host_test.go index e5e3a94e83..dbdbaa31fe 100644 --- a/internal/core/docker_host_test.go +++ b/internal/core/docker_host_test.go @@ -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" @@ -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 } diff --git a/network/network.go b/network/network.go index 49bbabad99..646ed463a8 100644 --- a/network/network.go +++ b/network/network.go @@ -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 } } diff --git a/reaper.go b/reaper.go index 1d269ce899..724d2635a1 100644 --- a/reaper.go +++ b/reaper.go @@ -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" @@ -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...), })