ipallocator

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 29 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 Allocator

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

func New

func (*Allocator) Allocate

func (a *Allocator) Allocate(ctx context.Context, claimer *Claimer, ip netip.Addr) error

func (*Allocator) AllocateNext

func (a *Allocator) AllocateNext(
	ctx context.Context,
	claimer *Claimer,
) (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(ctx context.Context, claimer *Claimer, 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,
	requesterFor func(obj runtime.Object) (Requester, error),
) *Allocators

func (*Allocators) AllocateCreate

func (a *Allocators) AllocateCreate(ctx context.Context, obj client.Object, dryRun bool) (Transaction, error)

func (*Allocators) AllocateUpdate

func (a *Allocators) AllocateUpdate(ctx context.Context, obj, oldObj client.Object, dryRun bool) (Transaction, error)

func (*Allocators) Release

func (a *Allocators) Release(ctx context.Context, obj client.Object, dryRun bool)

type Claimer added in v0.3.0

type Claimer struct {
	// Object is the claiming object.
	Object client.Object
	// Resource is the API resource of the claiming object.
	Resource string
	// ExternalVersion is the external API version to use for references.
	ExternalVersion string
}

Claimer represents a claimer of an IP.

type Interface

type Interface interface {
	IPFamily() corev1.IPFamily
	Allocate(ctx context.Context, claimer *Claimer, ip netip.Addr) error
	AllocateNext(ctx context.Context, claimer *Claimer) (netip.Addr, error)
	Release(ctx context.Context, claimer *Claimer, ip netip.Addr) error
	DryRun() Interface
}

type Request

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

type Requester added in v0.3.0

type Requester interface {
	GetRequests() []Request
	SetIP(idx int, 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