mirror of
https://github.com/moby/moby.git
synced 2026-07-11 18:13:57 +00:00
libnetwork: remove UnknownNetworkError
It was only returned in 2 places, and not used any different than a "notfound" error, so let's use a standard errdefs.NotFound Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -56,20 +56,6 @@ func (nnr NetworkNameError) Error() string {
|
||||
// Conflict denotes the type of this error
|
||||
func (nnr NetworkNameError) Conflict() {}
|
||||
|
||||
// UnknownNetworkError is returned when libnetwork could not find in its database
|
||||
// a network with the same name and id.
|
||||
type UnknownNetworkError struct {
|
||||
name string
|
||||
id string
|
||||
}
|
||||
|
||||
func (une *UnknownNetworkError) Error() string {
|
||||
return fmt.Sprintf("unknown network %s id %s", une.name, une.id)
|
||||
}
|
||||
|
||||
// NotFound denotes the type of this error
|
||||
func (une *UnknownNetworkError) NotFound() {}
|
||||
|
||||
// ActiveEndpointsError is returned when a network is deleted which has active
|
||||
// endpoints in it.
|
||||
type ActiveEndpointsError struct {
|
||||
|
||||
@@ -24,7 +24,7 @@ func TestErrorInterfaces(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
notFoundErrorList := []error{&UnknownNetworkError{}, ErrNoSuchNetwork(""), ErrNoSuchEndpoint("")}
|
||||
notFoundErrorList := []error{ErrNoSuchNetwork(""), ErrNoSuchEndpoint("")}
|
||||
for _, err := range notFoundErrorList {
|
||||
assert.Check(t, is.ErrorType(err, errdefs.IsNotFound))
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/containerd/log"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"github.com/docker/docker/libnetwork/datastore"
|
||||
"github.com/docker/docker/libnetwork/driverapi"
|
||||
"github.com/docker/docker/libnetwork/internal/netiputil"
|
||||
@@ -1021,7 +1022,7 @@ func (n *Network) delete(force bool, rmLBEndpoint bool) error {
|
||||
|
||||
n, err := c.getNetworkFromStore(id)
|
||||
if err != nil {
|
||||
return &UnknownNetworkError{name: name, id: id}
|
||||
return errdefs.NotFound(fmt.Errorf("unknown network %s id %s", name, id))
|
||||
}
|
||||
|
||||
// Only remove ingress on force removal or explicit LB endpoint removal
|
||||
@@ -1054,7 +1055,7 @@ func (n *Network) delete(force bool, rmLBEndpoint bool) error {
|
||||
// Reload the network from the store to update the epcnt.
|
||||
n, err = c.getNetworkFromStore(id)
|
||||
if err != nil {
|
||||
return &UnknownNetworkError{name: name, id: id}
|
||||
return errdefs.NotFound(fmt.Errorf("unknown network %s id %s", name, id))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user