Documentation
¶
Index ¶
- Constants
- func CloudCostViewTableRowsToCSV(writer *csv.Writer, ctr ViewTableRows, window string) error
- func DefaultMockCloudCostSet(start, end time.Time, provider, integration string) *opencost.CloudCostSet
- func NewIngestor(ingestorConfig IngestorConfig, repo Repository, config cloud.KeyedConfig) (*ingestor, error)
- type CloudCostIntegration
- type IngestionManager
- func (im *IngestionManager) DeleteConfig(key string)
- func (im *IngestionManager) GetIngestors() map[string]*ingestor
- func (im *IngestionManager) PutConfig(kc cloud.KeyedConfig)
- func (im *IngestionManager) Rebuild(integrationKey string) error
- func (im *IngestionManager) RebuildAll()
- func (im *IngestionManager) Repair(integrationKey string, start, end time.Time) error
- func (im *IngestionManager) RepairAll(start, end time.Time) error
- func (im *IngestionManager) SetConfigs(configs map[string]cloud.KeyedConfig)
- func (im *IngestionManager) StartAll()
- func (im *IngestionManager) StopAll()
- type IngestorConfig
- type IngestorStatus
- type MemoryRepository
- func (m *MemoryRepository) Expire(limit time.Time) error
- func (m *MemoryRepository) Get(startTime time.Time, billingIntegration string) (*opencost.CloudCostSet, error)
- func (m *MemoryRepository) Has(startTime time.Time, billingIntegration string) (bool, error)
- func (m *MemoryRepository) Keys() ([]string, error)
- func (m *MemoryRepository) Put(ccs *opencost.CloudCostSet) error
- type PipelineService
- func (s *PipelineService) GetCloudCostQuerier() Querier
- func (s *PipelineService) GetCloudCostRebuildHandler() func(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (s *PipelineService) GetCloudCostRepairHandler() func(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (s *PipelineService) GetCloudCostStatusHandler() func(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (dp *PipelineService) Status() []Status
- type Querier
- type QueryRequest
- type QueryService
- func (s *QueryService) GetCloudCostHandler() func(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (s *QueryService) GetCloudCostViewGraphHandler() func(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (s *QueryService) GetCloudCostViewTableHandler(tokenHook func(ViewTableRows) string) func(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- func (s *QueryService) GetCloudCostViewTotalsHandler() func(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
- type Repository
- type RepositoryQuerier
- func (rq *RepositoryQuerier) Query(ctx context.Context, request QueryRequest) (*opencost.CloudCostSetRange, error)
- func (rq *RepositoryQuerier) QueryViewGraph(ctx context.Context, request ViewQueryRequest) (ViewGraphData, error)
- func (rq *RepositoryQuerier) QueryViewTable(ctx context.Context, request ViewQueryRequest) (ViewTableRows, error)
- func (rq *RepositoryQuerier) QueryViewTotals(ctx context.Context, request ViewQueryRequest) (*ViewTotals, error)
- type SortDirection
- type SortField
- type Status
- type View
- type ViewGraphData
- type ViewGraphDataSet
- type ViewGraphDataSetItem
- type ViewQuerier
- type ViewQueryRequest
- type ViewTableRow
- type ViewTableRows
- type ViewTotals
Constants ¶
const DefaultChartItemsLength int = 10
DefaultChartItemsLength the default max number of items for a ViewGraphDataSet
Variables ¶
This section is empty.
Functions ¶
func CloudCostViewTableRowsToCSV ¶
func CloudCostViewTableRowsToCSV(writer *csv.Writer, ctr ViewTableRows, window string) error
CloudCostViewTableRowsToCSV takes the csv writer and writes the ViewTableRows into the writer.
func DefaultMockCloudCostSet ¶
func DefaultMockCloudCostSet(start, end time.Time, provider, integration string) *opencost.CloudCostSet
func NewIngestor ¶
func NewIngestor(ingestorConfig IngestorConfig, repo Repository, config cloud.KeyedConfig) (*ingestor, error)
NewIngestor is an initializer for ingestor
Types ¶
type CloudCostIntegration ¶
type CloudCostIntegration interface {
GetCloudCost(time.Time, time.Time) (*opencost.CloudCostSetRange, error)
GetStatus() cloud.ConnectionStatus
RefreshStatus() cloud.ConnectionStatus
}
CloudCostIntegration is an interface for retrieving daily granularity CloudCost data for a given range
func GetIntegrationFromConfig ¶
func GetIntegrationFromConfig(kc cloud.KeyedConfig) CloudCostIntegration
GetIntegrationFromConfig coverts any valid KeyedConfig into the appropriate BillingIntegration if possible
type IngestionManager ¶
type IngestionManager struct {
// contains filtered or unexported fields
}
IngestionManager is a config.Observer which creates Ingestor instances based on the signals that it receives from the config.Controller
func NewIngestionManager ¶
func NewIngestionManager(controller *config.Controller, repo Repository, ingConf IngestorConfig) *IngestionManager
NewIngestionManager creates a new IngestionManager and registers it with the provided integration controller
func (*IngestionManager) DeleteConfig ¶
func (im *IngestionManager) DeleteConfig(key string)
DeleteConfig is an imperative function which removes an ingestor with a matching key
func (*IngestionManager) GetIngestors ¶ added in v1.119.0
func (im *IngestionManager) GetIngestors() map[string]*ingestor
GetIngestors returns a copy of the ingestors map
func (*IngestionManager) PutConfig ¶
func (im *IngestionManager) PutConfig(kc cloud.KeyedConfig)
PutConfig is an imperative function which puts an ingestor for the provided Integration
func (*IngestionManager) Rebuild ¶
func (im *IngestionManager) Rebuild(integrationKey string) error
func (*IngestionManager) RebuildAll ¶
func (im *IngestionManager) RebuildAll()
func (*IngestionManager) Repair ¶
func (im *IngestionManager) Repair(integrationKey string, start, end time.Time) error
func (*IngestionManager) RepairAll ¶
func (im *IngestionManager) RepairAll(start, end time.Time) error
func (*IngestionManager) SetConfigs ¶
func (im *IngestionManager) SetConfigs(configs map[string]cloud.KeyedConfig)
SetConfigs is a declarative function for setting which BillingIntegrations IngestionManager should have ingestors for
func (*IngestionManager) StartAll ¶
func (im *IngestionManager) StartAll()
func (*IngestionManager) StopAll ¶
func (im *IngestionManager) StopAll()
type IngestorConfig ¶
type IngestorConfig struct {
MonthToDateRunInterval int
RefreshRate time.Duration
Resolution time.Duration
Duration time.Duration
QueryWindow time.Duration
RunWindow time.Duration
}
IngestorConfig is a configuration struct for an Ingestor
func DefaultIngestorConfiguration ¶
func DefaultIngestorConfiguration() IngestorConfig
DefaultIngestorConfiguration retrieves an IngestorConfig from env variables
type IngestorStatus ¶
type IngestorStatus struct {
Created time.Time
LastRun time.Time
NextRun time.Time
Runs int
Coverage opencost.Window
ConnectionStatus cloud.ConnectionStatus
}
IngestorStatus includes diagnostic values for a given Ingestor
type MemoryRepository ¶
type MemoryRepository struct {
// contains filtered or unexported fields
}
MemoryRepository is an implementation of Repository that uses a map keyed on config key and window start along with a RWMutex to make it threadsafe
func NewMemoryRepository ¶
func NewMemoryRepository() *MemoryRepository
func (*MemoryRepository) Expire ¶
func (m *MemoryRepository) Expire(limit time.Time) error
Expire deletes all items in the map with a start time before the given limit
func (*MemoryRepository) Get ¶
func (m *MemoryRepository) Get(startTime time.Time, billingIntegration string) (*opencost.CloudCostSet, error)
func (*MemoryRepository) Keys ¶
func (m *MemoryRepository) Keys() ([]string, error)
func (*MemoryRepository) Put ¶
func (m *MemoryRepository) Put(ccs *opencost.CloudCostSet) error
type PipelineService ¶
type PipelineService struct {
// contains filtered or unexported fields
}
PipelineService exposes CloudCost pipeline controls and diagnostics endpoints
func NewPipelineService ¶
func NewPipelineService(repo Repository, ic *config.Controller, ingConf IngestorConfig) *PipelineService
NewPipelineService is a constructor for a PipelineService
func (*PipelineService) GetCloudCostQuerier ¶ added in v1.119.0
func (s *PipelineService) GetCloudCostQuerier() Querier
GetCloudCostQuerier returns a querier that can query data from all cloud providers
func (*PipelineService) GetCloudCostRebuildHandler ¶
func (s *PipelineService) GetCloudCostRebuildHandler() func(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
GetCloudCostRebuildHandler creates a handler from a http request which initiates a rebuild of cloud cost pipeline, if an integrationKey is provided then it only rebuilds the specified billing integration
func (*PipelineService) GetCloudCostRepairHandler ¶
func (s *PipelineService) GetCloudCostRepairHandler() func(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
GetCloudCostRepairHandler creates a handler from a http request which initiates a repair of cloud cost for a given window, if an integrationKey is provided then it only repairs the specified integration
func (*PipelineService) GetCloudCostStatusHandler ¶
func (s *PipelineService) GetCloudCostStatusHandler() func(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
GetCloudCostStatusHandler creates a handler from a http request which returns a list of the billing integration status
func (*PipelineService) Status ¶
func (dp *PipelineService) Status() []Status
Status merges status values from the config.Controller and the IngestionManager to give a combined view of that state of configs and their ingestion status
type Querier ¶
type Querier interface {
Query(context.Context, QueryRequest) (*opencost.CloudCostSetRange, error)
}
Querier allows for querying ranges of CloudCost data
type QueryRequest ¶
type QueryRequest struct {
Start time.Time
End time.Time
AggregateBy []string
Accumulate opencost.AccumulateOption
Filter filter.Filter
}
func ParseCloudCostRequest ¶
func ParseCloudCostRequest(qp httputil.QueryParams) (*QueryRequest, error)
type QueryService ¶
type QueryService struct {
Querier Querier
ViewQuerier ViewQuerier
}
QueryService surfaces endpoints for accessing CloudCost data in raw form or for display in views
func NewQueryService ¶
func NewQueryService(querier Querier, viewQuerier ViewQuerier) *QueryService
func (*QueryService) GetCloudCostHandler ¶
func (s *QueryService) GetCloudCostHandler() func(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*QueryService) GetCloudCostViewGraphHandler ¶
func (s *QueryService) GetCloudCostViewGraphHandler() func(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*QueryService) GetCloudCostViewTableHandler ¶
func (s *QueryService) GetCloudCostViewTableHandler(tokenHook func(ViewTableRows) string) func(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
func (*QueryService) GetCloudCostViewTotalsHandler ¶
func (s *QueryService) GetCloudCostViewTotalsHandler() func(w http.ResponseWriter, r *http.Request, ps httprouter.Params)
type Repository ¶
type Repository interface {
Has(time.Time, string) (bool, error)
Get(time.Time, string) (*opencost.CloudCostSet, error)
Keys() ([]string, error)
Put(*opencost.CloudCostSet) error
Expire(time.Time) error
}
Repository is an interface for storing and retrieving CloudCost data
type RepositoryQuerier ¶
type RepositoryQuerier struct {
// contains filtered or unexported fields
}
RepositoryQuerier is an implementation of Querier and ViewQuerier which pulls directly from a Repository
func NewRepositoryQuerier ¶
func NewRepositoryQuerier(repo Repository) *RepositoryQuerier
func (*RepositoryQuerier) Query ¶
func (rq *RepositoryQuerier) Query(ctx context.Context, request QueryRequest) (*opencost.CloudCostSetRange, error)
func (*RepositoryQuerier) QueryViewGraph ¶
func (rq *RepositoryQuerier) QueryViewGraph(ctx context.Context, request ViewQueryRequest) (ViewGraphData, error)
func (*RepositoryQuerier) QueryViewTable ¶
func (rq *RepositoryQuerier) QueryViewTable(ctx context.Context, request ViewQueryRequest) (ViewTableRows, error)
func (*RepositoryQuerier) QueryViewTotals ¶
func (rq *RepositoryQuerier) QueryViewTotals(ctx context.Context, request ViewQueryRequest) (*ViewTotals, error)
type SortDirection ¶
type SortDirection string
SortDirection a string type that acts as an enumeration of possible request options
const ( SortDirectionNone SortDirection = "" SortDirectionAscending SortDirection = "asc" SortDirectionDescending SortDirection = "desc" )
func ParseSortDirection ¶
func ParseSortDirection(sortDirection string) (SortDirection, error)
ParseSortDirection provides a resilient way to parse one of the enumerated SortDirection types from a string or throws an error if it is not able to.
type SortField ¶
type SortField string
SortField a string type that acts as an enumeration of possible request options
func ParseSortField ¶
ParseSortField provides a resilient way to parse one of the enumerated SortField types from a string or throws an error if it is not able to.
type Status ¶
type Status struct {
Key string `json:"key"`
Source string `json:"source"`
Provider string `json:"provider"`
Active bool `json:"active"`
Valid bool `json:"valid"`
LastRun time.Time `json:"lastRun"`
NextRun time.Time `json:"nextRun"`
RefreshRate string `json:"refreshRate"`
Created time.Time `json:"created"`
Runs int `json:"runs"`
Coverage string `json:"coverage"`
ConnectionStatus string `json:"connectionStatus"`
Config cloudconfig.Config `json:"config"`
}
Status gives the details and metadata of a CloudCost integration
type View ¶
type View struct {
GraphData ViewGraphData `json:"graphData"`
TableTotal *ViewTableRow `json:"tableTotal"`
TableRows ViewTableRows `json:"tableRows"`
}
View serves data to the Cloud Cost front end, in the structure it requires (i.e. a graph and a table).
type ViewGraphData ¶
type ViewGraphData []*ViewGraphDataSet
func (ViewGraphData) Equal ¶
func (vgd ViewGraphData) Equal(that ViewGraphData) bool
type ViewGraphDataSet ¶
type ViewGraphDataSet struct {
Start time.Time `json:"start"`
End time.Time `json:"end"`
Items []ViewGraphDataSetItem `json:"items"`
}
func (*ViewGraphDataSet) Equal ¶
func (vgds *ViewGraphDataSet) Equal(that *ViewGraphDataSet) bool
NOTE: does not compare start and end times, just that the items are equal
type ViewGraphDataSetItem ¶
func (ViewGraphDataSetItem) Equal ¶
func (vgdsi ViewGraphDataSetItem) Equal(that ViewGraphDataSetItem) bool
type ViewQuerier ¶
type ViewQuerier interface {
QueryViewGraph(context.Context, ViewQueryRequest) (ViewGraphData, error)
QueryViewTotals(context.Context, ViewQueryRequest) (*ViewTotals, error)
QueryViewTable(context.Context, ViewQueryRequest) (ViewTableRows, error)
}
ViewQuerier defines a contract for return View types to the QueryService to service the View Api
type ViewQueryRequest ¶
type ViewQueryRequest struct {
QueryRequest
CostMetricName opencost.CostMetricName
ChartItemsLength int
Offset int
Limit int
SortDirection SortDirection
SortColumn SortField
}
func ParseCloudCostViewRequest ¶ added in v1.111.0
func ParseCloudCostViewRequest(qp httputil.QueryParams) (*ViewQueryRequest, error)
type ViewTableRow ¶
type ViewTableRow struct {
Name string `json:"name"`
Names []string `json:"names,omitempty"`
Token string `json:"token,omitempty"`
Labels map[string]string `json:"labels"`
KubernetesPercent float64 `json:"kubernetesPercent"`
Cost float64 `json:"cost"`
}
func (*ViewTableRow) Equal ¶
func (vtr *ViewTableRow) Equal(that *ViewTableRow) bool
type ViewTableRows ¶
type ViewTableRows []*ViewTableRow
func (ViewTableRows) Equal ¶
func (vtrs ViewTableRows) Equal(that ViewTableRows) bool
type ViewTotals ¶ added in v1.109.0
type ViewTotals struct {
NumResults int `json:"numResults"`
Combined *ViewTableRow `json:"combined"`
}