feat(catalog): honor skip-template-generation annotation on component and resource types#641
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (6)
📝 WalkthroughWalkthroughAdds support for an ChangesSkip Template Generation Annotation
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)
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.mdmarkdownlint-cli2 v0.22.1 (markdownlint v0.40.0) 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 |
… 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>
9fd6be9 to
272c084
Compare
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"on ComponentType, ResourceType, ClusterComponentType, or ClusterResourceType.