schema

package
v0.9.7 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HourToMonthUnitMultiplier = decimal.NewFromInt(730)

Functions

func AddRawValue

func AddRawValue(r gjson.Result, key string, v interface{}) gjson.Result

func CalculateCosts

func CalculateCosts(project *Project)

func GenerateProjectName added in v0.9.0

func GenerateProjectName(metadata *ProjectMetadata, dashboardEnabled bool) string

func MultiplyQuantities added in v0.7.4

func MultiplyQuantities(resource *Resource, multiplier decimal.Decimal)

func NewEmptyUsageMap added in v0.7.15

func NewEmptyUsageMap() map[string]*UsageData

func NewUsageMap added in v0.7.15

func NewUsageMap(m map[string]interface{}) map[string]*UsageData

func ParseAttributes added in v0.7.15

func ParseAttributes(i interface{}) map[string]gjson.Result

func SortResources

func SortResources(project *Project)

Types

type AttributeFilter

type AttributeFilter struct {
	Key        string  `json:"key"`
	Value      *string `json:"value,omitempty"`
	ValueRegex *string `json:"value_regex,omitempty"`
}

type CostComponent

type CostComponent struct {
	Name                 string
	Unit                 string
	UnitMultiplier       decimal.Decimal
	IgnoreIfMissingPrice bool
	ProductFilter        *ProductFilter
	PriceFilter          *PriceFilter
	HourlyQuantity       *decimal.Decimal
	MonthlyQuantity      *decimal.Decimal
	MonthlyDiscountPerc  float64

	HourlyCost  *decimal.Decimal
	MonthlyCost *decimal.Decimal
	// contains filtered or unexported fields
}

func (*CostComponent) CalculateCosts

func (c *CostComponent) CalculateCosts()

func (*CostComponent) Price

func (c *CostComponent) Price() decimal.Decimal

func (*CostComponent) PriceHash

func (c *CostComponent) PriceHash() string

func (*CostComponent) SetPrice

func (c *CostComponent) SetPrice(price decimal.Decimal)

func (*CostComponent) SetPriceHash

func (c *CostComponent) SetPriceHash(priceHash string)

func (*CostComponent) UnitMultiplierHourlyQuantity added in v0.7.0

func (c *CostComponent) UnitMultiplierHourlyQuantity() *decimal.Decimal

func (*CostComponent) UnitMultiplierMonthlyQuantity added in v0.7.0

func (c *CostComponent) UnitMultiplierMonthlyQuantity() *decimal.Decimal

func (*CostComponent) UnitMultiplierPrice added in v0.7.0

func (c *CostComponent) UnitMultiplierPrice() decimal.Decimal

type PriceFilter

type PriceFilter struct {
	PurchaseOption     *string `json:"purchaseOption,omitempty"`
	Unit               *string `json:"unit,omitempty"`
	Description        *string `json:"description,omitempty"`
	DescriptionRegex   *string `json:"description_regex,omitempty"`
	StartUsageAmount   *string `json:"startUsageAmount,omitempty"`
	EndUsageAmount     *string `json:"endUsageAmount,omitempty"`
	TermLength         *string `json:"termLength,omitempty"`
	TermPurchaseOption *string `json:"termPurchaseOption,omitempty"`
	TermOfferingClass  *string `json:"termOfferingClass,omitempty"`
}

type ProductFilter

type ProductFilter struct {
	VendorName       *string            `json:"vendorName,omitempty"`
	Service          *string            `json:"service,omitempty"`
	ProductFamily    *string            `json:"productFamily,omitempty"`
	Region           *string            `json:"region,omitempty"`
	Sku              *string            `json:"sku,omitempty"`
	AttributeFilters []*AttributeFilter `json:"attributeFilters,omitempty"`
}

type Project added in v0.7.19

type Project struct {
	Name          string
	Metadata      *ProjectMetadata
	PastResources []*Resource
	Resources     []*Resource
	Diff          []*Resource
	HasDiff       bool
}

Project contains the existing, planned state of resources and the diff between them.

func NewProject added in v0.7.19

func NewProject(name string, metadata *ProjectMetadata) *Project

