Skip to content

docs: document Trait removes and toEndpointResources macro#716

Merged
ChathurangaKCD merged 1 commit into
openchoreo:mainfrom
ChathurangaKCD:document-Trait-removes-and-toEndpointResources-macro
Jun 12, 2026
Merged

docs: document Trait removes and toEndpointResources macro#716
ChathurangaKCD merged 1 commit into
openchoreo:mainfrom
ChathurangaKCD:document-Trait-removes-and-toEndpointResources-macro

Conversation

@ChathurangaKCD

@ChathurangaKCD ChathurangaKCD commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Purpose

  • 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.

Related Issues

Include any related issues that are resolved by this PR.

Checklist

  • Updated sidebars.ts if adding a new documentation page
  • Run npm run start to preview the changes locally
  • Run npm run build to ensure the build passes without errors
  • Verified all links are working (no broken links)

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@ChathurangaKCD, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 09abb384-3adf-47c8-91c6-faa7fbec693a

📥 Commits

Reviewing files that changed from the base of the PR and between bf4d243 and 9447a97.

⛔ Files ignored due to path filters (3)
  • versioned_docs/version-v1.2.0-m.1/platform-engineer-guide/component-types/patching-syntax.md is excluded by !versioned_docs/**
  • versioned_docs/version-v1.2.0-m.1/reference/cel/context-variables.md is excluded by !versioned_docs/**
  • versioned_docs/version-v1.2.0-m.1/reference/cel/helper-functions.md is excluded by !versioned_docs/**
📒 Files selected for processing (3)
  • docs/platform-engineer-guide/component-types/patching-syntax.md
  • docs/reference/cel/context-variables.md
  • docs/reference/cel/helper-functions.md
📝 Walkthrough

Walkthrough

This PR adds documentation for two new platform engineer capabilities: the spec.removes mechanism for deleting resources in Traits, and a new workload helper function workload.toEndpointResources() for extracting route information from endpoint schemas. All changes are documentation-only additions across three reference and guide files.

Changes

Feature Documentation

Layer / File(s) Summary
Resource removal via spec.removes
docs/platform-engineer-guide/component-types/patching-syntax.md
Trait spec.removes targets resources by GVK with optional where filters to delete them. Documentation shows YAML structure (including targetPlane and forEach/var), clarifies execution order relative to creates and patches, provides configuration examples, and warns that built-in workload resource GVKs in apps/batch cannot be removed via admission webhook.
Workload endpoint helper documentation
docs/reference/cel/context-variables.md, docs/reference/cel/helper-functions.md
New workload.toEndpointResources(endpointName) helper parses endpoint schemas (OpenAPI for HTTP, protobuf for gRPC) and returns a CEL optional containing a deterministic list of route objects. Each route includes protocol kind, method name, gRPC service name, and HTTP path template. Helper operates best-effort: unparseable or missing schemas yield empty lists. Documentation includes examples for unwrapping the optional and generating per-route Gateway matches.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • VajiraPrabuddhaka
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the two main documentation additions: Trait removes section and toEndpointResources macro.
Description check ✅ Passed The description includes Purpose and Related Issues sections as required, but all four checklist items remain unchecked despite being documentation changes that likely require these verification steps.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

yashodgayashan
yashodgayashan previously approved these changes Jun 12, 2026

@yashodgayashan yashodgayashan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you need to have this for new release please add it to version docs as well

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 007f12e and bf4d243.

📒 Files selected for processing (3)
  • docs/platform-engineer-guide/component-types/patching-syntax.md
  • docs/reference/cel/context-variables.md
  • docs/reference/cel/helper-functions.md

Comment on lines +618 to +643
**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()}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

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>
@ChathurangaKCD ChathurangaKCD force-pushed the document-Trait-removes-and-toEndpointResources-macro branch from bf4d243 to 9447a97 Compare June 12, 2026 13:55
@ChathurangaKCD ChathurangaKCD merged commit bc62e67 into openchoreo:main Jun 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants