Skip to content

[Misc] Enhance template handling during build#103

Open
anirudhprasad-sap wants to merge 9 commits into
mainfrom
enhanceBuildChecks
Open

[Misc] Enhance template handling during build#103
anirudhprasad-sap wants to merge 9 commits into
mainfrom
enhanceBuildChecks

Conversation

@anirudhprasad-sap
Copy link
Copy Markdown
Contributor

@anirudhprasad-sap anirudhprasad-sap commented May 21, 2026

Enhance Template Handling During cds build

New Feature

✨ Improved the cds build process to give developers more control over Helm chart templates. Instead of blindly overriding or skipping plugin-generated templates, the build now intelligently handles user-provided templates in chart/templates/:

  • If a file with the same name as a plugin-generated template exists (_helpers.tpl, domain.yaml, cap-operator-cros.yaml, service-binding.yaml, service-instance.yaml), the user's version is used and a warning is emitted.
  • If the user's file matches the plugin default, an info message is logged instead.
  • Any additional/custom files in chart/templates/ not matching known plugin templates are copied alongside the standard templates.
  • A build start message is now emitted at the beginning of the build() method for better observability.

Changes

  • lib/build.js: Refactored copyTemplates() to use staticEntry/generatedEntry helpers modeling each known template. The method now compares user-provided templates against plugin defaults, logs appropriate messages, and copies extra user-defined files. Added fs module for directory reading, and imported getConfigurableCapOpCroYaml, isConfigurableTemplateChart, and getProjectFromValuesYaml from util.
  • lib/util.js: Added getProjectFromValuesYaml() helper function that reads values.yaml and Chart.yaml to build a normalized project descriptor object, consolidating logic previously scattered across build.js. Exported the new function.
  • README.md: Added documentation clarifying how custom files in chart/templates are handled during cds build, distinguishing between same-name overrides and additional files.
  • test/build.test.js: Added a new test case verifying that custom user-defined templates (including nested subdirectories) are copied into the generated chart while all standard plugin templates are still present. Fixed an existing test: a deleted _helpers.tpl in --with-templates mode now correctly expects the plugin to regenerate it (assertion changed from false to true).
  • 🔄 Regenerate and Update Summary
PR Bot Information

Version: 1.20.51

  • Event Trigger: pull_request.edited
  • Output Template: Default Template
  • LLM: anthropic--claude-4.6-sonnet
  • Correlation ID: 0b57b9c5-4336-47bf-9636-77c03d3d45da
  • File Content Strategy: Full file content
  • Summary Prompt: Default Prompt

Copy link
Copy Markdown
Contributor

@hyperspace-insights hyperspace-insights Bot left a comment

Choose a reason for hiding this comment

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

The PR introduces a meaningful enhancement to template handling, but there are several substantive issues: the missing isConfigurableTemplateChart argument to getHelperTpl is a functional regression for configurable-template charts, the readdir loop doesn't filter out subdirectories, and the double-invocation of generator functions should be addressed for correctness and efficiency. The test suite also needs better isolation to avoid stale gen/ output causing false positives.

PR Bot Information

Version: 1.20.51

  • LLM: anthropic--claude-4.6-sonnet
  • Event Trigger: pull_request.opened
  • File Content Strategy: Full file content
  • Correlation ID: cf9fa3e5-1d1f-4727-81d6-5453242bb5fd

Comment thread lib/build.js
Comment thread lib/build.js Outdated
Comment thread lib/build.js Outdated
Comment thread lib/build.js Outdated
Comment thread test/build.test.js
Comment thread README.md Outdated
anirudhprasad-sap and others added 9 commits May 26, 2026 12:01
… improve user-defined template support and logging
…uildPlugin and update template handling logic
Co-authored-by: hyperspace-insights[bot] <209611008+hyperspace-insights[bot]@users.noreply.github.com>
…orBuildPlugin and update tests for nested templates
…ervice parameter and determining service status internally
Copy link
Copy Markdown
Contributor

@hyperspace-insights hyperspace-insights Bot left a comment

Choose a reason for hiding this comment

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

The PR introduces a meaningful improvement to template handling during cds build, giving developers explicit control over plugin-generated vs. custom templates. The core logic is sound, but there are a few issues worth addressing: chartYaml.name being undefined can silently produce a broken Helm template string ({{ print "undefined" }}), the test isolation around gen directory cleanup is inconsistent, and the handling of directory entries in userTemplatesDir makes implicit assumptions (that known plugin template names are always files) that could cause unexpected behavior in edge cases.

PR Bot Information

Version: 1.20.51

  • LLM: anthropic--claude-4.6-sonnet
  • Event Trigger: pull_request.ready_for_review
  • Correlation ID: e0ad1280-510b-4272-a732-06097168eaa3
  • File Content Strategy: Full file content

Comment thread lib/build.js
Comment thread lib/build.js
Comment thread lib/build.js
Comment thread lib/build.js
Comment thread lib/util.js
Comment thread test/build.test.js
@cap-js cap-js deleted a comment from hyperspace-insights Bot May 26, 2026
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.

copyTemplates() treats chart/templates/ as an all-or-nothing override, silently dropping all SAP-generated templates

1 participant