Documentation
¶
Overview ¶
Package output renders reports as table / JSON.
Index ¶
- func Render(w io.Writer, r Report, format string) error
- func RenderDiff(w io.Writer, d DiffReport, format string) error
- func ResourceCostTotal(rc ResourceCost) float64
- func ValidateFiniteReport(r Report) error
- type CostComponent
- type CurrencyDiffTotal
- type DiffKind
- type DiffReport
- type ProvenanceEvidence
- type RateEvidence
- type Report
- type ResourceCost
- type ResourceDiff
- type SkippedResource
- type SourceEvidence
- type UsageEvidence
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RenderDiff ¶
func RenderDiff(w io.Writer, d DiffReport, format string) error
RenderDiff writes the diff report as table / json / markdown (PR-comment friendly).
func ResourceCostTotal ¶
func ResourceCostTotal(rc ResourceCost) float64
ResourceCostTotal sums the MonthlyCost of all components in a single resource.
func ValidateFiniteReport ¶ added in v0.4.0
ValidateFiniteReport rejects any component or aggregate that cannot be safely represented as finite JSON/table output.
Types ¶
type CostComponent ¶
type CostComponent struct {
Name string `json:"name"`
Unit string `json:"unit"`
HourlyCost float64 `json:"hourly_cost"`
MonthlyCost float64 `json:"monthly_cost"`
Currency string `json:"currency"`
Usage *UsageEvidence `json:"usage,omitempty"`
Rate *RateEvidence `json:"rate,omitempty"`
Provenance *ProvenanceEvidence `json:"provenance,omitempty"`
}
type CurrencyDiffTotal ¶ added in v0.4.0
type DiffKind ¶
type DiffKind string
DiffKind is + (added), - (removed), ~ (changed), = (unchanged).
type DiffReport ¶
type DiffReport struct {
Resources []ResourceDiff `json:"resources"`
Skipped []SkippedResource `json:"skipped"`
BeforeTotal float64 `json:"before_total"`
AfterTotal float64 `json:"after_total"`
DeltaTotal float64 `json:"delta_total"`
Currency string `json:"currency"`
TotalsByCurrency []CurrencyDiffTotal `json:"totals_by_currency,omitempty"`
TotalsComplete bool `json:"totals_complete"`
AggregationError string `json:"aggregation_error,omitempty"`
Policy any `json:"policy,omitempty"`
}
func ComputeDiff ¶
func ComputeDiff(before, after Report) DiffReport
ComputeDiff preserves the original convenience API. Invalid externally-built reports produce an explicit aggregation error rather than non-finite numbers.
func ComputeDiffChecked ¶ added in v0.4.0
func ComputeDiffChecked(before, after Report) (DiffReport, error)
ComputeDiffChecked pairs resources by address and computes monthly deltas, rejecting any non-finite component or aggregate before it can reach JSON.
type ProvenanceEvidence ¶ added in v0.4.0
type ProvenanceEvidence struct {
Kind string `json:"kind"`
Source SourceEvidence `json:"source"`
}
type RateEvidence ¶ added in v0.4.0
type Report ¶
type Report struct {
Resources []ResourceCost `json:"resources"`
Skipped []SkippedResource `json:"skipped"`
Policy any `json:"policy,omitempty"`
}
type ResourceCost ¶
type ResourceCost struct {
Address string `json:"address"`
Type string `json:"type"`
Components []CostComponent `json:"components"`
}