Browse Source

add omitempty to filters to clean up group report responses (#1952)

Signed-off-by: saweber <saweber@gmail.com>
Steven Weber 3 năm trước cách đây
mục cha
commit
7f05938db4
2 tập tin đã thay đổi với 22 bổ sung22 xóa
  1. 7 7
      pkg/filter/util/cloudcost.go
  2. 15 15
      pkg/util/allocationfilterutil/queryfilters.go

+ 7 - 7
pkg/filter/util/cloudcost.go

@@ -11,13 +11,13 @@ import (
 )
 
 type CloudCostFilter struct {
-	AccountIDs       []string `json:"accountIDs"`
-	Categories       []string `json:"categories"`
-	InvoiceEntityIDs []string `json:"invoiceEntityIDs"`
-	Labels           []string `json:"labels"`
-	Providers        []string `json:"providers"`
-	ProviderIDs      []string `json:"providerIDs"`
-	Services         []string `json:"services"`
+	AccountIDs       []string `json:"accountIDs,omitempty"`
+	Categories       []string `json:"categories,omitempty"`
+	InvoiceEntityIDs []string `json:"invoiceEntityIDs,omitempty"`
+	Labels           []string `json:"labels,omitempty"`
+	Providers        []string `json:"providers,omitempty"`
+	ProviderIDs      []string `json:"providerIDs,omitempty"`
+	Services         []string `json:"services,omitempty"`
 }
 
 func (g *CloudCostFilter) Equals(that CloudCostFilter) bool {

+ 15 - 15
pkg/util/allocationfilterutil/queryfilters.go

@@ -83,21 +83,21 @@ func AllHTTPParamKeys() []string {
 }
 
 type FilterV1 struct {
-	Annotations     []string `json:"annotations"`
-	Containers      []string `json:"containers"`
-	Controllers     []string `json:"controllers"`
-	ControllerKinds []string `json:"controllerKinds"`
-	Clusters        []string `json:"clusters"`
-	Departments     []string `json:"departments"`
-	Environments    []string `json:"environments"`
-	Labels          []string `json:"labels"`
-	Namespaces      []string `json:"namespaces"`
-	Nodes           []string `json:"nodes"`
-	Owners          []string `json:"owners"`
-	Pods            []string `json:"pods"`
-	Products        []string `json:"products"`
-	Services        []string `json:"services"`
-	Teams           []string `json:"teams"`
+	Annotations     []string `json:"annotations,omitempty"`
+	Containers      []string `json:"containers,omitempty"`
+	Controllers     []string `json:"controllers,omitempty"`
+	ControllerKinds []string `json:"controllerKinds,omitempty"`
+	Clusters        []string `json:"clusters,omitempty"`
+	Departments     []string `json:"departments,omitempty"`
+	Environments    []string `json:"environments,omitempty"`
+	Labels          []string `json:"labels,omitempty"`
+	Namespaces      []string `json:"namespaces,omitempty"`
+	Nodes           []string `json:"nodes,omitempty"`
+	Owners          []string `json:"owners,omitempty"`
+	Pods            []string `json:"pods,omitempty"`
+	Products        []string `json:"products,omitempty"`
+	Services        []string `json:"services,omitempty"`
+	Teams           []string `json:"teams,omitempty"`
 }
 
 func (f FilterV1) Equals(that FilterV1) bool {