Skip to content

feat(catalog): honor skip-template-generation annotation on component and resource types#641

Open
isuruRuhu wants to merge 1 commit into
openchoreo:mainfrom
isuruRuhu:feat/skip-template-generation-annotation
Open

feat(catalog): honor skip-template-generation annotation on component and resource types#641
isuruRuhu wants to merge 1 commit into
openchoreo:mainfrom
isuruRuhu:feat/skip-template-generation-annotation

Conversation

@isuruRuhu

@isuruRuhu isuruRuhu commented Jun 18, 2026

Copy link
Copy Markdown

Purpose

To hide a (Cluster)ComponentType's or (Cluster)ResourceType's auto-generated "create" card from the console via an annotation.

Goals

Describe the solutions that this feature/fix will introduce to resolve the problems described above

Approach

Describe how you are implementing the solutions. Include an animated GIF or screenshot if the change affects the UI (email documentation@wso2.com to review all UI text). Include a link to a Markdown file or Google doc if the feature write-up is too long to paste here.

User stories

Summary of user stories addressed by this change>

Release note

Brief description of the new feature or bug fix as it will appear in the release notes

Documentation

Link(s) to product documentation that addresses the changes of this PR. If no doc impact, enter “N/A” plus brief explanation of why there’s no doc impact

Training

Link to the PR for changes to the training content in https://github.com/wso2/WSO2-Training, if applicable

Certification

Type “Sent” when you have provided new/updated certification questions, plus four answers for each question (correct answer highlighted in bold), based on this change. Certification questions/answers should be sent to certification@wso2.com and NOT pasted in this PR. If there is no impact on certification exams, type “N/A” and explain why.

Marketing

Link to drafts of marketing content that will describe and promote this feature, including product page changes, technical articles, blog posts, videos, etc., if applicable

Automation tests

  • Unit tests

    Code coverage information

  • Integration tests

    Details about the test cases and coverage

Security checks

Samples

Provide high-level details about the samples related to this feature

Related PRs

List any other related PRs

Migrations (if applicable)

Describe migration steps and platforms on which migration has been tested

Test environment

List all JDK versions, operating systems, databases, and browser/versions on which this feature/fix was tested

Learning

Describe the research phase and any blog posts, patterns, libraries, or add-ons you used to solve the problem.

Summary by CodeRabbit

  • New Features
    • Resources can now opt out of auto-generated Template emission by setting openchoreo.dev/skip-template-generation: "true" on ComponentType, ResourceType, ClusterComponentType, or ClusterResourceType.
  • Bug Fixes
    • When the opt-out annotation is added, any previously emitted Templates are actively removed in both periodic full syncs and event-driven updates.
  • Tests
    • Added coverage to verify the opt-out behavior and ensure Template handling and schema requests follow the annotation.

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5ef466dd-145c-49eb-bf9b-32ae25bae030

📥 Commits

Reviewing files that changed from the base of the PR and between 9fd6be9 and 272c084.

📒 Files selected for processing (8)
  • .changeset/skip-template-generation-annotation.md
  • packages/openchoreo-client-node/src/index.ts
  • packages/openchoreo-client-node/src/resource-utils.test.ts
  • packages/openchoreo-client-node/src/resource-utils.ts
  • plugins/catalog-backend-module-openchoreo/src/provider/EventDeltaApplier.test.ts
  • plugins/catalog-backend-module-openchoreo/src/provider/EventDeltaApplier.ts
  • plugins/catalog-backend-module-openchoreo/src/provider/OpenChoreoEntityProvider.test.ts
  • plugins/catalog-backend-module-openchoreo/src/provider/OpenChoreoEntityProvider.ts
✅ Files skipped from review due to trivial changes (2)
  • .changeset/skip-template-generation-annotation.md
  • packages/openchoreo-client-node/src/index.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • packages/openchoreo-client-node/src/resource-utils.ts
  • plugins/catalog-backend-module-openchoreo/src/provider/OpenChoreoEntityProvider.test.ts
  • plugins/catalog-backend-module-openchoreo/src/provider/EventDeltaApplier.test.ts
  • packages/openchoreo-client-node/src/resource-utils.test.ts
  • plugins/catalog-backend-module-openchoreo/src/provider/OpenChoreoEntityProvider.ts
  • plugins/catalog-backend-module-openchoreo/src/provider/EventDeltaApplier.ts

📝 Walkthrough

