statuscalc

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: May 14, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package statuscalc provides utilities for calculating SubnetPool status metrics

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeBlockSizeKey

func NormalizeBlockSizeKey(key string) (string, error)

NormalizeBlockSizeKey ensures a block size key is in the standard format Converts "/24" to "24" and ensures it's a valid integer

Types

type CalculateResult

type CalculateResult struct {
	// AllocatedCount is the total number of allocations
	AllocatedCount int
	// FreeCountBySize maps block sizes to their free count
	// Uses both "24" and "/24" format keys for compatibility
	FreeCountBySize map[string]int
	// AllocatedCIDRs maps CIDRs to their cluster IDs
	AllocatedCIDRs map[string]string
}

CalculateResult contains the results of SubnetPool status calculations

func Calculate

func Calculate(poolCIDR string, allocations []*ipamv1.Subnet, childCIDRs []string) (*CalculateResult, error)

Calculate computes status metrics for a pool based on its CIDR, allocations, and child SubnetPools Returns: - AllocatedCount: Total number of allocations (including child SubnetPools) - FreeCountBySize: Map of blockSize -> free count - AllocatedCIDRs: Map of CIDR -> clusterID - error: Any error that occurred during calculation

Jump to

Keyboard shortcuts

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