add worker ndoes
This commit is contained in:
@@ -1040,3 +1040,33 @@ func Cronjob_delete(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(cronjobName + " Has been deleted")
|
||||
}
|
||||
|
||||
func Worker_nodes_plan(w http.ResponseWriter, r *http.Request) {
|
||||
Authorization(w, r)
|
||||
|
||||
var workerNodesPlan []models.WorkerNodesPlans
|
||||
|
||||
cursor, err := db.Worker_nodes_plan.Find(context.TODO(), bson.M{})
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
defer cursor.Close(context.TODO())
|
||||
|
||||
for cursor.Next(context.TODO()) {
|
||||
var plan models.WorkerNodesPlans
|
||||
if err := cursor.Decode(&plan); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
workerNodesPlan = append(workerNodesPlan, plan)
|
||||
}
|
||||
|
||||
if err := cursor.Err(); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(workerNodesPlan)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user