Documentation ¶
Index ¶
- Variables
- type Component
- type Cost
- type ModularState
- type Resource
- type State
- func (s *State) AddComponent(resAddress, compLabel string, component Component)
- func (s *State) Cost() (Cost, error)
- func (s *State) CostString() (string, error)
- func (s *State) EnsureResource(address, typ string, provider string, skipped, isSupported bool)
- func (s *State) GetCostComponents() []Component
Constants ¶
This section is empty.
Variables ¶
var ( ErrProductNotFound = fmt.Errorf("product not found") ErrPriceNotFound = fmt.Errorf("price not found") )
Errors that might be returned from NewState if either a product or a price are not found.
var HoursPerMonth = decimal.NewFromInt(730)
HoursPerMonth is an approximate number of hours in a month. It is calculated as 365 days in a year x 24 hours in a day / 12 months in year.
var Zero = Cost{}
Zero is Cost with zero value.
Functions ¶
This section is empty.
Types ¶
type Component ¶
type Component struct { Name string MonthlyQuantity decimal.Decimal HourlyQuantity decimal.Decimal Unit string Rate Cost Details []string Usage bool Error error }
Component describes the pricing of a single resource cost component. This includes Rate and Quantity and allows for final cost computation.
func (Component) GetRounded ¶
GetRounded returns component with rounded values to show
type Cost ¶
type Cost struct { // Decimal is price per month. decimal.Decimal // Currency of the cost. Currency string }
Cost represents a monthly or hourly cost of a cloud resource or its component.
type ModularState ¶ added in v1.7.0
type ModularState struct { ChildModules map[string]ModularState Resources map[string]Resource }
func (*ModularState) Cost ¶ added in v1.7.0
func (s *ModularState) Cost() (Cost, error)
func (*ModularState) ToClassicState ¶ added in v1.7.0
func (s *ModularState) ToClassicState() *State
func (*ModularState) TotalResourcesCount ¶ added in v1.7.0
func (s *ModularState) TotalResourcesCount() int
type Resource ¶
type Resource struct { Address string Provider string Type string Components map[string][]Component Skipped bool IsSupported bool }
Resource represents costs of a single cloud resource. Each Resource includes a Component map, keyed by the label.
type State ¶
State represents a collection of all the Resource costs (either prior or planned.) It is not tied to any specific cloud provider or IaC tool. Instead, it is a representation of a snapshot of cloud resources at a given point in time, with their associated costs.
func (*State) AddComponent ¶
AddComponent adds the Component with given label to the Resource at given address.
func (*State) Cost ¶
Cost returns the sum of the costs of every Resource included in this State. Error is returned if there is a mismatch in resource currencies.
func (*State) CostString ¶
CostString returns a string to show the breakdown of the costs for a state containing the resources and their components costs and total cost for the resources and the state
func (*State) EnsureResource ¶
EnsureResource creates Resource at the given address if it doesn't already exist.