Explorar el Código

Merge pull request #12333 from zmstone/0116-add-tags-for-action-and-connectors

feat: add 'tags' field for action and connector
Zaiming (Stone) Shi hace 2 años
padre
commit
4fa906731d

+ 12 - 1
apps/emqx/src/emqx_schema.erl

@@ -167,7 +167,8 @@
     client_ssl_opts_schema/1,
     client_ssl_opts_schema/1,
     ciphers_schema/1,
     ciphers_schema/1,
     tls_versions_schema/1,
     tls_versions_schema/1,
-    description_schema/0
+    description_schema/0,
+    tags_schema/0
 ]).
 ]).
 -export([password_converter/2, bin_str_converter/2]).
 -export([password_converter/2, bin_str_converter/2]).
 -export([authz_fields/0]).
 -export([authz_fields/0]).
@@ -3825,3 +3826,13 @@ description_schema() ->
             importance => ?IMPORTANCE_LOW
             importance => ?IMPORTANCE_LOW
         }
         }
     ).
     ).
+
+tags_schema() ->
+    sc(
+        hoconsc:array(binary()),
+        #{
+            desc => ?DESC(resource_tags),
+            required => false,
+            importance => ?IMPORTANCE_LOW
+        }
+    ).

+ 0 - 2
apps/emqx/test/emqx_common_test_helpers.erl

@@ -50,8 +50,6 @@
     client_ssl/1,
     client_ssl/1,
     client_mtls/0,
     client_mtls/0,
     client_mtls/1,
     client_mtls/1,
-    ssl_verify_fun_allow_any_host/0,
-    ssl_verify_fun_allow_any_host_impl/3,
     ensure_mnesia_stopped/0,
     ensure_mnesia_stopped/0,
     ensure_quic_listener/2,
     ensure_quic_listener/2,
     ensure_quic_listener/3,
     ensure_quic_listener/3,

+ 1 - 0
apps/emqx_bridge/src/schema/emqx_bridge_schema.erl

@@ -126,6 +126,7 @@ common_bridge_fields() ->
                     default => true
                     default => true
                 }
                 }
             )},
             )},
+        {tags, emqx_schema:tags_schema()},
         %% Create v2 connector then usr v1 /bridges_probe api to test connector
         %% Create v2 connector then usr v1 /bridges_probe api to test connector
         %% /bridges_probe should pass through v2 connector's description.
         %% /bridges_probe should pass through v2 connector's description.
         {description, emqx_schema:description_schema()}
         {description, emqx_schema:description_schema()}

+ 2 - 0
apps/emqx_bridge/src/schema/emqx_bridge_v2_schema.erl

@@ -270,6 +270,7 @@ examples(Method) ->
 top_level_common_action_keys() ->
 top_level_common_action_keys() ->
     [
     [
         <<"connector">>,
         <<"connector">>,
+        <<"tags">>,
         <<"description">>,
         <<"description">>,
         <<"enable">>,
         <<"enable">>,
         <<"local_topic">>,
         <<"local_topic">>,
@@ -301,6 +302,7 @@ make_consumer_action_schema(ActionParametersRef, Opts) ->
             mk(binary(), #{
             mk(binary(), #{
                 desc => ?DESC(emqx_connector_schema, "connector_field"), required => true
                 desc => ?DESC(emqx_connector_schema, "connector_field"), required => true
             })},
             })},
+        {tags, emqx_schema:tags_schema()},
         {description, emqx_schema:description_schema()},
         {description, emqx_schema:description_schema()},
         {parameters, ActionParametersRef},
         {parameters, ActionParametersRef},
         {resource_opts,
         {resource_opts,

+ 1 - 0
apps/emqx_bridge_azure_event_hub/src/emqx_bridge_azure_event_hub.erl

@@ -134,6 +134,7 @@ fields(actions) ->
                     mk(binary(), #{
                     mk(binary(), #{
                         desc => ?DESC(emqx_connector_schema, "connector_field"), required => true
                         desc => ?DESC(emqx_connector_schema, "connector_field"), required => true
                     })},
                     })},
+                {tags, emqx_schema:tags_schema()},
                 {description, emqx_schema:description_schema()}
                 {description, emqx_schema:description_schema()}
             ],
             ],
     override_documentations(Fields);
     override_documentations(Fields);

+ 1 - 0
apps/emqx_bridge_confluent/src/emqx_bridge_confluent_producer.erl

