render

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

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

View Source
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

func FormatExt(format string) (string, error)

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

func NewHandler(st *report.Store, brand, authToken string) http.Handler

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.

func RenderPDF

func RenderPDF(w io.Writer, d ReportData) error

RenderPDF writes a structured, tabular PDF of the same ReportData (independent layout from the HTML — the cost of a browser-free, pure-Go renderer).

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).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL