Sfoglia il codice sorgente

Merge pull request #9485 from thalesmg/refactor-doc-gen-50-mkIII

feat(docs): add tags to schemas
Thales Macedo Garitezi 3 anni fa
parent
commit
2d5208fc29

+ 1 - 1
apps/emqx/i18n/emqx_schema_i18n.conf

@@ -2050,7 +2050,7 @@ base_listener_enable_authn {
 Set <code>true</code> (default) to enable client authentication on this listener, the authentication
 Set <code>true</code> (default) to enable client authentication on this listener, the authentication
 process goes through the configured authentication chain.
 process goes through the configured authentication chain.
 When set to <code>false</code> to allow any clients with or without authentication information such as username or password to log in.
 When set to <code>false</code> to allow any clients with or without authentication information such as username or password to log in.
-When set to <code>quick_deny_anonymous<code>, it behaves like when set to <code>true</code> but clients will be
+When set to <code>quick_deny_anonymous</code>, it behaves like when set to <code>true</code>, but clients will be
 denied immediately without going through any authenticators if <code>username</code> is not provided. This is useful to fence off
 denied immediately without going through any authenticators if <code>username</code> is not provided. This is useful to fence off
 anonymous clients early.
 anonymous clients early.
 """
 """

+ 5 - 2
apps/emqx/src/emqx_schema.erl

@@ -111,7 +111,7 @@
     comma_separated_atoms/0
     comma_separated_atoms/0
 ]).
 ]).
 
 
--export([namespace/0, roots/0, roots/1, fields/1, desc/1]).
+-export([namespace/0, roots/0, roots/1, fields/1, desc/1, tags/0]).
 -export([conf_get/2, conf_get/3, keys/2, filter/1]).
 -export([conf_get/2, conf_get/3, keys/2, filter/1]).
 -export([server_ssl_opts_schema/2, client_ssl_opts_schema/1, ciphers_schema/1]).
 -export([server_ssl_opts_schema/2, client_ssl_opts_schema/1, ciphers_schema/1]).
 -export([sc/2, map/2]).
 -export([sc/2, map/2]).
@@ -120,6 +120,9 @@
 
 
 namespace() -> broker.
 namespace() -> broker.
 
 
+tags() ->
+    [<<"EMQX">>].
+
 roots() ->
 roots() ->
     %% TODO change config importance to a field metadata
     %% TODO change config importance to a field metadata
     roots(high) ++ roots(medium) ++ roots(low).
     roots(high) ++ roots(medium) ++ roots(low).
@@ -2342,7 +2345,7 @@ authentication(Which) ->
             undefined -> hoconsc:array(typerefl:map());
             undefined -> hoconsc:array(typerefl:map());
             Module -> Module:root_type()
             Module -> Module:root_type()
         end,
         end,
-    %% It is a lazy type because when handing runtime update requests
+    %% It is a lazy type because when handling runtime update requests
     %% the config is not checked by emqx_schema, but by the injected schema
     %% the config is not checked by emqx_schema, but by the injected schema
     Type = hoconsc:lazy(Type0),
     Type = hoconsc:lazy(Type0),
     #{
     #{

+ 1 - 1
apps/emqx_authn/src/emqx_authn.app.src

