feat: add 'tags' field for action and connector

This commit is contained in:
Zaiming (Stone) Shi 2024-01-16 13:29:49 +01:00
parent b6d0365027
commit ab66986f16
11 changed files with 30 additions and 1 deletions

View File

@ -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(string()),
#{
desc => ?DESC(resource_tags),
required => false,
importance => ?IMPORTANCE_LOW
}
).

View File

@ -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()}

View File

@ -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,

View File

@ -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);

View File

@ -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);

View File

@ -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().

View File

@ -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) ->

View File

@ -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(), #{

View File

@ -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()}
]. ].

View File

@ -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.

View File

@ -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."""