box: allow to set box.cfg table value via env var
All box.cfg options values used to be plain values or arrays. Now some options contain key-value or nested tables. This patch allows all such options to be set through environment variables too. Closes #8494 Closes #8051 @TarantoolBot document Title: Set box.cfg table value via env vars This patch implements a way to set tables as box.cfg options value in two different ways: * as plain key-value table: ``` bash> export TT_LOG_MODULES=aaa=info,bbb=error && ./tarantool Tarantool 2.10.0-beta1-1977-g2970bd57a type 'help' for interactive help tarantool> box.cfg{} ... 2023-04-11 07:22:10.951 [219020] main/103/interactive/box.load_cfg I> set \ 'log_modules' configuration option to {"aaa":"info","bbb":"error"} --- ... tarantool> box.cfg.log_modules.aaa --- - info ... tarantool> box.cfg.log_modules.bbb --- - error ... ``` * as a table in json encoding (important: don't forget to put env var value into single quotes): NO_WRAP ``` bash> export TT_METRICS='{"labels":{"alias":"mystorage"},"include":"all","exclude":["vinyl"]}' && ./tarantool Tarantool 2.10.0-beta1-1977-g2970bd57a type 'help' for interactive help tarantool> box.cfg{} ... 2023-04-11 07:26:03.635 [219288] main/103/interactive/box.load_cfg I> set \ 'metrics' configuration option to {"exclude":["vinyl"],"include":"all",\ "labels":{"alias":"mystorage"}} --- ... tarantool> box.cfg.metrics.include --- - all ... ``` NO_WRAP
Showing
- changelogs/unreleased/gh-8051-set-box-cfg-thru-env.md 4 additions, 0 deletionschangelogs/unreleased/gh-8051-set-box-cfg-thru-env.md
- src/box/lua/load_cfg.lua 24 additions, 1 deletionsrc/box/lua/load_cfg.lua
- test/box-luatest/gh_8051_set_box_cfg_thru_env_test.lua 92 additions, 0 deletionstest/box-luatest/gh_8051_set_box_cfg_thru_env_test.lua
Loading
Please register or sign in to comment