Documentation ¶
Index ¶
- func CalculateTierBuckets(requestCount decimal.Decimal, tierLimits []int) []decimal.Decimal
- func CreateUsageFile(path string) error
- func ResourceUsagesToYAML(resourceUsages []*ResourceUsage) (yamlv3.Node, bool)
- type ContextEnv
- type ReferenceFile
- type ReplaceResourceUsagesOpts
- type ResourceUsage
- type SyncResult
- type UsageFile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateTierBuckets ¶
func CreateUsageFile ¶
CreateUsageFile creates a blank usage file if it does not exists
func ResourceUsagesToYAML ¶
func ResourceUsagesToYAML(resourceUsages []*ResourceUsage) (yamlv3.Node, bool)
Types ¶
type ContextEnv ¶
type ContextEnv struct{}
type ReferenceFile ¶
type ReferenceFile struct {
*UsageFile
}
ReferenceFile represents the reference example usage file
func LoadReferenceFile ¶
func LoadReferenceFile() (*ReferenceFile, error)
LoadReferenceFile loads the reference example usage file
func (*ReferenceFile) FindMatchingResourceTypeUsage ¶
func (u *ReferenceFile) FindMatchingResourceTypeUsage(resourceType string) *ResourceUsage
func (*ReferenceFile) FindMatchingResourceUsage ¶
func (u *ReferenceFile) FindMatchingResourceUsage(name string) *ResourceUsage
FindMatchingResourceUsage returns the matching resource usage for the given resource name by looking for a resource with the same resource type
func (*ReferenceFile) SetDefaultValues ¶
func (u *ReferenceFile) SetDefaultValues()
SetDefaultValues updates the reference file to strip the values and set the default values
type ReplaceResourceUsagesOpts ¶
type ReplaceResourceUsagesOpts struct {
OverrideValueType bool
}
type ResourceUsage ¶
ResourceUsage represents a resource block in the usage file
func ResourceUsagesFromYAML ¶
func ResourceUsagesFromYAML(raw yamlv3.Node) ([]*ResourceUsage, error)
func (*ResourceUsage) Map ¶
func (r *ResourceUsage) Map() map[string]interface{}
func (*ResourceUsage) MergeResourceUsage ¶
func (r *ResourceUsage) MergeResourceUsage(src *ResourceUsage)
MergeResourceUsage merge ResourceItem from src to r without overriding r
type SyncResult ¶
func SyncUsageData ¶
func SyncUsageData(projectCtx *config.ProjectContext, usageFile *UsageFile, projects []*schema.Project) (*SyncResult, error)
func (*SyncResult) Merge ¶
func (s *SyncResult) Merge(other *SyncResult)
func (*SyncResult) ProjectContext ¶
func (s *SyncResult) ProjectContext() map[string]interface{}
type UsageFile ¶
type UsageFile struct { Version string `yaml:"version"` // We represent resource type usage in using a YAML node so we have control over the comments RawResourceTypeUsage yamlv3.Node `yaml:"resource_type_default_usage"` // The raw usage is then parsed into this struct ResourceTypeUsages []*ResourceUsage `yaml:"-"` // We represent resource usage in using a YAML node so we have control over the comments RawResourceUsage yamlv3.Node `yaml:"resource_usage"` // The raw usage is then parsed into this struct ResourceUsages []*ResourceUsage `yaml:"-"` }
func LoadUsageFile ¶
func LoadUsageFileFromString ¶
func NewBlankUsageFile ¶
func NewBlankUsageFile() *UsageFile
func (*UsageFile) InvalidKeys ¶
InvalidKeys returns a list of keys that are invalid in the usage file. It currently checks the reference usage file for a list of valid keys. In the future we will want this to usage the resource usage schema structs as well.