usage

package
v0.0.0-...-55ed90b Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateTierBuckets

func CalculateTierBuckets(requestCount decimal.Decimal, tierLimits []int) []decimal.Decimal

func CreateUsageFile

func CreateUsageFile(path string) error

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

type ResourceUsage struct {
	Name  string
	Items []*schema.UsageItem
}

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

type SyncResult struct {
	ResourceCount    int
	EstimationCount  int
	EstimationErrors map[string]error
}

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 LoadUsageFile(path string) (*UsageFile, error)

func LoadUsageFileFromString

func LoadUsageFileFromString(s string) (*UsageFile, error)

func NewBlankUsageFile

func NewBlankUsageFile() *UsageFile

func (*UsageFile) InvalidKeys

func (u *UsageFile) InvalidKeys() ([]string, error)

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.

func (*UsageFile) ToUsageDataMap

func (u *UsageFile) ToUsageDataMap() schema.UsageMap

func (*UsageFile) WriteToPath

func (u *UsageFile) WriteToPath(path string) error

Jump to

Keyboard shortcuts

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