Skip to content

Commit

Permalink
fix 🐛 HTTP API For UI (#399)
Browse files Browse the repository at this point in the history
* change

* change
  • Loading branch information
gongna-au committed Sep 4, 2022
1 parent eae9bf7 commit b0a9024
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions pkg/admin/router/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,46 +33,46 @@ import (

func init() {
admin.Register(func(router gin.IRoutes) {
if e, ok := router.(*gin.RouterGroup); ok {

routerGroup := e.Group("/")
routerGroup.GET("/tenants/:tenant/nodes", ListNodes)
routerGroup.POST("/tenants/:tenant/nodes", CreateNode)
routerGroup.GET("/tenants/:tenant/nodes/:node", GetNode)
routerGroup.PUT("/tenants/:tenant/nodes/:node", UpdateNode)
routerGroup.DELETE("/tenants/:tenant/nodes/:node", RemoveNode)

}

router.GET("/tenants/:tenant/nodes", ListNodes)
router.POST("/tenants/:tenant/nodes", CreateNode)
router.GET("/tenants/:tenant/nodes/:node", GetNode)
router.PUT("/tenants/:tenant/nodes/:node", UpdateNode)
router.DELETE("/tenants/:tenant/nodes/:node", RemoveNode)
})
}

func ListNodes(c *gin.Context) {
var results []config.Node
service := admin.GetService(c)
tenantName := c.Param("tenant")
clusters, err := service.ListClusters(c, tenantName)
if err != nil {
_ = c.Error(err)
return
}
var data []string
for _, cluster := range clusters {
groups, err := service.ListGroups(c, cluster)
if err != nil {
_ = c.Error(err)
continue
return
}
for _, group := range groups {
temp, err := service.ListNodes(c, cluster, group)
nodesArray, err := service.ListNodes(c, cluster, group)
if err != nil {
_ = c.Error(err)
continue
} else {
data = append(data, temp...)
return
}
for _, node := range nodesArray {
result, err := service.GetNode(c, cluster, group, node)
if err != nil {
_ = c.Error(err)
return
}
results = append(results, *result)
}
}
}
c.JSON(http.StatusOK, data)
c.JSON(http.StatusOK, results)
}

func GetNode(c *gin.Context) {
Expand All @@ -89,7 +89,7 @@ func GetNode(c *gin.Context) {
groups, err := service.ListGroups(c, cluster)
if err != nil {
_ = c.Error(err)
continue
return
}
for _, group := range groups {
data, err = service.GetNode(c, cluster, group, node)
Expand Down

0 comments on commit b0a9024

Please sign in to comment.