[lint] don't use deprecated types

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2023-12-05 10:59:26 +01:00 committed by Nicolas De loof
parent 8639fbae86
commit df1533a1ca
17 changed files with 71 additions and 56 deletions

View File

@ -34,6 +34,7 @@ import (
"github.com/docker/buildx/util/imagetools" "github.com/docker/buildx/util/imagetools"
"github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command"
moby "github.com/docker/docker/api/types" moby "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/checkpoint"
containerType "github.com/docker/docker/api/types/container" containerType "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/events" "github.com/docker/docker/api/types/events"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
@ -41,6 +42,7 @@ import (
"github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/registry"
"github.com/docker/docker/api/types/swarm" "github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/api/types/system"
"github.com/docker/docker/api/types/volume" "github.com/docker/docker/api/types/volume"
"github.com/docker/docker/client" "github.com/docker/docker/client"
"github.com/docker/docker/pkg/jsonmessage" "github.com/docker/docker/pkg/jsonmessage"
@ -94,7 +96,7 @@ func getCallingFunction() string {
// All methods and functions which need to be overridden for dry run. // All methods and functions which need to be overridden for dry run.
func (d *DryRunClient) ContainerAttach(ctx context.Context, container string, options moby.ContainerAttachOptions) (moby.HijackedResponse, error) { func (d *DryRunClient) ContainerAttach(ctx context.Context, container string, options containerType.AttachOptions) (moby.HijackedResponse, error) {
return moby.HijackedResponse{}, errors.New("interactive run is not supported in dry-run mode") return moby.HijackedResponse{}, errors.New("interactive run is not supported in dry-run mode")
} }
@ -143,7 +145,7 @@ func (d *DryRunClient) ContainerKill(ctx context.Context, container, signal stri
return nil return nil
} }
func (d *DryRunClient) ContainerList(ctx context.Context, options moby.ContainerListOptions) ([]moby.Container, error) { func (d *DryRunClient) ContainerList(ctx context.Context, options containerType.ListOptions) ([]moby.Container, error) {
caller := getCallingFunction() caller := getCallingFunction()
switch caller { switch caller {
case "start": case "start":
@ -162,7 +164,7 @@ func (d *DryRunClient) ContainerPause(ctx context.Context, container string) err
return nil return nil
} }
func (d *DryRunClient) ContainerRemove(ctx context.Context, container string, options moby.ContainerRemoveOptions) error { func (d *DryRunClient) ContainerRemove(ctx context.Context, container string, options containerType.RemoveOptions) error {
return nil return nil
} }
@ -174,7 +176,7 @@ func (d *DryRunClient) ContainerRestart(ctx context.Context, container string, o
return nil return nil
} }
func (d *DryRunClient) ContainerStart(ctx context.Context, container string, options moby.ContainerStartOptions) error { func (d *DryRunClient) ContainerStart(ctx context.Context, container string, options containerType.StartOptions) error {
return nil return nil
} }
@ -259,7 +261,7 @@ func (d *DryRunClient) ImagePush(ctx context.Context, ref string, options moby.I
return rc, nil return rc, nil
} }
func (d *DryRunClient) ImageRemove(ctx context.Context, imageName string, options moby.ImageRemoveOptions) ([]moby.ImageDeleteResponseItem, error) { func (d *DryRunClient) ImageRemove(ctx context.Context, imageName string, options moby.ImageRemoveOptions) ([]image.DeleteResponse, error) {
return nil, nil return nil, nil
} }
@ -341,7 +343,7 @@ func (d *DryRunClient) ConfigUpdate(ctx context.Context, id string, version swar
return d.apiClient.ConfigUpdate(ctx, id, version, config) return d.apiClient.ConfigUpdate(ctx, id, version, config)
} }
func (d *DryRunClient) ContainerCommit(ctx context.Context, container string, options moby.ContainerCommitOptions) (moby.IDResponse, error) { func (d *DryRunClient) ContainerCommit(ctx context.Context, container string, options containerType.CommitOptions) (moby.IDResponse, error) {
return d.apiClient.ContainerCommit(ctx, container, options) return d.apiClient.ContainerCommit(ctx, container, options)
} }
@ -357,7 +359,7 @@ func (d *DryRunClient) ContainerExecInspect(ctx context.Context, execID string)
return d.apiClient.ContainerExecInspect(ctx, execID) return d.apiClient.ContainerExecInspect(ctx, execID)
} }
func (d *DryRunClient) ContainerExecResize(ctx context.Context, execID string, options moby.ResizeOptions) error { func (d *DryRunClient) ContainerExecResize(ctx context.Context, execID string, options containerType.ResizeOptions) error {
return d.apiClient.ContainerExecResize(ctx, execID, options) return d.apiClient.ContainerExecResize(ctx, execID, options)
} }
@ -369,11 +371,11 @@ func (d *DryRunClient) ContainerInspectWithRaw(ctx context.Context, container st
return d.apiClient.ContainerInspectWithRaw(ctx, container, getSize) return d.apiClient.ContainerInspectWithRaw(ctx, container, getSize)
} }
func (d *DryRunClient) ContainerLogs(ctx context.Context, container string, options moby.ContainerLogsOptions) (io.ReadCloser, error) { func (d *DryRunClient) ContainerLogs(ctx context.Context, container string, options containerType.LogsOptions) (io.ReadCloser, error) {
return d.apiClient.ContainerLogs(ctx, container, options) return d.apiClient.ContainerLogs(ctx, container, options)
} }
func (d *DryRunClient) ContainerResize(ctx context.Context, container string, options moby.ResizeOptions) error { func (d *DryRunClient) ContainerResize(ctx context.Context, container string, options containerType.ResizeOptions) error {
return d.apiClient.ContainerResize(ctx, container, options) return d.apiClient.ContainerResize(ctx, container, options)
} }
@ -429,7 +431,7 @@ func (d *DryRunClient) ImageImport(ctx context.Context, source moby.ImageImportS
return d.apiClient.ImageImport(ctx, source, ref, options) return d.apiClient.ImageImport(ctx, source, ref, options)
} }
func (d *DryRunClient) ImageList(ctx context.Context, options moby.ImageListOptions) ([]moby.ImageSummary, error) { func (d *DryRunClient) ImageList(ctx context.Context, options moby.ImageListOptions) ([]image.Summary, error) {
return d.apiClient.ImageList(ctx, options) return d.apiClient.ImageList(ctx, options)
} }
@ -525,7 +527,7 @@ func (d *DryRunClient) PluginCreate(ctx context.Context, createContext io.Reader
return d.apiClient.PluginCreate(ctx, createContext, options) return d.apiClient.PluginCreate(ctx, createContext, options)
} }
func (d *DryRunClient) ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options moby.ServiceCreateOptions) (moby.ServiceCreateResponse, error) { func (d *DryRunClient) ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options moby.ServiceCreateOptions) (swarm.ServiceCreateResponse, error) {
return d.apiClient.ServiceCreate(ctx, service, options) return d.apiClient.ServiceCreate(ctx, service, options)
} }
@ -541,15 +543,15 @@ func (d *DryRunClient) ServiceRemove(ctx context.Context, serviceID string) erro
return d.apiClient.ServiceRemove(ctx, serviceID) return d.apiClient.ServiceRemove(ctx, serviceID)
} }
func (d *DryRunClient) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options moby.ServiceUpdateOptions) (moby.ServiceUpdateResponse, error) { func (d *DryRunClient) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options moby.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
return d.apiClient.ServiceUpdate(ctx, serviceID, version, service, options) return d.apiClient.ServiceUpdate(ctx, serviceID, version, service, options)
} }
func (d *DryRunClient) ServiceLogs(ctx context.Context, serviceID string, options moby.ContainerLogsOptions) (io.ReadCloser, error) { func (d *DryRunClient) ServiceLogs(ctx context.Context, serviceID string, options containerType.LogsOptions) (io.ReadCloser, error) {
return d.apiClient.ServiceLogs(ctx, serviceID, options) return d.apiClient.ServiceLogs(ctx, serviceID, options)
} }
func (d *DryRunClient) TaskLogs(ctx context.Context, taskID string, options moby.ContainerLogsOptions) (io.ReadCloser, error) { func (d *DryRunClient) TaskLogs(ctx context.Context, taskID string, options containerType.LogsOptions) (io.ReadCloser, error) {
return d.apiClient.TaskLogs(ctx, taskID, options) return d.apiClient.TaskLogs(ctx, taskID, options)
} }
@ -613,7 +615,7 @@ func (d *DryRunClient) Events(ctx context.Context, options moby.EventsOptions) (
return d.apiClient.Events(ctx, options) return d.apiClient.Events(ctx, options)
} }
func (d *DryRunClient) Info(ctx context.Context) (moby.Info, error) { func (d *DryRunClient) Info(ctx context.Context) (system.Info, error) {
return d.apiClient.Info(ctx) return d.apiClient.Info(ctx)
} }
@ -685,14 +687,14 @@ func (d *DryRunClient) Close() error {
return d.apiClient.Close() return d.apiClient.Close()
} }
func (d *DryRunClient) CheckpointCreate(ctx context.Context, container string, options moby.CheckpointCreateOptions) error { func (d *DryRunClient) CheckpointCreate(ctx context.Context, container string, options checkpoint.CreateOptions) error {
return d.apiClient.CheckpointCreate(ctx, container, options) return d.apiClient.CheckpointCreate(ctx, container, options)
} }
func (d *DryRunClient) CheckpointDelete(ctx context.Context, container string, options moby.CheckpointDeleteOptions) error { func (d *DryRunClient) CheckpointDelete(ctx context.Context, container string, options checkpoint.DeleteOptions) error {
return d.apiClient.CheckpointDelete(ctx, container, options) return d.apiClient.CheckpointDelete(ctx, container, options)
} }
func (d *DryRunClient) CheckpointList(ctx context.Context, container string, options moby.CheckpointListOptions) ([]moby.Checkpoint, error) { func (d *DryRunClient) CheckpointList(ctx context.Context, container string, options checkpoint.ListOptions) ([]checkpoint.Summary, error) {
return d.apiClient.CheckpointList(ctx, container, options) return d.apiClient.CheckpointList(ctx, container, options)
} }

