fix: fill_default/3 should populate default values for all parameters except the 'ds'

This commit is contained in:
zhongwencool 2024-07-10 10:12:04 +08:00
parent 7b6b9580c8
commit 937fb153c2
1 changed files with 4 additions and 5 deletions

View File

@ -499,15 +499,14 @@ fill_defaults(RawConf, Opts) ->
). ).
-spec fill_defaults(module(), raw_config(), hocon_tconf:opts()) -> map(). -spec fill_defaults(module(), raw_config(), hocon_tconf:opts()) -> map().
fill_defaults(_SchemaMod, RawConf = #{<<"durable_storage">> := _}, _) -> fill_defaults(SchemaMod, RawConf = #{<<"durable_storage">> := Ds}, Opts) ->
%% FIXME: kludge to prevent `emqx_config' module from filling in %% FIXME: kludge to prevent `emqx_config' module from filling in
%% the default values for backends and layouts. These records are %% the default values for backends and layouts. These records are
%% inside unions, and adding default values there will add %% inside unions, and adding default values there will add
%% incompatible fields. %% incompatible fields.
%% RawConf1 = maps:remove(<<"durable_storage">>, RawConf),
%% Note: this function is called for each individual conf root, so Conf = fill_defaults(SchemaMod, RawConf1, Opts),
%% this clause only affects this particular subtree. Conf#{<<"durable_storage">> => Ds};
RawConf;
fill_defaults(SchemaMod, RawConf, Opts0) -> fill_defaults(SchemaMod, RawConf, Opts0) ->
Opts = maps:merge(#{required => false, make_serializable => true}, Opts0), Opts = maps:merge(#{required => false, make_serializable => true}, Opts0),
hocon_tconf:check_plain( hocon_tconf:check_plain(