Bladeren bron

pkg/compose: remove uses of moby/errdefs

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Sebastiaan van Stijn 4 maanden geleden
bovenliggende
commit
c50d16cd78
3 gewijzigde bestanden met toevoegingen van 5 en 6 verwijderingen
  1. 2 0
      .golangci.yml
  2. 2 2
      pkg/compose/down_test.go
  3. 1 4
      pkg/compose/up.go

+ 2 - 0
.golangci.yml

@@ -30,6 +30,8 @@ linters:
           deny:
             - pkg: io/ioutil
               desc: io/ioutil package has been deprecated
+            - pkg: github.com/docker/docker/errdefs
+              desc: use github.com/containerd/errdefs instead.
             - pkg: golang.org/x/exp/maps
               desc: use stdlib maps package
             - pkg: golang.org/x/exp/slices

+ 2 - 2
pkg/compose/down_test.go

@@ -24,13 +24,13 @@ import (
 	"testing"
 
 	"github.com/compose-spec/compose-go/v2/types"
+	"github.com/containerd/errdefs"
 	"github.com/docker/cli/cli/streams"
 	"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/network"
 	"github.com/docker/docker/api/types/volume"
-	"github.com/docker/docker/errdefs"
 	"go.uber.org/mock/gomock"
 	"gotest.tools/v3/assert"
 
@@ -326,7 +326,7 @@ func TestDownRemoveImages(t *testing.T) {
 		if exists {
 			resp.RepoTags = []string{img}
 		} else {
-			err = errdefs.NotFound(fmt.Errorf("test specified that image %q should not exist", img))
+			err = errdefs.ErrNotFound.WithMessage(fmt.Sprintf("test specified that image %q should not exist", img))
 		}
 
 		api.EXPECT().ImageInspect(gomock.Any(), img).

+ 1 - 4
pkg/compose/up.go

@@ -18,7 +18,6 @@ package compose
 
 import (
 	"context"
-	"errors"
 	"fmt"
 	"os"
 	"os/signal"
@@ -32,7 +31,6 @@ import (
 	"github.com/docker/compose/v2/internal/tracing"
 	"github.com/docker/compose/v2/pkg/api"
 	"github.com/docker/compose/v2/pkg/progress"
-	"github.com/docker/docker/errdefs"
 	"github.com/eiannone/keyboard"
 	"github.com/hashicorp/go-multierror"
 	"github.com/sirupsen/logrus"
@@ -222,8 +220,7 @@ func (s *composeService) Up(ctx context.Context, project *types.Project, options
 					Follow: true,
 					Since:  ctr.State.StartedAt,
 				})
-				var notImplErr errdefs.ErrNotImplemented
-				if errors.As(err, &notImplErr) {
+				if cerrdefs.IsNotImplemented(err) {
 					// container may be configured with logging_driver: none
 					// as container already started, we might miss the very first logs. But still better than none
 					return s.doAttachContainer(ctx, event.Service, event.ID, event.Source, printer.HandleEvent)