fix: can't get default raw config
This commit is contained in:
parent
4ce3d43446
commit
65820eb943
|
@ -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() ->
|
||||
|
|
Loading…
Reference in New Issue