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 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 TagPropagation
- 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 ¶
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 ActualCostsResult ¶
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 Diginfra Cloud Usage API
type AddRunResponse ¶
type AddRunResponse struct { RunID string `json:"id"` CloudURL string `json:"cloudUrl"` PullRequestURL string `json:"pullRequestUrl"` CommentMarkdown string `json:"commentMarkdown"` GovernanceFailures output.GovernanceFailures `json:"governanceFailures"` GovernanceResults []GovernanceResult `json:"governanceResults"` }
type AuthClient ¶
type AuthClient struct {
Host string
}
AuthClient represents a client for Diginfra's authentication process.
type BatchRequest ¶
type BatchRequest struct {
// contains filtered or unexported fields
}
type CloudResourceIDVariables ¶
type CloudResourceIDVariables struct { RepoURL string `json:"repoUrl"` ProjectWithWorkspace string `json:"project"` ResourceIDAddresses []ResourceIDAddress `json:"addressResourceIds"` }
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) (AddRunResponse, error)
func (*DashboardAPIClient) QueryCLISettings ¶
func (c *DashboardAPIClient) QueryCLISettings() (QueryCLISettingsResponse, error)
func (*DashboardAPIClient) SavePostedPrComment ¶
func (c *DashboardAPIClient) SavePostedPrComment(ctx *config.RunContext, runId, comment string) error
type GovernanceResult ¶
type GraphQLQuery ¶
type LeveledLogger ¶
LeveledLogger is a wrapper around logrus.Entry that implements the retryablehttp.LeveledLogger interface.
func (*LeveledLogger) Debug ¶
func (l *LeveledLogger) Debug(msg string, keysAndValues ...interface{})
func (*LeveledLogger) Error ¶
func (l *LeveledLogger) Error(msg string, keysAndValues ...interface{})
func (*LeveledLogger) Info ¶
func (l *LeveledLogger) Info(msg string, keysAndValues ...interface{})
func (*LeveledLogger) Warn ¶
func (l *LeveledLogger) Warn(msg string, keysAndValues ...interface{})
type PolicyAPIClient ¶
type PolicyAPIClient struct { APIClient // contains filtered or unexported fields }
func NewPolicyAPIClient ¶
func NewPolicyAPIClient(ctx *config.RunContext) (*PolicyAPIClient, error)
NewPolicyAPIClient retrieves resource allow-list info from Diginfra Cloud and returns a new policy client
func (*PolicyAPIClient) UploadPolicyData ¶
func (c *PolicyAPIClient) UploadPolicyData(project *schema.Project, rds, pastRds []*schema.ResourceData) error
UploadPolicyData sends a filtered set of a project's resource information to Diginfra 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 Query GraphQLQuery // contains filtered or unexported fields }
type PricingAPIClient ¶
type PricingAPIClient struct { APIClient Currency string EventsDisabled bool // contains filtered or unexported fields }
func GetPricingAPIClient ¶
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 ¶
func (c *PricingAPIClient) AddEvent(name string, env map[string]interface{}) error
func (*PricingAPIClient) BatchRequests ¶
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 ¶
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 ¶
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 ResourceIDAddress ¶
type TagPropagation ¶
type UsageAPIClient ¶
func NewUsageAPIClient ¶
func NewUsageAPIClient(ctx *config.RunContext) *UsageAPIClient
NewUsageAPIClient returns a new Diginfra Cloud Usage API Client configured from the RunContext
func (*UsageAPIClient) ListActualCosts ¶
func (c *UsageAPIClient) ListActualCosts(vars ActualCostsQueryVariables) ([]ActualCostsResult, error)
ListActualCosts queries the Diginfra Cloud Usage API to retrieve any cloud provider reported costs associated with the resource.
func (*UsageAPIClient) ListUsageQuantities ¶
func (c *UsageAPIClient) ListUsageQuantities(vars []*UsageQuantitiesQueryVariables) ([]*schema.UsageData, error)
ListUsageQuantities queries the Diginfra Cloud Usage API to retrieve usage estimates derived from cloud provider reported usage and costs.
func (*UsageAPIClient) UploadCloudResourceIDs ¶
func (c *UsageAPIClient) UploadCloudResourceIDs(vars CloudResourceIDVariables) error
UploadCloudResourceIDs uploads cloud resource IDs to the Diginfra Cloud Usage API, so they may be used to calculate usage estimates.