mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-09-30 07:57:27 +02:00
Add a REST endpoint to list databases in all clusters
This commit is contained in:
@@ -37,6 +37,7 @@ type controllerInformer interface {
|
||||
ListQueue(workerID uint32) (*spec.QueueDump, error)
|
||||
GetWorkersCnt() uint32
|
||||
WorkerStatus(workerID uint32) (*spec.WorkerStatus, error)
|
||||
GetClusterDatabasesMap() map[string][]string
|
||||
}
|
||||
|
||||
// Server describes HTTP API server
|
||||
@@ -78,6 +79,7 @@ func New(controller controllerInformer, port int, logger *logrus.Logger) *Server
|
||||
|
||||
mux.HandleFunc("/clusters/", s.clusters)
|
||||
mux.HandleFunc("/workers/", s.workers)
|
||||
mux.HandleFunc("/databases/", s.databases)
|
||||
|
||||
s.http = http.Server{
|
||||
Addr: fmt.Sprintf(":%d", port),
|
||||
@@ -222,6 +224,14 @@ func (s *Server) workers(w http.ResponseWriter, req *http.Request) {
|
||||
s.respond(resp, err, w)
|
||||
}
|
||||
|
||||
func (s *Server) databases(w http.ResponseWriter, req *http.Request) {
|
||||
|
||||
databaseNamesPerCluster := s.controller.GetClusterDatabasesMap()
|
||||
s.respond(databaseNamesPerCluster, nil, w)
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
func (s *Server) allQueues(w http.ResponseWriter, r *http.Request) {
|
||||
workersCnt := s.controller.GetWorkersCnt()
|
||||
resp := make(map[uint32]*spec.QueueDump, workersCnt)
|
||||
|
||||
Reference in New Issue
Block a user