From bfc36efa0eaf72709f2d63446ea91e4f36f3b05f Mon Sep 17 00:00:00 2001 From: "Zaiming (Stone) Shi" Date: Thu, 2 Dec 2021 20:16:46 +0100 Subject: [PATCH] fix: pin hocon 0.21.1 --- apps/emqx/rebar.config | 2 +- apps/emqx/src/emqx_config.erl | 10 ++++++++-- build | 2 +- rebar.config | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/apps/emqx/rebar.config b/apps/emqx/rebar.config index 59c5cf045..5adcbd3bb 100644 --- a/apps/emqx/rebar.config +++ b/apps/emqx/rebar.config @@ -17,7 +17,7 @@ , {esockd, {git, "https://github.com/emqx/esockd", {tag, "5.9.0"}}} , {ekka, {git, "https://github.com/emqx/ekka", {tag, "0.11.1"}}} , {gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.5.1"}}} - , {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.20.6"}}} + , {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.22.0"}}} , {pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {tag, "2.0.4"}}} , {recon, {git, "https://github.com/ferd/recon", {tag, "2.5.1"}}} , {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "0.15.0"}}} diff --git a/apps/emqx/src/emqx_config.erl b/apps/emqx/src/emqx_config.erl index 2693d559e..ecb843ed5 100644 --- a/apps/emqx/src/emqx_config.erl +++ b/apps/emqx/src/emqx_config.erl @@ -272,9 +272,15 @@ init_load(SchemaMod, RawConf) when is_map(RawConf) -> ok = save_schema_mod_and_names(SchemaMod), %% check and save configs {_AppEnvs, CheckedConf} = check_config(SchemaMod, RawConf), + %% fill default values for raw config + Opts = #{only_fill_defaults => true, + logger => fun(_, _) -> ok end, %% everything should have been logged already + nullable => true %% TODO: evil, remove, nullable should be declared in schema + }, + RawConfWithDefaults = hocon_schema:check_plain(SchemaMod, RawConf, Opts), RootNames = get_root_names(), ok = save_to_config_map(maps:with(get_atom_root_names(), CheckedConf), - maps:with(RootNames, RawConf)). + maps:with(RootNames, RawConfWithDefaults)). include_dirs() -> [filename:join(emqx:data_dir(), "configs")]. @@ -283,7 +289,7 @@ include_dirs() -> when AppEnvs :: app_envs(), CheckedConf :: config(). check_config(SchemaMod, RawConf) -> Opts = #{return_plain => true, - nullable => true, + nullable => true, %% TODO: evil, remove, nullable should be declared in schema format => map }, {AppEnvs, CheckedConf} = diff --git a/build b/build index c79dc711c..9f9879df4 100755 --- a/build +++ b/build @@ -60,7 +60,7 @@ docgen() { conf_doc_markdown="$(pwd)/_build/${PROFILE}/rel/emqx/etc/emqx-config-doc.md" echo "===< Generating config document $conf_doc_markdown" # shellcheck disable=SC2086 - erl -noshell -pa $libs_dir1 $libs_dir2 -eval "file:write_file('$conf_doc_markdown', hocon_schema_doc:gen(emqx_conf_schema)), halt(0)." + erl -noshell -pa $libs_dir1 $libs_dir2 -eval "file:write_file('$conf_doc_markdown', hocon_schema_doc:gen(emqx_conf_schema, \"EMQ X ${PKG_VSN} Configuration\")), halt(0)." } make_rel() { diff --git a/rebar.config b/rebar.config index 4fbf1b136..33c1244d2 100644 --- a/rebar.config +++ b/rebar.config @@ -64,7 +64,7 @@ , {observer_cli, "1.7.1"} % NOTE: depends on recon 2.5.x , {getopt, "1.0.2"} , {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "0.15.0"}}} - , {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.20.6"}}} + , {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.22.0"}}} , {emqx_http_lib, {git, "https://github.com/emqx/emqx_http_lib.git", {tag, "0.4.1"}}} , {esasl, {git, "https://github.com/emqx/esasl", {tag, "0.2.0"}}} , {jose, {git, "https://github.com/potatosalad/erlang-jose", {tag, "1.11.1"}}}