Merge pull request #9392 from zhongwencool/fix-config-raw-default
fix: Config API can't get the default values from raw config
This commit is contained in:
commit
8355d7afa3
|
@ -268,7 +268,7 @@ config(put, #{body := Body}, Req) ->
|
|||
global_zone_configs(get, _Params, _Req) ->
|
||||
Paths = global_zone_roots(),
|
||||
Zones = lists:foldl(
|
||||
fun(Path, Acc) -> Acc#{Path => get_config_with_default([Path])} end,
|
||||
fun(Path, Acc) -> maps:merge(Acc, get_config_with_default(Path)) end,
|
||||
#{},
|
||||
Paths
|
||||
),
|
||||
|
@ -343,7 +343,7 @@ get_full_config() ->
|
|||
).
|
||||
|
||||
get_config_with_default(Path) ->
|
||||
emqx_config:fill_defaults(emqx:get_raw_config(Path)).
|
||||
emqx_config:fill_defaults(#{Path => emqx:get_raw_config([Path])}).
|
||||
|
||||
conf_path_from_querystr(Req) ->
|
||||
case proplists:get_value(<<"conf_path">>, cowboy_req:parse_qs(Req)) of
|
||||
|
|
|
@ -133,6 +133,18 @@ t_global_zone(_Config) ->
|
|||
|
||||
BadZones = emqx_map_lib:deep_put([<<"mqtt">>, <<"max_qos_allowed">>], Zones, 3),
|
||||
?assertMatch({error, {"HTTP/1.1", 400, _}}, update_global_zone(BadZones)),
|
||||
|
||||
%% Remove max_qos_allowed from raw config, but we still get default value(2).
|
||||
Mqtt0 = emqx_conf:get_raw([<<"mqtt">>]),
|
||||
?assertEqual(1, emqx_map_lib:deep_get([<<"max_qos_allowed">>], Mqtt0)),
|
||||
Mqtt1 = maps:remove(<<"max_qos_allowed">>, Mqtt0),
|
||||
ok = emqx_config:put_raw([<<"mqtt">>], Mqtt1),
|
||||
Mqtt2 = emqx_conf:get_raw([<<"mqtt">>]),
|
||||
?assertNot(maps:is_key(<<"max_qos_allowed">>, Mqtt2), Mqtt2),
|
||||
{ok, #{<<"mqtt">> := Mqtt3}} = get_global_zone(),
|
||||
%% the default value is 2
|
||||
?assertEqual(2, emqx_map_lib:deep_get([<<"max_qos_allowed">>], Mqtt3)),
|
||||
ok = emqx_config:put_raw([<<"mqtt">>], Mqtt0),
|
||||
ok.
|
||||
|
||||
get_global_zone() ->
|
||||
|
|
|
@ -22,3 +22,5 @@
|
|||
- Return 404 for status of unknown authenticator in `/authenticator/{id}/status` [#9328](https://github.com/emqx/emqx/pull/9328).
|
||||
|
||||
- Fix that JWT ACL rules are only applied if an `exp` claim is set [#9368](https://github.com/emqx/emqx/pull/9368).
|
||||
|
||||
- Fix that `/configs/global_zone` API cannot get the default value of the configuration [#9392](https://github.com/emqx/emqx/pull/9392).
|
||||
|
|
|
@ -20,3 +20,5 @@
|
|||
- 通过 `/authenticator/{id}/status` 请求未知认证器的状态时,将会返回 404。
|
||||
|
||||
- 修复 JWT ACL 规则只在设置了超期时间时才生效的问题 [#9368](https://github.com/emqx/emqx/pull/9368)。
|
||||
|
||||
- 修复 `/configs/global_zone` API 无法正确获取配置的默认值问题 [#9392](https://github.com/emqx/emqx/pull/9392)。
|
||||
|
|
Loading…
Reference in New Issue