Selaa lähdekoodia

Added namespace filtering

jnfrati 4 vuotta sitten
vanhempi
sitoutus
0566772157
2 muutettua tiedostoa jossa 9 lisäystä ja 0 poistoa
  1. 2 0
      api/types/kube_events.go
  2. 7 0
      internal/repository/gorm/event.go

+ 2 - 0
api/types/kube_events.go

@@ -61,6 +61,8 @@ type ListKubeEventRequest struct {
 	Limit int `schema:"limit"`
 	Skip  int `schema:"skip"`
 
+	Namespace string `schema:"namespace,omitempty"`
+
 	// can only be "timestamp" for now
 	SortBy string `schema:"sort_by"`
 

+ 7 - 0
internal/repository/gorm/event.go

@@ -213,6 +213,13 @@ func (repo *KubeEventRepository) ListEventsByProjectID(
 		)
 	}
 
+	if listOpts.Namespace != "" && listOpts.Namespace != "ALL" {
+		query = query.Where(
+			"LOWER(namespace) = LOWER(?)",
+			listOpts.Namespace,
+		)
+	}
+
 	// get the count before limit and offset
 	var count int64