Skip to content

Commit

Permalink
Include idle based on parameter
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Dresser <michaelmdresser@gmail.com>
  • Loading branch information
michaelmdresser committed Feb 12, 2024
1 parent df61406 commit e8c4980
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pkg/cmd/aggregatedcommandbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ func runAggregatedAllocationCommand(ko *utilities.KubeOptions, o AggregatedAlloc
"window": o.window,
"aggregate": strings.Join(aggregation, ","),
"accumulate": "true",
"includeIdle": "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, "include-idle", true, "include the __idle__ cost row in the response")

query.AddQueryBackendOptionsFlags(cmd, &options.QueryBackendOptions)
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/cmd/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ func runCostLabel(ko *utilities.KubeOptions, no *CostOptionsLabel) error {
"window": no.window,
"aggregate": strings.Join(aggregation, ","),
"accumulate": "true",
"includeIdle": "true",
"includeIdle": fmt.Sprintf("%t", no.includeIdle),
"idle": fmt.Sprintf("%t", no.includeIdle),
},
QueryBackendOptions: no.QueryBackendOptions,
})
Expand Down

0 comments on commit e8c4980

Please sign in to comment.