Documentation
¶
Overview ¶
Package render builds and renders per-tenant backup-assurance reports (HTML + PDF) over the report store's compliance and rule_321110 views.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrNoData = errors.New("no captured assets for tenant")
)
ErrNoData is returned by Build when a tenant has no captured assets (→ HTTP 404, distinct from a database failure → 500). errUnsupportedFormat is shared by the CLI and HTTP format checks.
Functions ¶
func FormatExt ¶
FormatExt validates an output format and returns its file extension ("" defaults to html). Shared by the CLI render command and the HTTP endpoint so both accept the same set.
func NewHandler ¶
NewHandler returns the read-only report HTTP surface: GET /report?tenant=&format= and GET /healthz. When authToken is non-empty, /report requires a matching Bearer token.
func RenderHTML ¶
func RenderHTML(w io.Writer, d ReportData) error
RenderHTML writes the branded HTML report. html/template auto-escapes all data, so a hostile asset name cannot inject markup.
Types ¶
type ReportData ¶
type ReportData struct {
Tenant string
BrandName string
GeneratedAt time.Time
Summary report.Summary
Compliance []report.ComplianceRow
Rule321 []report.Rule321Row
}
ReportData is everything a renderer needs for one tenant's current-snapshot report.
func Build ¶
func Build(ctx context.Context, st *report.Store, tenant, brand string, now time.Time) (ReportData, error)
Build assembles a tenant's report from the store. now is injected (testable). It errors when the tenant has no assets — there is nothing to assure.
func (ReportData) BadgeText ¶
func (d ReportData) BadgeText() string
BadgeText renders the 3-2-1-1-0 verdict as a word.
func (ReportData) CompliantPercent ¶
func (d ReportData) CompliantPercent() int
CompliantPercent is the share of assets meeting every SLA rule, 0..100 (0 when no assets).