output

package
v0.3.11 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package output renders reports as table / JSON.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(w io.Writer, r Report, format string) error

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.

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"`
}

type DiffKind

type DiffKind string

DiffKind is + (added), - (removed), ~ (changed), = (unchanged).

const (
	DiffAdd    DiffKind = "+"
	DiffRemove DiffKind = "-"
	DiffChange DiffKind = "~"
	DiffSame   DiffKind = "="
)

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"`
}

func ComputeDiff

func ComputeDiff(before, after Report) DiffReport

ComputeDiff pairs resources by address and computes monthly delta.

type Report

type Report struct {
	Resources []ResourceCost    `json:"resources"`
	Skipped   []SkippedResource `json:"skipped"`
}

func (Report) Total

func (r Report) Total() float64

Total returns the sum of MonthlyCost over all cost components.

type ResourceCost

type ResourceCost struct {
	Address    string          `json:"address"`
	Type       string          `json:"type"`
	Components []CostComponent `json:"components"`
}

type ResourceDiff

type ResourceDiff struct {
	Address       string   `json:"address"`
	Type          string   `json:"type"`
	Kind          DiffKind `json:"kind"`
	BeforeMonthly float64  `json:"before_monthly"`
	AfterMonthly  float64  `json:"after_monthly"`
	DeltaMonthly  float64  `json:"delta_monthly"`
}

type SkippedResource

type SkippedResource struct {
	Address string `json:"address"`
	Type    string `json:"type"`
	Reason  string `json:"reason"`
}

Jump to

Keyboard shortcuts

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