Walkthrough

Adds support for an openchoreo.dev/skip-template-generation: "true" annotation on (Cluster)ComponentType and (Cluster)ResourceType resources. A new constant and predicate are added in the client package and used in both the full-sync provider and event-driven delta applier to suppress Template entity emission, with delta handling also removing previously emitted Templates.

Changes

Skip Template Generation Annotation

Layer / File(s) Summary
Annotation constant and helper in openchoreo-client-node
packages/openchoreo-client-node/src/resource-utils.ts, packages/openchoreo-client-node/src/index.ts, packages/openchoreo-client-node/src/resource-utils.test.ts, .changeset/skip-template-generation-annotation.md
Defines SKIP_TEMPLATE_GENERATION_ANNOTATION and isTemplateGenerationSkipped, re-exports them from the package entrypoint, adds helper tests, and records the changeset note.
Full-sync skip logic in OpenChoreoEntityProvider
plugins/catalog-backend-module-openchoreo/src/provider/OpenChoreoEntityProvider.ts, plugins/catalog-backend-module-openchoreo/src/provider/OpenChoreoEntityProvider.test.ts
Adds annotation checks before schema fetching and Template creation for CTD, RTD, ClusterComponentType, and ClusterResourceType, with tests that assert skipped types omit Template entities and schema requests.
Event-driven skip logic in EventDeltaApplier
plugins/catalog-backend-module-openchoreo/src/provider/EventDeltaApplier.ts, plugins/catalog-backend-module-openchoreo/src/provider/EventDeltaApplier.test.ts
Adds annotation checks in all four refresh paths so annotated resources upsert only the base entity and emit a separate mutation removing the derived Template entity; tests cover annotated and unannotated cases.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • sameerajayasoma
  • Mirage20
  • kaviththiranga

Poem

🐇 A tiny true on the page did gleam,
And Templates hopped out of the stream.
Full sync stayed neat, delta cleaned the trail,
With schema-fetch trips set off the rail.
Hoppy code, soft code, skipping with grace —
No extra cards left in the race.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning Only Purpose is filled; the required sections like Goals, Approach, tests, release note, and links are left as placeholders. Fill in the template sections with concrete details for goals, approach, user stories, release note, tests, security checks, and any related links.
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: honoring the skip-template-generation annotation for component and resource types.
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

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 markdownlint-cli2 (0.22.1)
.changeset/skip-template-generation-annotation.md

