Yiyiyimu commented on a change in pull request #2036: URL: https://github.com/apache/apisix/pull/2036#discussion_r488739432
########## File path: apisix/core/etcd.lua ########## @@ -44,24 +48,134 @@ end _M.new = new +local function kvs_to_node(kvs) + local node = {} + node.key = kvs.key + node.value = kvs.value + node.createdIndex = tonumber(kvs.create_revision) + node.modifiedIndex = tonumber(kvs.mod_revision) + return node +end + +local function kvs_to_nodes(res) + res.body.node.dir = true + res.body.node.nodes = {} + for i=2, #res.body.kvs do + res.body.node.nodes[i-1] = kvs_to_node(res.body.kvs[i]) + end + return res +end + + +local function not_found(res) + res.body.message = "Key not found" + res.reason = "Not found" + res.status = 404 + return res +end + + +function _M.get_format(res, realkey) + if res.body.error == "etcdserver: user name is empty" then + return nil, "insufficient credentials code: 401" Review comment: 1. The error resulted from `get` when etcd auth failed in v3 is different from v2, so I tried to keep it the same 2. That's the only difference I know between v2 and v3. We could return other error directly. ---------------------------------------------------------------- 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: us...@infra.apache.org