labels

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Label prefix
	KongctlPrefix = "KONGCTL-"

	// Label keys (using prefix to avoid repetition)
	NamespaceKey = KongctlPrefix + "namespace"
	ProtectedKey = KongctlPrefix + "protected"

	// Deprecated label keys (kept for backward compatibility)
	// TODO: Remove in future version after migration period
	ManagedKey     = KongctlPrefix + "managed"      // Deprecated: use namespace presence instead
	LastUpdatedKey = KongctlPrefix + "last-updated" // Deprecated: not needed

	// Environment variables
	DebugEnvVar = "KONGCTL_DEBUG"

	// Label values
	TrueValue  = "true"
	FalseValue = "false"
)

Label keys used by kongctl

Variables

This section is empty.

Functions

func AddManagedLabels

func AddManagedLabels(labels map[string]string, namespace string) map[string]string

AddManagedLabels adds kongctl management labels Deprecated: Use BuildCreateLabels or BuildUpdateLabels instead

func AddManagedLabelsToPointerMap

func AddManagedLabelsToPointerMap(labels map[string]*string, namespace string) map[string]*string

AddManagedLabelsToPointerMap adds kongctl management labels to a pointer map Deprecated: Use BuildCreateLabels or BuildUpdateLabels instead

func BuildCreateLabels

func BuildCreateLabels(userLabels map[string]string, namespace string, protection any) map[string]string

BuildCreateLabels prepares labels for resource creation Adds management labels and handles protection status

func BuildUpdateLabels

func BuildUpdateLabels(
	desiredLabels, currentLabels map[string]string,
	namespace string,
	protection any,
) map[string]*string

BuildUpdateLabels prepares labels for resource update with removal support Returns a pointer map to support nil values for label removal

func BuildUpdateStringLabels added in v0.1.6

func BuildUpdateStringLabels(
	desiredLabels, currentLabels map[string]string,
	namespace string,
	protection any,
) map[string]string

BuildUpdateStringLabels prepares labels for update operations that expect map[string]string Nil values in the pointer-based representation are treated as deletions and thus omitted

func CompareUserLabels

func CompareUserLabels(current, desired map[string]string) bool

CompareUserLabels compares only user-defined labels between current and desired states Returns true if user labels differ, ignoring KONGCTL system labels

func ConvertStringMapToPointerMap

func ConvertStringMapToPointerMap(labels map[string]string) map[string]*string

ConvertStringMapToPointerMap converts map[string]string to map[string]*string

func DenormalizeLabels

func DenormalizeLabels(labels map[string]string) map[string]*string

DenormalizeLabels converts non-pointer map to pointer map for SDK

func ExtractLabelsFromField

func ExtractLabelsFromField(field any) map[string]string

ExtractLabelsFromField extracts labels from a planner field that could be various types Handles type assertions for map[string]any, map[string]string, etc.

func GetUserLabels

func GetUserLabels(labels map[string]string) map[string]string

GetUserLabels returns labels without KONGCTL prefix

func IsKongctlLabel

func IsKongctlLabel(key string) bool

IsKongctlLabel checks if label key is kongctl-managed

func IsManagedResource

func IsManagedResource(labels map[string]string) bool

IsManagedResource checks if resource has namespace label (new criteria for managed resources)

func IsProtectedResource

func IsProtectedResource(labels map[string]string) bool

IsProtectedResource checks if resource has protected label set to true

func NormalizeLabels

func NormalizeLabels(labels map[string]*string) map[string]string

NormalizeLabels converts pointer map to non-pointer map

func ValidateLabel

func ValidateLabel(key string) error

ValidateLabel ensures label key follows Konnect rules

Types

This section is empty.

Jump to

Keyboard shortcuts

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