fix(emqx_bridge_mongodb): use correct config when calling downgrade_type
Also limit result in mongodb ..._to_bridge_v1_config to not include more fields than what's in the schema (most notably `description`).
This commit is contained in:
parent
5d7ae4b980
commit
6143b3a2be
|
@ -913,7 +913,7 @@ format_resource(
|
|||
redact(
|
||||
maps:merge(
|
||||
RawConfFull#{
|
||||
type => downgrade_type(Type, RawConf),
|
||||
type => downgrade_type(Type, emqx_bridge_lib:get_conf(Type, BridgeName)),
|
||||
name => maps:get(<<"name">>, RawConf, BridgeName),
|
||||
node => Node
|
||||
},
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
-export([
|
||||
maybe_withdraw_rule_action/3,
|
||||
upgrade_type/1,
|
||||
downgrade_type/2
|
||||
downgrade_type/2,
|
||||
get_conf/2
|
||||
]).
|
||||
|
||||
%% @doc A bridge can be used as a rule action.
|
||||
|
|
|
@ -26,19 +26,21 @@
|
|||
|
||||
-define(SCHEMA_MODULE, emqx_bridge_mongodb).
|
||||
|
||||
connector_action_config_to_bridge_v1_config(ConnectorConfig, ActionConfig) ->
|
||||
fix_v1_type(
|
||||
maps:merge(
|
||||
connector_action_config_to_bridge_v1_config(
|
||||
#{<<"parameters">> := #{<<"mongo_type">> := MongoType}} = ConnectorConfig,
|
||||
ActionConfig
|
||||
) ->
|
||||
MergedConfig =
|
||||
emqx_utils_maps:deep_merge(
|
||||
maps:without(
|
||||
[<<"connector">>],
|
||||
emqx_utils_maps:unindent(<<"parameters">>, ActionConfig)
|
||||
),
|
||||
emqx_utils_maps:unindent(<<"parameters">>, ConnectorConfig)
|
||||
)
|
||||
).
|
||||
|
||||
fix_v1_type(#{<<"mongo_type">> := MongoType} = Conf) ->
|
||||
Conf#{<<"type">> => v1_type(MongoType)}.
|
||||
),
|
||||
BridgeV1Type = v1_type(MongoType),
|
||||
BridgeV1Keys = schema_keys(BridgeV1Type),
|
||||
maps:with(BridgeV1Keys, MergedConfig).
|
||||
|
||||
bridge_v1_config_to_action_config(BridgeV1Config, ConnectorName) ->
|
||||
ActionTopLevelKeys = schema_keys(mongodb_action),
|
||||
|
|
Loading…
Reference in New Issue