|
@@ -98,16 +98,16 @@ bridge_configs_to_transform(
|
|
|
end.
|
|
end.
|
|
|
|
|
|
|
|
split_bridge_to_connector_and_action(
|
|
split_bridge_to_connector_and_action(
|
|
|
- {ConnectorsMap, {BridgeType, BridgeName, BridgeConf, ConnectorFields, PreviousRawConfig}}
|
|
|
|
|
|
|
+ {ConnectorsMap, {BridgeType, BridgeName, ActionConf, ConnectorFields, PreviousRawConfig}}
|
|
|
) ->
|
|
) ->
|
|
|
%% Get connector fields from bridge config
|
|
%% Get connector fields from bridge config
|
|
|
ConnectorMap = lists:foldl(
|
|
ConnectorMap = lists:foldl(
|
|
|
fun({ConnectorFieldName, _Spec}, ToTransformSoFar) ->
|
|
fun({ConnectorFieldName, _Spec}, ToTransformSoFar) ->
|
|
|
- case maps:is_key(to_bin(ConnectorFieldName), BridgeConf) of
|
|
|
|
|
|
|
+ case maps:is_key(to_bin(ConnectorFieldName), ActionConf) of
|
|
|
true ->
|
|
true ->
|
|
|
NewToTransform = maps:put(
|
|
NewToTransform = maps:put(
|
|
|
to_bin(ConnectorFieldName),
|
|
to_bin(ConnectorFieldName),
|
|
|
- maps:get(to_bin(ConnectorFieldName), BridgeConf),
|
|
|
|
|
|
|
+ maps:get(to_bin(ConnectorFieldName), ActionConf),
|
|
|
ToTransformSoFar
|
|
ToTransformSoFar
|
|
|
),
|
|
),
|
|
|
NewToTransform;
|
|
NewToTransform;
|
|
@@ -118,23 +118,6 @@ split_bridge_to_connector_and_action(
|
|
|
#{},
|
|
#{},
|
|
|
ConnectorFields
|
|
ConnectorFields
|
|
|
),
|
|
),
|
|
|
- %% Remove connector fields from bridge config to create Action
|
|
|
|
|
- ActionMap0 = lists:foldl(
|
|
|
|
|
- fun
|
|
|
|
|
- ({enable, _Spec}, ToTransformSoFar) ->
|
|
|
|
|
- %% Enable filed is used in both
|
|
|
|
|
- ToTransformSoFar;
|
|
|
|
|
- ({ConnectorFieldName, _Spec}, ToTransformSoFar) ->
|
|
|
|
|
- case maps:is_key(to_bin(ConnectorFieldName), BridgeConf) of
|
|
|
|
|
- true ->
|
|
|
|
|
- maps:remove(to_bin(ConnectorFieldName), ToTransformSoFar);
|
|
|
|
|
- false ->
|
|
|
|
|
- ToTransformSoFar
|
|
|
|
|
- end
|
|
|
|
|
- end,
|
|
|
|
|
- BridgeConf,
|
|
|
|
|
- ConnectorFields
|
|
|
|
|
- ),
|
|
|
|
|
%% Generate a connector name, if needed. Avoid doing so if there was a previous config.
|
|
%% Generate a connector name, if needed. Avoid doing so if there was a previous config.
|
|
|
ConnectorName =
|
|
ConnectorName =
|
|
|
case PreviousRawConfig of
|
|
case PreviousRawConfig of
|
|
@@ -142,7 +125,7 @@ split_bridge_to_connector_and_action(
|
|
|
_ -> generate_connector_name(ConnectorsMap, BridgeName, 0)
|
|
_ -> generate_connector_name(ConnectorsMap, BridgeName, 0)
|
|
|
end,
|
|
end,
|
|
|
%% Add connector field to action map
|
|
%% Add connector field to action map
|
|
|
- ActionMap = maps:put(<<"connector">>, ConnectorName, ActionMap0),
|
|
|
|
|
|
|
+ ActionMap = maps:put(<<"connector">>, ConnectorName, ActionConf),
|
|
|
{BridgeType, BridgeName, ActionMap, ConnectorName, ConnectorMap}.
|
|
{BridgeType, BridgeName, ActionMap, ConnectorName, ConnectorMap}.
|
|
|
|
|
|
|
|
generate_connector_name(ConnectorsMap, BridgeName, Attempt) ->
|
|
generate_connector_name(ConnectorsMap, BridgeName, Attempt) ->
|
|
@@ -191,7 +174,7 @@ transform_old_style_bridges_to_connector_and_actions_of_type(
|
|
|
),
|
|
),
|
|
|
%% Add connectors and actions and remove bridges
|
|
%% Add connectors and actions and remove bridges
|
|
|
lists:foldl(
|
|
lists:foldl(
|
|
|
- fun({BridgeType, BridgeName, ActionMap, ConnectorName, ConnectorMap}, RawConfigSoFar) ->
|
|
|
|
|
|
|
+ fun({BridgeType, BridgeName, ActionMap0, ConnectorName, ConnectorMap}, RawConfigSoFar) ->
|
|
|
%% Add connector
|
|
%% Add connector
|
|
|
RawConfigSoFar1 = emqx_utils_maps:deep_put(
|
|
RawConfigSoFar1 = emqx_utils_maps:deep_put(
|
|
|
[<<"connectors">>, to_bin(ConnectorType), ConnectorName],
|
|
[<<"connectors">>, to_bin(ConnectorType), ConnectorName],
|
|
@@ -203,6 +186,7 @@ transform_old_style_bridges_to_connector_and_actions_of_type(
|
|
|
[<<"bridges">>, to_bin(BridgeType), BridgeName],
|
|
[<<"bridges">>, to_bin(BridgeType), BridgeName],
|
|
|
RawConfigSoFar1
|
|
RawConfigSoFar1
|
|
|
),
|
|
),
|
|
|
|
|
+ ActionMap = emqx_action_info:bridge_v1_to_action_fixup(BridgeType, ActionMap0),
|
|
|
%% Add action
|
|
%% Add action
|
|
|
RawConfigSoFar3 = emqx_utils_maps:deep_put(
|
|
RawConfigSoFar3 = emqx_utils_maps:deep_put(
|
|
|
[actions_config_name(), to_bin(maybe_rename(BridgeType)), BridgeName],
|
|
[actions_config_name(), to_bin(maybe_rename(BridgeType)), BridgeName],
|