Skip to content

fix: print engine.Render() result on debug level#570

Merged
dmmordvi merged 12 commits intomainfrom
fix/debug-for-engine-render-res
Mar 13, 2026
Merged

fix: print engine.Render() result on debug level#570
dmmordvi merged 12 commits intomainfrom
fix/debug-for-engine-render-res

Conversation

@dmmordvi
Copy link
Contributor

@dmmordvi dmmordvi commented Mar 4, 2026

Summary by Bito

  • Replaced a single TraceStruct log for rendered templates with a loop that selectively logs individual file contents at Debug level.
  • Added conditions to skip logging files that start with '_', end with NotesFileSuffix, or are empty after trimming.
  • Changed logging from tracing the entire renderedTemplates struct to detailed logging of qualifying template contents.

Signed-off-by: Dmitry Mordvinov <dmitry.mordvinov@flant.com>
@dmmordvi dmmordvi requested a review from ilya-lesikov March 4, 2026 16:42
}

if len(jsRenderedTemplates) > 0 {
maps.Copy(renderedTemplates, jsRenderedTemplates)
Copy link
Member

@ilya-lesikov ilya-lesikov Mar 10, 2026

Choose a reason for hiding this comment

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

I wonder, do we add any filepath in a comment on the first line of the resulting yaml?

With helm templates we add a comment like this:

---
# Source: testchart/templates/test.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  annotations: {}
  labels: {}

Can we add at least something like an entrypoint name? Either a bundle.js path or an entrypoint path (what is it, index.js, index.ts?). For backwards compatibility.

Actually I see now that there is a map with filepaths returned. Just make sure that at some point the paths are added as comments like this ^^

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ilya-lesikov We don't add comment # Source: ..., but print debug message like Rendered content of "testchart/templates/test.yaml": <yaml content from new line>. Should i use comment instead separate message?

Copy link
Contributor Author

@dmmordvi dmmordvi Mar 10, 2026

Choose a reason for hiding this comment

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

For JS/TS we print entrypoint file name (testchart/ts/src/index.ts / testchart/ts/src/index.js) or bundle file path (if there is no entrypoint). But it is still in progress on #565

Copy link
Member

Choose a reason for hiding this comment

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

A separate message is needed anyways. But we also need in commands like nelm chart render or in manifests saved in the release filename as a comment on the first line of the manifest, like we do now with helm templated manifests.

And I'd like it to be the actual filename from where it's sourced. If that's a bundle.js then bundle.js, if that's index.ts or index.js (for runtime dependency resolution), then it's that.

Signed-off-by: Dmitry Mordvinov <dmitry.mordvinov@flant.com>
Signed-off-by: Dmitry Mordvinov <dmitry.mordvinov@flant.com>
Signed-off-by: Dmitry Mordvinov <dmitry.mordvinov@flant.com>
@dmmordvi dmmordvi requested a review from ilya-lesikov March 11, 2026 15:07
}

once.Do(func() {
log.Default.Debug(ctx, "Rendered content:")
Copy link
Member

Choose a reason for hiding this comment

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

just always print it once on line 236, it's just a debug message, don't bother much. Even if no templates.

And using once for it while possible, probably not very idiomatic in Go. If ever needed something like this, better do it without once (via for i loop, or some other way)

Signed-off-by: Dmitry Mordvinov <dmitry.mordvinov@flant.com>
Signed-off-by: Dmitry Mordvinov <dmitry.mordvinov@flant.com>
Signed-off-by: Dmitry Mordvinov <dmitry.mordvinov@flant.com>
Signed-off-by: Dmitry Mordvinov <dmitry.mordvinov@flant.com>
Signed-off-by: Dmitry Mordvinov <dmitry.mordvinov@flant.com>
@dmmordvi dmmordvi enabled auto-merge (squash) March 13, 2026 13:13
@dmmordvi dmmordvi disabled auto-merge March 13, 2026 13:13
Signed-off-by: Dmitry Mordvinov <dmitry.mordvinov@flant.com>
Signed-off-by: Dmitry Mordvinov <dmitry.mordvinov@flant.com>
Signed-off-by: Dmitry Mordvinov <dmitry.mordvinov@flant.com>
@dmmordvi dmmordvi merged commit 9a7591e into main Mar 13, 2026
8 checks passed
@dmmordvi dmmordvi deleted the fix/debug-for-engine-render-res branch March 13, 2026 14:18
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