mirror of https://github.com/docker/compose.git
[lint] don't use deprecated types
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
8639fbae86
commit
df1533a1ca
|
@ -34,6 +34,7 @@ import (
|
|||
"github.com/docker/buildx/util/imagetools"
|
||||
"github.com/docker/cli/cli/command"
|
||||
moby "github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/checkpoint"
|
||||
containerType "github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/api/types/events"
|
||||
"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/registry"
|
||||
"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/client"
|
||||
"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.
|
||||
|
||||
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")
|
||||
}
|
||||
|
||||
|
@ -143,7 +145,7 @@ func (d *DryRunClient) ContainerKill(ctx context.Context, container, signal stri
|
|||
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()
|
||||
switch caller {
|
||||
case "start":
|
||||
|
@ -162,7 +164,7 @@ func (d *DryRunClient) ContainerPause(ctx context.Context, container string) err
|
|||
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
|
||||
}
|
||||
|
||||
|
@ -174,7 +176,7 @@ func (d *DryRunClient) ContainerRestart(ctx context.Context, container string, o
|
|||
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
|
||||
}
|
||||
|
||||
|
@ -259,7 +261,7 @@ func (d *DryRunClient) ImagePush(ctx context.Context, ref string, options moby.I
|
|||
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
|
||||
}
|
||||
|
||||
|
@ -341,7 +343,7 @@ func (d *DryRunClient) ConfigUpdate(ctx context.Context, id string, version swar
|
|||
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)
|
||||
}
|
||||
|
||||
|
@ -357,7 +359,7 @@ func (d *DryRunClient) ContainerExecInspect(ctx context.Context, execID string)
|
|||
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)
|
||||
}
|
||||
|
||||
|
@ -369,11 +371,11 @@ func (d *DryRunClient) ContainerInspectWithRaw(ctx context.Context, container st
|
|||
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)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -429,7 +431,7 @@ func (d *DryRunClient) ImageImport(ctx context.Context, source moby.ImageImportS
|
|||
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)
|
||||
}
|
||||
|
||||
|
@ -525,7 +527,7 @@ func (d *DryRunClient) PluginCreate(ctx context.Context, createContext io.Reader
|
|||
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)
|
||||
}
|
||||
|
||||
|
@ -541,15 +543,15 @@ func (d *DryRunClient) ServiceRemove(ctx context.Context, serviceID string) erro
|
|||
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)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -613,7 +615,7 @@ func (d *DryRunClient) Events(ctx context.Context, options moby.EventsOptions) (
|
|||
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)
|
||||
}
|
||||
|
||||
|
@ -685,14 +687,14 @@ func (d *DryRunClient) Close() error {
|
|||
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)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import (
|
|||
"github.com/compose-spec/compose-go/types"
|
||||
"github.com/docker/cli/cli/streams"
|
||||
moby "github.com/docker/docker/api/types"
|
||||
containerType "github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/pkg/stdcopy"
|
||||
"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) {
|
||||
var stdout io.ReadCloser
|
||||
var stdin io.WriteCloser
|
||||
cnx, err := s.apiClient().ContainerAttach(ctx, container, moby.ContainerAttachOptions{
|
||||
cnx, err := s.apiClient().ContainerAttach(ctx, container, containerType.AttachOptions{
|
||||
Stream: true,
|
||||
Stdin: true,
|
||||
Stdout: true,
|
||||
|
@ -171,7 +172,7 @@ func (s *composeService) getContainerStreams(ctx context.Context, container stri
|
|||
}
|
||||
|
||||
// Fallback to logs API
|
||||
logs, err := s.apiClient().ContainerLogs(ctx, container, moby.ContainerLogsOptions{
|
||||
logs, err := s.apiClient().ContainerLogs(ctx, container, containerType.LogsOptions{
|
||||
ShowStdout: true,
|
||||
ShowStderr: true,
|
||||
Follow: true,
|
||||
|
|
|
@ -26,6 +26,7 @@ import (
|
|||
"github.com/docker/compose/v2/pkg/api"
|
||||
"github.com/docker/compose/v2/pkg/utils"
|
||||
moby "github.com/docker/docker/api/types"
|
||||
containerType "github.com/docker/docker/api/types/container"
|
||||
"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) {
|
||||
var containers Containers
|
||||
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...),
|
||||
All: stopped,
|
||||
})
|
||||
|
@ -77,7 +78,7 @@ func (s *composeService) getSpecifiedContainer(ctx context.Context, projectName
|
|||
if containerIndex > 0 {
|
||||
defaultFilters = append(defaultFilters, containerNumberFilter(containerIndex))
|
||||
}
|
||||
containers, err := s.apiClient().ContainerList(ctx, moby.ContainerListOptions{
|
||||
containers, err := s.apiClient().ContainerList(ctx, containerType.ListOptions{
|
||||
Filters: filters.NewArgs(
|
||||
defaultFilters...,
|
||||
),
|
||||
|
|
|
@ -141,7 +141,7 @@ func (c *convergence) ensureService(ctx context.Context, project *types.Project,
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return c.service.apiClient().ContainerRemove(ctx, container.ID, moby.ContainerRemoveOptions{})
|
||||
return c.service.apiClient().ContainerRemove(ctx, container.ID, containerType.RemoveOptions{})
|
||||
}))
|
||||
continue
|
||||
}
|
||||
|
@ -515,7 +515,7 @@ func (s *composeService) recreateContainer(ctx context.Context, project *types.P
|
|||
return created, err
|
||||
}
|
||||
|
||||
err = s.apiClient().ContainerRemove(ctx, replaced.ID, moby.ContainerRemoveOptions{})
|
||||
err = s.apiClient().ContainerRemove(ctx, replaced.ID, containerType.RemoveOptions{})
|
||||
if err != nil {
|
||||
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 {
|
||||
w := progress.ContextWriter(ctx)
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
|
@ -764,7 +764,7 @@ func (s *composeService) startService(ctx context.Context, project *types.Projec
|
|||
}
|
||||
eventName := getContainerProgressName(container)
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import (
|
|||
|
||||
"github.com/compose-spec/compose-go/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/golang/mock/gomock"
|
||||
"gotest.tools/v3/assert"
|
||||
|
@ -63,7 +64,7 @@ func TestServiceLinks(t *testing.T) {
|
|||
Scale: 1,
|
||||
}
|
||||
|
||||
containerListOptions := moby.ContainerListOptions{
|
||||
containerListOptions := containerType.ListOptions{
|
||||
Filters: filters.NewArgs(
|
||||
projectFilter(testProject),
|
||||
serviceFilter("db"),
|
||||
|
@ -189,7 +190,7 @@ func TestServiceLinks(t *testing.T) {
|
|||
s.Labels = s.Labels.Add(api.OneoffLabel, "True")
|
||||
|
||||
c := testContainer("web", webContainerName, true)
|
||||
containerListOptionsOneOff := moby.ContainerListOptions{
|
||||
containerListOptionsOneOff := containerType.ListOptions{
|
||||
Filters: filters.NewArgs(
|
||||
projectFilter(testProject),
|
||||
serviceFilter("web"),
|
||||
|
|
|
@ -314,7 +314,7 @@ func (s *composeService) removeContainers(ctx context.Context, w progress.Writer
|
|||
return err
|
||||
}
|
||||
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,
|
||||
RemoveVolumes: volumes,
|
||||
})
|
||||
|
|
|
@ -28,6 +28,7 @@ import (
|
|||
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/image"
|
||||
"github.com/docker/docker/api/types/volume"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"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(), "789", stopOptions).Return(nil)
|
||||
|
||||
api.EXPECT().ContainerRemove(gomock.Any(), "123", moby.ContainerRemoveOptions{Force: true}).Return(nil)
|
||||
api.EXPECT().ContainerRemove(gomock.Any(), "456", moby.ContainerRemoveOptions{Force: true}).Return(nil)
|
||||
api.EXPECT().ContainerRemove(gomock.Any(), "789", moby.ContainerRemoveOptions{Force: true}).Return(nil)
|
||||
api.EXPECT().ContainerRemove(gomock.Any(), "123", containerType.RemoveOptions{Force: true}).Return(nil)
|
||||
api.EXPECT().ContainerRemove(gomock.Any(), "456", containerType.RemoveOptions{Force: true}).Return(nil)
|
||||
api.EXPECT().ContainerRemove(gomock.Any(), "789", containerType.RemoveOptions{Force: true}).Return(nil)
|
||||
|
||||
api.EXPECT().NetworkList(gomock.Any(), moby.NetworkListOptions{
|
||||
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(), "321", stopOptions).Return(nil)
|
||||
|
||||
api.EXPECT().ContainerRemove(gomock.Any(), "123", moby.ContainerRemoveOptions{Force: true}).Return(nil)
|
||||
api.EXPECT().ContainerRemove(gomock.Any(), "789", moby.ContainerRemoveOptions{Force: true}).Return(nil)
|
||||
api.EXPECT().ContainerRemove(gomock.Any(), "321", moby.ContainerRemoveOptions{Force: true}).Return(nil)
|
||||
api.EXPECT().ContainerRemove(gomock.Any(), "123", containerType.RemoveOptions{Force: true}).Return(nil)
|
||||
api.EXPECT().ContainerRemove(gomock.Any(), "789", containerType.RemoveOptions{Force: true}).Return(nil)
|
||||
api.EXPECT().ContainerRemove(gomock.Any(), "321", containerType.RemoveOptions{Force: true}).Return(nil)
|
||||
|
||||
api.EXPECT().NetworkList(gomock.Any(), moby.NetworkListOptions{
|
||||
Filters: filters.NewArgs(
|
||||
|
@ -167,7 +168,7 @@ func TestDownRemoveVolumes(t *testing.T) {
|
|||
Return(nil, 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)
|
||||
|
||||
|
@ -209,7 +210,7 @@ func TestDownRemoveImages(t *testing.T) {
|
|||
projectFilter(strings.ToLower(testProject)),
|
||||
filters.Arg("dangling", "false"),
|
||||
),
|
||||
}).Return([]moby.ImageSummary{
|
||||
}).Return([]image.Summary{
|
||||
{
|
||||
Labels: types.Labels{compose.ServiceLabel: "local-anonymous"},
|
||||
RepoTags: []string{"testproject-local-anonymous:latest"},
|
||||
|
@ -316,7 +317,7 @@ func TestDownRemoveImages_NoLabel(t *testing.T) {
|
|||
Return(moby.ImageInspect{}, nil, 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)
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import (
|
|||
"github.com/distribution/reference"
|
||||
moby "github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/docker/docker/api/types/image"
|
||||
"github.com/docker/docker/client"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"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
|
||||
// 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{
|
||||
Filters: filters.NewArgs(
|
||||
projectFilter(p.project.Name),
|
||||
|
|
|
@ -24,6 +24,7 @@ import (
|
|||
|
||||
"github.com/distribution/reference"
|
||||
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/errdefs"
|
||||
"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) {
|
||||
projectName = strings.ToLower(projectName)
|
||||
allContainers, err := s.apiClient().ContainerList(ctx, moby.ContainerListOptions{
|
||||
allContainers, err := s.apiClient().ContainerList(ctx, containerType.ListOptions{
|
||||
All: true,
|
||||
Filters: filters.NewArgs(projectFilter(projectName)),
|
||||
})
|
||||
|
|
|
@ -24,6 +24,7 @@ import (
|
|||
"testing"
|
||||
|
||||
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/volume"
|
||||
"github.com/golang/mock/gomock"
|
||||
|
@ -46,7 +47,7 @@ func TestKillAll(t *testing.T) {
|
|||
name := strings.ToLower(testProject)
|
||||
|
||||
ctx := context.Background()
|
||||
api.EXPECT().ContainerList(ctx, moby.ContainerListOptions{
|
||||
api.EXPECT().ContainerList(ctx, containerType.ListOptions{
|
||||
Filters: filters.NewArgs(projectFilter(name), hasConfigHashLabel()),
|
||||
}).Return(
|
||||
[]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)
|
||||
listOptions := moby.ContainerListOptions{
|
||||
listOptions := containerType.ListOptions{
|
||||
Filters: filters.NewArgs(projectFilter(name), serviceFilter(serviceName), hasConfigHashLabel()),
|
||||
}
|
||||
|
||||
|
@ -133,7 +134,7 @@ func anyCancellableContext() gomock.Matcher {
|
|||
return gomock.AssignableToTypeOf(ctxWithCancel)
|
||||
}
|
||||
|
||||
func projectFilterListOpt(withOneOff bool) moby.ContainerListOptions {
|
||||
func projectFilterListOpt(withOneOff bool) containerType.ListOptions {
|
||||
filter := filters.NewArgs(
|
||||
projectFilter(strings.ToLower(testProject)),
|
||||
hasConfigHashLabel(),
|
||||
|
@ -141,7 +142,7 @@ func projectFilterListOpt(withOneOff bool) moby.ContainerListOptions {
|
|||
if !withOneOff {
|
||||
filter.Add("label", fmt.Sprintf("%s=False", compose.OneoffLabel))
|
||||
}
|
||||
return moby.ContainerListOptions{
|
||||
return containerType.ListOptions{
|
||||
Filters: filter,
|
||||
All: true,
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
containerType "github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"github.com/docker/docker/pkg/stdcopy"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
@ -139,7 +140,7 @@ func (s *composeService) logContainers(ctx context.Context, consumer api.LogCons
|
|||
return err
|
||||
}
|
||||
|
||||
r, err := s.apiClient().ContainerLogs(ctx, cnt.ID, types.ContainerLogsOptions{
|
||||
r, err := s.apiClient().ContainerLogs(ctx, cnt.ID, containerType.LogsOptions{
|
||||
ShowStdout: true,
|
||||
ShowStderr: true,
|
||||
Follow: options.Follow,
|
||||
|
|
|
@ -25,7 +25,7 @@ import (
|
|||
|
||||
"github.com/compose-spec/compose-go/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/pkg/stdcopy"
|
||||
"github.com/golang/mock/gomock"
|
||||
|
@ -47,7 +47,7 @@ func TestComposeService_Logs_Demux(t *testing.T) {
|
|||
name := strings.ToLower(testProject)
|
||||
|
||||
ctx := context.Background()
|
||||
api.EXPECT().ContainerList(ctx, moby.ContainerListOptions{
|
||||
api.EXPECT().ContainerList(ctx, containerType.ListOptions{
|
||||
All: true,
|
||||
Filters: filters.NewArgs(oneOffFilter(false), projectFilter(name), hasConfigHashLabel()),
|
||||
}).Return(
|
||||
|
@ -61,7 +61,7 @@ func TestComposeService_Logs_Demux(t *testing.T) {
|
|||
ContainerInspect(anyCancellableContext(), "c").
|
||||
Return(moby.ContainerJSON{
|
||||
ContainerJSONBase: &moby.ContainerJSONBase{ID: "c"},
|
||||
Config: &container.Config{Tty: false},
|
||||
Config: &containerType.Config{Tty: false},
|
||||
}, nil)
|
||||
c1Reader, c1Writer := io.Pipe()
|
||||
t.Cleanup(func() {
|
||||
|
@ -118,7 +118,7 @@ func TestComposeService_Logs_ServiceFiltering(t *testing.T) {
|
|||
name := strings.ToLower(testProject)
|
||||
|
||||
ctx := context.Background()
|
||||
api.EXPECT().ContainerList(ctx, moby.ContainerListOptions{
|
||||
api.EXPECT().ContainerList(ctx, containerType.ListOptions{
|
||||
All: true,
|
||||
Filters: filters.NewArgs(oneOffFilter(false), projectFilter(name), hasConfigHashLabel()),
|
||||
}).Return(
|
||||
|
@ -140,7 +140,7 @@ func TestComposeService_Logs_ServiceFiltering(t *testing.T) {
|
|||
Return(
|
||||
moby.ContainerJSON{
|
||||
ContainerJSONBase: &moby.ContainerJSONBase{ID: id},
|
||||
Config: &container.Config{Tty: true},
|
||||
Config: &containerType.Config{Tty: true},
|
||||
},
|
||||
nil,
|
||||
)
|
||||
|
@ -172,7 +172,7 @@ func TestComposeService_Logs_ServiceFiltering(t *testing.T) {
|
|||
|
||||
type testLogConsumer struct {
|
||||
mu sync.Mutex
|
||||
// logs is keyed container; values are log lines
|
||||
// logs is keyed containerType; values are log lines
|
||||
logs map[string][]string
|
||||
}
|
||||
|
||||
|
|
|
@ -25,12 +25,13 @@ import (
|
|||
"github.com/docker/compose/v2/pkg/api"
|
||||
"github.com/docker/compose/v2/pkg/utils"
|
||||
moby "github.com/docker/docker/api/types"
|
||||
containerType "github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
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()),
|
||||
All: opts.All,
|
||||
})
|
||||
|
|
|
@ -21,6 +21,7 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
containerType "github.com/docker/docker/api/types/container"
|
||||
"github.com/golang/mock/gomock"
|
||||
"gotest.tools/v3/assert"
|
||||
|
||||
|
@ -41,7 +42,7 @@ func TestPs(t *testing.T) {
|
|||
ctx := context.Background()
|
||||
args := filters.NewArgs(projectFilter(strings.ToLower(testProject)), hasConfigHashLabel())
|
||||
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)
|
||||
c2, inspect2 := containerDetails("service1", "456", "running", "", 0)
|
||||
c2.Ports = []moby.Port{{PublicPort: 80, PrivatePort: 90, IP: "localhost"}}
|
||||
|
|
|
@ -29,6 +29,7 @@ import (
|
|||
"github.com/distribution/reference"
|
||||
"github.com/docker/buildx/driver"
|
||||
moby "github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/system"
|
||||
"github.com/docker/docker/pkg/jsonmessage"
|
||||
"github.com/docker/docker/registry"
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
@ -91,7 +92,7 @@ func (s *composeService) push(ctx context.Context, project *types.Project, optio
|
|||
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)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
|
||||
"github.com/docker/compose/v2/pkg/api"
|
||||
moby "github.com/docker/docker/api/types"
|
||||
containerType "github.com/docker/docker/api/types/container"
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
"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 {
|
||||
eventName := getContainerProgressName(container)
|
||||
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,
|
||||
Force: options.Force,
|
||||
})
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
containerType "github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/errdefs"
|
||||
|
||||
"github.com/docker/compose/v2/pkg/api"
|
||||
|
@ -111,7 +112,7 @@ func (s *composeService) start(ctx context.Context, projectName string, options
|
|||
}
|
||||
|
||||
var containers Containers
|
||||
containers, err := s.apiClient().ContainerList(ctx, moby.ContainerListOptions{
|
||||
containers, err := s.apiClient().ContainerList(ctx, containerType.ListOptions{
|
||||
Filters: filters.NewArgs(
|
||||
projectFilter(project.Name),
|
||||
oneOffFilter(false),
|
||||
|
|
Loading…
Reference in New Issue