tzssangglass commented on code in PR #7630:
URL: https://github.com/apache/apisix/pull/7630#discussion_r942070069


##########
apisix/core/config_etcd.lua:
##########
@@ -212,14 +212,15 @@ local function load_full_data(self, dir_res, headers)
         self:upgrade_version(item.modifiedIndex)
 
     else
-        if not dir_res.nodes then
-            dir_res.nodes = {}
+        local values = (dir_res and dir_res.nodes) or dir_res

Review Comment:
   `or dir_res` is useful.
   
   when we run the test case of: 
https://github.com/apache/apisix/blob/master/t/core/etcd-sync.t#L198-L216
   
   here `dir_res` = `res.body.list`, changed here: 
https://github.com/apache/apisix/pull/7630/files#diff-0dd73f147a1cb8d7591792a953ffd7714e5d41ef8123aeb681046b1dcbfef668R306
   
   the data struct like:
   
   ```json
   "body": {
        "list": {
               ...element
       }
   }
   ```
   
   and the `values` = `dir_res.list`
   
   
   in other cases,  `dir_res` = `res.body.node`, the data struct like:
   
   ```json
   "body": {
        "node": {
             "nodes": {
                 ...element
             }
       }
   }
   ```
   
   the `values` = `dir_res.node.nodes`
   
   `(dir_res and dir_res.nodes) or dir_res` is meant to be compatible with both.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to