From e93b71d8d50798777dbdc5019f7021b21c6fd214 Mon Sep 17 00:00:00 2001 From: Kjell Winblad Date: Fri, 10 Nov 2023 15:43:32 +0100 Subject: [PATCH] fix: problems found by @thalesmg in code review Co-authored-by: Thales Macedo Garitezi --- apps/emqx_bridge/src/emqx_action_info.erl | 4 +++- apps/emqx_bridge/src/emqx_bridge_v2.erl | 2 +- apps/emqx_bridge/src/schema/emqx_bridge_v2_schema.erl | 10 ++-------- apps/emqx_bridge_kafka/src/emqx_bridge_kafka.erl | 6 +++--- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/apps/emqx_bridge/src/emqx_action_info.erl b/apps/emqx_bridge/src/emqx_action_info.erl index 0c247ac6f..8e8d51aff 100644 --- a/apps/emqx_bridge/src/emqx_action_info.erl +++ b/apps/emqx_bridge/src/emqx_action_info.erl @@ -1,3 +1,5 @@ +%%-------------------------------------------------------------------- +%% Copyright (c) 2023 EMQ Technologies Co., Ltd. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -146,7 +148,7 @@ action_info_modules() -> lists:usort(lists:flatten(ActionInfoModules) ++ hard_coded_action_info_modules()). action_info_modules(App) -> - case application:get_env(App, emqx, action_info_module) of + case application:get_env(App, emqx_action_info_module) of {ok, Module} -> [Module]; _ -> diff --git a/apps/emqx_bridge/src/emqx_bridge_v2.erl b/apps/emqx_bridge/src/emqx_bridge_v2.erl index 77ef8bef3..70e248e56 100644 --- a/apps/emqx_bridge/src/emqx_bridge_v2.erl +++ b/apps/emqx_bridge/src/emqx_bridge_v2.erl @@ -101,7 +101,7 @@ %% Compatibility Layer API %% All public functions for the compatibility layer should be prefixed with -%% birdge_v1_ +%% bridge_v1_ -export([ bridge_v1_lookup_and_transform/2, diff --git a/apps/emqx_bridge/src/schema/emqx_bridge_v2_schema.erl b/apps/emqx_bridge/src/schema/emqx_bridge_v2_schema.erl index 65250ad40..fdf167db8 100644 --- a/apps/emqx_bridge/src/schema/emqx_bridge_v2_schema.erl +++ b/apps/emqx_bridge/src/schema/emqx_bridge_v2_schema.erl @@ -90,13 +90,10 @@ api_schema(Method) -> hoconsc:union(bridge_api_union(EE ++ APISchemas)). registered_api_schemas(Method) -> - %% We *must* do this to ensure the module is really loaded, especially when we use - %% `call_hocon' from `nodetool' to generate initial configurations. - _ = emqx_bridge_v2:module_info(), - RegistredSchmeas = emqx_action_info:registered_schema_modules(), + RegisteredSchemas = emqx_action_info:registered_schema_modules(), [ api_ref(SchemaModule, atom_to_binary(BridgeV2Type), Method ++ "_bridge_v2") - || {BridgeV2Type, SchemaModule} <- RegistredSchmeas + || {BridgeV2Type, SchemaModule} <- RegisteredSchemas ]. api_ref(Module, Type, Method) -> @@ -148,9 +145,6 @@ roots() -> end. fields(actions) -> - %% We *must* do this to ensure the module is really loaded, especially when we use - %% `call_hocon' from `nodetool' to generate initial configurations. - _ = emqx_bridge_v2:module_info(), enterprise_fields_actions() ++ registered_schema_fields(). diff --git a/apps/emqx_bridge_kafka/src/emqx_bridge_kafka.erl b/apps/emqx_bridge_kafka/src/emqx_bridge_kafka.erl index 3f270d921..0eb015cd3 100644 --- a/apps/emqx_bridge_kafka/src/emqx_bridge_kafka.erl +++ b/apps/emqx_bridge_kafka/src/emqx_bridge_kafka.erl @@ -527,17 +527,17 @@ fields(resource_opts) -> SupportedFields = [health_check_interval], CreationOpts = emqx_resource_schema:create_opts(_Overrides = []), lists:filter(fun({Field, _}) -> lists:member(Field, SupportedFields) end, CreationOpts); -fields(bridge_v2_field) -> +fields(action_field) -> {kafka_producer, mk( hoconsc:map(name, ref(emqx_bridge_kafka, kafka_producer_action)), #{ - desc => <<"Kafka Producer Bridge V2 Config">>, + desc => <<"Kafka Producer Action Config">>, required => false } )}; fields(action) -> - fields(bridge_v2_field). + fields(action_field). desc("config_connector") -> ?DESC("desc_config");