fix: dialyzer problem for community edition

This commit is contained in:
Kjell Winblad 2023-10-24 15:41:44 +02:00 committed by Zaiming (Stone) Shi
parent 6c6c2e0cff
commit 2d05e3a975
4 changed files with 25 additions and 7 deletions

View File

@ -432,11 +432,10 @@ create_dry_run_helper(BridgeType, ConnectorRawConf, BridgeV2RawConf) ->
create_dry_run(Type, Conf0) ->
Conf1 = maps:without([<<"name">>], Conf0),
TypeBin = bin(Type),
TypeAtom = binary_to_existing_atom(TypeBin),
RawConf = #{<<"bridges_v2">> => #{TypeBin => #{<<"temp_name">> => Conf1}}},
%% Check config
try
#{bridges_v2 := #{TypeAtom := #{temp_name := _Conf}}} =
_ =
hocon_tconf:check_plain(
emqx_bridge_v2_schema,
RawConf,

View File

@ -109,8 +109,13 @@ tags() ->
roots() ->
case fields(bridges_v2) of
[] -> [];
_ -> [{bridges_v2, ?HOCON(?R_REF(bridges_v2), #{importance => ?IMPORTANCE_LOW})}]
[] ->
[
{bridges_v2,
?HOCON(hoconsc:map(name, typerefl:map()), #{importance => ?IMPORTANCE_LOW})}
];
_ ->
[{bridges_v2, ?HOCON(?R_REF(bridges_v2), #{importance => ?IMPORTANCE_LOW})}]
end.
fields(bridges_v2) ->

View File

@ -263,12 +263,13 @@ create_dry_run(Type, Conf0, Callback) ->
Conf1 = maps:without([<<"name">>], Conf0),
RawConf = #{<<"connectors">> => #{TypeBin => #{<<"temp_name">> => Conf1}}},
try
#{connectors := #{TypeAtom := #{temp_name := Conf}}} =
CheckedConf =
hocon_tconf:check_plain(
emqx_connector_schema,
RawConf,
#{atom_key => true, required => false}
),
Conf = get_temp_conf(TypeAtom, CheckedConf),
case emqx_connector_ssl:convert_certs(TmpPath, Conf) of
{error, Reason} ->
{error, Reason};
@ -286,6 +287,14 @@ create_dry_run(Type, Conf0, Callback) ->
_ = file:del_dir_r(emqx_tls_lib:pem_dir(TmpPath))
end.
get_temp_conf(TypeAtom, CheckedConf) ->
case CheckedConf of
#{connectors := #{TypeAtom := #{temp_name := Conf}}} ->
Conf;
#{connectors := #{TypeAtom := #{<<"temp_name">> := Conf}}} ->
Conf
end.
remove(ConnectorId) ->
{ConnectorType, ConnectorName} = parse_connector_id(ConnectorId),
remove(ConnectorType, ConnectorName, #{}, #{}).

View File

@ -258,8 +258,13 @@ tags() ->
roots() ->
case fields(connectors) of
[] -> [];
_ -> [{connectors, ?HOCON(?R_REF(connectors), #{importance => ?IMPORTANCE_LOW})}]
[] ->
[
{connectors,
?HOCON(hoconsc:map(name, typerefl:map()), #{importance => ?IMPORTANCE_LOW})}
];
_ ->
[{connectors, ?HOCON(?R_REF(connectors), #{importance => ?IMPORTANCE_LOW})}]
end.
fields(connectors) ->