|
|
|
@ -31,9 +31,9 @@ func (ri *RingInfo) Merge(alter *RingInfo) error {
|
|
|
|
|
case ri.Ring != alter.Ring: |
|
|
|
|
// different ring
|
|
|
|
|
return fmt.Errorf("invalid %s: %v ≠ %v", "ring", ri.Ring, alter.Ring) |
|
|
|
|
case ri.Enabled != alter.Enabled: |
|
|
|
|
// different state
|
|
|
|
|
return fmt.Errorf("invalid %s: %v ≠ %v", "enabled", ri.Enabled, alter.Enabled) |
|
|
|
|
case ri.Enabled && !alter.Enabled: |
|
|
|
|
// can't disable via Merge
|
|
|
|
|
return fmt.Errorf("invalid %s: %v → %v", "enabled", ri.Enabled, alter.Enabled) |
|
|
|
|
case !canMergeAddress(ri.Address, alter.Address): |
|
|
|
|
// different address
|
|
|
|
|
return fmt.Errorf("invalid %s: %v ≠ %v", "address", ri.Address, alter.Address) |
|
|
|
@ -42,6 +42,15 @@ func (ri *RingInfo) Merge(alter *RingInfo) error {
|
|
|
|
|
return fmt.Errorf("invalid %s: %s ≠ %s", "keys", ri.Keys, alter.Keys) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ri.unsafeMerge(alter) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (ri *RingInfo) unsafeMerge(alter *RingInfo) error { |
|
|
|
|
// enable via Merge
|
|
|
|
|
if alter.Enabled { |
|
|
|
|
ri.Enabled = true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
switch { |
|
|
|
|
case ri.Keys == nil: |
|
|
|
|
// assign keypair
|
|
|
|
|