Skip to content

Commit

Permalink
Use 'format_items = map' for config sections by default
Browse files Browse the repository at this point in the history
- Lists should still have 'format_items = none' as default.
- Remove explicit 'format_items = map' for all sections.

For sections not converted yet:
- Convert to maps, if this is simple.
- For non-trivial cases, leave 'format_items = none' for now.
  • Loading branch information
Paweł Chrząszcz committed May 26, 2022
1 parent 669c0ae commit 5df2660
Show file tree
Hide file tree
Showing 60 changed files with 112 additions and 257 deletions.
2 changes: 1 addition & 1 deletion include/mongoose_config_spec.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
validate_keys = any :: mongoose_config_validator:validator(),
required = [] :: [mongoose_config_parser_toml:toml_key()] | all,
validate = any :: mongoose_config_validator:section_validator(),
format_items = none :: mongoose_config_spec:format_items(),
format_items = map :: mongoose_config_spec:format_items(),
process :: undefined | mongoose_config_parser_toml:list_processor(),
defaults = #{} :: #{mongoose_config_parser_toml:toml_key() =>
mongoose_config_parser_toml:config_part()},
Expand Down
3 changes: 1 addition & 2 deletions src/admin_extra/service_admin_extra.erl
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ config_spec() ->
validate = {enum, ?SUBMODS}},
validate = unique}
},
defaults = #{<<"submods">> => ?SUBMODS},
format_items = map
defaults = #{<<"submods">> => ?SUBMODS}
}.

mod_name(ModAtom) ->
Expand Down
3 changes: 1 addition & 2 deletions src/auth/ejabberd_auth_anonymous.erl
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ config_spec() ->
validate = {enum, [sasl_anon, login_anon, both]}}
},
defaults = #{<<"allow_multiple_connections">> => false,
<<"protocol">> => sasl_anon},
format_items = map
<<"protocol">> => sasl_anon}
}.

%% @doc Return true if multiple connections have been allowed in the config file
Expand Down
3 changes: 1 addition & 2 deletions src/auth/ejabberd_auth_dummy.erl
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ config_spec() ->
<<"variance">> => #option{type = integer,
validate = positive}},
defaults = #{<<"base_time">> => 50,
<<"variance">> => 450},
format_items = map
<<"variance">> => 450}
}.

authorize(Creds) ->
Expand Down
3 changes: 1 addition & 2 deletions src/auth/ejabberd_auth_external.erl
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ config_spec() ->
validate = non_empty}
},
required = [<<"program">>],
defaults = #{<<"instances">> => 1},
format_items = map
defaults = #{<<"instances">> => 1}
}.

-spec check_cache_last_options(mongooseim:host_type()) -> 'cache' | 'no_cache'.
Expand Down
5 changes: 1 addition & 4 deletions src/auth/ejabberd_auth_http.erl
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ stop(_HostType) ->

-spec config_spec() -> mongoose_config_spec:config_section().
config_spec() ->
#section{
items = #{<<"basic_auth">> => #option{type = string}},
format_items = map
}.
#section{items = #{<<"basic_auth">> => #option{type = string}}}.

-spec supports_sasl_module(mongooseim:host_type(), cyrsasl:sasl_module()) -> boolean().
supports_sasl_module(_HostType, cyrsasl_plain) -> true;
Expand Down
4 changes: 2 additions & 2 deletions src/auth/ejabberd_auth_jwt.erl
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ config_spec() ->
<<"username_key">> => #option{type = atom,
validate = non_empty}
},
required = all,
format_items = map
required = all
}.

jwt_secret_config_spec() ->
Expand All @@ -81,6 +80,7 @@ jwt_secret_config_spec() ->
<<"env">> => #option{type = string,
validate = non_empty},
<<"value">> => #option{type = string}},
format_items = none,
process = fun ?MODULE:process_jwt_secret/1
}.

Expand Down
3 changes: 1 addition & 2 deletions src/auth/ejabberd_auth_rdbms.erl
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ stop(_HostType) ->
config_spec() ->
#section{
items = #{<<"users_number_estimate">> => #option{type = boolean}},
defaults = #{<<"users_number_estimate">> => false},
format_items = map
defaults = #{<<"users_number_estimate">> => false}
}.

-spec supports_sasl_module(mongooseim:host_type(), cyrsasl:sasl_module()) -> boolean().
Expand Down
3 changes: 1 addition & 2 deletions src/auth/ejabberd_auth_riak.erl
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ config_spec() ->
#section{
items = #{<<"bucket_type">> => #option{type = binary,
validate = non_empty}},
defaults = #{<<"bucket_type">> => <<"users">>},
format_items = map
defaults = #{<<"bucket_type">> => <<"users">>}
}.

-spec supports_sasl_module(mongooseim:host_type(), cyrsasl:sasl_module()) -> boolean().
Expand Down
3 changes: 1 addition & 2 deletions src/auth/mongoose_gen_auth.erl
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ stop(Mod, HostType) ->
config_spec(Mod) ->
case is_exported(Mod, config_spec, 0) of
true -> Mod:config_spec();
false -> #section{items = #{},
format_items = map}
false -> #section{}
end.

-spec supports_sasl_module(ejabberd_auth:authmodule(), mongooseim:host_type(),
Expand Down
Loading

0 comments on commit 5df2660

Please sign in to comment.