2015-04-16 01:01:29 -04:00
|
|
|
package libnetwork
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
2015-05-14 17:56:15 -04:00
|
|
|
// ErrNoSuchNetwork is returned when a network query finds no result
|
|
|
|
type ErrNoSuchNetwork string
|
|
|
|
|
|
|
|
func (nsn ErrNoSuchNetwork) Error() string {
|
|
|
|
return fmt.Sprintf("network %s not found", string(nsn))
|
|
|
|
}
|
|
|
|
|
2015-06-09 19:38:11 -04:00
|
|
|
// NotFound denotes the type of this error
|
|
|
|
func (nsn ErrNoSuchNetwork) NotFound() {}
|
2015-05-14 17:56:15 -04:00
|
|
|
|
2016-05-22 22:55:17 -04:00
|
|
|
// ErrNoSuchEndpoint is returned when an endpoint query finds no result
|
2015-05-14 17:56:15 -04:00
|
|
|
type ErrNoSuchEndpoint string
|
|
|
|
|
|
|
|
func (nse ErrNoSuchEndpoint) Error() string {
|
|
|
|
return fmt.Sprintf("endpoint %s not found", string(nse))
|
|
|
|
}
|
|
|
|
|
2015-06-09 19:38:11 -04:00
|
|
|
// NotFound denotes the type of this error
|
|
|
|
func (nse ErrNoSuchEndpoint) NotFound() {}
|
2015-05-14 17:56:15 -04:00
|
|
|
|
|
|
|
// ErrInvalidNetworkDriver is returned if an invalid driver
|
|
|
|
// name is passed.
|
|
|
|
type ErrInvalidNetworkDriver string
|
|
|
|
|
|
|
|
func (ind ErrInvalidNetworkDriver) Error() string {
|
|
|
|
return fmt.Sprintf("invalid driver bound to network: %s", string(ind))
|
|
|
|
}
|
|
|
|
|
|
|
|
// BadRequest denotes the type of this error
|
|
|
|
func (ind ErrInvalidNetworkDriver) BadRequest() {}
|
|
|
|
|
|
|
|
// ErrInvalidJoin is returned if a join is attempted on an endpoint
|
|
|
|
// which already has a container joined.
|
|
|
|
type ErrInvalidJoin struct{}
|
|
|
|
|
|
|
|
func (ij ErrInvalidJoin) Error() string {
|
|
|
|
return "a container has already joined the endpoint"
|
|
|
|
}
|
|
|
|
|
|
|
|
// BadRequest denotes the type of this error
|
|
|
|
func (ij ErrInvalidJoin) BadRequest() {}
|
|
|
|
|
|
|
|
// ErrNoContainer is returned when the endpoint has no container
|
|
|
|
// attached to it.
|
|
|
|
type ErrNoContainer struct{}
|
|
|
|
|
|
|
|
func (nc ErrNoContainer) Error() string {
|
2015-06-19 21:41:31 -04:00
|
|
|
return "no container is attached to the endpoint"
|
2015-05-14 17:56:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Maskable denotes the type of this error
|
|
|
|
func (nc ErrNoContainer) Maskable() {}
|
|
|
|
|
|
|
|
// ErrInvalidID is returned when a query-by-id method is being invoked
|
|
|
|
// with an empty id parameter
|
|
|
|
type ErrInvalidID string
|
|
|
|
|
|
|
|
func (ii ErrInvalidID) Error() string {
|
|
|
|
return fmt.Sprintf("invalid id: %s", string(ii))
|
|
|
|
}
|
|
|
|
|
|
|
|
// BadRequest denotes the type of this error
|
|
|
|
func (ii ErrInvalidID) BadRequest() {}
|
|
|
|
|
|
|
|
// ErrInvalidName is returned when a query-by-name or resource create method is
|
2016-10-17 11:37:10 -04:00
|
|
|
// invoked with an invalid name parameter
|
2015-05-14 17:56:15 -04:00
|
|
|
type ErrInvalidName string
|
|
|
|
|
|
|
|
func (in ErrInvalidName) Error() string {
|
|
|
|
return fmt.Sprintf("invalid name: %s", string(in))
|
|
|
|
}
|
|
|
|
|
|
|
|
// BadRequest denotes the type of this error
|
|
|
|
func (in ErrInvalidName) BadRequest() {}
|
2015-04-16 01:01:29 -04:00
|
|
|
|
2015-05-23 00:52:02 -04:00
|
|
|
// ErrInvalidConfigFile type is returned when an invalid LibNetwork config file is detected
|
|
|
|
type ErrInvalidConfigFile string
|
|
|
|
|
|
|
|
func (cf ErrInvalidConfigFile) Error() string {
|
|
|
|
return fmt.Sprintf("Invalid Config file %q", string(cf))
|
|
|
|
}
|
|
|
|
|
2015-04-16 01:01:29 -04:00
|
|
|
// NetworkTypeError type is returned when the network type string is not
|
|
|
|
// known to libnetwork.
|
|
|
|
type NetworkTypeError string
|
|
|
|
|
|
|
|
func (nt NetworkTypeError) Error() string {
|
|
|
|
return fmt.Sprintf("unknown driver %q", string(nt))
|
|
|
|
}
|
|
|
|
|
2015-05-14 17:56:15 -04:00
|
|
|
// NotFound denotes the type of this error
|
|
|
|
func (nt NetworkTypeError) NotFound() {}
|
|
|
|
|
2015-04-16 01:01:29 -04:00
|
|
|
// NetworkNameError is returned when a network with the same name already exists.
|
|
|
|
type NetworkNameError string
|
|
|
|
|
2015-05-14 17:56:15 -04:00
|
|
|
func (nnr NetworkNameError) Error() string {
|
|
|
|
return fmt.Sprintf("network with name %s already exists", string(nnr))
|
2015-04-16 01:01:29 -04:00
|
|
|
}
|
|
|
|
|
2015-05-14 17:56:15 -04:00
|
|
|
// Forbidden denotes the type of this error
|
|
|
|
func (nnr NetworkNameError) Forbidden() {}
|
|
|
|
|
2016-10-28 13:04:22 -04:00
|
|
|
// UnknownNetworkError is returned when libnetwork could not find in its database
|
2015-04-16 01:01:29 -04:00
|
|
|
// 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)
|
|
|
|
}
|
|
|
|
|
2015-05-14 17:56:15 -04:00
|
|
|
// NotFound denotes the type of this error
|
|
|
|
func (une *UnknownNetworkError) NotFound() {}
|
|
|
|
|
2015-04-16 01:01:29 -04:00
|
|
|
// ActiveEndpointsError is returned when a network is deleted which has active
|
|
|
|
// endpoints in it.
|
|
|
|
type ActiveEndpointsError struct {
|
|
|
|
name string
|
|
|
|
id string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (aee *ActiveEndpointsError) Error() string {
|
2015-10-09 04:45:24 -04:00
|
|
|
return fmt.Sprintf("network %s has active endpoints", aee.name)
|
2015-04-16 01:01:29 -04:00
|
|
|
}
|
|
|
|
|
2015-05-14 17:56:15 -04:00
|
|
|
// Forbidden denotes the type of this error
|
|
|
|
func (aee *ActiveEndpointsError) Forbidden() {}
|
|
|
|
|
2016-10-28 13:04:22 -04:00
|
|
|
// UnknownEndpointError is returned when libnetwork could not find in its database
|
2015-04-16 01:01:29 -04:00
|
|
|
// an endpoint with the same name and id.
|
|
|
|
type UnknownEndpointError struct {
|
|
|
|
name string
|
|
|
|
id string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (uee *UnknownEndpointError) Error() string {
|
|
|
|
return fmt.Sprintf("unknown endpoint %s id %s", uee.name, uee.id)
|
|
|
|
}
|
2015-04-28 01:57:36 -04:00
|
|
|
|
2015-05-14 17:56:15 -04:00
|
|
|
// NotFound denotes the type of this error
|
|
|
|
func (uee *UnknownEndpointError) NotFound() {}
|
|
|
|
|
2015-05-06 16:02:40 -04:00
|
|
|
// ActiveContainerError is returned when an endpoint is deleted which has active
|
|
|
|
// containers attached to it.
|
|
|
|
type ActiveContainerError struct {
|
|
|
|
name string
|
|
|
|
id string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ace *ActiveContainerError) Error() string {
|
|
|
|
return fmt.Sprintf("endpoint with name %s id %s has active containers", ace.name, ace.id)
|
|
|
|
}
|
|
|
|
|
2015-05-14 17:56:15 -04:00
|
|
|
// Forbidden denotes the type of this error
|
|
|
|
func (ace *ActiveContainerError) Forbidden() {}
|
|
|
|
|
2015-04-28 01:57:36 -04:00
|
|
|
// InvalidContainerIDError is returned when an invalid container id is passed
|
|
|
|
// in Join/Leave
|
|
|
|
type InvalidContainerIDError string
|
|
|
|
|
|
|
|
func (id InvalidContainerIDError) Error() string {
|
|
|
|
return fmt.Sprintf("invalid container id %s", string(id))
|
|
|
|
}
|
2015-05-14 17:56:15 -04:00
|
|
|
|
|
|
|
// BadRequest denotes the type of this error
|
|
|
|
func (id InvalidContainerIDError) BadRequest() {}
|
2016-05-24 19:17:19 -04:00
|
|
|
|
|
|
|
// ManagerRedirectError is returned when the request should be redirected to Manager
|
|
|
|
type ManagerRedirectError string
|
|
|
|
|
|
|
|
func (mr ManagerRedirectError) Error() string {
|
|
|
|
return "Redirect the request to the manager"
|
|
|
|
}
|
|
|
|
|
|
|
|
// Maskable denotes the type of this error
|
|
|
|
func (mr ManagerRedirectError) Maskable() {}
|