Overview
Why Use Version Selectors?
Version selector rules help you:- Enforce release channels - Only stable versions in production
- Block bad versions - Prevent known-bad releases from deploying
- Naming conventions - Require specific version formats
- Feature flags - Control rollout of experimental features
Configuration
Add a version selector rule to your policy:Properties
| Property | Type | Required | Description |
|---|---|---|---|
selector | Selector | Yes | CEL expression to match allowed versions |
description | string | No | Human-readable explanation of the rule |
Selector Expressions
Version selectors use CEL expressions to evaluate version metadata:Available Fields
| Field | Type | Description |
|---|---|---|
version.tag | string | Version tag (e.g., “v1.2.3”) |
version.metadata | object | Custom metadata on the version |
version.createdAt | string | When the version was created |
Common Patterns
Stable Versions Only
Block pre-release versions from production:Semantic Version Pattern
Require semantic versioning format:Block Specific Versions
Prevent known-bad versions from deploying:Release Channel by Metadata
Use version metadata for release channels:Major Version Restriction
Restrict major version changes:Feature Flag Versions
Control feature rollout by version metadata:Selector Operators
| Operator | Description | Example |
|---|---|---|
Equals | Exact match | tag Equals "v1.0.0" |
NotEquals | Not equal | tag NotEquals "v1.0.0" |
In | Value in list | tag In ["v1.0.0", "v1.0.1"] |
NotIn | Value not in list | tag NotIn ["v1.0.0"] |
Contains | String contains | tag Contains "beta" |
DoesNotContain | String does not contain | tag DoesNotContain "rc" |
StartsWith | String starts with | tag StartsWith "v2." |
EndsWith | String ends with | tag EndsWith "-stable" |
Matches | Regex match | tag Matches "^v[0-9]+" |
Exists | Field exists | metadata.approved Exists |
DoesNotExist | Field does not exist | metadata.blocked DoesNotExist |
Best Practices
Environment Guidelines
| Environment | Version Policy |
|---|---|
| Development | Allow all versions |
| QA | Allow all or beta+ |
| Staging | Stable and beta |
| Production | Stable only |
Recommendations
- ✅ Use
descriptionto explain why versions are restricted - ✅ Start permissive and tighten over time
- ✅ Use metadata for release channels instead of parsing tags
- ✅ Document blocked versions with links to issues
- ✅ Test selectors in lower environments first
Anti-Patterns
- ❌ Overly complex regex patterns
- ❌ Blocking without documentation
- ❌ Inconsistent version tagging conventions
- ❌ Forgetting to update blocked version lists
Next Steps
- Policies Overview - Learn about policy structure
- Environment Progression - Control promotion flow
- Selectors - Deep dive into selector syntax