CEL Functions¶
All functions available in Hydra's CEL environment.
Ref Builder¶
The ref builder is a chainable API for constructing dependency edges in ref-parser pick rules.
refBuilder()¶
Creates a new empty ref builder.
.incoming(endpoint)¶
Creates a ref pointing to the current resource from the endpoint.
.outgoing(endpoint)¶
Creates a ref pointing from the current resource to the endpoint.
.label(string)¶
Sets the semantic label for the ref.
.tag(string)¶
Adds a behavioral tag to the ref.
.desc(string)¶
Adds a description to the ref.
.attribute(key, value)¶
Adds a metadata attribute.
Endpoint Functions¶
id(gvk, ns, name)¶
Creates a resource endpoint from GVK, namespace, and name variables:
id(gvk, ns, name) // Current resource's identity
id("v1/Namespace", "", ns) // Namespace resource
id("v1/ServiceAccount", ns, name) // ServiceAccount in same ns
id(o.apiVersion + "/" + o.kind, ns, o.name) // From ownerReference
idString(gvk, ns, name)¶
Like id() but all arguments are treated as string literals:
ref(provider, value)¶
Creates a non-ID reference endpoint (for external/abstract references):
Cluster Inventory Functions¶
Available only when cluster state is loaded.
clusterEntities()¶
Returns all entities from the cluster inventory:
clusterEntities(selector)¶
Returns entities prefiltered by a selector object. Supported fields follow Hydra's resource
selector shape, for example group, version, kind, apiVersion, gvk, namespace/ns,
gvkn, name, and id.
clusterEntities({"namespace": ns}).filter(e, e.gvk == "events.k8s.io/v1/Event")
clusterEntities({"namespace": ns, "gvk": "events.k8s.io/v1/Event"})
managedNamespaces()¶
Returns all namespaces that are managed by Hydra apps.
templateEntities()¶
Returns all entities from rendered templates.
templateEntities(selector)¶
Returns template entities prefiltered by a selector object:
involvedObjectEvents(workloadId)¶
Returns Events related to a specific workload:
Utility Functions¶
has(field)¶
Null-safe field existence check:
string(value)¶
Convert a value to string:
annotations(entity) / labels(entity)¶
Extract annotations or labels as map[string]string:
ordinalRange(start, count)¶
Generate a sequence of integers:
List Operations¶
Standard CEL list methods:
list.map(item, expr) // Transform each element
list.filter(item, condition) // Keep matching elements
list.size() // Count elements
string.startsWith(prefix) // String prefix check
string.matches(regex) // Regex match
list.contains(elem) // Element membership
Example: Map ownerReferences to Refs¶
entity.metadata.ownerReferences.filter(o, has(o.controller) && o.controller).map(o,
refBuilder().outgoing(id(o.apiVersion + "/" + o.kind, ns, o.name))
.label("owner")
.attribute("kubernetes:ownerController", "true")
)