...
1
16
17 package ipallocator
18
19 import (
20 "errors"
21 "fmt"
22 "net"
23
24 api "k8s.io/kubernetes/pkg/apis/core"
25 )
26
27
28
29 type Interface interface {
30 Allocate(net.IP) error
31 AllocateNext() (net.IP, error)
32 Release(net.IP) error
33 ForEach(func(net.IP))
34 CIDR() net.IPNet
35 IPFamily() api.IPFamily
36 Has(ip net.IP) bool
37 Destroy()
38 EnableMetrics()
39
40
41 DryRun() Interface
42 }
43
44 var (
45 ErrFull = errors.New("range is full")
46 ErrAllocated = errors.New("provided IP is already allocated")
47 ErrMismatchedNetwork = errors.New("the provided network does not match the current range")
48 ErrNotReady = errors.New("allocator not ready")
49 )
50
51 type ErrNotInRange struct {
52 IP net.IP
53 ValidRange string
54 }
55
56 func (e *ErrNotInRange) Error() string {
57 return fmt.Sprintf("the provided IP (%v) is not in the valid range. The range of valid IPs is %s", e.IP, e.ValidRange)
58 }
59
View as plain text