fix(ft): add descriptions for missing ft schema fields

This commit is contained in:
Ilya Averyanov 2023-04-06 13:20:41 +03:00
parent bd7250cb13
commit eae2478678
2 changed files with 26 additions and 15 deletions

View File

@ -9,7 +9,7 @@
-import(hoconsc, [mk/2, ref/2]).
-export([roots/0, fields/1, namespace/0, tags/0]).
-export([roots/0, fields/1, namespace/0, tags/0, desc/1]).
-export([translate/1]).
@ -125,6 +125,11 @@ fields(transport_options) ->
[headers, max_retries, request_timeout], emqx_connector_http:fields("request")
).
desc(s3) ->
"S3 connection options";
desc(transport_options) ->
"Options for the HTTP transport layer used by the S3 client".
translate(Conf) ->
Options = #{atom_key => true},
#{s3 := TranslatedConf} = hocon_tconf:check_plain(

View File

@ -6,10 +6,11 @@
-behaviour(hocon_schema).
-export([namespace/0, roots/0, fields/1, translations/0, translation/1]).
-export([namespace/0, roots/0, fields/1, translations/0, translation/1, desc/1]).
-define(EE_SCHEMA_MODULES, [
emqx_license_schema,
emqx_s3_schema,
emqx_ft_schema
]).
@ -17,16 +18,10 @@ namespace() ->
emqx_conf_schema:namespace().
roots() ->
lists:foldl(
fun(Module, Roots) ->
Roots ++ apply(Module, roots, [])
end,
emqx_conf_schema:roots(),
?EE_SCHEMA_MODULES
).
emqx_conf_schema:roots() ++ ee_roots().
fields(Name) ->
ee_fields(?EE_SCHEMA_MODULES, Name).
ee_delegate(fields, ?EE_SCHEMA_MODULES, Name).
translations() ->
emqx_conf_schema:translations().
@ -34,16 +29,27 @@ translations() ->
translation(Name) ->
emqx_conf_schema:translation(Name).
desc(Name) ->
ee_delegate(desc, ?EE_SCHEMA_MODULES, Name).
%%------------------------------------------------------------------------------
%% helpers
%%------------------------------------------------------------------------------
ee_fields([EEMod | EEMods], Name) ->
ee_roots() ->
lists:flatmap(
fun(Module) ->
apply(Module, roots, [])
end,
?EE_SCHEMA_MODULES
).
ee_delegate(Method, [EEMod | EEMods], Name) ->
case lists:member(Name, apply(EEMod, roots, [])) of
true ->
apply(EEMod, fields, [Name]);
EEMod:Method(Name);
false ->
ee_fields(EEMods, Name)
ee_delegate(Method, EEMods, Name)
end;
ee_fields([], Name) ->
emqx_conf_schema:fields(Name).
ee_delegate(Method, [], Name) ->
emqx_conf_schema:Method(Name).