Skip to main content
Ctrlplane uses CEL (Common Expression Language) for writing powerful selectors and matching expressions. CEL is a simple, fast, and safe expression language developed by Google.

Overview

CEL expressions are used in:
  • Resource selectors — Match resources to environments
  • Policy selectors — Target policies to specific releases
  • Relationship rules — Define how entities connect

Basic Syntax

Accessing Fields

Comparison Operators

Logical Operators

Arithmetic Operators

Available Variables

Resource Context

When writing resource selectors:

Environment Context

When writing environment selectors:

Deployment Context

When writing deployment selectors:

Version Context

When writing version selectors:

String Functions

contains

Check if a string contains a substring:

startsWith

Check if a string starts with a prefix:

endsWith

Check if a string ends with a suffix:

matches

Regular expression matching:

size

Get string length:

toLowerCase / toUpperCase

Case conversion:

List Operations

in

Check if a value is in a list:

size

Get list length:

exists

Check if any element matches:

all

Check if all elements match:

Map Operations

has

Check if a key exists in a map:
This is safer than direct access when the key might not exist.

Key Access

Access map values:

Conditional Expressions

Ternary Operator

Null-Safe Access

Use has() for optional fields:
Or use the default pattern:

Common Patterns

Production Resources

Multi-Region Targeting

Kind Filtering

Team-Based Selection

Exclude Deprecated

Critical Tier in Production

US Regions Only

Canary Resources

Complex Multi-Condition

Policy Selector Examples

Target Production Environment

Target Critical Deployments

Target Specific Environment + Deployment

Version Filtering

Relationship Rule Examples

Match by Region

Match by Account

Type Coercion

CEL is strongly typed. Use these functions to convert types:

String to Integer

Integer to String

Type Checking

Error Handling

Safe Field Access

Always use has() for optional fields to avoid runtime errors:

Default Values

Provide defaults for optional fields:

Performance Tips

Prefer Simple Expressions

Short-Circuit Evaluation

CEL uses short-circuit evaluation. Put cheap checks first:

Avoid Redundant Checks

Debugging

Test Expressions

Use the API to test your CEL expressions:

Common Errors

Escaping Quotes

In YAML, escape quotes properly:
In JSON:

Reference

Reserved Keywords

These words are reserved in CEL:
  • true, false, null
  • in
  • as
  • break, const, continue, else, for, function, if, import, let, loop, package, namespace, return, var, void, while

Operator Precedence

From highest to lowest:
  1. () - Grouping
  2. . [] - Member access
  3. - ! - Unary
  4. * / % - Multiplicative
  5. + - - Additive
  6. < <= > >= in - Relational
  7. == != - Equality
  8. && - Logical AND
  9. || - Logical OR
  10. ?: - Conditional

Next Steps

Selectors

Use CEL in selectors

Relationships

CEL in relationship rules

Policies

Target policies with CEL

Environments

Dynamic environment membership