{"modulePath":"github.com/openshift-hyperfleet/hyperfleet-api","version":"v0.4.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package util\n\n## Constants\n\n```go\nconst (\n\tCELVarStatuses = \"statuses\" // Array of adapter statuses\n\tCELVarResource = \"resource\" // Full cluster/nodepool object\n)\n```\nCEL context variable names These constants ensure consistency between environment declaration and activation map\n\n```go\nconst CELCostLimit = 10000\n```\nCELCostLimit 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.\n\n```go\nconst RedactedPlaceholder = \"***REDACTED***\"\n```\nRedactedPlaceholder is the string used to replace sensitive field values\n\n## Functions\n\n```go\nfunc Empty[T any]() T\n```\nEmpty returns an empty value of type T.\n\n```go\nfunc EmptyStringToNil(a string) *string\n```\n\n```go\nfunc FromEmptyPtr[T any](v *T) *T\n```\nFromEmptyPtr emulates ToPtr(FromPtr(x)) sequence\n\n```go\nfunc FromPtr[T any](v *T) T\n```\nFromPtr returns the pointer value or empty.\n\n```go\nfunc GetAccountIDFromContext(ctx context.Context) string\n```\n\n```go\nfunc MapAdapterToConditionType(adapterName string) string\n```\nMapAdapterToConditionType 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\").\n\n```go\nfunc MaskSensitiveFields(data map[string]interface{}) map[string]interface{}\n```\nMaskSensitiveFields 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.\n\nKeys are checked case-insensitively against sensitivePatterns. Redacted values are replaced with RedactedPlaceholder.\n\nRecursion is limited to maxMaskingDepth to prevent stack overflow (SEC-03).\n\nExamples:\n\n  - \"adminPassword\" → redacted (contains \"password\")\n  - \"pullSecret\" → redacted (contains \"secret\")\n  - \"gcpServiceAccountKey\" → redacted (contains \"accountkey\")\n  - \"clusterName\" → NOT redacted (no sensitive pattern match)\n\n```go\nfunc NewConditionMappingEnvironment() (*cel.Env, error)\n```\nNewConditionMappingEnvironment 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.\n\n```go\nfunc NilToEmptyString(a *string) string\n```\n\n```go\nfunc PtrString(v string) *string\n```\nPtrString returns a pointer to the given string.\n\n```go\nfunc ToPtr[T any](v T) *T\n```\nToPtr returns a pointer copy of value.\n\n","path":"github.com/openshift-hyperfleet/hyperfleet-api/pkg/util","name":"util","synopsis":"","isRedistributable":true}