View File

@ -26,6 +26,7 @@ import (
"github.com/compose-spec/compose-go/types" "github.com/compose-spec/compose-go/types"
"github.com/docker/cli/cli/streams" "github.com/docker/cli/cli/streams"
moby "github.com/docker/docker/api/types" moby "github.com/docker/docker/api/types"
containerType "github.com/docker/docker/api/types/container"
"github.com/docker/docker/pkg/stdcopy" "github.com/docker/docker/pkg/stdcopy"
"github.com/moby/term" "github.com/moby/term"
@ -157,7 +158,7 @@ func (s *composeService) attachContainerStreams(ctx context.Context, container s
func (s *composeService) getContainerStreams(ctx context.Context, container string) (io.WriteCloser, io.ReadCloser, error) { func (s *composeService) getContainerStreams(ctx context.Context, container string) (io.WriteCloser, io.ReadCloser, error) {
var stdout io.ReadCloser var stdout io.ReadCloser
var stdin io.WriteCloser var stdin io.WriteCloser
cnx, err := s.apiClient().ContainerAttach(ctx, container, moby.ContainerAttachOptions{ cnx, err := s.apiClient().ContainerAttach(ctx, container, containerType.AttachOptions{
Stream: true, Stream: true,
Stdin: true, Stdin: true,
Stdout: true, Stdout: true,
@ -171,7 +172,7 @@ func (s *composeService) getContainerStreams(ctx context.Context, container stri
} }
// Fallback to logs API // Fallback to logs API
logs, err := s.apiClient().ContainerLogs(ctx, container, moby.ContainerLogsOptions{ logs, err := s.apiClient().ContainerLogs(ctx, container, containerType.LogsOptions{
ShowStdout: true, ShowStdout: true,
ShowStderr: true, ShowStderr: true,
Follow: true, Follow: true,

View File

@ -26,6 +26,7 @@ import (
"github.com/docker/compose/v2/pkg/api" "github.com/docker/compose/v2/pkg/api"
"github.com/docker/compose/v2/pkg/utils" "github.com/docker/compose/v2/pkg/utils"
moby "github.com/docker/docker/api/types" moby "github.com/docker/docker/api/types"
containerType "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
) )
@ -43,7 +44,7 @@ const (
func (s *composeService) getContainers(ctx context.Context, project string, oneOff oneOff, stopped bool, selectedServices ...string) (Containers, error) { func (s *composeService) getContainers(ctx context.Context, project string, oneOff oneOff, stopped bool, selectedServices ...string) (Containers, error) {
var containers Containers var containers Containers
f := getDefaultFilters(project, oneOff, selectedServices...) f := getDefaultFilters(project, oneOff, selectedServices...)
containers, err := s.apiClient().ContainerList(ctx, moby.ContainerListOptions{ containers, err := s.apiClient().ContainerList(ctx, containerType.ListOptions{
Filters: filters.NewArgs(f...), Filters: filters.NewArgs(f...),
All: stopped, All: stopped,
}) })
@ -77,7 +78,7 @@ func (s *composeService) getSpecifiedContainer(ctx context.Context, projectName
if containerIndex > 0 { if containerIndex > 0 {
defaultFilters = append(defaultFilters, containerNumberFilter(containerIndex)) defaultFilters = append(defaultFilters, containerNumberFilter(containerIndex))
} }
containers, err := s.apiClient().ContainerList(ctx, moby.ContainerListOptions{ containers, err := s.apiClient().ContainerList(ctx, containerType.ListOptions{
Filters: filters.NewArgs( Filters: filters.NewArgs(
defaultFilters..., defaultFilters...,
), ),

View File

@ -141,7 +141,7 @@ func (c *convergence) ensureService(ctx context.Context, project *types.Project,
if err != nil { if err != nil {
return err return err
} }
return c.service.apiClient().ContainerRemove(ctx, container.ID, moby.ContainerRemoveOptions{}) return c.service.apiClient().ContainerRemove(ctx, container.ID, containerType.RemoveOptions{})
})) }))
continue continue
} }
@ -515,7 +515,7 @@ func (s *composeService) recreateContainer(ctx context.Context, project *types.P
return created, err return created, err
} }
err = s.apiClient().ContainerRemove(ctx, replaced.ID, moby.ContainerRemoveOptions{}) err = s.apiClient().ContainerRemove(ctx, replaced.ID, containerType.RemoveOptions{})
if err != nil { if err != nil {
return created, err return created, err
} }
@ -549,7 +549,7 @@ func setDependentLifecycle(project *types.Project, service string, strategy stri
func (s *composeService) startContainer(ctx context.Context, container moby.Container) error { func (s *composeService) startContainer(ctx context.Context, container moby.Container) error {
w := progress.ContextWriter(ctx) w := progress.ContextWriter(ctx)
w.Event(progress.NewEvent(getContainerProgressName(container), progress.Working, "Restart")) w.Event(progress.NewEvent(getContainerProgressName(container), progress.Working, "Restart"))
err := s.apiClient().ContainerStart(ctx, container.ID, moby.ContainerStartOptions{}) err := s.apiClient().ContainerStart(ctx, container.ID, containerType.StartOptions{})
if err != nil { if err != nil {
return err return err
} }
@ -764,7 +764,7 @@ func (s *composeService) startService(ctx context.Context, project *types.Projec
} }
eventName := getContainerProgressName(container) eventName := getContainerProgressName(container)
w.Event(progress.StartingEvent(eventName)) w.Event(progress.StartingEvent(eventName))
err := s.apiClient().ContainerStart(ctx, container.ID, moby.ContainerStartOptions{}) err := s.apiClient().ContainerStart(ctx, container.ID, containerType.StartOptions{})
if err != nil { if err != nil {
return err return err
} }

View File

@ -24,6 +24,7 @@ import (
"github.com/compose-spec/compose-go/types" "github.com/compose-spec/compose-go/types"
moby "github.com/docker/docker/api/types" moby "github.com/docker/docker/api/types"
containerType "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/golang/mock/gomock" "github.com/golang/mock/gomock"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
@ -63,7 +64,7 @@ func TestServiceLinks(t *testing.T) {
Scale: 1, Scale: 1,
} }
containerListOptions := moby.ContainerListOptions{ containerListOptions := containerType.ListOptions{
Filters: filters.NewArgs( Filters: filters.NewArgs(
projectFilter(testProject), projectFilter(testProject),
serviceFilter("db"), serviceFilter("db"),
@ -189,7 +190,7 @@ func TestServiceLinks(t *testing.T) {
s.Labels = s.Labels.Add(api.OneoffLabel, "True") s.Labels = s.Labels.Add(api.OneoffLabel, "True")
c := testContainer("web", webContainerName, true) c := testContainer("web", webContainerName, true)
containerListOptionsOneOff := moby.ContainerListOptions{ containerListOptionsOneOff := containerType.ListOptions{
Filters: filters.NewArgs( Filters: filters.NewArgs(
projectFilter(testProject), projectFilter(testProject),
serviceFilter("web"), serviceFilter("web"),

View File

@ -314,7 +314,7 @@ func (s *composeService) removeContainers(ctx context.Context, w progress.Writer
return err return err
} }
w.Event(progress.RemovingEvent(eventName)) w.Event(progress.RemovingEvent(eventName))
err = s.apiClient().ContainerRemove(ctx, container.ID, moby.ContainerRemoveOptions{ err = s.apiClient().ContainerRemove(ctx, container.ID, containerType.RemoveOptions{
Force: true, Force: true,
RemoveVolumes: volumes, RemoveVolumes: volumes,
}) })

View File

@ -28,6 +28,7 @@ import (
moby "github.com/docker/docker/api/types" moby "github.com/docker/docker/api/types"
containerType "github.com/docker/docker/api/types/container" containerType "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/image"
"github.com/docker/docker/api/types/volume" "github.com/docker/docker/api/types/volume"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"github.com/golang/mock/gomock" "github.com/golang/mock/gomock"
@ -73,9 +74,9 @@ func TestDown(t *testing.T) {
api.EXPECT().ContainerStop(gomock.Any(), "456", stopOptions).Return(nil) api.EXPECT().ContainerStop(gomock.Any(), "456", stopOptions).Return(nil)
api.EXPECT().ContainerStop(gomock.Any(), "789", stopOptions).Return(nil) api.EXPECT().ContainerStop(gomock.Any(), "789", stopOptions).Return(nil)
api.EXPECT().ContainerRemove(gomock.Any(), "123", moby.ContainerRemoveOptions{Force: true}).Return(nil) api.EXPECT().ContainerRemove(gomock.Any(), "123", containerType.RemoveOptions{Force: true}).Return(nil)
api.EXPECT().ContainerRemove(gomock.Any(), "456", moby.ContainerRemoveOptions{Force: true}).Return(nil) api.EXPECT().ContainerRemove(gomock.Any(), "456", containerType.RemoveOptions{Force: true}).Return(nil)
api.EXPECT().ContainerRemove(gomock.Any(), "789", moby.ContainerRemoveOptions{Force: true}).Return(nil) api.EXPECT().ContainerRemove(gomock.Any(), "789", containerType.RemoveOptions{Force: true}).Return(nil)
api.EXPECT().NetworkList(gomock.Any(), moby.NetworkListOptions{ api.EXPECT().NetworkList(gomock.Any(), moby.NetworkListOptions{
Filters: filters.NewArgs( Filters: filters.NewArgs(
@ -127,9 +128,9 @@ func TestDownRemoveOrphans(t *testing.T) {
api.EXPECT().ContainerStop(gomock.Any(), "789", stopOptions).Return(nil) api.EXPECT().ContainerStop(gomock.Any(), "789", stopOptions).Return(nil)
api.EXPECT().ContainerStop(gomock.Any(), "321", stopOptions).Return(nil) api.EXPECT().ContainerStop(gomock.Any(), "321", stopOptions).Return(nil)
api.EXPECT().ContainerRemove(gomock.Any(), "123", moby.ContainerRemoveOptions{Force: true}).Return(nil) api.EXPECT().ContainerRemove(gomock.Any(), "123", containerType.RemoveOptions{Force: true}).Return(nil)
api.EXPECT().ContainerRemove(gomock.Any(), "789", moby.ContainerRemoveOptions{Force: true}).Return(nil) api.EXPECT().ContainerRemove(gomock.Any(), "789", containerType.RemoveOptions{Force: true}).Return(nil)
api.EXPECT().ContainerRemove(gomock.Any(), "321", moby.ContainerRemoveOptions{Force: true}).Return(nil) api.EXPECT().ContainerRemove(gomock.Any(), "321", containerType.RemoveOptions{Force: true}).Return(nil)
api.EXPECT().NetworkList(gomock.Any(), moby.NetworkListOptions{ api.EXPECT().NetworkList(gomock.Any(), moby.NetworkListOptions{
Filters: filters.NewArgs( Filters: filters.NewArgs(
@ -167,7 +168,7 @@ func TestDownRemoveVolumes(t *testing.T) {
Return(nil, nil) Return(nil, nil)
api.EXPECT().ContainerStop(gomock.Any(), "123", containerType.StopOptions{}).Return(nil) api.EXPECT().ContainerStop(gomock.Any(), "123", containerType.StopOptions{}).Return(nil)
api.EXPECT().ContainerRemove(gomock.Any(), "123", moby.ContainerRemoveOptions{Force: true, RemoveVolumes: true}).Return(nil) api.EXPECT().ContainerRemove(gomock.Any(), "123", containerType.RemoveOptions{Force: true, RemoveVolumes: true}).Return(nil)
api.EXPECT().VolumeRemove(gomock.Any(), "myProject_volume", true).Return(nil) api.EXPECT().VolumeRemove(gomock.Any(), "myProject_volume", true).Return(nil)
@ -209,7 +210,7 @@ func TestDownRemoveImages(t *testing.T) {
projectFilter(strings.ToLower(testProject)), projectFilter(strings.ToLower(testProject)),
filters.Arg("dangling", "false"), filters.Arg("dangling", "false"),
), ),
}).Return([]moby.ImageSummary{ }).Return([]image.Summary{
{ {
Labels: types.Labels{compose.ServiceLabel: "local-anonymous"}, Labels: types.Labels{compose.ServiceLabel: "local-anonymous"},
RepoTags: []string{"testproject-local-anonymous:latest"}, RepoTags: []string{"testproject-local-anonymous:latest"},
@ -316,7 +317,7 @@ func TestDownRemoveImages_NoLabel(t *testing.T) {
Return(moby.ImageInspect{}, nil, nil) Return(moby.ImageInspect{}, nil, nil)
api.EXPECT().ContainerStop(gomock.Any(), "123", containerType.StopOptions{}).Return(nil) api.EXPECT().ContainerStop(gomock.Any(), "123", containerType.StopOptions{}).Return(nil)
api.EXPECT().ContainerRemove(gomock.Any(), "123", moby.ContainerRemoveOptions{Force: true}).Return(nil) api.EXPECT().ContainerRemove(gomock.Any(), "123", containerType.RemoveOptions{Force: true}).Return(nil)
api.EXPECT().ImageRemove(gomock.Any(), "testproject-service1:latest", moby.ImageRemoveOptions{}).Return(nil, nil) api.EXPECT().ImageRemove(gomock.Any(), "testproject-service1:latest", moby.ImageRemoveOptions{}).Return(nil, nil)

View File

@ -26,6 +26,7 @@ import (
"github.com/distribution/reference" "github.com/distribution/reference"
moby "github.com/docker/docker/api/types" moby "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/image"
"github.com/docker/docker/client" "github.com/docker/docker/client"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"golang.org/x/sync/errgroup" "golang.org/x/sync/errgroup"
@ -149,7 +150,7 @@ func (p *ImagePruner) namedImages(ctx context.Context) ([]string, error) {
// //
// The image name could either have been defined by the user or implicitly // The image name could either have been defined by the user or implicitly
// created from the project + service name. // created from the project + service name.
func (p *ImagePruner) labeledLocalImages(ctx context.Context) ([]moby.ImageSummary, error) { func (p *ImagePruner) labeledLocalImages(ctx context.Context) ([]image.Summary, error) {
imageListOpts := moby.ImageListOptions{ imageListOpts := moby.ImageListOptions{
Filters: filters.NewArgs( Filters: filters.NewArgs(
projectFilter(p.project.Name), projectFilter(p.project.Name),

View File

@ -24,6 +24,7 @@ import (
"github.com/distribution/reference" "github.com/distribution/reference"
moby "github.com/docker/docker/api/types" moby "github.com/docker/docker/api/types"
containerType "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"golang.org/x/sync/errgroup" "golang.org/x/sync/errgroup"
@ -34,7 +35,7 @@ import (
func (s *composeService) Images(ctx context.Context, projectName string, options api.ImagesOptions) ([]api.ImageSummary, error) { func (s *composeService) Images(ctx context.Context, projectName string, options api.ImagesOptions) ([]api.ImageSummary, error) {
projectName = strings.ToLower(projectName) projectName = strings.ToLower(projectName)
allContainers, err := s.apiClient().ContainerList(ctx, moby.ContainerListOptions{ allContainers, err := s.apiClient().ContainerList(ctx, containerType.ListOptions{
All: true, All: true,
Filters: filters.NewArgs(projectFilter(projectName)), Filters: filters.NewArgs(projectFilter(projectName)),
}) })

View File

@ -24,6 +24,7 @@ import (
"testing" "testing"
moby "github.com/docker/docker/api/types" moby "github.com/docker/docker/api/types"
containerType "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/volume" "github.com/docker/docker/api/types/volume"
"github.com/golang/mock/gomock" "github.com/golang/mock/gomock"
@ -46,7 +47,7 @@ func TestKillAll(t *testing.T) {
name := strings.ToLower(testProject) name := strings.ToLower(testProject)
ctx := context.Background() ctx := context.Background()
api.EXPECT().ContainerList(ctx, moby.ContainerListOptions{ api.EXPECT().ContainerList(ctx, containerType.ListOptions{
Filters: filters.NewArgs(projectFilter(name), hasConfigHashLabel()), Filters: filters.NewArgs(projectFilter(name), hasConfigHashLabel()),
}).Return( }).Return(
[]moby.Container{testContainer("service1", "123", false), testContainer("service1", "456", false), testContainer("service2", "789", false)}, nil) []moby.Container{testContainer("service1", "123", false), testContainer("service1", "456", false), testContainer("service2", "789", false)}, nil)
@ -79,7 +80,7 @@ func TestKillSignal(t *testing.T) {
} }
name := strings.ToLower(testProject) name := strings.ToLower(testProject)
listOptions := moby.ContainerListOptions{ listOptions := containerType.ListOptions{
Filters: filters.NewArgs(projectFilter(name), serviceFilter(serviceName), hasConfigHashLabel()), Filters: filters.NewArgs(projectFilter(name), serviceFilter(serviceName), hasConfigHashLabel()),
} }
@ -133,7 +134,7 @@ func anyCancellableContext() gomock.Matcher {
return gomock.AssignableToTypeOf(ctxWithCancel) return gomock.AssignableToTypeOf(ctxWithCancel)
} }
func projectFilterListOpt(withOneOff bool) moby.ContainerListOptions { func projectFilterListOpt(withOneOff bool) containerType.ListOptions {
filter := filters.NewArgs( filter := filters.NewArgs(
projectFilter(strings.ToLower(testProject)), projectFilter(strings.ToLower(testProject)),
hasConfigHashLabel(), hasConfigHashLabel(),
@ -141,7 +142,7 @@ func projectFilterListOpt(withOneOff bool) moby.ContainerListOptions {
if !withOneOff { if !withOneOff {
filter.Add("label", fmt.Sprintf("%s=False", compose.OneoffLabel)) filter.Add("label", fmt.Sprintf("%s=False", compose.OneoffLabel))
} }
return moby.ContainerListOptions{ return containerType.ListOptions{
Filters: filter, Filters: filter,
All: true, All: true,
} }

View File

@ -23,6 +23,7 @@ import (
"time" "time"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
containerType "github.com/docker/docker/api/types/container"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"github.com/docker/docker/pkg/stdcopy" "github.com/docker/docker/pkg/stdcopy"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
@ -139,7 +140,7 @@ func (s *composeService) logContainers(ctx context.Context, consumer api.LogCons
return err return err
} }
r, err := s.apiClient().ContainerLogs(ctx, cnt.ID, types.ContainerLogsOptions{ r, err := s.apiClient().ContainerLogs(ctx, cnt.ID, containerType.LogsOptions{
ShowStdout: true, ShowStdout: true,
ShowStderr: true, ShowStderr: true,
Follow: options.Follow, Follow: options.Follow,

View File

@ -25,7 +25,7 @@ import (
"github.com/compose-spec/compose-go/types" "github.com/compose-spec/compose-go/types"
moby "github.com/docker/docker/api/types" moby "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container" containerType "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/pkg/stdcopy" "github.com/docker/docker/pkg/stdcopy"
"github.com/golang/mock/gomock" "github.com/golang/mock/gomock"
@ -47,7 +47,7 @@ func TestComposeService_Logs_Demux(t *testing.T) {
name := strings.ToLower(testProject) name := strings.ToLower(testProject)
ctx := context.Background() ctx := context.Background()
api.EXPECT().ContainerList(ctx, moby.ContainerListOptions{ api.EXPECT().ContainerList(ctx, containerType.ListOptions{
All: true, All: true,
Filters: filters.NewArgs(oneOffFilter(false), projectFilter(name), hasConfigHashLabel()), Filters: filters.NewArgs(oneOffFilter(false), projectFilter(name), hasConfigHashLabel()),
}).Return( }).Return(
@ -61,7 +61,7 @@ func TestComposeService_Logs_Demux(t *testing.T) {
ContainerInspect(anyCancellableContext(), "c"). ContainerInspect(anyCancellableContext(), "c").
Return(moby.ContainerJSON{ Return(moby.ContainerJSON{
ContainerJSONBase: &moby.ContainerJSONBase{ID: "c"}, ContainerJSONBase: &moby.ContainerJSONBase{ID: "c"},
Config: &container.Config{Tty: false}, Config: &containerType.Config{Tty: false},
}, nil) }, nil)
c1Reader, c1Writer := io.Pipe() c1Reader, c1Writer := io.Pipe()
t.Cleanup(func() { t.Cleanup(func() {
@ -118,7 +118,7 @@ func TestComposeService_Logs_ServiceFiltering(t *testing.T) {
name := strings.ToLower(testProject) name := strings.ToLower(testProject)
ctx := context.Background() ctx := context.Background()
api.EXPECT().ContainerList(ctx, moby.ContainerListOptions{ api.EXPECT().ContainerList(ctx, containerType.ListOptions{
All: true, All: true,
Filters: filters.NewArgs(oneOffFilter(false), projectFilter(name), hasConfigHashLabel()), Filters: filters.NewArgs(oneOffFilter(false), projectFilter(name), hasConfigHashLabel()),
}).Return( }).Return(
@ -140,7 +140,7 @@ func TestComposeService_Logs_ServiceFiltering(t *testing.T) {
Return( Return(
moby.ContainerJSON{ moby.ContainerJSON{
ContainerJSONBase: &moby.ContainerJSONBase{ID: id}, ContainerJSONBase: &moby.ContainerJSONBase{ID: id},
Config: &container.Config{Tty: true}, Config: &containerType.Config{Tty: true},
}, },
nil, nil,
) )
@ -172,7 +172,7 @@ func TestComposeService_Logs_ServiceFiltering(t *testing.T) {
type testLogConsumer struct { type testLogConsumer struct {
mu sync.Mutex mu sync.Mutex
// logs is keyed container; values are log lines // logs is keyed containerType; values are log lines
logs map[string][]string logs map[string][]string
} }

View File

@ -25,12 +25,13 @@ import (
"github.com/docker/compose/v2/pkg/api" "github.com/docker/compose/v2/pkg/api"
"github.com/docker/compose/v2/pkg/utils" "github.com/docker/compose/v2/pkg/utils"
moby "github.com/docker/docker/api/types" moby "github.com/docker/docker/api/types"
containerType "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
func (s *composeService) List(ctx context.Context, opts api.ListOptions) ([]api.Stack, error) { func (s *composeService) List(ctx context.Context, opts api.ListOptions) ([]api.Stack, error) {
list, err := s.apiClient().ContainerList(ctx, moby.ContainerListOptions{ list, err := s.apiClient().ContainerList(ctx, containerType.ListOptions{
Filters: filters.NewArgs(hasProjectLabelFilter(), hasConfigHashLabel()), Filters: filters.NewArgs(hasProjectLabelFilter(), hasConfigHashLabel()),
All: opts.All, All: opts.All,
}) })

View File

@ -21,6 +21,7 @@ import (
"strings" "strings"
"testing" "testing"
containerType "github.com/docker/docker/api/types/container"
"github.com/golang/mock/gomock" "github.com/golang/mock/gomock"
"gotest.tools/v3/assert" "gotest.tools/v3/assert"
@ -41,7 +42,7 @@ func TestPs(t *testing.T) {
ctx := context.Background() ctx := context.Background()
args := filters.NewArgs(projectFilter(strings.ToLower(testProject)), hasConfigHashLabel()) args := filters.NewArgs(projectFilter(strings.ToLower(testProject)), hasConfigHashLabel())
args.Add("label", "com.docker.compose.oneoff=False") args.Add("label", "com.docker.compose.oneoff=False")
listOpts := moby.ContainerListOptions{Filters: args, All: false} listOpts := containerType.ListOptions{Filters: args, All: false}
c1, inspect1 := containerDetails("service1", "123", "running", "healthy", 0) c1, inspect1 := containerDetails("service1", "123", "running", "healthy", 0)
c2, inspect2 := containerDetails("service1", "456", "running", "", 0) c2, inspect2 := containerDetails("service1", "456", "running", "", 0)
c2.Ports = []moby.Port{{PublicPort: 80, PrivatePort: 90, IP: "localhost"}} c2.Ports = []moby.Port{{PublicPort: 80, PrivatePort: 90, IP: "localhost"}}

View File

@ -29,6 +29,7 @@ import (
"github.com/distribution/reference" "github.com/distribution/reference"
"github.com/docker/buildx/driver" "github.com/docker/buildx/driver"
moby "github.com/docker/docker/api/types" moby "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/system"
"github.com/docker/docker/pkg/jsonmessage" "github.com/docker/docker/pkg/jsonmessage"
"github.com/docker/docker/registry" "github.com/docker/docker/registry"
"golang.org/x/sync/errgroup" "golang.org/x/sync/errgroup"
@ -91,7 +92,7 @@ func (s *composeService) push(ctx context.Context, project *types.Project, optio
return eg.Wait() return eg.Wait()
} }
func (s *composeService) pushServiceImage(ctx context.Context, tag string, info moby.Info, configFile driver.Auth, w progress.Writer, quietPush bool) error { func (s *composeService) pushServiceImage(ctx context.Context, tag string, info system.Info, configFile driver.Auth, w progress.Writer, quietPush bool) error {
ref, err := reference.ParseNormalizedNamed(tag) ref, err := reference.ParseNormalizedNamed(tag)
if err != nil { if err != nil {
return err return err

View File

@ -23,6 +23,7 @@ import (
"github.com/docker/compose/v2/pkg/api" "github.com/docker/compose/v2/pkg/api"
moby "github.com/docker/docker/api/types" moby "github.com/docker/docker/api/types"
containerType "github.com/docker/docker/api/types/container"
"golang.org/x/sync/errgroup" "golang.org/x/sync/errgroup"
"github.com/docker/compose/v2/pkg/progress" "github.com/docker/compose/v2/pkg/progress"
@ -105,7 +106,7 @@ func (s *composeService) remove(ctx context.Context, containers Containers, opti
eg.Go(func() error { eg.Go(func() error {
eventName := getContainerProgressName(container) eventName := getContainerProgressName(container)
w.Event(progress.RemovingEvent(eventName)) w.Event(progress.RemovingEvent(eventName))
err := s.apiClient().ContainerRemove(ctx, container.ID, moby.ContainerRemoveOptions{ err := s.apiClient().ContainerRemove(ctx, container.ID, containerType.RemoveOptions{
RemoveVolumes: options.Volumes, RemoveVolumes: options.Volumes,
Force: options.Force, Force: options.Force,
}) })

View File

@ -23,6 +23,7 @@ import (
"strings" "strings"
"time" "time"
containerType "github.com/docker/docker/api/types/container"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
"github.com/docker/compose/v2/pkg/api" "github.com/docker/compose/v2/pkg/api"
@ -111,7 +112,7 @@ func (s *composeService) start(ctx context.Context, projectName string, options
} }
var containers Containers var containers Containers
containers, err := s.apiClient().ContainerList(ctx, moby.ContainerListOptions{ containers, err := s.apiClient().ContainerList(ctx, containerType.ListOptions{
Filters: filters.NewArgs( Filters: filters.NewArgs(
projectFilter(project.Name), projectFilter(project.Name),
oneOffFilter(false), oneOffFilter(false),