func (*Project) AllResources added in v0.7.19

func (p *Project) AllResources() []*Resource

AllResources returns a pointer list of all resources of the state.

func (*Project) CalculateDiff added in v0.7.19

func (p *Project) CalculateDiff()

CalculateDiff calculates the diff of past and current resources

type ProjectMetadata added in v0.9.0

type ProjectMetadata struct {
	Path               string `json:"path"`
	Type               string `json:"type"`
	VCSRepoURL         string `json:"vcsRepoUrl,omitempty"`
	VCSSubPath         string `json:"vcsSubPath,omitempty"`
	VCSPullRequestURL  string `json:"vcsPullRequestUrl,omitempty"`
	TerraformWorkspace string `json:"terraformWorkspace,omitempty"`
}

type Provider

type Provider interface {
	Type() string
	DisplayType() string
	AddMetadata(*ProjectMetadata)
	LoadResources(map[string]*UsageData) ([]*Project, error)
}

type RegistryItem

type RegistryItem struct {
	Name                string
	Notes               []string
	RFunc               ResourceFunc
	ReferenceAttributes []string
	NoPrice             bool
}

type Resource

type Resource struct {
	Name           string
	CostComponents []*CostComponent
	SubResources   []*Resource
	HourlyCost     *decimal.Decimal
	MonthlyCost    *decimal.Decimal
	IsSkipped      bool
	NoPrice        bool
	SkipMessage    string
	ResourceType   string
	Tags           map[string]string
	UsageSchema    []*UsageSchemaItem
}

func AllProjectResources added in v0.7.19

func AllProjectResources(projects []*Project) []*Resource

AllProjectResources returns the resources for all projects

func (*Resource) CalculateCosts

func (r *Resource) CalculateCosts()

func (*Resource) FlattenedSubResources

func (r *Resource) FlattenedSubResources() []*Resource

func (*Resource) RemoveCostComponent

func (r *Resource) RemoveCostComponent(costComponent *CostComponent)

type ResourceData

type ResourceData struct {
	Type         string
	ProviderName string
	Address      string
	Tags         map[string]string
	RawValues    gjson.Result

	CFResource cloudformation.Resource
	// contains filtered or unexported fields
}

func NewCFResourceData added in v0.9.2

func NewCFResourceData(resourceType string, providerName string, address string, tags map[string]string, cfResource cloudformation.Resource) *ResourceData

func NewResourceData

func NewResourceData(resourceType string, providerName string, address string, tags map[string]string, rawValues gjson.Result) *ResourceData

func (*ResourceData) AddReference

func (d *ResourceData) AddReference(key string, reference *ResourceData)

func (*ResourceData) Get

func (d *ResourceData) Get(key string) gjson.Result

func (*ResourceData) References

func (d *ResourceData) References(key string) []*ResourceData

func (*ResourceData) Set

func (d *ResourceData) Set(key string, value interface{})

type ResourceFunc

type ResourceFunc func(*ResourceData, *UsageData) *Resource

type UsageData added in v0.7.12

type UsageData struct {
	Address    string
	Attributes map[string]gjson.Result
}

func NewUsageData added in v0.7.12

func NewUsageData(address string, attributes map[string]gjson.Result) *UsageData

func (*UsageData) Get added in v0.7.12

func (u *UsageData) Get(key string) gjson.Result

func (*UsageData) GetFloat added in v0.9.2

func (u *UsageData) GetFloat(key string) *float64

func (*UsageData) GetInt added in v0.9.2

func (u *UsageData) GetInt(key string) *int64

func (*UsageData) GetString added in v0.9.7

func (u *UsageData) GetString(key string) *string

func (*UsageData) GetStringArray added in v0.9.7

func (u *UsageData) GetStringArray(key string) *[]string

type UsageSchemaItem added in v0.9.2

type UsageSchemaItem struct {
	Key          string
	DefaultValue interface{}
	ValueType    UsageVariableType
}

type UsageVariableType added in v0.9.2

type UsageVariableType int
const (
	Int64 UsageVariableType = iota
	String
	Float64
	StringArray
)

Jump to

Keyboard shortcuts

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