fix: use populated non-raw conf when checking if bridge_v2 is enabled

This commit is contained in:
Kjell Winblad 2023-10-28 07:42:45 +02:00
parent 917e13c0e9
commit babf5f973a
1 changed files with 7 additions and 6 deletions

View File

@ -737,13 +737,14 @@ is_bridge_enabled_v1(BridgeType, BridgeName) ->
throw(not_found)
end.
is_bridge_enabled_v2(BridgeType, BridgeName) ->
try emqx_bridge:lookup(BridgeType, binary_to_existing_atom(BridgeName)) of
{ok, #{raw_config := ConfMap}} ->
maps:get(<<"enable">>, ConfMap, false);
{error, not_found} ->
throw(not_found)
is_bridge_enabled_v2(BridgeV1Type, BridgeName) ->
BridgeV2Type = emqx_bridge_v2:bridge_v1_type_to_bridge_v2_type(BridgeV1Type),
try emqx:get_config([bridges_v2, BridgeV2Type, binary_to_existing_atom(BridgeName)]) of
ConfMap ->
maps:get(enable, ConfMap, true)
catch
error:{config_not_found, _} ->
throw(not_found);
error:badarg ->
%% catch non-existing atom,
%% none-existing atom means it is not available in config PT storage.