allocator

package
v0.0.0-...-fd663ac Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2021 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFull              = errors.New("range is full")
	ErrAllocated         = errors.New("provided IP is already allocated")
	ErrMismatchedNetwork = errors.New("the provided network does not match the current range")
)

Functions

This section is empty.

Types

type Interface

type Interface interface {
	Allocate(net.IP) error
	AllocateNext() (net.IP, error)
	Release(net.IP) error
	ForEach(func(net.IP))
	CIDR() net.IPNet

	// For testing
	Has(ip net.IP) bool
}

copied from k8s.io/kubernetes/pkg/registry/core/service/ipallocator/allocator.go Interface manages the allocation of IP addresses out of a range. Interface should be threadsafe.

type Range

type Range struct {
	Log logr.Logger
	// contains filtered or unexported fields
}

func NewAllocatorCIDRRange

func NewAllocatorCIDRRange(cidr *net.IPNet, client client.Client) (*Range, error)

NewAllocatorCDRRange creates a Range over a net.IPNet

func (*Range) Allocate

func (r *Range) Allocate(ip net.IP) error

func (*Range) AllocateNext

func (r *Range) AllocateNext() (net.IP, error)

func (*Range) CIDR

func (r *Range) CIDR() net.IPNet

func (*Range) ForEach

func (r *Range) ForEach(func(net.IP))

func (*Range) Has

func (r *Range) Has(ip net.IP) bool

For testing

func (*Range) Release

func (r *Range) Release(ip net.IP) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL