docs: document Trait removes and toEndpointResources macro#716
Conversation
|
Warning Review limit reached
More reviews will be available in 46 minutes and 45 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (3)
📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR adds documentation for two new platform engineer capabilities: the ChangesFeature Documentation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
yashodgayashan
left a comment
There was a problem hiding this comment.
If you need to have this for new release please add it to version docs as well
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/reference/cel/helper-functions.md`:
- Around line 618-643: The example conditional treats only an absent optional as
a fallback but not an explicitly-present empty list; update the CEL expression
that uses workload.toEndpointResources(endpoint.key) so it treats an empty list
the same as no value. Concretely, replace the .hasValue() / .value() branch with
a check on the resolved list (e.g. use
workload.toEndpointResources(endpoint.key).orValue([]).size() > 0 ?
workload.toEndpointResources(endpoint.key).orValue([]).map(r, {...}) :
oc_omit()), referencing workload.toEndpointResources(endpoint.key) and the
existing map(r, {"method": ...}) so an empty array will trigger oc_omit() like a
missing optional.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: c4f0f02c-65c7-4188-adea-86461ed3fc39
📒 Files selected for processing (3)
docs/platform-engineer-guide/component-types/patching-syntax.mddocs/reference/cel/context-variables.mddocs/reference/cel/helper-functions.md
| **Returns:** a CEL **optional** wrapping a list of route objects. Consume it with `.orValue([])`, or guard with `.hasValue()` / `.value()`. Each route object contains: | ||
|
|
||
| | Field | Type | Description | | ||
| | --------- | ------ | --------------------------------------------------------------------------------------- | | ||
| | `kind` | string | Protocol of the route: `"HTTP"` or `"gRPC"` | | ||
| | `service` | string | Fully-qualified gRPC service name (e.g. `greeter.Greeter`). Empty for HTTP routes | | ||
| | `method` | string | HTTP verb (`GET`/`POST`/...) for HTTP routes, or the gRPC method name (e.g. `SayHello`) | | ||
| | `path` | string | HTTP path template (e.g. `/v1/pets/{id}`). Empty for gRPC routes | | ||
|
|
||
| Routes are returned in a deterministic (sorted) order so rendered output is stable. | ||
|
|
||
| :::note Best-effort extraction | ||
| A missing, empty, or unparseable schema (or an endpoint protocol with no extractor, such as TCP/UDP) yields an empty list — never a render failure. Schema format is inferred from the endpoint type (`HTTP` → OpenAPI, `gRPC` → protobuf) unless `workload.endpoints[name].schema.type` overrides it. Only OpenAPI and protobuf extractors exist today; GraphQL and AsyncAPI are reserved and currently degrade to an empty list. | ||
| ::: | ||
|
|
||
| **Examples:** | ||
|
|
||
| ```yaml | ||
| # gRPC: render one GRPCRoute match per (service, method) from the proto schema. | ||
| # Falls back to a catch-all rule (no matches) when the endpoint has no parseable schema. | ||
| rules: | ||
| - matches: >- | ||
| ${workload.toEndpointResources(endpoint.key).hasValue() | ||
| ? workload.toEndpointResources(endpoint.key).value().map(r, | ||
| {"method": {"type": "Exact", "service": r.service, "method": r.method}}) | ||
| : oc_omit()} |
There was a problem hiding this comment.
Align the fallback contract before publishing the example.
The note says missing/unparseable schemas yield an empty list, but the gRPC sample only omits matches when the optional is absent. If the helper returns a present optional with [], this example renders matches: [] instead of the catch-all behavior described.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docs/reference/cel/helper-functions.md` around lines 618 - 643, The example
conditional treats only an absent optional as a fallback but not an
explicitly-present empty list; update the CEL expression that uses
workload.toEndpointResources(endpoint.key) so it treats an empty list the same
as no value. Concretely, replace the .hasValue() / .value() branch with a check
on the resolved list (e.g. use
workload.toEndpointResources(endpoint.key).orValue([]).size() > 0 ?
workload.toEndpointResources(endpoint.key).orValue([]).map(r, {...}) :
oc_omit()), referencing workload.toEndpointResources(endpoint.key) and the
existing map(r, {"method": ...}) so an empty array will trigger oc_omit() like a
missing optional.
- Add a "Removing Resources" section to the Patching Syntax page covering the Trait spec.removes section: target shape, execution order, the workload-kind removal restriction, and forEach removal. - Document the opt-in workload.toEndpointResources() CEL macro under Workload Helpers, with route fields and gRPC/HTTP examples, and link to it from the workload context-variables reference. Signed-off-by: Chathuranga Dassanayake <chathura2ihl@gmail.com>
bf4d243 to
9447a97
Compare
Purpose
Related Issues
Checklist
sidebars.tsif adding a new documentation pagenpm run startto preview the changes locallynpm run buildto ensure the build passes without errors