ipallocator

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAllocated = errors.New("provided IP is already allocated")
	ErrNotFound  = errors.New("provided IP was not found")
)

Functions

This section is empty.

Types

type Accessor

type Accessor interface {
	GetNamespace() string
	GetName() string
	GetUID() types.UID
	GetRequests() []Request
	SetIP(idx int, addr netip.Addr)
}

type Allocator

type Allocator struct {
	// contains filtered or unexported fields
}

func (*Allocator) Allocate

func (a *Allocator) Allocate(namespace string, claimRef v1alpha1.IPClaimRef, ip netip.Addr) error

func (*Allocator) AllocateNext

func (a *Allocator) AllocateNext(
	namespace string,
	claimRef v1alpha1.IPClaimRef,
	version, kind string,
) (netip.Addr, error)

func (*Allocator) DryRun

func (a *Allocator) DryRun() Interface

func (*Allocator) IPFamily

func (a *Allocator) IPFamily() corev1.IPFamily

func (*Allocator) Release

func (a *Allocator) Release(namespace string, ip netip.Addr) error

type Allocators

type Allocators struct {
	// contains filtered or unexported fields
}

func NewAllocators

func NewAllocators(
	allocByIPFamily map[corev1.IPFamily]Interface,
	gv schema.GroupVersion,
	kind, resource string,
	accessorFor func(obj runtime.Object) (Accessor, error),
) *Allocators

func (*Allocators) AllocateCreate

func (a *Allocators) AllocateCreate(obj runtime.Object, dryRun bool) (Transaction, error)

func (*Allocators) AllocateUpdate

func (a *Allocators) AllocateUpdate(obj, oldObj runtime.Object, dryRun bool) (Transaction, error)

func (*Allocators) Release

func (a *Allocators) Release(obj runtime.Object, dryRun bool)

type Interface

type Interface interface {
	IPFamily() corev1.IPFamily
	Allocate(namespace string, claimRef v1alpha1.IPClaimRef, ip netip.Addr) error
	AllocateNext(namespace string, claimRef v1alpha1.IPClaimRef, version, kind string) (netip.Addr, error)
	Release(namespace string, ip netip.Addr) error
	DryRun() Interface
}

type Request

type Request struct {
	IPFamily corev1.IPFamily
	Addr     netip.Addr
}

type Transaction

type Transaction interface {
	Commit()
	Revert()
}

Jump to

Keyboard shortcuts

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