Documentation
¶
Index ¶
- Constants
- Variables
- func ConditionTypeProvider(base types.Provider) types.Provider
- func Hash(options ...HashOption) cel.EnvOption
- func IsConditionType(t *cel.Type) bool
- func IsValidConditionStatus(s string) bool
- func JSON(options ...JSONOption) cel.EnvOption
- func Lists(options ...ListsOption) cel.EnvOption
- func Maps(options ...MapsOption) cel.EnvOption
- func Omit() cel.EnvOption
- func Random() cel.EnvOption
- func Runtime() cel.EnvOption
- type Condition
- type HashOption
- type JSONOption
- type ListsOption
- type MapsOption
Constants ¶
const ConditionTypeName = "kro.run.Condition"
ConditionTypeName is the CEL type name for Condition values.
const RuntimeTypeName = "kro.run.Runtime"
RuntimeTypeName is the CEL type name for the singleton runtime variable.
const RuntimeVarName = "runtime"
RuntimeVarName is the identifier kro injects into the CEL evaluation context for the runtime variable.
Variables ¶
var RuntimeSingleton ref.Val = &runtimeValue{}
RuntimeSingleton is the stateless value injected at evaluation time as the `runtime` variable.
Functions ¶
func ConditionTypeProvider ¶ added in v0.9.3
ConditionTypeProvider wraps a base types.Provider so the CEL type-checker can resolve the kro.run.Condition type and its four string fields, letting a misspelled field access fail at build time instead of evaluation time. cel.CustomTypeProvider replaces the environment's provider outright, so this wrapper must be outermost and delegate everything else to base.
func Hash ¶ added in v0.9.1
func Hash(options ...HashOption) cel.EnvOption
Hash returns a CEL library that provides hash functions for generating checksums and identifiers.
Library functions:
hash.fnv64a() computes the FNV-1a 64-bit hash of a string.
The function takes one argument: - value: a string to hash
Returns a bytes value containing the hash (8 bytes).
FNV-1a is a fast, non-cryptographic hash function suitable for checksums, identifiers, and cache keys. It is the recommended hash function for all use cases in kro.
Example usage:
base64.encode(hash.fnv64a('hello world'))
hash.fnv64a(schema.spec.data).base64()
hash.sha256() computes the SHA-256 hash of a string.
The function takes one argument: - value: a string to hash
Returns a bytes value containing the hash (32 bytes).
SHA-256 is provided for backwards compatibility only. Use hash.fnv() for new code unless you have a specific requirement for SHA-256.
Example usage:
base64.encode(hash.sha256('hello world'))
hash.sha256(schema.spec.data).base64()
hash.md5() computes the MD5 hash of a string.
The function takes one argument: - value: a string to hash
Returns a bytes value containing the hash (16 bytes).
MD5 is provided for backwards compatibility only. Use hash.fnv() for new code unless you have a specific requirement for MD5.
Example usage:
base64.encode(hash.md5('hello world'))
hash.md5(schema.spec.data).base64()
func IsConditionType ¶ added in v0.9.3
IsConditionType reports whether t is the CEL Condition type returned by runtime.newCondition and runtime.condition.
func IsValidConditionStatus ¶ added in v0.9.3
IsValidConditionStatus reports whether s is a valid Condition status (True, False, or Unknown).
func JSON ¶ added in v0.9.0
func JSON(options ...JSONOption) cel.EnvOption
JSON returns a CEL library that provides JSON parsing functions.
Library functions:
json.unmarshal() parses a JSON string and returns the parsed value.
The function takes one argument: - jsonString: a string containing JSON
Returns a dynamic type that can be: - map for JSON objects - list for JSON arrays - string, int, double, bool for JSON primitives - null for JSON null
Example usage:
json.unmarshal('{"name": "test"}').name
json.unmarshal('[1,2,3]')[0]
json.unmarshal(schema.spec.config).enabled
json.marshal() converts a CEL value to a JSON string.
The function takes one argument: - value: any CEL value (map, list, string, number, bool, null)
Returns a JSON string representation of the value.
Example usage:
json.marshal({"name": "test", "count": 42})
json.marshal([1, 2, 3])
json.marshal(schema.spec.config)
func Lists ¶ added in v0.9.0
func Lists(options ...ListsOption) cel.EnvOption
Lists returns a CEL library that provides index-mutation functions for lists. All functions are pure — they return a new list and do not modify the input.
SetAtIndex ¶
Returns a new list with the element at index replaced by value. Index must be in [0, size(list)).
lists.setAtIndex(list(T), int, T) -> list(T)
Examples:
lists.setAtIndex([1, 2, 3], 1, 99) // [1, 99, 3] lists.setAtIndex(["a", "b", "c"], 0, "z") // ["z", "b", "c"]
InsertAtIndex ¶
Returns a new list with value inserted before the element at index. Index must be in [0, size(list)]. An index equal to size(list) appends.
lists.insertAtIndex(list(T), int, T) -> list(T)
Examples:
lists.insertAtIndex([1, 2, 3], 1, 99) // [1, 99, 2, 3] lists.insertAtIndex([1, 2, 3], 0, 99) // [99, 1, 2, 3] lists.insertAtIndex([1, 2, 3], 3, 99) // [1, 2, 3, 99]
RemoveAtIndex ¶
Returns a new list with the element at index removed. Index must be in [0, size(list)).
lists.removeAtIndex(list(T), int) -> list(T)
Examples:
lists.removeAtIndex([1, 2, 3], 1) // [1, 3] lists.removeAtIndex([1, 2, 3], 0) // [2, 3] lists.removeAtIndex([1, 2, 3], 2) // [1, 2]
func Maps ¶ added in v0.9.0
func Maps(options ...MapsOption) cel.EnvOption
Maps returns a cel.EnvOption to configure extended functions for map manipulation.
Merge ¶
Merges two maps. Keys from the second map overwrite already available keys in the first map. Keys must be of type string, value types must be identical in the maps merged.
map(string, T).merge(map(string, T)) -> map(string, T)
Examples:
{}.merge({}) == {}
{}.merge({'a': 1}) == {'a': 1}`},
{}.merge({'a': 2.1}) == {'a': 2.1}`},
{}.merge({'a': 'foo'}) == {'a': 'foo'}`},
{'a': 1}.merge({}) == {'a': 1}`},
{'a': 1}.merge({'b': 2}) == {'a': 1, 'b': 2}`},
{'a': 1}.merge({'a': 2, 'b': 2}) == {'a': 2, 'b': 2}`},
DeepMerge ¶
Recursively merges two maps. Keys from the second map overwrite keys in the first; nested maps are merged rather than replaced. Lists and scalars are replaced. Unlike merge, accepts dyn/object-typed values.
dyn.deepMerge(dyn) -> dyn
Examples:
{'a': {'x': 1}}.deepMerge({'a': {'y': 2}}) == {'a': {'x': 1, 'y': 2}}
{'a': {'x': 1}}.deepMerge({'a': {'x': 9}}) == {'a': {'x': 9}}
func Omit ¶ added in v0.9.0
Omit returns a cel.EnvOption that registers the omit() function.
omit() is a zero-argument function that returns a sentinel value. When the resolver encounters this sentinel as a field's resolved value, it removes the field (or array element) from the rendered object instead of writing it.
omit() is only valid in standalone template field expressions. It must not be used in includeWhen, readyWhen, forEach, or string template fragments.
Example usage:
policy: ${schema.spec.policy != "" ? schema.spec.policy : omit()}
scaling: ${schema.spec.autoscaling.enabled ? schema.spec.scaling : omit()}
func Random ¶
Random returns a CEL library that provides deterministic random generation functions.
Library functions:
random.seededString(length: int, seed: string) → string
Generates a deterministic random alphanumeric string of the given length using the seed. Same length and seed always produce the same string.
random.seededString(10, schema.metadata.uid)
random.seededInt(min: int, max: int, seed: string) → int
Generates a deterministic random integer in [min, max) using the seed. Same min, max, and seed always produce the same integer.
random.seededInt(30000, 32768, schema.metadata.uid)
func Runtime ¶ added in v0.9.3
Runtime returns a CEL library providing the `runtime` variable used to author custom status conditions on RGD instances:
runtime.newCondition({type: 'X', status: 'True', reason: '', message: ''})
runtime.condition(schema, 'ResourcesReady').status == 'True'
newCondition constructs a Condition from a map with keys type, status, reason, and message (type and status required; status must be True, False, or Unknown). condition looks up a condition by type on obj.status.conditions[], returning an empty Condition when not found.
Types ¶
type Condition ¶ added in v0.9.3
Condition is the Go representation of a CEL Condition value, mirroring the shape of kro's wire conditions. Field names are prefixed where they would collide with the ref.Val interface (Type() method).
func (*Condition) ConvertToNative ¶ added in v0.9.3
func (*Condition) ConvertToType ¶ added in v0.9.3
type HashOption ¶ added in v0.9.1
type HashOption func(*hashLibrary) *hashLibrary
HashOption is a functional option for configuring the hash library.
func HashVersion ¶ added in v0.9.1
func HashVersion(version uint32) HashOption
HashVersion configures the version of the hash library.
type JSONOption ¶ added in v0.9.0
type JSONOption func(*jsonLibrary) *jsonLibrary
JSONOption is a functional option for configuring the json library.
func JSONVersion ¶ added in v0.9.0
func JSONVersion(version uint32) JSONOption
JSONVersion configures the version of the json library.
type ListsOption ¶ added in v0.9.0
type ListsOption func(*listsLibrary) *listsLibrary
ListsOption is a functional option for configuring the lists library.
func ListsVersion ¶ added in v0.9.0
func ListsVersion(version uint32) ListsOption
ListsVersion configures the version of the lists library.
The version limits which functions are available. Only functions introduced below or equal to the given version are included in the library. If this option is not set, all functions are available.
See the library documentation to determine which version a function was introduced. If the documentation does not state which version a function was introduced, it can be assumed to be introduced at version 0, when the library was first created.
type MapsOption ¶ added in v0.9.0
type MapsOption func(*mapsLib) *mapsLib
func MapsVersion ¶ added in v0.9.0
func MapsVersion(version uint32) MapsOption
MapsVersion configures the version of the maps library.
The version limits which functions are available. Only functions introduced below or equal to the given version included in the library. If this option is not set, all functions are available.
See the library documentation to determine which version a function was introduced. If the documentation does not state which version a function was introduced, it can be assumed to be introduced at version 0, when the library was first created.