fix(gw): fix deep_merge can't update the configuration correctly

This commit is contained in:
JianBo He 2022-04-28 22:27:44 +08:00
parent 7061d94cf9
commit 49b51db231
1 changed files with 10 additions and 15 deletions

View File

@ -478,12 +478,9 @@ pre_config_update(_, {update_authn, GwName, Conf}, RawConf) ->
of of
undefined -> undefined ->
badres_authn(not_found, GwName); badres_authn(not_found, GwName);
_ -> Authn ->
{ok, NAuthn = maps:merge(Authn, Conf),
emqx_map_lib:deep_merge( {ok, emqx_map_lib:deep_put([GwName, ?AUTHN_BIN], RawConf, NAuthn)}
RawConf,
#{GwName => #{?AUTHN_BIN => Conf}}
)}
end; end;
pre_config_update(_, {update_authn, GwName, {LType, LName}, Conf}, RawConf) -> pre_config_update(_, {update_authn, GwName, {LType, LName}, Conf}, RawConf) ->
case case
@ -502,17 +499,15 @@ pre_config_update(_, {update_authn, GwName, {LType, LName}, Conf}, RawConf) ->
Auth -> Auth ->
NListener = maps:put( NListener = maps:put(
?AUTHN_BIN, ?AUTHN_BIN,
emqx_map_lib:deep_merge(Auth, Conf), maps:merge(Auth, Conf),
Listener Listener
), ),
NGateway = #{ {ok,
GwName => emqx_map_lib:deep_put(
#{ [GwName, <<"listeners">>, LType, LName],
<<"listeners">> => RawConf,
#{LType => #{LName => NListener}} NListener
} )}
},
{ok, emqx_map_lib:deep_merge(RawConf, NGateway)}
end end
end; end;
pre_config_update(_, {remove_authn, GwName}, RawConf) -> pre_config_update(_, {remove_authn, GwName}, RawConf) ->