Documentation
¶
Index ¶
- Variables
- func AddRawValue(r gjson.Result, key string, v interface{}) gjson.Result
- func BuildEstimates(projects []*Workspace, projectPtrToUsageMap map[*Workspace]ConsumptionMap)
- func ComputeCosts(project *Workspace)
- func ExtractMissingVarsCausingMissingAttributeKeys(r *ResourceSpec, attribute string) []string
- func IsEmptyPathTypeError(err error) bool
- func ParseAttributes(i interface{}) map[string]gjson.Result
- func ScaleQuantities(resource *Estimate, multiplier decimal.Decimal)
- func SortEstimates(project *Workspace)
- type AttributeMatch
- type AttributeWithUnknownKeys
- type BlankCoreResource
- type CatalogBuilder
- type CatalogEntry
- type CatalogItem
- type CatalogItemWithConsumptionParams
- type CloudResourceIDFunc
- type ConsumptionField
- type ConsumptionMap
- type ConsumptionParam
- type ConsumptionProfile
- func (u *ConsumptionProfile) CalcEstimationSummary() map[string]bool
- func (u *ConsumptionProfile) Copy() *ConsumptionProfile
- func (u *ConsumptionProfile) Get(key string) gjson.Result
- func (u *ConsumptionProfile) GetFloat(key string) *float64
- func (u *ConsumptionProfile) GetInt(key string) *int64
- func (u *ConsumptionProfile) GetString(key string) *string
- func (u *ConsumptionProfile) GetStringArray(key string) *[]string
- func (u *ConsumptionProfile) IsEmpty(key string) bool
- func (u *ConsumptionProfile) Merge(other *ConsumptionProfile) *ConsumptionProfile
- type Diagnostic
- func NewDiagJSONParsingFailure(err error) *Diagnostic
- func NewDiagMissingVars(vars ...string) *Diagnostic
- func NewDiagModuleEvaluationFailure(err error) *Diagnostic
- func NewDiagRunQuotaExceeded(err error) *Diagnostic
- func NewDiagTerragruntEvaluationFailure(err error) *Diagnostic
- func NewDiagTerragruntModuleEvaluationFailure(err error) *Diagnostic
- func NewEmptyPathTypeError(err error) *Diagnostic
- func NewFailedDownloadDiagnostic(source string, err error) *Diagnostic
- func NewPrivateRegistryDiag(source string, moduleLocation *string, err error) *Diagnostic
- type Estimate
- type LegacyBuilder
- type LineItem
- func (c *LineItem) CalculateCosts()
- func (c *LineItem) CustomPrice() *decimal.Decimal
- func (c *LineItem) Price() decimal.Decimal
- func (c *LineItem) PriceHash() string
- func (c *LineItem) SetCustomPrice(price *decimal.Decimal)
- func (c *LineItem) SetPrice(price decimal.Decimal)
- func (c *LineItem) SetPriceHash(priceHash string)
- func (c *LineItem) SetPriceNotFound()
- func (c *LineItem) UnitMultiplierHourlyQuantity() *decimal.Decimal
- func (c *LineItem) UnitMultiplierMonthlyQuantity() *decimal.Decimal
- func (c *LineItem) UnitMultiplierPrice() decimal.Decimal
- type ObservedCost
- type Policies
- type Policy
- type ProductSelector
- type Projects
- type RateSelector
- type ReferenceIDFunc
- type RegionLookupFunc
- type Remediater
- type ResourceSpec
- func (d *ResourceSpec) AddReference(k string, reference *ResourceSpec, reverseRefAttrs []string)
- func (d *ResourceSpec) Get(key string) gjson.Result
- func (d *ResourceSpec) GetBoolOrDefault(key string, def bool) bool
- func (d *ResourceSpec) GetFloat64OrDefault(key string, def float64) float64
- func (d *ResourceSpec) GetInt64OrDefault(key string, def int64) int64
- func (d *ResourceSpec) GetStringOrDefault(key, def string) string
- func (d *ResourceSpec) IsEmpty(key string) bool
- func (d *ResourceSpec) References(keys ...string) []*ResourceSpec
- func (d *ResourceSpec) ReplaceReference(k string, oldReference *ResourceSpec, newReference *ResourceSpec)
- func (d *ResourceSpec) Set(key string, value interface{})
- type TagPropagation
- type UnpricedEntry
- type UsageEstimator
- type UsageVariableType
- type Vendor
- type VendorMeta
- type Workspace
- func (p *Workspace) AddProviderMetadata(metadatas []VendorMeta)
- func (p *Workspace) AllPartialResources() []*UnpricedEntry
- func (p *Workspace) AllResources() []*Estimate
- func (p *Workspace) BuildResources(usageMap ConsumptionMap)
- func (p *Workspace) CalculateDiff()
- func (p *Workspace) NameWithWorkspace() string
- type WorkspaceMeta
- func (m *WorkspaceMeta) AddError(err error)
- func (m *WorkspaceMeta) GenerateProjectName(remote vcs.Remote, dashboardEnabled bool) string
- func (m *WorkspaceMeta) HasErrors() bool
- func (m *WorkspaceMeta) IsEmptyProjectError() bool
- func (m *WorkspaceMeta) IsRunQuotaExceeded() (string, bool)
- func (m *WorkspaceMeta) WorkspaceLabel() string
Constants ¶
This section is empty.
Variables ¶
var ( HourToMonthUnitMultiplier = decimal.NewFromInt(730) MonthToHourUnitMultiplier = decimal.NewFromInt(1).Div(HourToMonthUnitMultiplier) DaysInMonth = HourToMonthUnitMultiplier.DivRound(decimal.NewFromInt(24), 24) DayToMonthUnitMultiplier = DaysInMonth.DivRound(HourToMonthUnitMultiplier, 24) )
Functions ¶
func BuildEstimates ¶
func BuildEstimates(projects []*Workspace, projectPtrToUsageMap map[*Workspace]ConsumptionMap)
func ComputeCosts ¶
func ComputeCosts(project *Workspace)
func ExtractMissingVarsCausingMissingAttributeKeys ¶
func ExtractMissingVarsCausingMissingAttributeKeys(r *ResourceSpec, attribute string) []string
func IsEmptyPathTypeError ¶
IsEmptyPathTypeError checks if the error is a diag for an empty path type.
func ParseAttributes ¶
func ScaleQuantities ¶
func SortEstimates ¶
func SortEstimates(project *Workspace)
Types ¶
type AttributeMatch ¶
type BlankCoreResource ¶
BlankCoreResource is a helper struct for NoPrice and Skipped resources that are evaluated as part of the Policy API. This implements the CoreResource interface and returns a skipped resource that doesn't affect the CLI output.
func (BlankCoreResource) BuildResource ¶
func (b BlankCoreResource) BuildResource() *Estimate
func (BlankCoreResource) CoreType ¶
func (b BlankCoreResource) CoreType() string
func (BlankCoreResource) PopulateUsage ¶
func (b BlankCoreResource) PopulateUsage(u *ConsumptionProfile)
func (BlankCoreResource) UsageSchema ¶
func (b BlankCoreResource) UsageSchema() []*ConsumptionField
type CatalogBuilder ¶
type CatalogBuilder func(*ResourceSpec) CatalogItem
type CatalogEntry ¶
type CatalogEntry struct {
Name string
Notes []string
RFunc LegacyBuilder
CoreRFunc CatalogBuilder
ReferenceAttributes []string
CustomRefIDFunc ReferenceIDFunc
DefaultRefIDFunc ReferenceIDFunc
CloudResourceIDFunc CloudResourceIDFunc
NoPrice bool
// GetRegion is used to look up the region of a resource if it has a region that
// cannot be calculated from the default resource/provider data. If the GetRegion
// is nil or the return result is empty the region will be calculated from the
// default resource/provider data.
GetRegion RegionLookupFunc
}
type CatalogItem ¶
type CatalogItem interface {
CoreType() string
UsageSchema() []*ConsumptionField
PopulateUsage(u *ConsumptionProfile)
BuildResource() *Estimate
}
CatalogItem is the new/preferred way to represent provider-agnostic resources that support advanced features such as C3X Cloud usage estimates and actual costs.
type CatalogItemWithConsumptionParams ¶
type CatalogItemWithConsumptionParams interface {
CatalogItem
UsageEstimationParams() []ConsumptionParam
}
CatalogItemWithConsumptionParams is a CoreResource that sends additional parameters (e.g. Lambda memory size) to the Usage API when estimating usage.
type CloudResourceIDFunc ¶
type CloudResourceIDFunc func(d *ResourceSpec) []string
CloudResourceIDFunc is used to calculate the cloud resource ids (AWS ARN, Google HREF, etc...) associated with the resource
type ConsumptionField ¶
type ConsumptionField struct {
Key string
DefaultValue interface{}
Value interface{}
ValueType UsageVariableType
Description string
}
type ConsumptionMap ¶
type ConsumptionMap struct {
// contains filtered or unexported fields
}
ConsumptionMap is a map of address to UsageData built from a usage file. ConsumptionMap is a standalone type so that we can do more involved matching functionality.
func NewUsageMap ¶
func NewUsageMap(data map[string]*ConsumptionProfile) ConsumptionMap
NewUsageMap initialises a Usage map with the provided usage key data. It builds a set of wildcard keys if any are found and sorts them ready for searching by Attribute name at a later point.
func NewUsageMapFromInterface ¶
func NewUsageMapFromInterface(m map[string]interface{}) ConsumptionMap
NewUsageMapFromInterface returns an initialised UsageMap from interface map.
func (ConsumptionMap) Data ¶
func (usage ConsumptionMap) Data() map[string]*ConsumptionProfile
Data returns the entire map of usage data stored.
func (ConsumptionMap) Get ¶
func (usage ConsumptionMap) Get(address string) *ConsumptionProfile
Get returns UsageData for a given resource address, this can be a combined/merged UsageData from multiple keys. Usage data is merged adhering to the following hierarchy:
- Resource type defaults - e.g. aws_lambda:
- Wildcard specified data - e.g. aws_lambda.my_lambda[*]
- Exact resource data - e.g. aws_lambda.my_lambda["foo"]
Duplicate keys specified between levels are always overwritten by keys specified at a lower level, e.g:
aws_lambda.my_lambda[*]: monthly_requests: 700000000 request_duration_ms: 750 aws_lambda.my_lambda["foo"]: request_duration_ms: 100 << this overwrites the 750 value given in the wildcard usage
If no usage key is found, Get will return nil.
type ConsumptionParam ¶
type ConsumptionProfile ¶
func NewUsageData ¶
func NewUsageData(address string, attributes map[string]gjson.Result) *ConsumptionProfile
func (*ConsumptionProfile) CalcEstimationSummary ¶
func (u *ConsumptionProfile) CalcEstimationSummary() map[string]bool
CalcEstimationSummary returns a map where a value of true means the attribute key has an actual estimate, false means it is using the defaults
func (*ConsumptionProfile) Copy ¶
func (u *ConsumptionProfile) Copy() *ConsumptionProfile
Copy returns a clone of UsageData u.
func (*ConsumptionProfile) GetFloat ¶
func (u *ConsumptionProfile) GetFloat(key string) *float64
func (*ConsumptionProfile) GetInt ¶
func (u *ConsumptionProfile) GetInt(key string) *int64
func (*ConsumptionProfile) GetString ¶
func (u *ConsumptionProfile) GetString(key string) *string
func (*ConsumptionProfile) GetStringArray ¶
func (u *ConsumptionProfile) GetStringArray(key string) *[]string
func (*ConsumptionProfile) IsEmpty ¶
func (u *ConsumptionProfile) IsEmpty(key string) bool
Return true if the key doesn't exist, is null, or is an empty string. Needed because gjson.Exists returns true as long as a key exists, even if it's empty or null.
func (*ConsumptionProfile) Merge ¶
func (u *ConsumptionProfile) Merge(other *ConsumptionProfile) *ConsumptionProfile
Merge returns a new UsageData which is the result of adding all keys from other that do not already exists in the usage data
type Diagnostic ¶
type Diagnostic struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data"`
IsError bool `json:"isError"`
// FriendlyMessage should be used to display a readable message to the CLI user.
FriendlyMessage string `json:"-"`
}
Diagnostic holds information about all diagnostics associated with a project. This can be both critical or warnings.
func NewDiagJSONParsingFailure ¶
func NewDiagJSONParsingFailure(err error) *Diagnostic
NewDiagJSONParsingFailure returns a project diag for a JSON parsing failure in the intermediary JSON that the HCL provider generates. This is considered a critical error as a project will not have any costs if this happens.
func NewDiagMissingVars ¶
func NewDiagMissingVars(vars ...string) *Diagnostic
NewDiagMissingVars returns a ProjectDiag for missing Terraform vars. This is considered a non-critical error and is used to notify the user.
func NewDiagModuleEvaluationFailure ¶
func NewDiagModuleEvaluationFailure(err error) *Diagnostic
NewDiagModuleEvaluationFailure returns a project diag for a module evaluation failure. This is used when a Terraform module fails to evaluate. This can either be a root module of a Terraform project or a child module.
func NewDiagRunQuotaExceeded ¶
func NewDiagRunQuotaExceeded(err error) *Diagnostic
NewDiagRunQuotaExceeded returns a project diag for a run quota exceeded error.
func NewDiagTerragruntEvaluationFailure ¶
func NewDiagTerragruntEvaluationFailure(err error) *Diagnostic
NewDiagTerragruntEvaluationFailure returns a project diag for a Terragrunt evaluation failure. This is used when a Terragrunt fails to run/evaluate in most cases this means that the entire project is not evaluated. It is considered a critical error.
func NewDiagTerragruntModuleEvaluationFailure ¶
func NewDiagTerragruntModuleEvaluationFailure(err error) *Diagnostic
NewDiagTerragruntModuleEvaluationFailure returns a project diag for a terragrunt module evaluation failure. This is used when a Terraform module which a Terragrunt configuration file references fails to evaluate.
func NewEmptyPathTypeError ¶
func NewEmptyPathTypeError(err error) *Diagnostic
NewEmptyPathTypeError returns a project diag to indicate that a path type cannot be detected.
func NewFailedDownloadDiagnostic ¶
func NewFailedDownloadDiagnostic(source string, err error) *Diagnostic
NewFailedDownloadDiagnostic returns a project diag for a failed module download. This contains additional information about the module source and the type of source.
func NewPrivateRegistryDiag ¶
func NewPrivateRegistryDiag(source string, moduleLocation *string, err error) *Diagnostic
NewPrivateRegistryDiag returns a project diag for a private registry module download failure. This contains additional information about the module source and the discovered location returned by the registry.
func (*Diagnostic) Error ¶
func (p *Diagnostic) Error() string
type Estimate ¶
type Estimate struct {
Name string
CostComponents []*LineItem
ActualCosts []*ObservedCost
SubResources []*Estimate
HourlyCost *decimal.Decimal
MonthlyCost *decimal.Decimal
MonthlyUsageCost *decimal.Decimal
IsSkipped bool
NoPrice bool
SkipMessage string
ResourceType string
Tags *map[string]string
DefaultTags *map[string]string
TagPropagation *TagPropagation
ProviderSupportsDefaultTags bool
ProviderLink string
UsageSchema []*ConsumptionField
EstimateUsage UsageEstimator
EstimationSummary map[string]bool
Metadata map[string]gjson.Result
MissingVarsCausingUnknownTagKeys []string
MissingVarsCausingUnknownDefaultTagKeys []string
// contains filtered or unexported fields
}
func AllProjectResources ¶
AllProjectResources returns the resources for all projects
func BuildResource ¶
func BuildResource(partial *UnpricedEntry, fetchedUsage *ConsumptionProfile) *Estimate
BuildResource create a new Resource from the CoreResource, or (for backward compatibility) returns a previously built Resource
func ComputeDiff ¶
ComputeDiff calculates the diff of past and current resources
func (*Estimate) BaseResourceName ¶
BaseResourceName returns the base resource name of the resource. This is the resource name of the top level resource in the hierarchy.
func (*Estimate) BaseResourceType ¶
BaseResourceType returns the base resource type of the resource. This is the resource type of the top level resource in the hierarchy. For example, if the resource is a subresource of a `aws_instance` resource (e.g. ebs_block_device), the base resource type will be `aws_instance`.
func (*Estimate) CalculateCosts ¶
func (r *Estimate) CalculateCosts()
func (*Estimate) FlattenedSubResources ¶
FlattenedSubResources returns a list of resources from the given resources, flattening all sub resources recursively. It also sets the parent resource for each sub resource so that the full resource can be reconstructed.
func (*Estimate) RemoveCostComponent ¶
type LegacyBuilder ¶
type LegacyBuilder func(*ResourceSpec, *ConsumptionProfile) *Estimate
type LineItem ¶
type LineItem struct {
Name string
Unit string
UnitMultiplier decimal.Decimal
// UnitRounding specifies the number of decimal places that the output unit should be rounded to.
// This should be set to 0 if using MonthToHourUnitMultiplier otherwise the unit will show with
// redundant .000 decimal places.
UnitRounding *int32
IgnoreIfMissingPrice bool
ProductFilter *ProductSelector
PriceFilter *RateSelector
HourlyQuantity *decimal.Decimal
MonthlyQuantity *decimal.Decimal
MonthlyDiscountPerc float64
HourlyCost *decimal.Decimal
MonthlyCost *decimal.Decimal
UsageBased bool
PriceNotFound bool
// contains filtered or unexported fields
}
func (*LineItem) CalculateCosts ¶
func (c *LineItem) CalculateCosts()
func (*LineItem) CustomPrice ¶
func (*LineItem) SetCustomPrice ¶
func (*LineItem) SetPriceHash ¶
func (*LineItem) SetPriceNotFound ¶
func (c *LineItem) SetPriceNotFound()
SetPriceNotFound zeros the price and marks the component as having a price not found.
func (*LineItem) UnitMultiplierHourlyQuantity ¶
func (*LineItem) UnitMultiplierMonthlyQuantity ¶
func (*LineItem) UnitMultiplierPrice ¶
type ObservedCost ¶
type Policy ¶
type Policy struct {
ID string `json:"id"`
Title string `json:"title"`
Description string `json:"description"`
ResourceType string `json:"resource_type"`
ResourceAttributes json.RawMessage `json:"resource_attributes"`
Address string `json:"address"`
Suggested string `json:"suggested"`
NoCost bool `json:"no_cost"`
Cost *decimal.Decimal `json:"cost"`
}
type ProductSelector ¶
type ProductSelector 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 []*AttributeMatch `json:"attributeFilters,omitempty"`
}
type Projects ¶
type Projects []*Workspace
Projects is a slice of Project that is ordered alphabetically by project name.
type RateSelector ¶
type RateSelector 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 ReferenceIDFunc ¶
type ReferenceIDFunc func(d *ResourceSpec) []string
ReferenceIDFunc is used to let references be built using non-standard IDs (anything other than d.Get("id").string)
type RegionLookupFunc ¶
type RegionLookupFunc func(defaultRegion string, d *ResourceSpec) string
RegionLookupFunc is used to look up the region of a resource, this is used to calculate the region of a resource if the region requires a lookup from reference attributes.
type Remediater ¶
type Remediater interface {
// Describe provides an English description of the remediation action X that
// would fit into a sentence "May we X?" (e.g. "enable bucket metrics").
// The description can be used to prompt the user before taking action.
Describe() string
// Remediate attempts to fix a problem in the cloud that prevents estimation,
// e.g. by enabling metrics collection on certain resources.
Remediate() error
}
Remediater allows correction of cloud configuration issues so that future runs of C3X will provide more accurate results.
type ResourceSpec ¶
type ResourceSpec struct {
Type string
ProviderName string
Address string
Tags *map[string]string
DefaultTags *map[string]string
ProviderSupportsDefaultTags bool
ProviderLink string
TagPropagation *TagPropagation
RawValues gjson.Result
ReferencesMap map[string][]*ResourceSpec
CFResource cloudformation.Resource
UsageData *ConsumptionProfile
Metadata map[string]gjson.Result
ProjectMetadata map[string]string
MissingVarsCausingUnknownTagKeys []string
MissingVarsCausingUnknownDefaultTagKeys []string
// Region is the region of the resource. When building a resource callers should
// use this value instead of the deprecated d.Get("region").String() or
// lookupRegion method.
Region string
}
func NewCFResourceData ¶
func NewCFResourceData(resourceType string, providerName string, address string, tags *map[string]string, cfResource cloudformation.Resource) *ResourceSpec
func NewResourceData ¶
func (*ResourceSpec) AddReference ¶
func (d *ResourceSpec) AddReference(k string, reference *ResourceSpec, reverseRefAttrs []string)
func (*ResourceSpec) GetBoolOrDefault ¶
func (d *ResourceSpec) GetBoolOrDefault(key string, def bool) bool
func (*ResourceSpec) GetFloat64OrDefault ¶
func (d *ResourceSpec) GetFloat64OrDefault(key string, def float64) float64
GetFloat64OrDefault returns the value of key within ResourceData as a float64. If the retrieved value is not set GetFloat64OrDefault will return def.
func (*ResourceSpec) GetInt64OrDefault ¶
func (d *ResourceSpec) GetInt64OrDefault(key string, def int64) int64
GetInt64OrDefault returns the value of key within ResourceData as an int64. If the retrieved value is not set GetInt64OrDefault will return def.
func (*ResourceSpec) GetStringOrDefault ¶
func (d *ResourceSpec) GetStringOrDefault(key, def string) string
GetStringOrDefault returns the value of key within ResourceData as a string. If the retrieved value is not set GetStringOrDefault will return def.
func (*ResourceSpec) IsEmpty ¶
func (d *ResourceSpec) IsEmpty(key string) bool
Return true if the key doesn't exist, is null, or is an empty string. Needed because gjson.Exists returns true as long as a key exists, even if it's empty or null.
func (*ResourceSpec) References ¶
func (d *ResourceSpec) References(keys ...string) []*ResourceSpec
func (*ResourceSpec) ReplaceReference ¶
func (d *ResourceSpec) ReplaceReference(k string, oldReference *ResourceSpec, newReference *ResourceSpec)
func (*ResourceSpec) Set ¶
func (d *ResourceSpec) Set(key string, value interface{})
type TagPropagation ¶
type TagPropagation struct {
To string // a human-readable name of the type being propagated to - will not always have a tf type
From *string // e.g. SERVICE, TASK_DEFINITION
Tags *map[string]string // tags that were propagated from the above resource, if any
Attribute string // the attribute that can be used to configured propagation, e.g. propagate_tags
HasRequiredAttributes bool // whether the resource has the required attributes to warrant propagating tags
}
type UnpricedEntry ¶
type UnpricedEntry struct {
Type string
Address string
Tags *map[string]string
DefaultTags *map[string]string
ProviderSupportsDefaultTags bool
ProviderLink string
TagPropagation *TagPropagation
UsageData *ConsumptionProfile
Metadata map[string]gjson.Result
MissingVarsCausingUnknownTagKeys []string
MissingVarsCausingUnknownDefaultTagKeys []string
// CoreResource is the new/preferred struct for providing an intermediate-object
// that contains all provider-derived information, but has not yet been built into
// a Resource.
CoreResource CatalogItem
// Resource field is provided for backward compatibility with provider resource builders
// that have not yet been converted to build CoreResource's
Resource *Estimate
// CloudResourceIDs are collected during parsing in case they need to be uploaded to the
// Cloud Usage API to be used in the usage estimate calculations.
CloudResourceIDs []string
}
UnpricedEntry is used to collect all information required to construct a resource that is generated by provider parser and pass it back up to top level functions that can supply additional provider-agnostic information (such as C3X Cloud usage estimates) before the resource is built.
func NewPartialResource ¶
func NewPartialResource(d *ResourceSpec, r *Estimate, cr CatalogItem, cloudResourceIds []string) *UnpricedEntry
type UsageEstimator ¶
UsageEstimator queries cloud providers to gather past usage information, then projects future usage based on the results.
type UsageVariableType ¶
type UsageVariableType int
const ( Int64 UsageVariableType = iota String Float64 StringArray SubResourceUsage KeyValueMap )
type Vendor ¶
type Vendor interface {
Type() string
DisplayType() string
ProjectName() string
RelativePath() string
VarFiles() []string
AddMetadata(*WorkspaceMeta)
LoadResources(ConsumptionMap) ([]*Workspace, error)
Context() *settings.ProjectSession
}
type VendorMeta ¶
type VendorMeta struct {
Name string `json:"name,omitempty"`
DefaultTags map[string]string `json:"defaultTags,omitempty"`
Filename string `json:"filename,omitempty"`
StartLine int64 `json:"startLine,omitempty"`
EndLine int64 `json:"endLine,omitempty"`
AttributesWithUnknownKeys []AttributeWithUnknownKeys `json:"attributesWithUnknownKeys,omitempty"`
}
type Workspace ¶
type Workspace struct {
Name string
Metadata *WorkspaceMeta
PartialPastResources []*UnpricedEntry
PartialResources []*UnpricedEntry
PastResources []*Estimate
Resources []*Estimate
Diff []*Estimate
HasDiff bool
DisplayName string
}
Workspace contains the existing, planned state of resources and the diff between them.
func NewProject ¶
func NewProject(name string, metadata *WorkspaceMeta) *Workspace
func (*Workspace) AddProviderMetadata ¶
func (p *Workspace) AddProviderMetadata(metadatas []VendorMeta)
func (*Workspace) AllPartialResources ¶
func (p *Workspace) AllPartialResources() []*UnpricedEntry
AllPartialResources returns a pointer list of the current and past partial resources
func (*Workspace) AllResources ¶
AllResources returns a pointer list of all resources of the state.
func (*Workspace) BuildResources ¶
func (p *Workspace) BuildResources(usageMap ConsumptionMap)
BuildResources builds the resources from the partial resources and sets the PastResources and Resources fields.
func (*Workspace) CalculateDiff ¶
func (p *Workspace) CalculateDiff()
CalculateDiff calculates the diff of past and current resources
func (*Workspace) NameWithWorkspace ¶
NameWithWorkspace returns the project Name appended with the parenthesized workspace name from Metadata if one exists.
type WorkspaceMeta ¶
type WorkspaceMeta struct {
Path string `json:"path"`
Type string `json:"type"`
ConfigSha string `json:"configSha,omitempty"`
PolicySha string `json:"policySha,omitempty"`
PastPolicySha string `json:"pastPolicySha,omitempty"`
TerraformModulePath string `json:"terraformModulePath,omitempty"`
TerraformWorkspace string `json:"terraformWorkspace,omitempty"`
VCSSubPath string `json:"vcsSubPath,omitempty"`
VCSCodeChanged *bool `json:"vcsCodeChanged,omitempty"`
Errors []*Diagnostic `json:"errors,omitempty"` // contains merged current and past errors
CurrentErrors []*Diagnostic `json:"currentErrors,omitempty"`
PastErrors []*Diagnostic `json:"pastErrors,omitempty"`
Warnings []*Diagnostic `json:"warnings,omitempty"`
Policies Policies `json:"policies,omitempty"`
Providers []VendorMeta `json:"providers,omitempty"`
RemoteModuleCalls []string `json:"remoteModuleCalls,omitempty"`
}
func DetectProjectMetadata ¶
func DetectProjectMetadata(path string) *WorkspaceMeta
DetectProjectMetadata returns a new ProjectMetadata struct initialized from environment variables and the provided path.
func (*WorkspaceMeta) AddError ¶
func (m *WorkspaceMeta) AddError(err error)
AddError pushes the provided error onto the metadata list. It does a naive conversion to ProjectDiag if the error provided is not already a diagnostic.
func (*WorkspaceMeta) GenerateProjectName ¶
func (m *WorkspaceMeta) GenerateProjectName(remote vcs.Remote, dashboardEnabled bool) string
func (*WorkspaceMeta) HasErrors ¶
func (m *WorkspaceMeta) HasErrors() bool
func (*WorkspaceMeta) IsEmptyProjectError ¶
func (m *WorkspaceMeta) IsEmptyProjectError() bool
func (*WorkspaceMeta) IsRunQuotaExceeded ¶
func (m *WorkspaceMeta) IsRunQuotaExceeded() (string, bool)
IsRunQuotaExceeded checks if any of the project diags are of type "run quota exceeded". If found it returns the associated message with this diag. This should be used when in any output that notifies the user.
func (*WorkspaceMeta) WorkspaceLabel ¶
func (m *WorkspaceMeta) WorkspaceLabel() string