Documentation ¶
Index ¶
- Constants
- Variables
- func FormatCost2DP(currency string, d *decimal.Decimal) string
- func FormatOutput(format string, r Root, opts Options) ([]byte, error)
- func LoadAdditionalCommentData(path string) (string, error)
- func ToDiff(out Root, opts Options) ([]byte, error)
- func ToHTML(out Root, opts Options) ([]byte, error)
- func ToJSON(out Root, opts Options) ([]byte, error)
- func ToSlackMessage(out Root, opts Options) ([]byte, error)
- func ToTable(out Root, opts Options) ([]byte, error)
- type ActualCosts
- type Breakdown
- type CostComponent
- type GovernanceFailures
- type MarkdownCtx
- type MarkdownOptions
- type MarkdownOutput
- type Metadata
- type Options
- type PolicyCheck
- type PolicyCheckFailures
- type PolicyCheckOutput
- type PolicyCheckResourceDetails
- type PolicyCheckViolations
- type PolicyOutput
- type Project
- type Projects
- type ReportInput
- type Resource
- type Root
- type Summary
- type SummaryOptions
Constants ¶
const ( UPDATED = iota ADDED REMOVED )
Variables ¶
var (
GitHubMaxMessageSize = 262144 // bytes
)
Functions ¶
func FormatCost2DP ¶ added in v0.10.14
func FormatOutput ¶ added in v0.10.0
FormatOutput returns Root r as the format specified. The default format is a table output.
func LoadAdditionalCommentData ¶ added in v0.10.30
LoadAdditionalCommentData reads the file at the path into a string.
Types ¶
type ActualCosts ¶ added in v0.10.12
type Breakdown ¶ added in v0.7.19
type Breakdown struct { Resources []Resource `json:"resources"` FreeResources []Resource `json:"freeResources,omitempty"` TotalHourlyCost *decimal.Decimal `json:"totalHourlyCost"` TotalMonthlyCost *decimal.Decimal `json:"totalMonthlyCost"` TotalMonthlyUsageCost *decimal.Decimal `json:"totalMonthlyUsageCost"` }
func (*Breakdown) HasResources ¶ added in v0.10.32
HasResources returns true if the breakdown has any resources or free resources. This is used to determine if the breakdown should be shown in the output.
func (*Breakdown) TotalMonthlyBaselineCost ¶ added in v0.10.35
type CostComponent ¶ added in v0.7.4
type CostComponent struct { Name string `json:"name"` Unit string `json:"unit"` HourlyQuantity *decimal.Decimal `json:"hourlyQuantity"` MonthlyQuantity *decimal.Decimal `json:"monthlyQuantity"` Price decimal.Decimal `json:"price"` HourlyCost *decimal.Decimal `json:"hourlyCost"` MonthlyCost *decimal.Decimal `json:"monthlyCost"` UsageBased bool `json:"usageBased,omitempty"` PriceNotFound bool `json:"priceNotFound"` }
type GovernanceFailures ¶ added in v0.10.30
type GovernanceFailures []string
GovernanceFailures defines a list of governance failures that were returned from infracost cloud.
func (GovernanceFailures) Error ¶ added in v0.10.30
func (g GovernanceFailures) Error() string
Error implements the Error interface returning the failures as a single message that can be used in stderr.
type MarkdownCtx ¶ added in v0.10.17
type MarkdownCtx struct { Root Root SkippedProjectCount int ErroredProjectCount int SkippedUnchangedProjectCount int DiffOutput string Options Options MarkdownOptions MarkdownOptions RunQuotaMsg string UsageCostsMsg string CostDetailsMsg string }
MarkdownCtx holds information that can be used and executed with a go template.
type MarkdownOptions ¶ added in v0.9.17
type MarkdownOutput ¶ added in v0.10.25
MarkdownOutput holds the message converted to markdown with additional information about its length.
func ToMarkdown ¶ added in v0.9.13
func ToMarkdown(out Root, opts Options, markdownOpts MarkdownOptions) (MarkdownOutput, error)
type Metadata ¶ added in v0.10.10
type Metadata struct { InfracostCommand string `json:"infracostCommand"` Branch string `json:"vcsBranch"` BaseCommitSHA string `json:"vcsBaseCommitSha,omitempty"` CommitSHA string `json:"vcsCommitSha"` CommitAuthorName string `json:"vcsCommitAuthorName"` CommitAuthorEmail string `json:"vcsCommitAuthorEmail"` CommitTimestamp time.Time `json:"vcsCommitTimestamp"` CommitMessage string `json:"vcsCommitMessage"` VCSRepositoryURL string `json:"vcsRepositoryUrl,omitempty"` VCSProvider string `json:"vcsProvider,omitempty"` VCSBaseBranch string `json:"vcsBaseBranch,omitempty"` VCSPullRequestTitle string `json:"vcsPullRequestTitle,omitempty"` VCSPullRequestURL string `json:"vcsPullRequestUrl,omitempty"` VCSPullRequestAuthor string `json:"vcsPullRequestAuthor,omitempty"` VCSPullRequestLabels []string `json:"vcsPullRequestLabels,omitempty"` VCSPipelineRunID string `json:"vcsPipelineRunId,omitempty"` VCSPullRequestID string `json:"vcsPullRequestId,omitempty"` UsageApiEnabled bool `json:"usageApiEnabled,omitempty"` UsageFilePath string `json:"usageFilePath,omitempty"` ConfigFilePath string `json:"configFilePath,omitempty"` ConfigFileHasUsageFile bool `json:"configFileHasUsageFile,omitempty"` }
Metadata holds common information used to identify the system that Infracost is run within.
func NewMetadata ¶ added in v0.10.10
func NewMetadata(ctx *config.RunContext) Metadata
NewMetadata returns a Metadata struct filled with information built from the RunContext.
type PolicyCheck ¶ added in v0.9.20
type PolicyCheck struct { Enabled bool Failures PolicyCheckFailures Passed []string }
PolicyCheck holds information if a given run has any policy checks enabled. This struct is used in templates to create useful cost policy outputs.
func (PolicyCheck) HasFailed ¶ added in v0.9.20
func (p PolicyCheck) HasFailed() bool
HasFailed returns if the PolicyCheck has any cost policy failures
type PolicyCheckFailures ¶ added in v0.9.20
type PolicyCheckFailures []string
PolicyCheckFailures defines a list of policy check failures that can be collected from a policy evaluation.
func (PolicyCheckFailures) Error ¶ added in v0.9.20
func (p PolicyCheckFailures) Error() string
Error implements the Error interface returning the failures as a single message that can be used in stderr.
type PolicyCheckOutput ¶ added in v0.10.25
type PolicyCheckResourceDetails ¶ added in v0.10.25
type PolicyCheckResourceDetails struct { Address string ResourceType string Path string Line int Violations []PolicyCheckViolations }
type PolicyCheckViolations ¶ added in v0.10.25
type PolicyOutput ¶ added in v0.10.25
type PolicyOutput struct { HasFailures bool HasWarnings bool Checks []PolicyCheckOutput }
PolicyOutput holds normalized PolicyCheck and TagPolicyCheck data so it can be output in a uniform "Policies" section of the infracost comment.
func NewPolicyOutput ¶ added in v0.10.25
func NewPolicyOutput(pc PolicyCheck) PolicyOutput
NewPolicyOutput normalizes a PolicyCheck suitable for use in the output markdown template.
type Project ¶ added in v0.7.19
type Project struct { Name string `json:"name"` DisplayName string `json:"displayName"` Metadata *schema.ProjectMetadata `json:"metadata"` PastBreakdown *Breakdown `json:"pastBreakdown"` Breakdown *Breakdown `json:"breakdown"` Diff *Breakdown `json:"diff"` Summary *Summary `json:"summary"` // contains filtered or unexported fields }
func (*Project) LabelWithMetadata ¶ added in v0.10.4
LabelWithMetadata returns the display name of the project appended with any distinguishing metadata (Module path or Workspace)
func (*Project) ToSchemaProject ¶ added in v0.9.23
ToSchemaProject generates a schema.Project from a Project. The created schema.Project is not suitable to be used outside simple schema.Project to schema.Project comparisons. It contains missing information that cannot be inferred from a Project.
type Projects ¶ added in v0.9.23
type Projects []Project
func (Projects) IsRunQuotaExceeded ¶ added in v0.10.31
IsRunQuotaExceeded checks if any of the project metadata have errored with a "run quota exceeded" error. If found it returns the associated message with this diag. This should be used when in any output that notifies the user.
type ReportInput ¶ added in v0.7.8
func LoadPaths ¶ added in v0.9.17
func LoadPaths(paths []string) ([]ReportInput, error)
type Resource ¶ added in v0.7.4
type Resource struct { Name string `json:"name"` ResourceType string `json:"resourceType,omitempty"` Tags *map[string]string `json:"tags,omitempty"` Metadata map[string]interface{} `json:"metadata"` HourlyCost *decimal.Decimal `json:"hourlyCost,omitempty"` MonthlyCost *decimal.Decimal `json:"monthlyCost,omitempty"` MonthlyUsageCost *decimal.Decimal `json:"monthlyUsageCost,omitempty"` CostComponents []CostComponent `json:"costComponents,omitempty"` ActualCosts []ActualCosts `json:"actualCosts,omitempty"` SubResources []Resource `json:"subresources,omitempty"` }
type Root ¶ added in v0.7.4
type Root struct { Version string `json:"version"` Metadata Metadata `json:"metadata"` RunID string `json:"runId,omitempty"` CloudURL string `json:"cloudUrl,omitempty"` Currency string `json:"currency"` Projects Projects `json:"projects"` TotalHourlyCost *decimal.Decimal `json:"totalHourlyCost"` TotalMonthlyCost *decimal.Decimal `json:"totalMonthlyCost"` TotalMonthlyUsageCost *decimal.Decimal `json:"totalMonthlyUsageCost,omitempty"` PastTotalHourlyCost *decimal.Decimal `json:"pastTotalHourlyCost"` PastTotalMonthlyCost *decimal.Decimal `json:"pastTotalMonthlyCost"` PastTotalMonthlyUsageCost *decimal.Decimal `json:"pastTotalMonthlyUsageCost,omitempty"` DiffTotalHourlyCost *decimal.Decimal `json:"diffTotalHourlyCost"` DiffTotalMonthlyCost *decimal.Decimal `json:"diffTotalMonthlyCost"` DiffTotalMonthlyUsageCost *decimal.Decimal `json:"diffTotalMonthlyUsageCost,omitempty"` TimeGenerated time.Time `json:"timeGenerated"` Summary *Summary `json:"summary"` FullSummary *Summary `json:"-"` IsCIRun bool `json:"-"` }
func Combine ¶ added in v0.7.4
func Combine(inputs []ReportInput) (Root, error)
func CompareTo ¶ added in v0.9.23
CompareTo generates an output Root using another Root as the base snapshot. Each project in current Root will have all past resources overwritten with the matching projects in the prior Root. If we can't find a matching project then we assume that the project has been newly created and will show a 100% increase in the output Root.
func Load ¶ added in v0.7.4
Load reads the file at the location p and the file body into a Root struct. Load naively validates that the Infracost JSON body is valid by checking the that the version attribute is within a supported range.
func ToOutputFormat ¶ added in v0.7.4
func (*Root) ExampleProjectName ¶ added in v0.9.21
func (*Root) HasDiff ¶ added in v0.10.16
HasDiff returns true if any project has a difference in monthly cost or resources
func (*Root) HasUnsupportedResources ¶ added in v0.10.32
HasUnsupportedResources returns if the summary has any unsupported resources. This is used to determine if the summary should be shown in different output formats.
type Summary ¶ added in v0.8.0
type Summary struct { TotalResources *int `json:"totalResources,omitempty"` TotalDetectedResources *int `json:"totalDetectedResources,omitempty"` TotalSupportedResources *int `json:"totalSupportedResources,omitempty"` TotalUnsupportedResources *int `json:"totalUnsupportedResources,omitempty"` TotalUsageBasedResources *int `json:"totalUsageBasedResources,omitempty"` TotalNoPriceResources *int `json:"totalNoPriceResources,omitempty"` SupportedResourceCounts *map[string]int `json:"supportedResourceCounts,omitempty"` UnsupportedResourceCounts *map[string]int `json:"unsupportedResourceCounts,omitempty"` NoPriceResourceCounts *map[string]int `json:"noPriceResourceCounts,omitempty"` EstimatedUsageCounts *map[string]int `json:"-"` UnestimatedUsageCounts *map[string]int `json:"-"` TotalEstimatedUsages *int `json:"-"` TotalUnestimatedUsages *int `json:"-"` }
func BuildSummary ¶ added in v0.8.0
func BuildSummary(resources []*schema.Resource, opts SummaryOptions) (*Summary, error)