-
Notifications
You must be signed in to change notification settings - Fork 12
HTML report for validate commands #366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
nirs
wants to merge
9
commits into
RamenDR:main
Choose a base branch
from
nirs:html-report-impl
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
+829
−1
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f76d712 to
f2f6693
Compare
Use product name (e.g., "Claude Opus 4.5") instead of API model ID (e.g., "claude-4-opus-20250514") for consistency. Signed-off-by: Nir Soffer <nsoffer@redhat.com>
f2f6693 to
e7a8a01
Compare
Document the architecture for generating HTML reports from command output.
Each command will have its own report type with specific data, while sharing
common templates for header, footer, and summary sections.
Key design decisions:
- Separate report types per command (application.Report, clusters.Report, etc.)
- All reports embed report.Report with common fields
- Template composition using Go's html/template with {{define}} and {{template}}
- Shared templates in report/templates/*.tmpl, command templates in each package
- Struct-based data passing (HeaderData, SummaryData) for type safety
- report.Template() returns fresh template set, commands add their template
- Base.SummaryData(order) converts Summary to template data with specified key order,
key names are used directly as CSS classes
This document will be updated as implementation progresses.
Assisted-by: Cursor/Claude Opus 4.5
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
Git on Windows converts LF to CRLF on checkout, causing golden file
comparisons to fail. Add .gitattributes to force LF for *.html and
*.tmpl files.
Example failed test:
=== RUN TestIncludeIndent
html_test.go:153: output mismatch:
--- expected
+++ actual
@@ -1,7 +1,7 @@
-<div>
+<div>
- <section>
+ <section>
- <ul>
+ <ul>
- <li>Item</li>
+ <li>Item</li>
- </ul>
+ </ul>
- </section>
+ </section>
</div>
\ No newline at end of file
--- FAIL: TestIncludeIndent (0.00s)
Example attributes:
% git check-attr eol pkg/**/*.{html,tmpl}
pkg/report/testdata/include-indent.html: eol: lf
pkg/validate/application/testdata/report.html: eol: lf
pkg/validate/clusters/testdata/report.html: eol: lf
pkg/report/templates/application.tmpl: eol: lf
pkg/report/templates/base.tmpl: eol: lf
pkg/report/templates/style.tmpl: eol: lf
pkg/validate/application/report.tmpl: eol: lf
pkg/validate/clusters/report.tmpl: eol: lf
Assisted-by: Cursor/Claude Opus 4.5
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
Create dedicated report types for validate-application and validate-clusters commands in new sub-packages. This is preparation for command-specific HTML report generation. Each report type embeds report.Report (which includes Base, Config, Namespaces) and adds only command-specific fields: - application.Report: report.Application, report.ApplicationStatus - clusters.Report: report.ClustersStatus This structure: - Clearly defines what data each command produces - Avoids optional fields that belong to other commands - Enables command-specific HTML templates - Reuses report.Report.Equal() for comparison The existing validate package code continues to use report.Report for now. Migration to the new types will follow in subsequent commits. Assisted-by: Cursor/Claude Opus 4.5 Signed-off-by: Nir Soffer <nsoffer@redhat.com>
Templates (pkg/report/templates/):
- base.tmpl: Defines header, footer, and summary blocks. Header shows
title, optional subtitle, and status. Summary renders items as a list
with CSS classes.
- style.tmpl: Placeholder CSS reset (full styling to be added later).
- application.tmpl: Shared block for displaying application name and
namespace, used by validate-application and gather-application
reports.
Code (pkg/report/html.go):
- Template() returns a fresh template set with shared definitions and
Funcs
- HeaderData, SummaryData, SummaryItem types for passing data to shared
templates
- Base.SummaryData(order) converts Summary map to template data with
specified order
Templates use consistent whitespace trimming:
{{define "name" -}}
...
{{- end}}
so callers don't need to manage whitespace at call sites.
Assisted-by: Cursor/Claude Opus 4.5
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
Each command has:
- report.tmpl: Command-specific HTML template defining the "report" block
- html.go: templateData wrapper with HeaderData() and SummaryData() methods,
Template() that combines shared and command templates
- html_test.go: Golden file test for WriteHTML, unit tests for helper methods
- testdata/report.html: Golden file for output verification
The templateData wrapper embeds *Report so templates can access both report
fields directly ({{.Application.Name}}) and wrapper methods ({{.HeaderData}}).
SummaryOrder in pkg/validate/report.go defines display order: OK, Problem, Stale.
Each package passes this to Base.SummaryData() for consistent ordering.
Template whitespace pattern: only trim at definition boundaries
({{define "report" -}}...{{- end}}), template calls need no trimming.
Assisted-by: Cursor/Claude Opus 4.5
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
Add 'includeHTML', 'includeCSS' and 'indent' template functions to allow
proper indentation of the output HTML.
- includeHTML: execute a template and return the rendered HTML. Must be
called in HTML context.
- includeCSS: execute a template and return the rendered CSS. Must be
called in stylesheet context. (<style>...</style>).
- indent: indent all lines except the first (which is already
indented in the outer template)
This enables clean, readable templates where visual indentation
matches output.
Helm-style (visual indentation doesn't match output):
<div>
{{ include "section" . | indent 4 }}
</div>
Our style (WYSIWYG):
<div>
{{ includeHTML "section" . | indent 4 }}
</div>
Output (properly nested):
<div>
<section>
<ul>
<li>Item</li>
</ul>
</section>
</div>
Assisted-by: Cursor/Claude Opus 4.5
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
Update validate templates to use the new include*/indent functions,
producing properly indented HTML output.
Before:
<section>
<h2>Report Details</h2>
<h3>Summary</h3>
<ul>
<li class="ok">ok: 2</li>
</ul>
After:
<section>
<h2>Report Details</h2>
<h3>Summary</h3>
<ul>
<li class="ok">ok: 2</li>
</ul>
Assisted-by: Cursor/Claude Opus 4.5
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
e7a8a01 to
3ac078a
Compare
parikshithb
reviewed
Jan 16, 2026
9b2f836 to
15b8545
Compare
- Simplify report template to keep the shared report structure - The command template contains now only the specific content - Remove unused application template - Remove summary template and infrastructure, we will add it later if needed Need to update the previous commit with the changes. Signed-off-by: Nir Soffer <nsoffer@redhat.com>
15b8545 to
11e22d5
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This branch adds HTML report generation for validate commands.
application.Report,clusters.Report) that embed common fields and add command-specific datapkg/report/templates/, withTemplate()function for compositiontemplateDatawrapper, and golden file testsOut of Scope
Example output