@@ -1,7 +1,7 @@
 %% -*- mode: erlang -*-
 %% -*- mode: erlang -*-
 {application, emqx_authn, [
 {application, emqx_authn, [
     {description, "EMQX Authentication"},
     {description, "EMQX Authentication"},
-    {vsn, "0.1.11"},
+    {vsn, "0.1.12"},
     {modules, []},
     {modules, []},
     {registered, [emqx_authn_sup, emqx_authn_registry]},
     {registered, [emqx_authn_sup, emqx_authn_registry]},
     {applications, [kernel, stdlib, emqx_resource, emqx_connector, ehttpc, epgsql, mysql, jose]},
     {applications, [kernel, stdlib, emqx_resource, emqx_connector, ehttpc, epgsql, mysql, jose]},

+ 4 - 0
apps/emqx_authn/src/emqx_authn_schema.erl

@@ -22,6 +22,7 @@
 -export([
 -export([
     common_fields/0,
     common_fields/0,
     roots/0,
     roots/0,
+    tags/0,
     fields/1,
     fields/1,
     authenticator_type/0,
     authenticator_type/0,
     authenticator_type_without_scram/0,
     authenticator_type_without_scram/0,
@@ -32,6 +33,9 @@
 
 
 roots() -> [].
 roots() -> [].
 
 
+tags() ->
+    [<<"Authentication">>].
+
 common_fields() ->
 common_fields() ->
     [{enable, fun enable/1}].
     [{enable, fun enable/1}].
 
 

+ 4 - 0
apps/emqx_authn/src/enhanced_authn/emqx_enhanced_authn_scram_mnesia.erl

@@ -25,6 +25,7 @@
 
 
 -export([
 -export([
     namespace/0,
     namespace/0,
+    tags/0,
     roots/0,
     roots/0,
     fields/1,
     fields/1,
     desc/1
     desc/1
@@ -105,6 +106,9 @@ mnesia(boot) ->
 
 
 namespace() -> "authn-scram-builtin_db".
 namespace() -> "authn-scram-builtin_db".
 
 
+tags() ->
+    [<<"Authentication">>].
+
 roots() -> [?CONF_NS].
 roots() -> [?CONF_NS].
 
 
 fields(?CONF_NS) ->
 fields(?CONF_NS) ->

+ 4 - 0
apps/emqx_authn/src/simple_authn/emqx_authn_http.erl

@@ -26,6 +26,7 @@
 
 
 -export([
 -export([
     namespace/0,
     namespace/0,
+    tags/0,
     roots/0,
     roots/0,
     fields/1,
     fields/1,
     desc/1,
     desc/1,
@@ -51,6 +52,9 @@
 
 
 namespace() -> "authn-http".
 namespace() -> "authn-http".
 
 
+tags() ->
+    [<<"Authentication">>].
+
 roots() ->
 roots() ->
     [
     [
         {?CONF_NS,
         {?CONF_NS,

+ 4 - 0
apps/emqx_authn/src/simple_authn/emqx_authn_jwt.erl

@@ -25,6 +25,7 @@
 
 
 -export([
 -export([
     namespace/0,
     namespace/0,
+    tags/0,
     roots/0,
     roots/0,
     fields/1,
     fields/1,
     desc/1
     desc/1
@@ -44,6 +45,9 @@
 
 
 namespace() -> "authn-jwt".
 namespace() -> "authn-jwt".
 
 
+tags() ->
+    [<<"Authentication">>].
+
 roots() ->
 roots() ->
     [
     [
         {?CONF_NS,
         {?CONF_NS,

+ 4 - 0
apps/emqx_authn/src/simple_authn/emqx_authn_mnesia.erl

@@ -26,6 +26,7 @@
 
 
 -export([
 -export([
     namespace/0,
     namespace/0,
+    tags/0,
     roots/0,
     roots/0,
     fields/1,
     fields/1,
     desc/1
     desc/1
@@ -107,6 +108,9 @@ mnesia(boot) ->
 
 
 namespace() -> "authn-builtin_db".
 namespace() -> "authn-builtin_db".
 
 
+tags() ->
+    [<<"Authentication">>].
+
 roots() -> [?CONF_NS].
 roots() -> [?CONF_NS].
 
 
 fields(?CONF_NS) ->
 fields(?CONF_NS) ->

+ 4 - 0
apps/emqx_authn/src/simple_authn/emqx_authn_mongodb.erl

@@ -25,6 +25,7 @@
 
 
 -export([
 -export([
     namespace/0,
     namespace/0,
+    tags/0,
     roots/0,
     roots/0,
     fields/1,
     fields/1,
     desc/1
     desc/1
@@ -44,6 +45,9 @@
 
 
 namespace() -> "authn-mongodb".
 namespace() -> "authn-mongodb".
 
 
+tags() ->
+    [<<"Authentication">>].
+
 roots() ->
 roots() ->
     [
     [
         {?CONF_NS,
         {?CONF_NS,

+ 4 - 0
apps/emqx_authn/src/simple_authn/emqx_authn_mysql.erl

@@ -27,6 +27,7 @@
 
 
 -export([
 -export([
     namespace/0,
     namespace/0,
+    tags/0,
     roots/0,
     roots/0,
     fields/1,
     fields/1,
     desc/1
     desc/1
@@ -46,6 +47,9 @@
 
 
 namespace() -> "authn-mysql".
 namespace() -> "authn-mysql".
 
 
+tags() ->
+    [<<"Authentication">>].
+
 roots() -> [?CONF_NS].
 roots() -> [?CONF_NS].
 
 
 fields(?CONF_NS) ->
 fields(?CONF_NS) ->

+ 4 - 0
apps/emqx_authn/src/simple_authn/emqx_authn_pgsql.erl

@@ -26,6 +26,7 @@
 
 
 -export([
 -export([
     namespace/0,
     namespace/0,
+    tags/0,
     roots/0,
     roots/0,
     fields/1,
     fields/1,
     desc/1
     desc/1
@@ -50,6 +51,9 @@
 
 
 namespace() -> "authn-postgresql".
 namespace() -> "authn-postgresql".
 
 
+tags() ->
+    [<<"Authentication">>].
+
 roots() -> [?CONF_NS].
 roots() -> [?CONF_NS].
 
 
 fields(?CONF_NS) ->
 fields(?CONF_NS) ->

+ 4 - 0
apps/emqx_authn/src/simple_authn/emqx_authn_redis.erl

@@ -25,6 +25,7 @@
 
 
 -export([
 -export([
     namespace/0,
     namespace/0,
+    tags/0,
     roots/0,
     roots/0,
     fields/1,
     fields/1,
     desc/1
     desc/1
@@ -44,6 +45,9 @@
 
 
 namespace() -> "authn-redis".
 namespace() -> "authn-redis".
 
 
+tags() ->
+    [<<"Authentication">>].
+
 roots() ->
 roots() ->
     [
     [
         {?CONF_NS,
         {?CONF_NS,

+ 4 - 0
apps/emqx_authz/src/emqx_authz_schema.erl

@@ -33,6 +33,7 @@
 -export([
 -export([
     namespace/0,
     namespace/0,
     roots/0,
     roots/0,
+    tags/0,
     fields/1,
     fields/1,
     validations/0,
     validations/0,
     desc/1
     desc/1
@@ -65,6 +66,9 @@ type_names() ->
 
 
 namespace() -> authz.
 namespace() -> authz.
 
 
+tags() ->
+    [<<"Authorization">>].
+
 %% @doc authorization schema is not exported
 %% @doc authorization schema is not exported
 %% but directly used by emqx_schema
 %% but directly used by emqx_schema
 roots() -> [].
 roots() -> [].

+ 4 - 1
apps/emqx_bridge/src/schema/emqx_bridge_schema.erl

@@ -20,7 +20,7 @@
 
 
 -import(hoconsc, [mk/2, ref/2]).
 -import(hoconsc, [mk/2, ref/2]).
 
 
--export([roots/0, fields/1, desc/1, namespace/0]).
+-export([roots/0, fields/1, desc/1, namespace/0, tags/0]).
 
 
 -export([
 -export([
     get_response/0,
     get_response/0,
@@ -104,6 +104,9 @@ metrics_status_fields() ->
 
 
 namespace() -> "bridge".
 namespace() -> "bridge".
 
 
+tags() ->
+    [<<"Bridge">>].
+
 roots() -> [bridges].
 roots() -> [bridges].
 
 
 fields(bridges) ->
 fields(bridges) ->

+ 6 - 1
apps/emqx_conf/src/emqx_conf_schema.erl

@@ -38,7 +38,9 @@
     cipher/0
     cipher/0
 ]).
 ]).
 
 
--export([namespace/0, roots/0, fields/1, translations/0, translation/1, validations/0, desc/1]).
+-export([
+    namespace/0, roots/0, fields/1, translations/0, translation/1, validations/0, desc/1, tags/0
+]).
 -export([conf_get/2, conf_get/3, keys/2, filter/1]).
 -export([conf_get/2, conf_get/3, keys/2, filter/1]).
 
 
 %% Static apps which merge their configs into the merged emqx.conf
 %% Static apps which merge their configs into the merged emqx.conf
@@ -67,6 +69,9 @@
 %% root config should not have a namespace
 %% root config should not have a namespace
 namespace() -> undefined.
 namespace() -> undefined.
 
 
+tags() ->
+    [<<"EMQX">>].
+
 roots() ->
 roots() ->
     PtKey = ?EMQX_AUTHENTICATION_SCHEMA_MODULE_PT_KEY,
     PtKey = ?EMQX_AUTHENTICATION_SCHEMA_MODULE_PT_KEY,
     case persistent_term:get(PtKey, undefined) of
     case persistent_term:get(PtKey, undefined) of

+ 4 - 1
apps/emqx_gateway/src/emqx_gateway_schema.erl

@@ -49,12 +49,15 @@
 ]).
 ]).
 -elvis([{elvis_style, dont_repeat_yourself, disable}]).
 -elvis([{elvis_style, dont_repeat_yourself, disable}]).
 
 
--export([namespace/0, roots/0, fields/1, desc/1]).
+-export([namespace/0, roots/0, fields/1, desc/1, tags/0]).
 
 
 -export([proxy_protocol_opts/0]).
 -export([proxy_protocol_opts/0]).
 
 
 namespace() -> gateway.
 namespace() -> gateway.
 
 
+tags() ->
+    [<<"Gateway">>].
+
 roots() -> [gateway].
 roots() -> [gateway].
 
 
 fields(gateway) ->
 fields(gateway) ->

+ 4 - 0
apps/emqx_rule_engine/src/emqx_rule_engine_schema.erl

@@ -23,6 +23,7 @@
 
 
 -export([
 -export([
     namespace/0,
     namespace/0,
+    tags/0,
     roots/0,
     roots/0,
     fields/1,
     fields/1,
     desc/1,
     desc/1,
@@ -33,6 +34,9 @@
 
 
 namespace() -> rule_engine.
 namespace() -> rule_engine.
 
 
+tags() ->
+    [<<"Rule Engine">>].
+
 roots() -> ["rule_engine"].
 roots() -> ["rule_engine"].
 
 
 fields("rule_engine") ->
 fields("rule_engine") ->

+ 9 - 2
bin/nodetool

@@ -24,12 +24,19 @@ main(Args) ->
         ["hocon" | Rest] ->
         ["hocon" | Rest] ->
             %% forward the call to hocon_cli
             %% forward the call to hocon_cli
             hocon_cli:main(Rest);
             hocon_cli:main(Rest);
-        ["check_license_key", Key] ->
-            check_license(#{key => list_to_binary(Key)});
+        ["check_license_key", Key0] ->
+            Key = cleanup_key(Key0),
+            check_license(#{key => Key});
         _ ->
         _ ->
             do(Args)
             do(Args)
     end.
     end.
 
 
+%% the key is a string (list) representation of a binary, so we need
+%% to remove the leading and trailing angle brackets.
+cleanup_key(Str0) ->
+    Str1 = iolist_to_binary(string:replace(Str0, "<<", "", leading)),
+    iolist_to_binary(string:replace(Str1, ">>", "", trailing)).
+
 do(Args) ->
 do(Args) ->
     ok = do_with_halt(Args, "mnesia_dir", fun create_mnesia_dir/2),
     ok = do_with_halt(Args, "mnesia_dir", fun create_mnesia_dir/2),
     ok = do_with_halt(Args, "chkconfig", fun("-config", X) -> chkconfig(X) end),
     ok = do_with_halt(Args, "chkconfig", fun("-config", X) -> chkconfig(X) end),

+ 11 - 6
lib-ee/emqx_license/src/emqx_license_schema.erl

@@ -13,7 +13,7 @@
 
 
 -behaviour(hocon_schema).
 -behaviour(hocon_schema).
 
 
--export([roots/0, fields/1, validations/0, desc/1]).
+-export([roots/0, fields/1, validations/0, desc/1, tags/0]).
 
 
 -export([
 -export([
     default_license/0,
     default_license/0,
@@ -31,10 +31,13 @@ roots() ->
             )}
             )}
     ].
     ].
 
 
+tags() ->
+    [<<"License">>].
+
 fields(key_license) ->
 fields(key_license) ->
     [
     [
         {key, #{
         {key, #{
-            type => string(),
+            type => binary(),
             default => default_license(),
             default => default_license(),
             %% so it's not logged
             %% so it's not logged
             sensitive => true,
             sensitive => true,
@@ -82,7 +85,9 @@ check_license_watermark(Conf) ->
 %% NOTE: when updating a new key, the schema doc in emqx_license_schema_i18n.conf
 %% NOTE: when updating a new key, the schema doc in emqx_license_schema_i18n.conf
 %% should be updated accordingly
 %% should be updated accordingly
 default_license() ->
 default_license() ->
-    "MjIwMTExCjAKMTAKRXZhbHVhdGlvbgpjb250YWN0QGVtcXguaW8KZ"
-    "GVmYXVsdAoyMDIzMDEwOQoxODI1CjEwMAo=.MEUCIG62t8W15g05f"
-    "1cKx3tA3YgJoR0dmyHOPCdbUxBGxgKKAiEAhHKh8dUwhU+OxNEaOn"
-    "8mgRDtiT3R8RZooqy6dEsOmDI=".
+    <<
+        "MjIwMTExCjAKMTAKRXZhbHVhdGlvbgpjb250YWN0QGVtcXguaW8KZ"
+        "GVmYXVsdAoyMDIzMDEwOQoxODI1CjEwMAo=.MEUCIG62t8W15g05f"
+        "1cKx3tA3YgJoR0dmyHOPCdbUxBGxgKKAiEAhHKh8dUwhU+OxNEaOn"
+        "8mgRDtiT3R8RZooqy6dEsOmDI="
+    >>.