Kaynağa Gözat

Added namespace filtering

jnfrati 4 yıl önce
ebeveyn
işleme
0566772157

+ 2 - 0
api/types/kube_events.go

@@ -61,6 +61,8 @@ type ListKubeEventRequest struct {
 	Limit int `schema:"limit"`
 	Limit int `schema:"limit"`
 	Skip  int `schema:"skip"`
 	Skip  int `schema:"skip"`
 
 
+	Namespace string `schema:"namespace,omitempty"`
+
 	// can only be "timestamp" for now
 	// can only be "timestamp" for now
 	SortBy string `schema:"sort_by"`
 	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
 	// get the count before limit and offset
 	var count int64
 	var count int64