Skip to content

Commit

Permalink
feat: add 'tags' field for action and connector
Browse files Browse the repository at this point in the history
  • Loading branch information
zmstone committed Jan 16, 2024
1 parent b6d0365 commit ab66986
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 1 deletion.
13 changes: 12 additions & 1 deletion apps/emqx/src/emqx_schema.erl
Expand Up @@ -167,7 +167,8 @@
client_ssl_opts_schema/1,
ciphers_schema/1,
tls_versions_schema/1,
description_schema/0
description_schema/0,
tags_schema/0
]).
-export([password_converter/2, bin_str_converter/2]).
-export([authz_fields/0]).
Expand Down Expand Up @@ -3825,3 +3826,13 @@ description_schema() ->
importance => ?IMPORTANCE_LOW
}
).

tags_schema() ->
sc(
hoconsc:array(string()),
#{
desc => ?DESC(resource_tags),
required => false,
importance => ?IMPORTANCE_LOW
}
).
1 change: 1 addition & 0 deletions apps/emqx_bridge/src/schema/emqx_bridge_schema.erl
Expand Up @@ -126,6 +126,7 @@ common_bridge_fields() ->
default => true
}
)},
{tags, emqx_schema:tags_schema()},
%% Create v2 connector then usr v1 /bridges_probe api to test connector
%% /bridges_probe should pass through v2 connector's description.
{description, emqx_schema:description_schema()}
Expand Down
2 changes: 2 additions & 0 deletions apps/emqx_bridge/src/schema/emqx_bridge_v2_schema.erl
Expand Up @@ -270,6 +270,7 @@ examples(Method) ->
top_level_common_action_keys() ->
[
<<"connector">>,
<<"tags">>,
<<"description">>,
<<"enable">>,
<<"local_topic">>,
Expand Down Expand Up @@ -301,6 +302,7 @@ make_consumer_action_schema(ActionParametersRef, Opts) ->
mk(binary(), #{
desc => ?DESC(emqx_connector_schema, "connector_field"), required => true
})},
{tags, emqx_schema:tags_schema()},
{description, emqx_schema:description_schema()},
{parameters, ActionParametersRef},
{resource_opts,
Expand Down
Expand Up @@ -134,6 +134,7 @@ fields(actions) ->
mk(binary(), #{
desc => ?DESC(emqx_connector_schema, "connector_field"), required => true
})},
{tags, emqx_schema:tags_schema()},
{description, emqx_schema:description_schema()}
],
override_documentations(Fields);
Expand Down
Expand Up @@ -121,6 +121,7 @@ fields(actions) ->
mk(binary(), #{
desc => ?DESC(emqx_connector_schema, "connector_field"), required => true
})},
{tags, emqx_schema:tags_schema()},
{description, emqx_schema:description_schema()}
],
override_documentations(Fields);
Expand Down
2 changes: 2 additions & 0 deletions apps/emqx_bridge_http/src/emqx_bridge_http_schema.erl
Expand Up @@ -76,6 +76,7 @@ fields("http_action") ->
mk(binary(), #{
desc => ?DESC(emqx_connector_schema, "connector_field"), required => true
})},
{tags, emqx_schema:tags_schema()},
{description, emqx_schema:description_schema()},
%% Note: there's an implicit convention in `emqx_bridge' that,
%% for egress bridges with this config, the published messages
Expand Down Expand Up @@ -175,6 +176,7 @@ basic_config() ->
default => true
}
)},
{tags, emqx_schema:tags_schema()},
{description, emqx_schema:description_schema()}
] ++ connector_opts().

Expand Down
1 change: 1 addition & 0 deletions apps/emqx_bridge_kafka/src/emqx_bridge_kafka.erl
Expand Up @@ -297,6 +297,7 @@ fields(kafka_producer_action) ->
mk(binary(), #{
desc => ?DESC(emqx_connector_schema, "connector_field"), required => true
})},
{tags, emqx_schema:tags_schema()},
{description, emqx_schema:description_schema()}
] ++ producer_opts(action);
fields(kafka_consumer) ->
Expand Down
1 change: 1 addition & 0 deletions apps/emqx_bridge_syskeeper/src/emqx_bridge_syskeeper.erl
Expand Up @@ -86,6 +86,7 @@ fields(action) ->
fields(config) ->
[
{enable, mk(boolean(), #{desc => ?DESC("config_enable"), default => true})},
{tags, emqx_schema:tags_schema()},
{description, emqx_schema:description_schema()},
{connector,
mk(binary(), #{
Expand Down
1 change: 1 addition & 0 deletions apps/emqx_connector/src/schema/emqx_connector_schema.erl
Expand Up @@ -503,6 +503,7 @@ api_fields("put_connector", _Type, Fields) ->
common_fields() ->
[
{enable, mk(boolean(), #{desc => ?DESC("config_enable"), default => true})},
{tags, emqx_schema:tags_schema()},
{description, emqx_schema:description_schema()}
].

Expand Down
3 changes: 3 additions & 0 deletions 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 changes: 5 additions & 0 deletions rel/i18n/emqx_schema.hocon
Expand Up @@ -1570,6 +1570,11 @@ description.label:
description.desc:
"""Descriptive text."""

resource_tags.label:
"""Tags"""
resource_tags.desc:
"""Tags to annotate this config entry."""

session_persistence_enable.desc:
"""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."""
Expand Down

0 comments on commit ab66986

Please sign in to comment.