markdownlint-cli2 v0.22.1 (markdownlint v0.40.0)
Error: Unable to use configuration file '/coderabbit-0.markdownlint-cli2.jsonc'; ENOENT: no such file or directory, open '/coderabbit-0.markdownlint-cli2.jsonc'
at throwForConfigurationFile (file:///usr/local/lib/node_modules/markdownlint-cli2/markdownlint-cli2.mjs:48:9)
at readOptionsOrConfig (file:///usr/local/lib/node_modules/markdownlint-cli2/markdownlint-cli2.mjs:169:5)
at async main (file:///usr/local/lib/node_modules/markdownlint-cli2/markdownlint-cli2.mjs:927:21)
at async file:///usr/local/lib/node_modules/markdownlint-cli2/markdownlint-cli2-bin.mjs:14:22 {
[cause]: Error: ENOENT: no such file or directory, open '/coderabbit-0.markdownlint-cli2.jsonc'
at async open (node:internal/fs/promises:640:25)
at async Object.readFile (node:internal/fs/promises:1287:14)
at async readOptionsOrConfig (file:///usr/local/lib/node_modules/markdownlint-cli2/markdownlint-cli2.mjs:141:17)
at async main (file:///usr/local/lib/node_modules/markdownlint-cli2/markdownlint-cli2.mjs:927:21)
at async file:///usr/local/lib/node_modules/markdownlint-cli2/markdownlint-cli2-bin.mjs:14:22 {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/coderabbit-0.markdownlint-cli2.jsonc'
}
}


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.

@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 69.44444% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...odule-openchoreo/src/provider/EventDeltaApplier.ts 64.28% 10 Missing ⚠️
...penchoreo/src/provider/OpenChoreoEntityProvider.ts 75.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 `@plugins/catalog-backend-module-openchoreo/src/provider/EventDeltaApplier.ts`:
- Around line 1076-1079: The skip-path update logic at lines 1076-1079 (and
similarly at lines 1126, 1214, and 1256) performs two separate mutation calls -
upsertEntities followed by removeEntityRefs. These should be consolidated into a
single atomic delta mutation to prevent stale Template entities from remaining
if the second call fails or concurrent events interleave. Refactor the upsert
and remove operations in these locations within the refreshResourceType,
refreshClusterComponentType, and refreshClusterResourceType methods to use one
combined atomic delta mutation operation instead of two separate applyMutation
calls.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: d4d356b1-1646-4b97-b214-55d3c383bb30

📥 Commits

Reviewing files that changed from the base of the PR and between 8381554 and 9fd6be9.

📒 Files selected for processing (8)
  • .changeset/skip-template-generation-annotation.md
  • packages/openchoreo-client-node/src/index.ts
  • packages/openchoreo-client-node/src/resource-utils.test.ts
  • packages/openchoreo-client-node/src/resource-utils.ts
  • plugins/catalog-backend-module-openchoreo/src/provider/EventDeltaApplier.test.ts
  • plugins/catalog-backend-module-openchoreo/src/provider/EventDeltaApplier.ts
  • plugins/catalog-backend-module-openchoreo/src/provider/OpenChoreoEntityProvider.test.ts
  • plugins/catalog-backend-module-openchoreo/src/provider/OpenChoreoEntityProvider.ts

Comment on lines +1076 to +1079
await this.upsertEntities([ctEntity]);
await this.removeEntityRefs([
this.buildEntityRef('template', ns, `template-${name}`),
]);

Copy link
Copy Markdown

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

Use one atomic delta mutation for skip-path updates.

At Line 1076 (and similarly at Lines 1126, 1214, 1256), the skip flow does two separate applyMutation calls (upsert, then remove). If the second call fails or concurrent events interleave, stale Template entities can remain even though skip is set.

Proposed fix
+  private async upsertAndRemoveEntities(
+    addedEntities: Entity[],
+    removedRefs: string[],
+  ): Promise<void> {
+    const connection = this.getConnection();
+    if (!connection || (addedEntities.length === 0 && removedRefs.length === 0)) {
+      return;
+    }
+    await connection.applyMutation({
+      type: 'delta',
+      added: this.toDeferred(addedEntities),
+      removed: removedRefs.map(entityRef => ({
+        entityRef,
+        locationKey: this.locationKey(),
+      })),
+    });
+  }
-      await this.upsertEntities([ctEntity]);
-      await this.removeEntityRefs([
-        this.buildEntityRef('template', ns, `template-${name}`),
-      ]);
+      await this.upsertAndRemoveEntities(
+        [ctEntity],
+        [this.buildEntityRef('template', ns, `template-${name}`)],
+      );

Apply the same pattern in refreshResourceType, refreshClusterComponentType, and refreshClusterResourceType.

Also applies to: 1126-1129, 1214-1222, 1256-1264

🤖 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 `@plugins/catalog-backend-module-openchoreo/src/provider/EventDeltaApplier.ts`
around lines 1076 - 1079, The skip-path update logic at lines 1076-1079 (and
similarly at lines 1126, 1214, and 1256) performs two separate mutation calls -
upsertEntities followed by removeEntityRefs. These should be consolidated into a
single atomic delta mutation to prevent stale Template entities from remaining
if the second call fails or concurrent events interleave. Refactor the upsert
and remove operations in these locations within the refreshResourceType,
refreshClusterComponentType, and refreshClusterResourceType methods to use one
combined atomic delta mutation operation instead of two separate applyMutation
calls.

@LakshanSS

Copy link
Copy Markdown
Contributor

Thanks for your contribution! @isuruRuhu
we need to use below format to fix the DCO check
git commit -s -m "your message"

… and resource types

(Cluster)ComponentTypes and (Cluster)ResourceTypes annotated with
openchoreo.dev/skip-template-generation: "true" no longer get an
auto-generated scaffolder Template (create card). Both the periodic full
sync and the event-driven delta path honor the annotation; the delta
path actively removes a previously emitted Template when the annotation
is added to a live resource, so the card disappears without waiting for
a full sync. The type entity itself is still ingested — only the
Template is suppressed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: isuruRuhu <isuru.ruhu@gmail.com>
@isuruRuhu isuruRuhu force-pushed the feat/skip-template-generation-annotation branch from 9fd6be9 to 272c084 Compare June 25, 2026 04:37
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.

2 participants