From 8df76da9ac94e2c754bf60f47afcb76ae18376b7 Mon Sep 17 00:00:00 2001 From: ieQu1 <99872536+ieQu1@users.noreply.github.com> Date: Tue, 5 Apr 2022 10:42:25 +0200 Subject: [PATCH] chore(formatting): Fix formatting of modules, authz and authn --- apps/emqx/src/emqx_schema.erl | 3 +- .../src/simple_authn/emqx_authn_http.erl | 3 +- apps/emqx_authz/src/emqx_authz_schema.erl | 104 ++++++++++-------- apps/emqx_modules/src/emqx_modules_schema.erl | 3 +- .../src/emqx_retainer_schema.erl | 12 +- 5 files changed, 72 insertions(+), 53 deletions(-) diff --git a/apps/emqx/src/emqx_schema.erl b/apps/emqx/src/emqx_schema.erl index 85105d20e..90cd9cbff 100644 --- a/apps/emqx/src/emqx_schema.erl +++ b/apps/emqx/src/emqx_schema.erl @@ -1294,7 +1294,8 @@ fields("broker_perf") -> "Change this parameter only when there are many wildcard topics.
\n" "NOTE: when changing from/to `global` lock, it requires all\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" " - `global`: updates are protected with a global lock. Recommended for large clusters." } diff --git a/apps/emqx_authn/src/simple_authn/emqx_authn_http.erl b/apps/emqx_authn/src/simple_authn/emqx_authn_http.erl index d03379198..88e4d83a5 100644 --- a/apps/emqx_authn/src/simple_authn/emqx_authn_http.erl +++ b/apps/emqx_authn/src/simple_authn/emqx_authn_http.erl @@ -78,7 +78,8 @@ common_fields() -> {mechanism, emqx_authn_schema:mechanism('password_based')}, {backend, emqx_authn_schema:backend(http)}, {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} ] ++ emqx_authn_schema:common_fields() ++ maps:to_list( diff --git a/apps/emqx_authz/src/emqx_authz_schema.erl b/apps/emqx_authz/src/emqx_authz_schema.erl index e8fa55b35..0123ee951 100644 --- a/apps/emqx_authz/src/emqx_authz_schema.erl +++ b/apps/emqx_authz/src/emqx_authz_schema.erl @@ -27,12 +27,13 @@ -type action() :: publish | subscribe | all. -type permission() :: allow | deny. --export([ namespace/0 - , roots/0 - , fields/1 - , validations/0 - , desc/1 - ]). +-export([ + namespace/0, + roots/0, + fields/1, + validations/0, + desc/1 +]). -export([ headers_no_content_type/1, @@ -94,38 +95,45 @@ fields("authorization") -> }} ]; fields(file) -> - [ {type, #{type => file, desc => "Backend type."}} - , {enable, #{type => boolean(), - default => true, - desc => "Enable this backend." - }} - , {path, #{type => string(), - required => true, - desc => " -Path to the file which contains the ACL rules.
-If the file provisioned before starting EMQX node, -it can be placed anywhere as long as EMQX has read access to it. - -In case the rule-set is created from EMQX dashboard or management API, -the file will be placed in `authz` subdirectory inside EMQX's `data_dir`, -and the new rules will override all rules from the old config file. -" - }} + [ + {type, #{type => file, desc => "Backend type."}}, + {enable, #{ + type => boolean(), + default => true, + desc => "Enable this backend." + }}, + {path, #{ + type => string(), + required => true, + desc => + "\n" + "Path to the file which contains the ACL rules.
\n" + "If the file provisioned before starting EMQX node,\n" + "it can be placed anywhere as long as EMQX has read access to it.\n" + "\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`,\n" + "and the new rules will override all rules from the old config file.\n" + }} ]; 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(); 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(); fields(mnesia) -> - [ {type, #{type => 'built_in_database', desc => "Backend type."}} - , {enable, #{type => boolean(), - default => true, - desc => "Enable this backend." - }} + [ + {type, #{type => 'built_in_database', desc => "Backend type."}}, + {enable, #{ + type => boolean(), + default => true, + desc => "Enable this backend." + }} ]; fields(mongo_single) -> mongo_common_fields() ++ emqx_connector_mongo:fields(single); @@ -137,11 +145,14 @@ fields(mysql) -> connector_fields(mysql) ++ [{query, query()}]; fields(postgresql) -> - [ {query, query()} - , {type, #{type => postgresql, desc => "Backend type."}} - , {enable, #{type => boolean(), - desc => "Enable this backend.", - default => true}} + [ + {query, query()}, + {type, #{type => postgresql, desc => "Backend type."}}, + {enable, #{ + type => boolean(), + desc => "Enable this backend.", + default => true + }} ] ++ emqx_connector_pgsql:fields(config); fields(redis_single) -> connector_fields(redis, single) ++ @@ -321,15 +332,16 @@ union_array(Item) when is_list(Item) -> hoconsc:array(hoconsc:union(Item)). query() -> - #{type => binary(), - desc => "Database query used to retrieve authorization data.", - validator => fun(S) -> - case size(S) > 0 of - true -> ok; - _ -> {error, "Request query"} - end - end - }. + #{ + type => binary(), + desc => "Database query used to retrieve authorization data.", + validator => fun(S) -> + case size(S) > 0 of + true -> ok; + _ -> {error, "Request query"} + end + end + }. connector_fields(DB) -> connector_fields(DB, config). diff --git a/apps/emqx_modules/src/emqx_modules_schema.erl b/apps/emqx_modules/src/emqx_modules_schema.erl index 702ab7b98..a74406488 100644 --- a/apps/emqx_modules/src/emqx_modules_schema.erl +++ b/apps/emqx_modules/src/emqx_modules_schema.erl @@ -42,7 +42,8 @@ fields("telemetry") -> fields("delayed") -> [ {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") -> [ diff --git a/apps/emqx_retainer/src/emqx_retainer_schema.erl b/apps/emqx_retainer/src/emqx_retainer_schema.erl index 74c95ffe2..74732bf9b 100644 --- a/apps/emqx_retainer/src/emqx_retainer_schema.erl +++ b/apps/emqx_retainer/src/emqx_retainer_schema.erl @@ -26,7 +26,8 @@ fields("retainer") -> , {stop_publish_clear_msg, sc(boolean(), "When the retained flag of the `PUBLISH` message is set and Payload is empty, " "whether to continue to publish the message.
" - "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)} , {backend, backend_config()} ]; @@ -52,9 +53,12 @@ fields(flow_control) -> 0)} , {batch_deliver_limiter, sc(emqx_limiter_schema:bucket_name(), "The rate limiter name for retained messages' delivery.
" - "Limiter helps to avoid delivering too many messages to the client at once, which may cause the client " - "to block or crash, or drop messages due to exceeding the size of the message queue.
" - "The names of the available rate limiters are taken from the existing rate limiters under `limiter.batch`.
" + "Limiter helps to avoid delivering too many messages to the client at once, " + "which may cause the client " + "to block or crash, or drop messages due to exceeding the size of the message" + " queue.
" + "The names of the available rate limiters are taken from the existing rate " + "limiters under `limiter.batch`.
" "If this field is empty, limiter is not used.", undefined)} ].