mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-08 22:24:17 +08:00
set static nodes to list
This commit is contained in:
parent
b41353b415
commit
6ccafe82ed
3 changed files with 14 additions and 5 deletions
|
@ -326,6 +326,7 @@ func getNetworkNodes(w http.ResponseWriter, r *http.Request) {
|
|||
if len(filteredNodes) > 0 {
|
||||
nodes = filteredNodes
|
||||
}
|
||||
nodes = logic.AddStaticNodestoList(nodes)
|
||||
|
||||
// returns all the nodes in JSON/API format
|
||||
apiNodes := logic.GetAllNodesAPI(nodes[:])
|
||||
|
@ -362,10 +363,10 @@ func getAllNodes(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
if !userPlatformRole.FullAccess {
|
||||
nodes = logic.GetFilteredNodesByUserAccess(*user, nodes)
|
||||
} else {
|
||||
nodes = logic.AddStaticNodestoList(nodes)
|
||||
}
|
||||
|
||||
}
|
||||
nodes = logic.AddStaticNodestoList(nodes)
|
||||
// return all the nodes in JSON/API format
|
||||
apiNodes := logic.GetAllNodesAPI(nodes[:])
|
||||
logger.Log(3, r.Header.Get("user"), "fetched all nodes they have access to")
|
||||
|
|
|
@ -48,6 +48,9 @@ type ApiNode struct {
|
|||
InetNodeReq InetNodeReq `json:"inet_node_req" yaml:"inet_node_req"`
|
||||
InternetGwID string `json:"internetgw_node_id" yaml:"internetgw_node_id"`
|
||||
AdditionalRagIps []string `json:"additional_rag_ips" yaml:"additional_rag_ips"`
|
||||
IsStatic bool `json:"is_static"`
|
||||
IsUserNode bool `json:"is_user_node"`
|
||||
StaticNode ExtClient `json:"static_node"`
|
||||
}
|
||||
|
||||
// ApiNode.ConvertToServerNode - converts an api node to a server node
|
||||
|
@ -183,6 +186,9 @@ func (nm *Node) ConvertToAPINode() *ApiNode {
|
|||
for _, ip := range nm.AdditionalRagIps {
|
||||
apiNode.AdditionalRagIps = append(apiNode.AdditionalRagIps, ip.String())
|
||||
}
|
||||
apiNode.IsStatic = nm.IsStatic
|
||||
apiNode.IsUserNode = nm.IsUserNode
|
||||
apiNode.StaticNode = nm.StaticNode
|
||||
return &apiNode
|
||||
}
|
||||
|
||||
|
|
|
@ -688,7 +688,7 @@ func GetFilteredNodesByUserAccess(user models.User, nodes []models.Node) (filter
|
|||
nodesMap := make(map[string]struct{})
|
||||
allNetworkRoles := make(map[models.UserRoleID]struct{})
|
||||
defer func() {
|
||||
logic.AddStaticNodestoList(nodes)
|
||||
filteredNodes = logic.AddStaticNodestoList(filteredNodes)
|
||||
}()
|
||||
if len(user.NetworkRoles) > 0 {
|
||||
for _, netRoles := range user.NetworkRoles {
|
||||
|
@ -698,7 +698,8 @@ func GetFilteredNodesByUserAccess(user models.User, nodes []models.Node) (filter
|
|||
}
|
||||
}
|
||||
if _, ok := user.NetworkRoles[models.AllNetworks]; ok {
|
||||
return nodes
|
||||
filteredNodes = nodes
|
||||
return
|
||||
}
|
||||
if len(user.UserGroups) > 0 {
|
||||
for userGID := range user.UserGroups {
|
||||
|
@ -706,7 +707,8 @@ func GetFilteredNodesByUserAccess(user models.User, nodes []models.Node) (filter
|
|||
if err == nil {
|
||||
if len(userG.NetworkRoles) > 0 {
|
||||
if _, ok := userG.NetworkRoles[models.AllNetworks]; ok {
|
||||
return nodes
|
||||
filteredNodes = nodes
|
||||
return
|
||||
}
|
||||
for _, netRoles := range userG.NetworkRoles {
|
||||
for netRoleI := range netRoles {
|
||||
|
|
Loading…
Add table
Reference in a new issue