membphis commented on code in PR #12057:
URL: https://github.com/apache/apisix/pull/12057#discussion_r2002393612


##########
apisix/discovery/kubernetes/init.lua:
##########
@@ -372,13 +372,37 @@ local _M = {
 }
 
 
+local function refresh_token(handle, token_file)
+    local file, err = read_env(token_file)
+    if err then
+        core.log.error("failed to read token file path: ", err)
+        return
+    end
+
+    local token, err = util.read_file(file)
+    if err then
+        core.log.error("failed to refresh token from file: ", err)
+        return
+    end
+
+    token = token:gsub("%s+", "")
+    if token ~= handle.apiserver.token then
+        core.log.info("kubernetes token updated")
+        handle.apiserver.token = token
+    end
+end
+
 local function start_fetch(handle)
     local timer_runner
     timer_runner = function(premature)
         if premature then
             return
         end
 
+        if handle.token_file then
+            refresh_token(handle, handle.token_file)

Review Comment:
   bad name
   
   `cache` -> `refresh`: this is a good name
   no cache -> refresh: it is weird
   
   it should be name to `read token` or `fetch token`



-- 
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