From 08d17a33eab2037c52c1e092c2b5f9de963537b0 Mon Sep 17 00:00:00 2001 From: behrooz Date: Wed, 3 Sep 2025 16:48:20 +0330 Subject: [PATCH] fix --- handler/handler.go | 7 +++++++ main.go | 2 +- models/workloads.go | 19 +++++++++++++------ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/handler/handler.go b/handler/handler.go index c182832..a9d581a 100644 --- a/handler/handler.go +++ b/handler/handler.go @@ -1074,6 +1074,12 @@ func Worker_nodes_plan(w http.ResponseWriter, r *http.Request) { func ClusterStats(w http.ResponseWriter, r *http.Request) { data := models.ClusterStats{ + Name: "vcluster-cluster", + ClusterId: "6547", + Status: "Healthy", + Version: "v3.31.0", + Alerts: "0/1", + Endpoint: "http://aa.bugx.ir", ResourceUsage: models.ResourceUsage{ CPU: models.Usage{Used: 65, Total: 100, Unit: "cores"}, Memory: models.Usage{Used: 8.2, Total: 16, Unit: "GB"}, @@ -1087,6 +1093,7 @@ func ClusterStats(w http.ResponseWriter, r *http.Request) { SchedulerLatency: "8ms", }, Health: models.Health{ + Status: "Healthy", NodesHealthy: 3, NodesTotal: 3, PodsRunning: 10, diff --git a/main.go b/main.go index 9187905..6f765ce 100644 --- a/main.go +++ b/main.go @@ -128,7 +128,7 @@ func main() { router.HandleFunc("/createcluster", handler.CreateClusterHandler) router.HandleFunc("/deletecluster", handler.Deletecluster) router.HandleFunc("/clusters", handler.ListUserClusters) - router.HandleFunc("/cluster/stats", handler.ClusterStats) + router.HandleFunc("/cluster_stats", handler.ClusterStats) router.HandleFunc("/connect", handler.Connect) // router.HandleFunc("/cluster_nodes", handler.Cluster_nodes) router.HandleFunc("/cluster_namespaces", handler.Cluster_namespaces) diff --git a/models/workloads.go b/models/workloads.go index 3c6b418..1d6bb38 100644 --- a/models/workloads.go +++ b/models/workloads.go @@ -115,6 +115,12 @@ type ClusterStats struct { Performance Performance `json:"performance"` Health Health `json:"health"` Uptime Uptime `json:"uptime"` + Name string `json:"name"` + ClusterId string `json:"clusterId"` + Status string `json:"status"` + Version string `json:"version"` + Alerts string `json:"alerts"` + Endpoint string `json:"endpoint"` } type ResourceUsage struct { @@ -138,12 +144,13 @@ type Performance struct { } type Health struct { - NodesHealthy int `json:"nodesHealthy"` - NodesTotal int `json:"nodesTotal"` - PodsRunning int `json:"podsRunning"` - PodsTotal int `json:"podsTotal"` - Alerts int `json:"alerts"` - Warnings int `json:"warnings"` + NodesHealthy int `json:"nodesHealthy"` + NodesTotal int `json:"nodesTotal"` + PodsRunning int `json:"podsRunning"` + PodsTotal int `json:"podsTotal"` + Alerts int `json:"alerts"` + Warnings int `json:"warnings"` + Status string `json:"healthy"` } type Uptime struct {