util

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CELVarStatuses = "statuses" // Array of adapter statuses
	CELVarResource = "resource" // Full cluster/nodepool object
)

CEL context variable names These constants ensure consistency between environment declaration and activation map

View Source
const CELCostLimit = 10000

CELCostLimit is the maximum cost allowed for CEL expression evaluation. Prevents CPU spikes from misconfigured or pathological expressions. Used by both runtime evaluation and startup validation.

View Source
const RedactedPlaceholder = "***REDACTED***"

RedactedPlaceholder is the string used to replace sensitive field values

Variables

This section is empty.

Functions

func Empty

func Empty[T any]() T

Empty returns an empty value of type T.

func EmptyStringToNil

func EmptyStringToNil(a string) *string

func FromEmptyPtr

func FromEmptyPtr[T any](v *T) *T

FromEmptyPtr emulates ToPtr(FromPtr(x)) sequence

func FromPtr

func FromPtr[T any](v *T) T

FromPtr returns the pointer value or empty.

func GetAccountIDFromContext

func GetAccountIDFromContext(ctx context.Context) string

func MapAdapterToConditionType added in v0.3.1

func MapAdapterToConditionType(adapterName string) string

MapAdapterToConditionType converts an adapter name to a semantic condition type (PascalCase + "Successful" suffix). Used to derive the type name for per-adapter conditions mirrored into resource status (e.g. "adapter1" → "Adapter1Successful", "my-adapter" → "MyAdapterSuccessful").

func MaskSensitiveFields added in v0.3.1

func MaskSensitiveFields(data map[string]interface{}) map[string]interface{}

MaskSensitiveFields redacts adapter data keys matching sensitive patterns before exposing to CEL evaluation context. This prevents accidental leakage of credentials in public API condition messages/reasons.

Keys are checked case-insensitively against sensitivePatterns. Redacted values are replaced with RedactedPlaceholder.

Recursion is limited to maxMaskingDepth to prevent stack overflow (SEC-03).

Examples:

  • "adminPassword" → redacted (contains "password")
  • "pullSecret" → redacted (contains "secret")
  • "gcpServiceAccountKey" → redacted (contains "accountkey")
  • "clusterName" → NOT redacted (no sensitive pattern match)

func NewConditionMappingEnvironment added in v0.3.1

func NewConditionMappingEnvironment() (*cel.Env, error)

NewConditionMappingEnvironment creates a CEL environment for condition mapping with context variables and custom functions. This environment is used both for validation (at config load time) and runtime evaluation.

func NilToEmptyString

func NilToEmptyString(a *string) string

func PtrString

func PtrString(v string) *string

PtrString returns a pointer to the given string.

func ToPtr

func ToPtr[T any](v T) *T

ToPtr returns a pointer copy of value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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