chore(formatting): Fix formatting of modules, authz and authn

This commit is contained in:
ieQu1 2022-04-05 10:42:25 +02:00
parent 43aa2ea481
commit 8df76da9ac
5 changed files with 72 additions and 53 deletions

View File

@ -1294,7 +1294,8 @@ fields("broker_perf") ->
"Change this parameter only when there are many wildcard topics.<br/>\n" "Change this parameter only when there are many wildcard topics.<br/>\n"
"NOTE: when changing from/to `global` lock, it requires all\n" "NOTE: when changing from/to `global` lock, it requires all\n"
"nodes in the cluster to be stopped before the change.\n\n" "nodes in the cluster to be stopped before the change.\n\n"
" - `key`: mnesia transactional updates with per-key locks. Recommended for a single-node setup.\n" " - `key`: mnesia transactional updates with per-key locks. "
"Recommended for a single-node setup.\n"
" - `tab`: mnesia transactional updates with table lock. Recommended for a cluster setup.\n" " - `tab`: mnesia transactional updates with table lock. Recommended for a cluster setup.\n"
" - `global`: updates are protected with a global lock. Recommended for large clusters." " - `global`: updates are protected with a global lock. Recommended for large clusters."
} }

View File

@ -78,7 +78,8 @@ common_fields() ->
{mechanism, emqx_authn_schema:mechanism('password_based')}, {mechanism, emqx_authn_schema:mechanism('password_based')},
{backend, emqx_authn_schema:backend(http)}, {backend, emqx_authn_schema:backend(http)},
{url, fun url/1}, {url, fun url/1},
{body, hoconsc:mk(map([{fuzzy, term(), binary()}]), #{desc => "Body of the HTTP request."})}, {body,
hoconsc:mk(map([{fuzzy, term(), binary()}]), #{desc => "Body of the HTTP request."})},
{request_timeout, fun request_timeout/1} {request_timeout, fun request_timeout/1}
] ++ emqx_authn_schema:common_fields() ++ ] ++ emqx_authn_schema:common_fields() ++
maps:to_list( maps:to_list(

View File

@ -27,12 +27,13 @@
-type action() :: publish | subscribe | all. -type action() :: publish | subscribe | all.
-type permission() :: allow | deny. -type permission() :: allow | deny.
-export([ namespace/0 -export([
, roots/0 namespace/0,
, fields/1 roots/0,
, validations/0 fields/1,
, desc/1 validations/0,
]). desc/1
]).
-export([ -export([
headers_no_content_type/1, headers_no_content_type/1,
@ -94,35 +95,42 @@ fields("authorization") ->
}} }}
]; ];
fields(file) -> fields(file) ->
[ {type, #{type => file, desc => "Backend type."}} [
, {enable, #{type => boolean(), {type, #{type => file, desc => "Backend type."}},
{enable, #{
type => boolean(),
default => true, default => true,
desc => "Enable this backend." desc => "Enable this backend."
}} }},
, {path, #{type => string(), {path, #{
type => string(),
required => true, required => true,
desc => " desc =>
Path to the file which contains the ACL rules.<br> "\n"
If the file provisioned before starting EMQX node, "Path to the file which contains the ACL rules.<br>\n"
it can be placed anywhere as long as EMQX has read access to it. "If the file provisioned before starting EMQX node,\n"
"it can be placed anywhere as long as EMQX has read access to it.\n"
In case the rule-set is created from EMQX dashboard or management API, "\n"
the file will be placed in `authz` subdirectory inside EMQX's `data_dir`, "In case the rule-set is created from EMQX dashboard or management API,\n"
and the new rules will override all rules from the old config file. "the file will be placed in `authz` subdirectory inside EMQX's `data_dir`,\n"
" "and the new rules will override all rules from the old config file.\n"
}} }}
]; ];
fields(http_get) -> fields(http_get) ->
[ {method, #{type => get, default => get, desc => "HTTP method."}} [
, {headers, fun headers_no_content_type/1} {method, #{type => get, default => get, desc => "HTTP method."}},
{headers, fun headers_no_content_type/1}
] ++ http_common_fields(); ] ++ http_common_fields();
fields(http_post) -> fields(http_post) ->
[ {method, #{type => post, default => post, desc => "HTTP method."}} [
, {headers, fun headers/1} {method, #{type => post, default => post, desc => "HTTP method."}},
{headers, fun headers/1}
] ++ http_common_fields(); ] ++ http_common_fields();
fields(mnesia) -> fields(mnesia) ->
[ {type, #{type => 'built_in_database', desc => "Backend type."}} [
, {enable, #{type => boolean(), {type, #{type => 'built_in_database', desc => "Backend type."}},
{enable, #{
type => boolean(),
default => true, default => true,
desc => "Enable this backend." desc => "Enable this backend."
}} }}
@ -137,11 +145,14 @@ fields(mysql) ->
connector_fields(mysql) ++ connector_fields(mysql) ++
[{query, query()}]; [{query, query()}];
fields(postgresql) -> fields(postgresql) ->
[ {query, query()} [
, {type, #{type => postgresql, desc => "Backend type."}} {query, query()},
, {enable, #{type => boolean(), {type, #{type => postgresql, desc => "Backend type."}},
{enable, #{
type => boolean(),
desc => "Enable this backend.", desc => "Enable this backend.",
default => true}} default => true
}}
] ++ emqx_connector_pgsql:fields(config); ] ++ emqx_connector_pgsql:fields(config);
fields(redis_single) -> fields(redis_single) ->
connector_fields(redis, single) ++ connector_fields(redis, single) ++
@ -321,7 +332,8 @@ union_array(Item) when is_list(Item) ->
hoconsc:array(hoconsc:union(Item)). hoconsc:array(hoconsc:union(Item)).
query() -> query() ->
#{type => binary(), #{
type => binary(),
desc => "Database query used to retrieve authorization data.", desc => "Database query used to retrieve authorization data.",
validator => fun(S) -> validator => fun(S) ->
case size(S) > 0 of case size(S) > 0 of

View File

@ -42,7 +42,8 @@ fields("telemetry") ->
fields("delayed") -> fields("delayed") ->
[ [
{enable, hoconsc:mk(boolean(), #{default => false, desc => "Enable `delayed` module."})}, {enable, hoconsc:mk(boolean(), #{default => false, desc => "Enable `delayed` module."})},
{max_delayed_messages, sc(integer(), #{desc => "Maximum number of delayed messages (0 is no limit)."})} {max_delayed_messages,
sc(integer(), #{desc => "Maximum number of delayed messages (0 is no limit)."})}
]; ];
fields("rewrite") -> fields("rewrite") ->
[ [

View File

@ -26,7 +26,8 @@ fields("retainer") ->
, {stop_publish_clear_msg, sc(boolean(), , {stop_publish_clear_msg, sc(boolean(),
"When the retained flag of the `PUBLISH` message is set and Payload is empty, " "When the retained flag of the `PUBLISH` message is set and Payload is empty, "
"whether to continue to publish the message.<br/>" "whether to continue to publish the message.<br/>"
"See: http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718038", "See: "
"http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718038",
false)} false)}
, {backend, backend_config()} , {backend, backend_config()}
]; ];
@ -52,9 +53,12 @@ fields(flow_control) ->
0)} 0)}
, {batch_deliver_limiter, sc(emqx_limiter_schema:bucket_name(), , {batch_deliver_limiter, sc(emqx_limiter_schema:bucket_name(),
"The rate limiter name for retained messages' delivery.<br/>" "The rate limiter name for retained messages' delivery.<br/>"
"Limiter helps to avoid delivering too many messages to the client at once, which may cause the client " "Limiter helps to avoid delivering too many messages to the client at once, "
"to block or crash, or drop messages due to exceeding the size of the message queue.<br/>" "which may cause the client "
"The names of the available rate limiters are taken from the existing rate limiters under `limiter.batch`.<br/>" "to block or crash, or drop messages due to exceeding the size of the message"
" queue.<br/>"
"The names of the available rate limiters are taken from the existing rate "
"limiters under `limiter.batch`.<br/>"
"If this field is empty, limiter is not used.", "If this field is empty, limiter is not used.",
undefined)} undefined)}
]. ].