From cdcd661e27672baebba8c1741c65d9c70e8872b5 Mon Sep 17 00:00:00 2001 From: HuanXin-Chen <1056216208@qq.com> Date: Wed, 11 Sep 2024 08:23:31 -0700 Subject: [PATCH] style(secret): remove some tips --- apisix/secret/gcp.lua | 8 ++++---- apisix/utils/google-cloud-oauth.lua | 1 + t/secret/gcp.t | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/apisix/secret/gcp.lua b/apisix/secret/gcp.lua index b729216e7281..854503a1c4b6 100644 --- a/apisix/secret/gcp.lua +++ b/apisix/secret/gcp.lua @@ -142,7 +142,7 @@ local function get_secret(oauth, secrets_id) end -local function make_request_to_gcp(conf, secrets_id) +local function request_to_gcp(conf, secrets_id) local auth_config, err = fetch_oauth_conf(conf) if not auth_config then return nil, err @@ -174,11 +174,11 @@ function _M.get(conf, key) return nil, "can't find main key, key: " .. key end - local sub_key = idx and str_sub(key, idx + 1) or nil + local sub_key = idx and str_sub(key, idx + 1) core.log.info("main: ", main_key, sub_key and ", sub: " .. sub_key or "") - local res, err = make_request_to_gcp(conf, main_key) + local res, err = request_to_gcp(conf, main_key) if not res then return nil, "failed to retrtive data from gcp secret manager: " .. err end @@ -189,7 +189,7 @@ function _M.get(conf, key) local data, err = core.json.decode(res) if not data then - return nil, "failed to decode result, res: " .. res .. ", err: " .. err + return nil, "failed to decode result, err: " .. err end return data[sub_key] diff --git a/apisix/utils/google-cloud-oauth.lua b/apisix/utils/google-cloud-oauth.lua index 6cb352848bad..6b59ecc6453d 100644 --- a/apisix/utils/google-cloud-oauth.lua +++ b/apisix/utils/google-cloud-oauth.lua @@ -86,6 +86,7 @@ function _M.generate_jwt_token(self) aud = self.token_uri, scope = self.scope, iat = get_timestamp(), + --- access token lifetime : 60 * 60 exp = get_timestamp() + (60 * 60) }) diff --git a/t/secret/gcp.t b/t/secret/gcp.t index 163bda317156..b89ca1d9a9b6 100644 --- a/t/secret/gcp.t +++ b/t/secret/gcp.t @@ -26,7 +26,7 @@ run_tests; __DATA__ -=== TEST 1: sanity +=== TEST 1: sanity: validate different schema situation --- config location /t { content_by_lua_block {