spacewander commented on a change in pull request #2772:
URL: https://github.com/apache/apisix/pull/2772#discussion_r525030453
##########
File path: apisix/core/etcd.lua
##########
@@ -92,17 +94,28 @@ function _M.get_format(res, realkey)
if not res.body.kvs then
return not_found(res)
end
+
res.body.action = "get"
- -- In etcd v2, the direct key asked for is `node`, others which under this
dir are `nodes`
- -- While in v3, this structure is flatten and all keys related the key
asked for are `kvs`
- res.body.node = kvs_to_node(res.body.kvs[1])
- if not res.body.kvs[1].value then
- -- remove last "/" when necesary
- if string.sub(res.body.node.key, -1, -1) == "/" then
- res.body.node.key = string.sub(res.body.node.key, 1,
#res.body.node.key-1)
+ if not is_dir then
+ local key = res.body.kvs[1].key
+ if key ~= real_key then
+ return not_found(res)
+ end
+
+ res.body.node = kvs_to_node(res.body.kvs[1])
+
+ else
+ -- In etcd v2, the direct key asked for is `node`, others which under
this dir are `nodes`
+ -- While in v3, this structure is flatten and all keys related the key
asked for are `kvs`
+ res.body.node = kvs_to_node(res.body.kvs[1])
+ if not res.body.kvs[1].value then
+ -- remove last "/" when necesary
+ if string.sub(res.body.node.key, -1, -1) == "/" then
Review comment:
@tokers Updated
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]