AlinsRan commented on code in PR #12333:
URL: https://github.com/apache/apisix/pull/12333#discussion_r2158092743
##########
docs/en/latest/deployment-modes.md:
##########
@@ -293,7 +295,7 @@ routes:
#END
```
-*WARNING*: APISIX will not load the rules into memory from file
`conf/apisix.yaml` if there is no `#END` at the end.
+*WARNING*: APISIX will not load the rules into memory from file
`conf/apisix.yaml` if there is no `#END` at the end. However, when using
`conf/apisix.json`, the `#END` marker is not required, as APISIX can directly
parse and validate the JSON structure.
Review Comment:
You need to clarify the priority of the `apisix.yaml` and `apisix.json`
configuration files.
When both files exist, which one is valid.
##########
apisix/core/config_yaml.lua:
##########
@@ -69,9 +68,36 @@ local mt = {
end
}
+local apisix_config
+local apisix_config_mtime
+local apisix_config_path
+
+local apisix_yaml_path = profile:yaml_path("apisix")
+local apisix_json_path = ngx.re.sub(apisix_yaml_path, [[\.yaml$]], ".json",
"jo")
+local file_configs = {
+ {path = apisix_yaml_path, type = "yaml"},
+ {path = apisix_json_path, type = "json"}
+}
+
+local function get_config_file_info()
+ local paths_str = ""
Review Comment:
The variable name is not clear, it is only used to record errors.
This function has many return values, you can consider using a table.
refer to:
```
local function get_config_file_info()
local not_found_paths = {}
for _, config in ipairs(file_configs) do
local attr, err = lfs.attributes(config.path)
if attr then
return config.path, config.type, attr.modification
else
table.insert(not_found_paths, config.path)
log.warn("failed to fetch attributes for ", config.path, ": ",
err)
end
end
local paths_str = table.concat(not_found_paths, ", ")
return nil, nil, nil, "Failed to find any configuration file with path "
.. paths_str
end
```
--
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]