zones: ErrUnknownNode and ErrInvalidNode
Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
@@ -5,4 +5,12 @@ import "errors"
|
|||||||
var (
|
var (
|
||||||
// ErrInvalidName indicates the name isn't valid
|
// ErrInvalidName indicates the name isn't valid
|
||||||
ErrInvalidName = errors.New("invalid name")
|
ErrInvalidName = errors.New("invalid name")
|
||||||
|
|
||||||
|
// ErrUnknownNode indicates there is a reference to a node
|
||||||
|
// we don't have on the tree
|
||||||
|
ErrUnknownNode = errors.New("node does not exist")
|
||||||
|
|
||||||
|
// ErrInvalidNode indicates the nodes can't be used for
|
||||||
|
// the intended purpose
|
||||||
|
ErrInvalidNode = errors.New("invalid node")
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -183,8 +183,10 @@ func (m *Machine) applyWireguardPeerConfig(ring int, pc wireguard.PeerConfig) er
|
|||||||
switch {
|
switch {
|
||||||
case !found:
|
case !found:
|
||||||
// unknown
|
// unknown
|
||||||
|
return core.Wrap(ErrUnknownNode, pc.Endpoint.Host)
|
||||||
case ring == 1 && m.zone != peer.zone:
|
case ring == 1 && m.zone != peer.zone:
|
||||||
// invalid zone
|
// invalid zone
|
||||||
|
return core.Wrap(ErrInvalidNode, peer.Name)
|
||||||
default:
|
default:
|
||||||
// apply RingInfo
|
// apply RingInfo
|
||||||
ri := &RingInfo{
|
ri := &RingInfo{
|
||||||
@@ -197,8 +199,6 @@ func (m *Machine) applyWireguardPeerConfig(ring int, pc wireguard.PeerConfig) er
|
|||||||
|
|
||||||
return peer.applyRingInfo(ring, ri)
|
return peer.applyRingInfo(ring, ri)
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Errorf("%q: invalid peer endpoint", pc.Endpoint.Host)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Machine) applyZoneNodeID(zoneID, nodeID int) error {
|
func (m *Machine) applyZoneNodeID(zoneID, nodeID int) error {
|
||||||
|
|||||||
Reference in New Issue
Block a user