refactor(emqx_schema): remove union wrapper around array of maps

it's previously a union of array (of maps) and map.
since the second union member has been removed
there is no point of keeping the union wrapper
This commit is contained in:
Zaiming (Stone) Shi 2022-06-26 14:13:14 +02:00
parent 2cdf95aaa3
commit 5dec0be6e4
1 changed files with 12 additions and 12 deletions

View File

@ -2216,29 +2216,29 @@ str(B) when is_binary(B) ->
str(S) when is_list(S) ->
S.
authentication(Type) ->
authentication(Which) ->
Desc =
case Type of
case Which of
global -> ?DESC(global_authentication);
listener -> ?DESC(listener_authentication)
end,
%% authentication schema is lazy to make it more 'plugable'
%% the type checks are done in emqx_auth application when it boots.
%% and in emqx_authentication_config module for runtime changes.
Default = hoconsc:lazy(hoconsc:union([hoconsc:array(typerefl:map())])),
%% as the type is lazy, the runtime module injection
%% The runtime module injection
%% from EMQX_AUTHENTICATION_SCHEMA_MODULE_PT_KEY
%% is for now only affecting document generation.
%% maybe in the future, we can find a more straightforward way to support
%% * document generation (at compile time)
%% * type checks before boot (in bin/emqx config generation)
%% * type checks at runtime (when changing configs via management API)
Type0 =
case persistent_term:get(?EMQX_AUTHENTICATION_SCHEMA_MODULE_PT_KEY, undefined) of
undefined -> hoconsc:array(typerefl:map());
Module -> Module:root_type()
end,
%% It is a lazy type because when handing runtime update requests
%% the config is not checked by emqx_schema, but by the injected schema
Type = hoconsc:lazy(Type0),
#{
type =>
case persistent_term:get(?EMQX_AUTHENTICATION_SCHEMA_MODULE_PT_KEY, undefined) of
undefined -> Default;
Module -> hoconsc:lazy(Module:root_type())
end,
type => Type,
desc => Desc
}.