Przeglądaj źródła

Create query interfaces

Niko Kovacevic 4 lat temu
rodzic
commit
db71ec4a20
2 zmienionych plików z 42 dodań i 0 usunięć
  1. 2 0
      pkg/kubecost/allocation.go
  2. 40 0
      pkg/kubecost/query.go

+ 2 - 0
pkg/kubecost/allocation.go

@@ -1760,6 +1760,8 @@ func (as *AllocationSet) ComputeIdleAllocations(assetSet *AssetSet) (map[string]
 	return idleAllocs, nil
 }
 
+// TODO etl -- deprecate!
+
 // ComputeIdleAllocationsByNode computes the idle allocations for the AllocationSet,
 // given a set of Assets. Ideally, assetSet should contain only Nodes, but if
 // it contains other Assets, they will be ignored; only CPU, GPU and RAM are

+ 40 - 0
pkg/kubecost/query.go

@@ -0,0 +1,40 @@
+package kubecost
+
+import "time"
+
+type Querier interface {
+	AllocationQuerier
+	SummaryAllocationQuerier
+}
+
+type AllocationQuerier interface {
+	QueryAllocation(start, end time.Time, opts *AllocationQueryOptions) (chan *AllocationSetRange, chan error)
+	QueryAllocationSync(start, end time.Time, opts *AllocationQueryOptions) (*AllocationSetRange, error)
+}
+
+type SummaryAllocationQuerier interface {
+	QuerySummaryAllocation(start, end time.Time, opts *AllocationQueryOptions) (chan *SummaryAllocationSetRange, chan error)
+	QuerySummaryAllocationSync(start, end time.Time, opts *AllocationQueryOptions) (*SummaryAllocationSetRange, error)
+}
+
+type AllocationQueryOptions struct {
+	Accumulate        bool
+	AccumulateBy      time.Duration
+	AggregateBy       []string
+	Compute           bool
+	FilterFuncs       []AllocationMatchFunc
+	IdleByNode        bool
+	IncludeExternal   bool
+	IncludeIdle       bool
+	LabelConfig       *LabelConfig
+	MergeUnallocated  bool
+	Reconcile         bool
+	ReconcileNetwork  bool
+	ShareFuncs        []AllocationMatchFunc
+	SharedHourlyCosts map[string]float64
+	ShareIdle         string
+	ShareSplit        string
+	ShareTenancyCosts bool
+	SplitIdle         bool
+	Step              time.Duration
+}