@@ -121,6 +121,7 @@ fields(actions) ->
                     mk(binary(), #{
                     mk(binary(), #{
                         desc => ?DESC(emqx_connector_schema, "connector_field"), required => true
                         desc => ?DESC(emqx_connector_schema, "connector_field"), required => true
                     })},
                     })},
+                {tags, emqx_schema:tags_schema()},
                 {description, emqx_schema:description_schema()}
                 {description, emqx_schema:description_schema()}
             ],
             ],
     override_documentations(Fields);
     override_documentations(Fields);

+ 2 - 0
apps/emqx_bridge_http/src/emqx_bridge_http_schema.erl

@@ -76,6 +76,7 @@ fields("http_action") ->
             mk(binary(), #{
             mk(binary(), #{
                 desc => ?DESC(emqx_connector_schema, "connector_field"), required => true
                 desc => ?DESC(emqx_connector_schema, "connector_field"), required => true
             })},
             })},
+        {tags, emqx_schema:tags_schema()},
         {description, emqx_schema:description_schema()},
         {description, emqx_schema:description_schema()},
         %% Note: there's an implicit convention in `emqx_bridge' that,
         %% Note: there's an implicit convention in `emqx_bridge' that,
         %% for egress bridges with this config, the published messages
         %% for egress bridges with this config, the published messages
@@ -175,6 +176,7 @@ basic_config() ->
                     default => true
                     default => true
                 }
                 }
             )},
             )},
+        {tags, emqx_schema:tags_schema()},
         {description, emqx_schema:description_schema()}
         {description, emqx_schema:description_schema()}
     ] ++ connector_opts().
     ] ++ connector_opts().
 
 

+ 1 - 0
apps/emqx_bridge_kafka/src/emqx_bridge_kafka.erl

@@ -297,6 +297,7 @@ fields(kafka_producer_action) ->
             mk(binary(), #{
             mk(binary(), #{
                 desc => ?DESC(emqx_connector_schema, "connector_field"), required => true
                 desc => ?DESC(emqx_connector_schema, "connector_field"), required => true
             })},
             })},
+        {tags, emqx_schema:tags_schema()},
         {description, emqx_schema:description_schema()}
         {description, emqx_schema:description_schema()}
     ] ++ producer_opts(action);
     ] ++ producer_opts(action);
 fields(kafka_consumer) ->
 fields(kafka_consumer) ->

+ 1 - 0
apps/emqx_bridge_syskeeper/src/emqx_bridge_syskeeper.erl

@@ -86,6 +86,7 @@ fields(action) ->
 fields(config) ->
 fields(config) ->
     [
     [
         {enable, mk(boolean(), #{desc => ?DESC("config_enable"), default => true})},
         {enable, mk(boolean(), #{desc => ?DESC("config_enable"), default => true})},
+        {tags, emqx_schema:tags_schema()},
         {description, emqx_schema:description_schema()},
         {description, emqx_schema:description_schema()},
         {connector,
         {connector,
             mk(binary(), #{
             mk(binary(), #{

+ 1 - 0
apps/emqx_connector/src/schema/emqx_connector_schema.erl

@@ -503,6 +503,7 @@ api_fields("put_connector", _Type, Fields) ->
 common_fields() ->
 common_fields() ->
     [
     [
         {enable, mk(boolean(), #{desc => ?DESC("config_enable"), default => true})},
         {enable, mk(boolean(), #{desc => ?DESC("config_enable"), default => true})},
+        {tags, emqx_schema:tags_schema()},
         {description, emqx_schema:description_schema()}
         {description, emqx_schema:description_schema()}
     ].
     ].
 
 

+ 3 - 0
changes/ce/feat-12333.en.md

@@ -0,0 +1,3 @@
+Add 'tags' field for actions and connectors
+
+Similar to 'description' field (which is a free text annotation), 'tags' can be used to annotate actions and connectors for filtering/grouping.

+ 5 - 0
rel/i18n/emqx_schema.hocon

@@ -1570,6 +1570,11 @@ description.label:
 description.desc:
 description.desc:
 """Descriptive text."""
 """Descriptive text."""
 
 
+resource_tags.label:
+"""Tags"""
+resource_tags.desc:
+"""Tags to annotate this config entry."""
+
 session_persistence_enable.desc:
 session_persistence_enable.desc:
 """Use durable storage for client sessions persistence.
 """Use durable storage for client sessions persistence.
 If enabled, sessions configured to outlive client connections, along with their corresponding messages, will be durably stored and survive broker downtime."""
 If enabled, sessions configured to outlive client connections, along with their corresponding messages, will be durably stored and survive broker downtime."""