MCPcopy Index your code
hub / github.com/eolinker/goku_lite / EditNode

Function EditNode

console/controller/node/node.go:125–187  ·  view source on GitHub ↗

EditNode 修改节点信息

(httpResponse http.ResponseWriter, httpRequest *http.Request)

Source from the content-addressed store, hash-verified

123
124//EditNode 修改节点信息
125func EditNode(httpResponse http.ResponseWriter, httpRequest *http.Request) {
126
127 nodeName := httpRequest.PostFormValue("nodeName")
128 listenAddress := httpRequest.PostFormValue("listenAddress")
129 adminAddress := httpRequest.PostFormValue("adminAddress")
130 groupID := httpRequest.PostFormValue("groupID")
131 nodeID := httpRequest.PostFormValue("nodeID")
132
133 gatewayPath := httpRequest.PostFormValue("gatewayPath")
134 // key := httpRequest.PostFormValue("key")
135
136 if !utils.ValidateRemoteAddr(listenAddress) {
137 controller.WriteError(httpResponse,
138 "230006",
139 "node", "[ERROR]Illegal listenAddress!",
140 errors.New("illegal listenAddress"))
141 return
142 }
143 if !utils.ValidateRemoteAddr(adminAddress) {
144 controller.WriteError(httpResponse,
145 "230007",
146 "node", "[ERROR]Illegal listenAddress!",
147 errors.New("illegal listenAddress"))
148 return
149 }
150
151 id, err := strconv.Atoi(nodeID)
152 if err != nil {
153
154 controller.WriteError(httpResponse, "230001", "node", "[ERROR]Illegal nodeID!", err)
155 return
156 }
157 gID, err := strconv.Atoi(groupID)
158 if err != nil && groupID != "" {
159 controller.WriteError(httpResponse, "230015", "node", "[ERROR]Illegal groupID!", err)
160 return
161 }
162
163 if gID != 0 {
164 // 检查分组是否存在
165 flag, err := node.CheckNodeGroupIsExist(gID)
166
167 if !flag {
168 controller.WriteError(
169 httpResponse,
170 "230014",
171 "node",
172 "[ERROR]The node group does not exist!",
173 err)
174 return
175 }
176 }
177
178 result, err := node.EditNode(nodeName, listenAddress, adminAddress, gatewayPath, id, gID)
179
180 if err != nil {
181 controller.WriteError(httpResponse, "330000", "node", result, nil)
182 return

Callers

nothing calls this directly

Calls 6

ValidateRemoteAddrFunction · 0.92
WriteErrorFunction · 0.92
CheckNodeGroupIsExistFunction · 0.92
EditNodeFunction · 0.92
WriteResultInfoFunction · 0.92
NewMethod · 0.65

Tested by

no test coverage detected