Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -1018,7 +1018,7 @@ func (c *Controller) NewSandbox(ctx context.Context, containerID string, options |
| 1018 | 1018 |
// GetSandbox returns the Sandbox which has the passed id. |
| 1019 | 1019 |
// |
| 1020 | 1020 |
// It returns an [ErrInvalidID] when passing an invalid ID, or an |
| 1021 |
-// [types.NotFoundError] if no Sandbox was found for the container. |
|
| 1021 |
+// [errdefs.ErrNotFound] if no Sandbox was found for the container. |
|
| 1022 | 1022 |
func (c *Controller) GetSandbox(containerID string) (*Sandbox, error) {
|
| 1023 | 1023 |
if containerID == "" {
|
| 1024 | 1024 |
return nil, types.InvalidParameterErrorf("invalid id: id is empty")
|
| ... | ... |
@@ -1042,7 +1042,7 @@ func (c *Controller) GetSandbox(containerID string) (*Sandbox, error) {
|
| 1042 | 1042 |
} |
| 1043 | 1043 |
|
| 1044 | 1044 |
// SandboxByID returns the Sandbox which has the passed id. |
| 1045 |
-// If not found, a [types.NotFoundError] is returned. |
|
| 1045 |
+// If not found, a [errdefs.NotFoundError] is returned. |
|
| 1046 | 1046 |
func (c *Controller) SandboxByID(id string) (*Sandbox, error) {
|
| 1047 | 1047 |
if id == "" {
|
| 1048 | 1048 |
return nil, types.InvalidParameterErrorf("invalid id: id is empty")
|
| ... | ... |
@@ -12,6 +12,7 @@ import ( |
| 12 | 12 |
"strconv" |
| 13 | 13 |
"testing" |
| 14 | 14 |
|
| 15 |
+ cerrdefs "github.com/containerd/errdefs" |
|
| 15 | 16 |
"github.com/google/go-cmp/cmp/cmpopts" |
| 16 | 17 |
"github.com/moby/moby/v2/daemon/libnetwork/driverapi" |
| 17 | 18 |
"github.com/moby/moby/v2/daemon/libnetwork/drivers/bridge/internal/firewaller" |
| ... | ... |
@@ -555,7 +556,7 @@ func TestCreate(t *testing.T) {
|
| 555 | 555 |
if err == nil {
|
| 556 | 556 |
t.Fatal("Expected bridge driver to refuse creation of second network with default name")
|
| 557 | 557 |
} |
| 558 |
- if _, ok := err.(types.ForbiddenError); !ok {
|
|
| 558 |
+ if !cerrdefs.IsPermissionDenied(err) {
|
|
| 559 | 559 |
t.Fatal("Creation of second network with default name failed with unexpected error type")
|
| 560 | 560 |
} |
| 561 | 561 |
} |
| ... | ... |
@@ -4,7 +4,7 @@ import ( |
| 4 | 4 |
"context" |
| 5 | 5 |
"testing" |
| 6 | 6 |
|
| 7 |
- "github.com/moby/moby/v2/daemon/libnetwork/types" |
|
| 7 |
+ cerrdefs "github.com/containerd/errdefs" |
|
| 8 | 8 |
) |
| 9 | 9 |
|
| 10 | 10 |
func TestDriver(t *testing.T) {
|
| ... | ... |
@@ -27,7 +27,7 @@ func TestDriver(t *testing.T) {
|
| 27 | 27 |
if err == nil {
|
| 28 | 28 |
t.Fatal("Second network creation should fail on this driver")
|
| 29 | 29 |
} |
| 30 |
- if _, ok := err.(types.ForbiddenError); !ok {
|
|
| 30 |
+ if !cerrdefs.IsPermissionDenied(err) {
|
|
| 31 | 31 |
t.Fatal("Second network creation failed with unexpected error type")
|
| 32 | 32 |
} |
| 33 | 33 |
|
| ... | ... |
@@ -35,7 +35,7 @@ func TestDriver(t *testing.T) {
|
| 35 | 35 |
if err == nil {
|
| 36 | 36 |
t.Fatal("network deletion should fail on this driver")
|
| 37 | 37 |
} |
| 38 |
- if _, ok := err.(types.ForbiddenError); !ok {
|
|
| 38 |
+ if !cerrdefs.IsPermissionDenied(err) {
|
|
| 39 | 39 |
t.Fatal("network deletion failed with unexpected error type")
|
| 40 | 40 |
} |
| 41 | 41 |
|
| ... | ... |
@@ -44,7 +44,7 @@ func TestDriver(t *testing.T) {
|
| 44 | 44 |
if err == nil {
|
| 45 | 45 |
t.Fatal("any network deletion should fail on this driver")
|
| 46 | 46 |
} |
| 47 |
- if _, ok := err.(types.ForbiddenError); !ok {
|
|
| 47 |
+ if !cerrdefs.IsPermissionDenied(err) {
|
|
| 48 | 48 |
t.Fatal("any network deletion failed with unexpected error type")
|
| 49 | 49 |
} |
| 50 | 50 |
} |
| ... | ... |
@@ -4,7 +4,7 @@ import ( |
| 4 | 4 |
"context" |
| 5 | 5 |
"testing" |
| 6 | 6 |
|
| 7 |
- "github.com/moby/moby/v2/daemon/libnetwork/types" |
|
| 7 |
+ cerrdefs "github.com/containerd/errdefs" |
|
| 8 | 8 |
) |
| 9 | 9 |
|
| 10 | 10 |
func TestDriver(t *testing.T) {
|
| ... | ... |
@@ -27,7 +27,7 @@ func TestDriver(t *testing.T) {
|
| 27 | 27 |
if err == nil {
|
| 28 | 28 |
t.Fatalf("Second network creation should fail on this driver")
|
| 29 | 29 |
} |
| 30 |
- if _, ok := err.(types.ForbiddenError); !ok {
|
|
| 30 |
+ if !cerrdefs.IsPermissionDenied(err) {
|
|
| 31 | 31 |
t.Fatalf("Second network creation failed with unexpected error type")
|
| 32 | 32 |
} |
| 33 | 33 |
|
| ... | ... |
@@ -35,7 +35,7 @@ func TestDriver(t *testing.T) {
|
| 35 | 35 |
if err == nil {
|
| 36 | 36 |
t.Fatalf("network deletion should fail on this driver")
|
| 37 | 37 |
} |
| 38 |
- if _, ok := err.(types.ForbiddenError); !ok {
|
|
| 38 |
+ if !cerrdefs.IsPermissionDenied(err) {
|
|
| 39 | 39 |
t.Fatalf("network deletion failed with unexpected error type")
|
| 40 | 40 |
} |
| 41 | 41 |
|
| ... | ... |
@@ -44,7 +44,7 @@ func TestDriver(t *testing.T) {
|
| 44 | 44 |
if err == nil {
|
| 45 | 45 |
t.Fatalf("any network deletion should fail on this driver")
|
| 46 | 46 |
} |
| 47 |
- if _, ok := err.(types.ForbiddenError); !ok {
|
|
| 47 |
+ if !cerrdefs.IsPermissionDenied(err) {
|
|
| 48 | 48 |
t.Fatalf("any network deletion failed with unexpected error type")
|
| 49 | 49 |
} |
| 50 | 50 |
} |
| ... | ... |
@@ -10,6 +10,7 @@ import ( |
| 10 | 10 |
"strings" |
| 11 | 11 |
"sync" |
| 12 | 12 |
|
| 13 |
+ cerrdefs "github.com/containerd/errdefs" |
|
| 13 | 14 |
"github.com/containerd/log" |
| 14 | 15 |
"github.com/moby/moby/v2/daemon/internal/sliceutil" |
| 15 | 16 |
"github.com/moby/moby/v2/daemon/internal/stringid" |
| ... | ... |
@@ -988,7 +989,7 @@ func (ep *Endpoint) deleteEndpoint(force bool) error {
|
| 988 | 988 |
} |
| 989 | 989 |
|
| 990 | 990 |
if err := driver.DeleteEndpoint(n.id, epid); err != nil {
|
| 991 |
- if _, ok := err.(types.ForbiddenError); ok {
|
|
| 991 |
+ if cerrdefs.IsPermissionDenied(err) {
|
|
| 992 | 992 |
return err |
| 993 | 993 |
} |
| 994 | 994 |
|
| ... | ... |
@@ -12,6 +12,7 @@ import ( |
| 12 | 12 |
"sync" |
| 13 | 13 |
"time" |
| 14 | 14 |
|
| 15 |
+ cerrdefs "github.com/containerd/errdefs" |
|
| 15 | 16 |
"github.com/containerd/log" |
| 16 | 17 |
"github.com/moby/moby/v2/daemon/internal/sliceutil" |
| 17 | 18 |
"github.com/moby/moby/v2/daemon/internal/stringid" |
| ... | ... |
@@ -1141,7 +1142,7 @@ func (n *Network) deleteNetwork() error {
|
| 1141 | 1141 |
|
| 1142 | 1142 |
if err := d.DeleteNetwork(n.ID()); err != nil {
|
| 1143 | 1143 |
// Forbidden Errors should be honored |
| 1144 |
- if _, ok := err.(types.ForbiddenError); ok {
|
|
| 1144 |
+ if cerrdefs.IsPermissionDenied(err) {
|
|
| 1145 | 1145 |
return err |
| 1146 | 1146 |
} |
| 1147 | 1147 |
|
| ... | ... |
@@ -389,21 +389,6 @@ type MaskableError interface {
|
| 389 | 389 |
Maskable() |
| 390 | 390 |
} |
| 391 | 391 |
|
| 392 |
-// InvalidParameterError is an interface for errors originated by a bad request |
|
| 393 |
-type InvalidParameterError = errdefs.ErrInvalidParameter |
|
| 394 |
- |
|
| 395 |
-// NotFoundError is an interface for errors raised because a needed resource is not available |
|
| 396 |
-type NotFoundError = errdefs.ErrNotFound |
|
| 397 |
- |
|
| 398 |
-// ForbiddenError is an interface for errors which denote a valid request that cannot be honored |
|
| 399 |
-type ForbiddenError = errdefs.ErrForbidden |
|
| 400 |
- |
|
| 401 |
-// UnavailableError is an interface for errors returned when the required service is not available |
|
| 402 |
-type UnavailableError = errdefs.ErrUnavailable |
|
| 403 |
- |
|
| 404 |
-// NotImplementedError is an interface for errors raised because of requested functionality is not yet implemented |
|
| 405 |
-type NotImplementedError = errdefs.ErrNotImplemented |
|
| 406 |
- |
|
| 407 | 392 |
// InternalError is an interface for errors raised because of an internal error |
| 408 | 393 |
type InternalError interface {
|
| 409 | 394 |
// Internal makes implementer into InternalError type |
| ... | ... |
@@ -414,27 +399,27 @@ type InternalError interface {
|
| 414 | 414 |
* Well-known Error Formatters |
| 415 | 415 |
******************************/ |
| 416 | 416 |
|
| 417 |
-// InvalidParameterErrorf creates an instance of InvalidParameterError |
|
| 417 |
+// InvalidParameterErrorf creates an instance of [errdefs.ErrInvalidParameter]. |
|
| 418 | 418 |
func InvalidParameterErrorf(format string, params ...any) error {
|
| 419 | 419 |
return errdefs.InvalidParameter(fmt.Errorf(format, params...)) |
| 420 | 420 |
} |
| 421 | 421 |
|
| 422 |
-// NotFoundErrorf creates an instance of NotFoundError |
|
| 422 |
+// NotFoundErrorf creates an instance of [errdefs.ErrNotFound]. |
|
| 423 | 423 |
func NotFoundErrorf(format string, params ...any) error {
|
| 424 | 424 |
return errdefs.NotFound(fmt.Errorf(format, params...)) |
| 425 | 425 |
} |
| 426 | 426 |
|
| 427 |
-// ForbiddenErrorf creates an instance of ForbiddenError |
|
| 427 |
+// ForbiddenErrorf creates an instance of [errdefs.ErrForbidden]. |
|
| 428 | 428 |
func ForbiddenErrorf(format string, params ...any) error {
|
| 429 | 429 |
return errdefs.Forbidden(fmt.Errorf(format, params...)) |
| 430 | 430 |
} |
| 431 | 431 |
|
| 432 |
-// UnavailableErrorf creates an instance of UnavailableError |
|
| 432 |
+// UnavailableErrorf creates an instance of [errdefs.ErrUnavailable] |
|
| 433 | 433 |
func UnavailableErrorf(format string, params ...any) error {
|
| 434 | 434 |
return errdefs.Unavailable(fmt.Errorf(format, params...)) |
| 435 | 435 |
} |
| 436 | 436 |
|
| 437 |
-// NotImplementedErrorf creates an instance of NotImplementedError |
|
| 437 |
+// NotImplementedErrorf creates an instance of [errdefs.ErrNotImplemented]. |
|
| 438 | 438 |
func NotImplementedErrorf(format string, params ...any) error {
|
| 439 | 439 |
return errdefs.NotImplemented(fmt.Errorf(format, params...)) |
| 440 | 440 |
} |