Skip to content

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

Open
isuruRuhu wants to merge 3 commits 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 3 commits 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 the openchoreo.dev/skip-template-generation: "true" annotation on ComponentType, ResourceType, ClusterComponentType, or ClusterResourceType definitions.
    • When enabled, previously emitted Templates are automatically removed. This behavior is applied in both periodic full syncs and event-driven updates.

isuruRuhu and others added 3 commits June 11, 2026 15:44
… 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>
PR openchoreo#619 moved all Build & Deploy fields into a nested buildAndDeploy
object, but GitSourceField and BuildWorkflowParameters kept reading the
selected workflow from the old top-level path formData.workflow_name.
They never saw the selection, so the Git source section (repo/branch/
path/secret) never appeared and the Workflow Parameters fields never
populated for any component type when building from source.

Both fields now read formContext.formData.buildAndDeploy.workflow_name.

Only the app package is touched (changeset-ignored), so no changeset.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…generation-annotation

# Conflicts:
#	packages/app/src/scaffolder/BuildWorkflowParameters/BuildWorkflowParametersExtension.tsx
#	packages/app/src/scaffolder/GitSourceField/GitSourceField.tsx
@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Review Change Stack

📝 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 introduced in the openchoreo-client-node package and consumed in both the full-sync provider and the event-driven delta applier to suppress Template entity emission and actively remove previously emitted Templates.

Changes

Skip Template Generation Annotation

Layer / File(s) Summary
Annotation constant and helper
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
Exports SKIP_TEMPLATE_GENERATION_ANNOTATION constant and isTemplateGenerationSkipped(resource) predicate from resource-utils.ts, re-exports both from index.ts, tests exact-"true"-only match semantics, and records the changeset.
Full-sync skip in OpenChoreoEntityProvider
plugins/catalog-backend-module-openchoreo/src/provider/OpenChoreoEntityProvider.ts, plugins/catalog-backend-module-openchoreo/src/provider/OpenChoreoEntityProvider.test.ts
Adds early-return null guards in all four template-generation loops (CTD, RTD, ClusterComponentType, ClusterResourceType) so that annotated types skip schema fetching and Template entity creation. Tests confirm Template entities and schema fetches are absent for skipped types.
Event-driven skip in EventDeltaApplier
plugins/catalog-backend-module-openchoreo/src/provider/EventDeltaApplier.ts, plugins/catalog-backend-module-openchoreo/src/provider/EventDeltaApplier.test.ts
Adds early-return branches in refreshComponentType, refreshResourceType, refreshClusterComponentType, and refreshClusterResourceType that upsert only the primary entity and emit a separate mutation to actively remove the derived template entity. Tests assert mutation contents for annotation-present and annotation-absent cases.

Sequence Diagram(s)

sequenceDiagram
  participant Kubernetes as Kubernetes API
  participant OpenChoreoEntityProvider
  participant EventDeltaApplier
  participant CatalogMutation as Catalog Mutation

  rect rgba(70, 130, 180, 0.5)
    Note over OpenChoreoEntityProvider: Full sync path
    Kubernetes-->>OpenChoreoEntityProvider: list (Cluster)ComponentType / (Cluster)ResourceType
    OpenChoreoEntityProvider->>OpenChoreoEntityProvider: isTemplateGenerationSkipped(resource)?
    alt annotation = "true"
      OpenChoreoEntityProvider->>CatalogMutation: emit type entity (no Template, no schema fetch)
    else no annotation
      OpenChoreoEntityProvider->>Kubernetes: GET /schema?type=<name>
      OpenChoreoEntityProvider->>CatalogMutation: emit type entity + Template entity
    end
  end

  rect rgba(60, 179, 113, 0.5)
    Note over EventDeltaApplier: Event-driven delta path
    Kubernetes-->>EventDeltaApplier: watch event (MODIFIED)
    EventDeltaApplier->>EventDeltaApplier: isTemplateGenerationSkipped(resource)?
    alt annotation = "true"
      EventDeltaApplier->>CatalogMutation: upsert(type entity only)
      EventDeltaApplier->>CatalogMutation: remove(template:namespace/template-name)
    else no annotation
      EventDeltaApplier->>CatalogMutation: upsert(type entity + Template entity)
    end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • sameerajayasoma
  • Mirage20
  • kaviththiranga
  • stefinie123

Poem

🐇 Hippity-hoppity, annotations galore,
A "true" on your resource means templates no more!
The delta applier scrubs what once was made,
Full sync skips the schema fetch unafraid.
From cluster to namespace, the rabbit checks true —
No cards left unguarded when skipping's your cue! 🎉

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is largely incomplete. It only fills the 'Purpose' section with a brief explanation, but all other required sections (Goals, Approach, User stories, Release note, Documentation, Training, Certification, Marketing, Automation tests, Security checks, Samples, Related PRs, Migrations, Test environment, Learning) remain as unfilled template placeholders. Complete all required sections in the PR description template. At minimum, provide Goals, Approach, Release note, Documentation, and Automation tests with actual content rather than placeholder text.
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 accurately and specifically describes the main feature: honoring the skip-template-generation annotation on 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

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.

@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 12 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...odule-openchoreo/src/provider/EventDeltaApplier.ts 50.00% 10 Missing ⚠️
...penchoreo/src/provider/OpenChoreoEntityProvider.ts 83.33% 2 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"

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