nic-6443 commented on code in PR #12885:
URL: https://github.com/apache/apisix/pull/12885#discussion_r3393074074
##########
apisix/cli/file.lua:
##########
@@ -105,7 +105,7 @@ local function resolve_conf_var(conf)
end
if new_key ~= key then
new_keys[new_key] = "dummy" -- we only care about checking the
key
- conf.key = nil
+ conf[key] = nil
Review Comment:
The fix itself looks right. One heads-up for the test that was requested:
since #13078, standalone `apisix.yaml` substitutes env vars in the raw text
*before* YAML parsing (`resolve_conf_var_in_text`), so the original repro from
#12884 (env var as an upstream node key in apisix.yaml) no longer reaches this
function on master. A test modeled on the issue's repro steps won't cover this
line. The remaining callers of `resolve_conf_var` are `config.yaml` (this file,
in `read_yaml_conf`) and JSON standalone mode (`apisix.json` in
`core/config_yaml.lua`), so the test needs to target one of those.
An easy way is a shell test for an env var used as a `config.yaml` key, e.g.
in `t/cli/test_http_config.sh` next to the existing custom shdict case:
```sh
echo '
nginx_config:
http:
custom_lua_shared_dict:
"${{DICT_NAME}}": 1m
' > conf/config.yaml
DICT_NAME=test_dict make init
if ! grep "lua_shared_dict test_dict 1m;" conf/nginx.conf > /dev/null; then
echo "failed: resolve env var in config key"
exit 1
fi
if grep "DICT_NAME" conf/nginx.conf > /dev/null; then
echo "failed: stale unresolved env var key should be removed"
exit 1
fi
```
The second grep fails without this fix (the stale `${{DICT_NAME}}` entry
stays in the table and gets rendered as an extra `lua_shared_dict` line) and
passes with it.
--
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]