Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add 'tags' field for action and connector #12333

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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(binary()),
#{
desc => ?DESC(resource_tags),
required => false,
importance => ?IMPORTANCE_LOW
}
).
2 changes: 0 additions & 2 deletions apps/emqx/test/emqx_common_test_helpers.erl
Expand Up @@ -50,8 +50,6 @@
client_ssl/1,
client_mtls/0,
client_mtls/1,
ssl_verify_fun_allow_any_host/0,
ssl_verify_fun_allow_any_host_impl/3,
ensure_mnesia_stopped/0,
ensure_quic_listener/2,
ensure_quic_listener/3,
Expand Down
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