fix(config): reset config failed due to rootname not found
This commit is contained in:
parent
8dbb14b668
commit
b652a64dbb
|
@ -214,15 +214,13 @@ get_default_value([RootName | _] = KeyPath) ->
|
||||||
BinKeyPath = [bin(Key) || Key <- KeyPath],
|
BinKeyPath = [bin(Key) || Key <- KeyPath],
|
||||||
case find_raw([RootName]) of
|
case find_raw([RootName]) of
|
||||||
{ok, RawConf} ->
|
{ok, RawConf} ->
|
||||||
RawConf1 = emqx_map_lib:deep_remove(BinKeyPath, RawConf),
|
RawConf1 = emqx_map_lib:deep_remove(BinKeyPath, #{bin(RootName) => RawConf}),
|
||||||
SchemaMod = get_schema_mod(RootName),
|
try fill_defaults(get_schema_mod(RootName), RawConf1) of FullConf ->
|
||||||
try fill_defaults(SchemaMod, RawConf1) of FullConf ->
|
|
||||||
case emqx_map_lib:deep_find(BinKeyPath, FullConf) of
|
case emqx_map_lib:deep_find(BinKeyPath, FullConf) of
|
||||||
{not_found, _, _} -> {error, no_default_value};
|
{not_found, _, _} -> {error, no_default_value};
|
||||||
{ok, Val} -> {ok, Val}
|
{ok, Val} -> {ok, Val}
|
||||||
end
|
end
|
||||||
catch error:_ ->
|
catch error : Reason -> {error, Reason}
|
||||||
{error, required_conf}
|
|
||||||
end;
|
end;
|
||||||
{not_found, _, _} ->
|
{not_found, _, _} ->
|
||||||
{error, {rootname_not_found, RootName}}
|
{error, {rootname_not_found, RootName}}
|
||||||
|
|
|
@ -82,8 +82,8 @@ handle_call({add_child, ConfKeyPath, HandlerName}, _From,
|
||||||
|
|
||||||
handle_call({change_config, SchemaModule, ConfKeyPath, UpdateArgs}, _From,
|
handle_call({change_config, SchemaModule, ConfKeyPath, UpdateArgs}, _From,
|
||||||
#{handlers := Handlers} = State) ->
|
#{handlers := Handlers} = State) ->
|
||||||
OldConf = emqx_config:get_root(ConfKeyPath),
|
OldConf = emqx_config:get([]),
|
||||||
OldRawConf = emqx_config:get_root_raw(ConfKeyPath),
|
OldRawConf = emqx_config:get_raw([]),
|
||||||
Result = try
|
Result = try
|
||||||
{NewRawConf, OverrideConf} = process_upadate_request(ConfKeyPath, OldRawConf,
|
{NewRawConf, OverrideConf} = process_upadate_request(ConfKeyPath, OldRawConf,
|
||||||
Handlers, UpdateArgs),
|
Handlers, UpdateArgs),
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
|
|
||||||
-define(MAX_DEPTH, 1).
|
-define(MAX_DEPTH, 1).
|
||||||
|
|
||||||
-define(ERR_MSG(MSG), io_lib:format("~p", [MSG])).
|
-define(ERR_MSG(MSG), list_to_binary(io_lib:format("~p", [MSG]))).
|
||||||
|
|
||||||
api_spec() ->
|
api_spec() ->
|
||||||
{config_apis() ++ [config_reset_api()], []}.
|
{config_apis() ++ [config_reset_api()], []}.
|
||||||
|
|
Loading…
Reference in New Issue