Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parameter idle (default true) which toggles includeIdle and idle query params to Allocation API #164

Merged
merged 3 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/cmd/aggregatedcommandbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ func runAggregatedAllocationCommand(ko *utilities.KubeOptions, o AggregatedAlloc
"window": o.window,
"aggregate": strings.Join(aggregation, ","),
"accumulate": "true",
"includeIdle": fmt.Sprintf("%t", o.includeIdle),
"idle": fmt.Sprintf("%t", o.includeIdle),
"filterNamespaces": o.filterNamespace,
},
QueryBackendOptions: o.QueryBackendOptions,
Expand Down
2 changes: 2 additions & 0 deletions pkg/cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
type CostOptions struct {
window string
filterNamespace string
includeIdle bool

isHistorical bool

Expand All @@ -24,6 +25,7 @@ type CostOptions struct {
func addCostOptionsFlags(cmd *cobra.Command, options *CostOptions) {
cmd.Flags().StringVar(&options.window, "window", "1d", "The window of data to query. See https://github.com/kubecost/docs/blob/master/allocation.md#querying for a detailed explanation of what can be passed here.")
cmd.Flags().BoolVar(&options.isHistorical, "historical", false, "show the total cost during the window instead of the projected monthly rate based on the data in the window")
cmd.Flags().BoolVar(&options.includeIdle, "idle", true, "include the __idle__ cost row in the response")

query.AddQueryBackendOptionsFlags(cmd, &options.QueryBackendOptions)
}
Expand Down
8 changes: 5 additions & 3 deletions pkg/cmd/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ func runCostLabel(ko *utilities.KubeOptions, no *CostOptionsLabel) error {
allocations, err := query.QueryAllocation(query.AllocationParameters{
Ctx: context.Background(),
QueryParams: map[string]string{
"window": no.window,
"aggregate": strings.Join(aggregation, ","),
"accumulate": "true",
"window": no.window,
"aggregate": strings.Join(aggregation, ","),
"accumulate": "true",
"includeIdle": fmt.Sprintf("%t", no.includeIdle),
"idle": fmt.Sprintf("%t", no.includeIdle),
},
QueryBackendOptions: no.QueryBackendOptions,
})
Expand Down
7 changes: 4 additions & 3 deletions pkg/cmd/tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,10 @@ func runTUI(ko *utilities.KubeOptions, do display.AllocationDisplayOptions, qo q
queriedAllocs, err := query.QueryAllocation(query.AllocationParameters{
Ctx: queryContext,
QueryParams: map[string]string{
"window": windowOptions[windowIndex],
"aggregate": strings.Join(aggregation, ","),
"accumulate": "true",
"window": windowOptions[windowIndex],
"aggregate": strings.Join(aggregation, ","),
"accumulate": "true",
"includeIdle": "true",
},
QueryBackendOptions: qo,
})
Expand Down
Loading