spacewander commented on a change in pull request #2965: URL: https://github.com/apache/apisix/pull/2965#discussion_r548434807
########## File path: apisix/cli/etcd.lua ########## @@ -160,31 +163,38 @@ function _M.init(env, show_output) for index, host in ipairs(yaml_conf.etcd.host) do local is_success = true - local token_head = "" + local errmsg + local auth_token local user = yaml_conf.etcd.user local password = yaml_conf.etcd.password if user and password then - local uri_auth = host .. "/v3/auth/authenticate" + local auth_url = host .. "/v3/auth/authenticate" local json_auth = { name = etcd_conf.user, password = etcd_conf.password } - local post_json_auth = dkjson.encode(json_auth) - local cmd_auth = "curl -s " .. uri_auth .. " -X POST -d '" .. - post_json_auth .. "' --connect-timeout " .. timeout - .. " --max-time " .. timeout * 2 .. " --retry 1 2>&1" - local res_auth = util.execute_cmd(cmd_auth) - local body_auth, _, err_auth = dkjson.decode(res_auth) - if err_auth then - util.die(cmd_auth, "\n", res_auth) + local post_json_auth = dkjson.encode(json_auth) + local response_body = {} + local _, err = http.request{url = auth_url, method = "POST", + source = ltn12.source.string(post_json_auth), + sink = ltn12.sink.table(response_body), + headers = {["Content-Length"] = #post_json_auth}} + -- err is string type + if err and type(err) == "string" then Review comment: Better to add more info about the `err` handle, so that people can know what you are doing without looking into luasocket's doc. ---------------------------------------------------------------- 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