refactor: fix lint issues from cleanup changes

Assisted-By: docker-agent
Signed-off-by: Nicolas De loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De loof 2026-04-27 11:32:00 +00:00 committed by Guillaume Lours
parent 40d363baf9
commit 07832c4df1
12 changed files with 17 additions and 19 deletions

View file

@ -17,7 +17,6 @@
package compose
import (
"context"
"time"
"github.com/docker/cli/cli/command"
@ -27,7 +26,7 @@ import (
)
// withBackend creates a compose backend and passes it to fn.
func withBackend(ctx context.Context, dockerCli command.Cli, opts *BackendOptions, fn func(api.Compose) error) error {
func withBackend(dockerCli command.Cli, opts *BackendOptions, fn func(api.Compose) error) error {
backend, err := compose.NewComposeService(dockerCli, opts.Options...)
if err != nil {
return err

View file

@ -62,7 +62,7 @@ func runKill(ctx context.Context, dockerCli command.Cli, backendOptions *Backend
return err
}
return withBackend(ctx, dockerCli, backendOptions, func(backend api.Compose) error {
return withBackend(dockerCli, backendOptions, func(backend api.Compose) error {
err := backend.Kill(ctx, name, api.KillOptions{
RemoveOrphans: opts.removeOrphans,
Project: project,

View file

@ -49,7 +49,7 @@ func runPause(ctx context.Context, dockerCli command.Cli, backendOptions *Backen
if err != nil {
return err
}
return withBackend(ctx, dockerCli, backendOptions, func(backend api.Compose) error {
return withBackend(dockerCli, backendOptions, func(backend api.Compose) error {
return backend.Pause(ctx, name, api.PauseOptions{
Services: services,
Project: project,
@ -81,7 +81,7 @@ func runUnPause(ctx context.Context, dockerCli command.Cli, backendOptions *Back
if err != nil {
return err
}
return withBackend(ctx, dockerCli, backendOptions, func(backend api.Compose) error {
return withBackend(dockerCli, backendOptions, func(backend api.Compose) error {
return backend.UnPause(ctx, name, api.PauseOptions{
Services: services,
Project: project,

View file

@ -67,7 +67,7 @@ func runRestart(ctx context.Context, dockerCli command.Cli, backendOptions *Back
}
}
return withBackend(ctx, dockerCli, backendOptions, func(backend api.Compose) error {
return withBackend(dockerCli, backendOptions, func(backend api.Compose) error {
return backend.Restart(ctx, name, api.RestartOptions{
Timeout: optionalTimeout(opts.timeout, opts.timeChanged),
Services: services,

View file

@ -61,7 +61,7 @@ func runStart(ctx context.Context, dockerCli command.Cli, backendOptions *Backen
if opts.waitTimeout > 0 {
timeout = time.Duration(opts.waitTimeout) * time.Second
}
return withBackend(ctx, dockerCli, backendOptions, func(backend api.Compose) error {
return withBackend(dockerCli, backendOptions, func(backend api.Compose) error {
return backend.Start(ctx, name, api.StartOptions{
AttachTo: services,
Project: project,

View file

@ -57,7 +57,7 @@ func runStop(ctx context.Context, dockerCli command.Cli, backendOptions *Backend
if err != nil {
return err
}
return withBackend(ctx, dockerCli, backendOptions, func(backend api.Compose) error {
return withBackend(dockerCli, backendOptions, func(backend api.Compose) error {
return backend.Stop(ctx, name, api.StopOptions{
Timeout: optionalTimeout(opts.timeout, opts.timeChanged),
Services: services,

View file

@ -252,7 +252,7 @@ func (s *composeService) removeNetwork(ctx context.Context, composeNetworkName s
func (s *composeService) removeImage(ctx context.Context, image string) error {
id := fmt.Sprintf("Image %s", image)
return s.removeResource(ctx, id, func() error {
return s.removeResource(id, func() error {
_, err := s.apiClient().ImageRemove(ctx, image, client.ImageRemoveOptions{})
return err
})
@ -267,7 +267,7 @@ func (s *composeService) removeVolume(ctx context.Context, id string) error {
return nil
}
return s.removeResource(ctx, resource, func() error {
return s.removeResource(resource, func() error {
_, err := s.apiClient().VolumeRemove(ctx, id, client.VolumeRemoveOptions{
Force: true,
})
@ -277,7 +277,7 @@ func (s *composeService) removeVolume(ctx context.Context, id string) error {
// removeResource emits a "Removing" progress event, calls op, then emits the appropriate
// completion event based on the error: nil→Removed, conflict→still-in-use warning, not-found→gone warning.
func (s *composeService) removeResource(ctx context.Context, eventID string, op func() error) error {
func (s *composeService) removeResource(eventID string, op func() error) error {
s.events.On(newEvent(eventID, api.Working, "Removing"))
err := op()
if err == nil {

View file

@ -44,7 +44,7 @@ func TestKillAll(t *testing.T) {
name := strings.ToLower(testProject)
api.EXPECT().ContainerList(t.Context(), client.ContainerListOptions{
Filters: projectFilter(name).Add("label", api.ConfigHashLabel),
Filters: projectFilter(name).Add("label", compose.ConfigHashLabel),
}).Return(client.ContainerListResult{
Items: []container.Summary{
testContainer("service1", "123", false),
@ -83,7 +83,7 @@ func TestKillSignal(t *testing.T) {
name := strings.ToLower(testProject)
listOptions := client.ContainerListOptions{
Filters: projectFilter(name).Add("label", serviceFilter(serviceName), api.ConfigHashLabel),
Filters: projectFilter(name).Add("label", serviceFilter(serviceName), compose.ConfigHashLabel),
}
api.EXPECT().ContainerList(t.Context(), listOptions).Return(client.ContainerListResult{
@ -145,7 +145,7 @@ func anyCancellableContext() gomock.Matcher {
}
func projectFilterListOpt(withOneOff bool) client.ContainerListOptions {
filter := projectFilter(strings.ToLower(testProject)).Add("label", api.ConfigHashLabel)
filter := projectFilter(strings.ToLower(testProject)).Add("label", compose.ConfigHashLabel)
if !withOneOff {
filter.Add("label", oneOffFilter(false))
}

View file

@ -98,7 +98,7 @@ func TestComposeService_Logs_Demux(t *testing.T) {
api.EXPECT().ContainerList(t.Context(), client.ContainerListOptions{
All: true,
Filters: projectFilter(name).Add("label", oneOffFilter(false), api.ConfigHashLabel),
Filters: projectFilter(name).Add("label", oneOffFilter(false), compose.ConfigHashLabel),
}).Return(
client.ContainerListResult{
Items: []containerType.Summary{
@ -166,7 +166,7 @@ func TestComposeService_Logs_ServiceFiltering(t *testing.T) {
api.EXPECT().ContainerList(t.Context(), client.ContainerListOptions{
All: true,
Filters: projectFilter(name).Add("label", oneOffFilter(false), api.ConfigHashLabel),
Filters: projectFilter(name).Add("label", oneOffFilter(false), compose.ConfigHashLabel),
}).Return(
client.ContainerListResult{
Items: []containerType.Summary{

View file

@ -38,7 +38,7 @@ func TestPs(t *testing.T) {
assert.NilError(t, err)
listOpts := client.ContainerListOptions{
Filters: projectFilter(strings.ToLower(testProject)).Add("label", api.ConfigHashLabel, oneOffFilter(false)),
Filters: projectFilter(strings.ToLower(testProject)).Add("label", compose.ConfigHashLabel, oneOffFilter(false)),
All: false,
}
c1, inspect1 := containerDetails("service1", "123", containerType.StateRunning, containerType.Healthy, 0)

View file

@ -27,7 +27,7 @@ import (
"github.com/docker/compose/v5/pkg/api"
)
func (s *composeService) Remove(ctx context.Context, projectName string, options api.RemoveOptions) error {
func (s *composeService) Remove(ctx context.Context, projectName string, options api.RemoveOptions) error { //nolint:gocyclo
projectName = strings.ToLower(projectName)
if options.Stop {

View file

@ -74,4 +74,3 @@ func (s Set[T]) Diff(other Set[T]) Set[T] {
}
return out
}