feat(catalog): honor skip-template-generation annotation on component and resource types#641
Conversation
… 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
📝 WalkthroughWalkthroughAdds support for an ChangesSkip Template Generation Annotation
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 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 |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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 `@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
📒 Files selected for processing (8)
.changeset/skip-template-generation-annotation.mdpackages/openchoreo-client-node/src/index.tspackages/openchoreo-client-node/src/resource-utils.test.tspackages/openchoreo-client-node/src/resource-utils.tsplugins/catalog-backend-module-openchoreo/src/provider/EventDeltaApplier.test.tsplugins/catalog-backend-module-openchoreo/src/provider/EventDeltaApplier.tsplugins/catalog-backend-module-openchoreo/src/provider/OpenChoreoEntityProvider.test.tsplugins/catalog-backend-module-openchoreo/src/provider/OpenChoreoEntityProvider.ts
| await this.upsertEntities([ctEntity]); | ||
| await this.removeEntityRefs([ | ||
| this.buildEntityRef('template', ns, `template-${name}`), | ||
| ]); |
There was a problem hiding this comment.
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.
|
Thanks for your contribution! @isuruRuhu |
Purpose
To hide a (Cluster)ComponentType's or (Cluster)ResourceType's auto-generated "create" card from the console via an annotation.
Goals
Approach
User stories
Release note
Documentation
Training
Certification
Marketing
Automation tests
Security checks
Samples
Related PRs
Migrations (if applicable)
Test environment
Learning
Summary by CodeRabbit
openchoreo.dev/skip-template-generation: "true"annotation on ComponentType, ResourceType, ClusterComponentType, or ClusterResourceType definitions.