Documentation ¶
Index ¶
- Variables
- func ReportCLIError(ctx *config.RunContext, cliErr error, replacePath bool) error
- type APIClient
- type APIError
- type APIErrorResponse
- type ActualCostComponent
- type ActualCostsQueryVariables
- type ActualCostsResult
- type AddRunResponse
- type AuthClient
- type BatchRequest
- type CloudResourceIDVariables
- type CommentFormat
- type CreateAPIKeyResponse
- type DashboardAPIClient
- type GovernanceResult
- type GraphQLQuery
- type LeveledLogger
- type PolicyAPIClient
- type PriceQueryKey
- type PriceQueryResult
- type PricingAPIClient
- func (c *PricingAPIClient) AddEvent(name string, env map[string]interface{}) error
- func (c *PricingAPIClient) BatchRequests(resources []*schema.Resource, batchSize int) []BatchRequest
- func (c *PricingAPIClient) FlushCache() error
- func (c *PricingAPIClient) PerformRequest(req BatchRequest) ([]PriceQueryResult, error)
- type QueryCLISettingsResponse
- type ResourceIDAddress
- type UsageAPIClient
- type UsageQuantitiesQueryVariables
Constants ¶
This section is empty.
Variables ¶
var ( ErrorCodeExceededQuota = "above_quota" ErrorCodeAPIKeyInvalid = "invalid_api_key" )
Functions ¶
func ReportCLIError ¶
func ReportCLIError(ctx *config.RunContext, cliErr error, replacePath bool) error
Types ¶
type APIClient ¶
type APIClient struct {
// contains filtered or unexported fields
}
func (*APIClient) AddAuthHeaders ¶
func (*APIClient) AddDefaultHeaders ¶
type APIError ¶
type APIError struct { // Msg defines a human-readable string that is safe to show to the user // to give more context about an error. Msg string // Code is the original StatusCode of the error. Code int // ErrorCode is the internal error code that can accompany errors from different status codes. ErrorCode string // contains filtered or unexported fields }
APIError defines an api error that is designed to be showed to the user in a output form (comment/stdout/html).
type APIErrorResponse ¶
type ActualCostComponent ¶ added in v0.10.12
type ActualCostComponent struct { UsageType string Description string MonthlyCost string MonthlyQuantity string Price string Unit string Currency string }
ActualCostComponent represents an individual line item of actual costs for a resource
type ActualCostsQueryVariables ¶ added in v0.10.12
type ActualCostsResult ¶ added in v0.10.12
type ActualCostsResult struct { Address string ResourceID string StartTimestamp time.Time EndTimestamp time.Time CostComponents []ActualCostComponent }
ActualCostsResult contains the cost information of actual costs retrieved from the Infracost Cloud Usage API
type AddRunResponse ¶ added in v0.9.16
type AddRunResponse struct { RunID string `json:"id"` CloudURL string `json:"cloudUrl"` PullRequestURL string `json:"pullRequestUrl"` GovernanceFailures output.GovernanceFailures `json:"governanceFailures"` GovernanceComment string `json:"governanceComment"` GovernanceResults []GovernanceResult `json:"governanceResults"` }
type AuthClient ¶ added in v0.10.3
type AuthClient struct {
Host string
}
AuthClient represents a client for Infracost's authentication process.
type BatchRequest ¶ added in v0.10.25
type BatchRequest struct {
// contains filtered or unexported fields
}
type CloudResourceIDVariables ¶ added in v0.10.13
type CloudResourceIDVariables struct { RepoURL string `json:"repoUrl"` ProjectWithWorkspace string `json:"project"` ResourceIDAddresses []ResourceIDAddress `json:"addressResourceIds"` }
type CommentFormat ¶ added in v0.10.30
type CommentFormat string
var ( CommentFormatMarkdownHTML CommentFormat = "MARKDOWN_HTML" CommentFormatMarkdown CommentFormat = "MARKDOWN" )
type CreateAPIKeyResponse ¶
type DashboardAPIClient ¶
type DashboardAPIClient struct {
APIClient
}
func NewDashboardAPIClient ¶
func NewDashboardAPIClient(ctx *config.RunContext) *DashboardAPIClient
func (*DashboardAPIClient) AddRun ¶
func (c *DashboardAPIClient) AddRun(ctx *config.RunContext, out output.Root, commentFormat CommentFormat) (AddRunResponse, error)
func (*DashboardAPIClient) QueryCLISettings ¶ added in v0.10.7
func (c *DashboardAPIClient) QueryCLISettings() (QueryCLISettingsResponse, error)
type GovernanceResult ¶ added in v0.10.30
type GraphQLQuery ¶
type LeveledLogger ¶ added in v0.10.17
LeveledLogger is a wrapper around logrus.Entry that implements the retryablehttp.LeveledLogger interface.
func (*LeveledLogger) Debug ¶ added in v0.10.17
func (l *LeveledLogger) Debug(msg string, keysAndValues ...interface{})
func (*LeveledLogger) Error ¶ added in v0.10.17
func (l *LeveledLogger) Error(msg string, keysAndValues ...interface{})
func (*LeveledLogger) Info ¶ added in v0.10.17
func (l *LeveledLogger) Info(msg string, keysAndValues ...interface{})
func (*LeveledLogger) Warn ¶ added in v0.10.17
func (l *LeveledLogger) Warn(msg string, keysAndValues ...interface{})
type PolicyAPIClient ¶ added in v0.10.30
type PolicyAPIClient struct { APIClient // contains filtered or unexported fields }
func NewPolicyAPIClient ¶ added in v0.10.30
func NewPolicyAPIClient(ctx *config.RunContext) (*PolicyAPIClient, error)
NewPolicyAPIClient retrieves resource allow-list info from Infracost Cloud and returns a new policy client
func (*PolicyAPIClient) UploadPolicyData ¶ added in v0.10.30
func (c *PolicyAPIClient) UploadPolicyData(project *schema.Project, rds, pastRds []*schema.ResourceData) error
UploadPolicyData sends a filtered set of a project's resource information to Infracost Cloud and potentially adds PolicySha and PastPolicySha to the project's metadata.
type PriceQueryKey ¶
type PriceQueryKey struct { Resource *schema.Resource CostComponent *schema.CostComponent }
type PriceQueryResult ¶
type PriceQueryResult struct { PriceQueryKey Result gjson.Result // contains filtered or unexported fields }
type PricingAPIClient ¶
type PricingAPIClient struct { APIClient Currency string EventsDisabled bool // contains filtered or unexported fields }
func GetPricingAPIClient ¶ added in v0.10.29
func GetPricingAPIClient(ctx *config.RunContext) *PricingAPIClient
GetPricingAPIClient initializes and returns an instance of PricingAPIClient using the given RunContext configuration. If an instance of PricingAPIClient has already been created, it will return the existing instance. This is done to ensure that the client cache is global across the application.
func NewPricingAPIClient ¶
func NewPricingAPIClient(ctx *config.RunContext) *PricingAPIClient
NewPricingAPIClient creates a new instance of PricingAPIClient using the given RunContext configuration. Most callers should use GetPricingAPIClient instead of this function to ensure that the client cache is global across the application. This function is useful for creating isolated pricing clients which do not share the global cache.
func (*PricingAPIClient) AddEvent ¶ added in v0.9.5
func (c *PricingAPIClient) AddEvent(name string, env map[string]interface{}) error
func (*PricingAPIClient) BatchRequests ¶ added in v0.10.25
func (c *PricingAPIClient) BatchRequests(resources []*schema.Resource, batchSize int) []BatchRequest
BatchRequests batches all the queries for these resources so we can use less GraphQL requests Use PriceQueryKeys to keep track of which query maps to which sub-resource and price component.
func (*PricingAPIClient) FlushCache ¶ added in v0.10.29
func (c *PricingAPIClient) FlushCache() error
FlushCache writes the in memory cache to the filesystem. This allows the cache to be persisted between runs. FlushCache should only be called once, at program termination.
func (*PricingAPIClient) PerformRequest ¶ added in v0.10.25
func (c *PricingAPIClient) PerformRequest(req BatchRequest) ([]PriceQueryResult, error)
PerformRequest sends a batch request to the Pricing API endpoint to fetch pricing details for the provided queries. It optimizes the API call by checking a local cache for previous results. If the results of a given query are cached, they are used directly; otherwise, a request to the API is made.
type QueryCLISettingsResponse ¶ added in v0.10.7
type ResourceIDAddress ¶ added in v0.10.13
type UsageAPIClient ¶ added in v0.10.12
func NewUsageAPIClient ¶ added in v0.10.12
func NewUsageAPIClient(ctx *config.RunContext) *UsageAPIClient
NewUsageAPIClient returns a new Infracost Cloud Usage API Client configured from the RunContext
func (*UsageAPIClient) ListActualCosts ¶ added in v0.10.12
func (c *UsageAPIClient) ListActualCosts(vars ActualCostsQueryVariables) ([]ActualCostsResult, error)
ListActualCosts queries the Infracost Cloud Usage API to retrieve any cloud provider reported costs associated with the resource.
func (*UsageAPIClient) ListUsageQuantities ¶ added in v0.10.12
func (c *UsageAPIClient) ListUsageQuantities(vars []*UsageQuantitiesQueryVariables) ([]*schema.UsageData, error)
ListUsageQuantities queries the Infracost Cloud Usage API to retrieve usage estimates derived from cloud provider reported usage and costs.
func (*UsageAPIClient) UploadCloudResourceIDs ¶ added in v0.10.13
func (c *UsageAPIClient) UploadCloudResourceIDs(vars CloudResourceIDVariables) error
UploadCloudResourceIDs uploads cloud resource IDs to the Infracost Cloud Usage API, so they may be used to calculate usage estimates.