chore: allow lazy type environment variable override
This commit is contained in:
parent
5dec0be6e4
commit
55558ccfbd
|
@ -144,7 +144,7 @@ get_root([RootName | _]) ->
|
|||
%% @doc For the given path, get raw root value enclosed in a single-key map.
|
||||
%% key is ensured to be binary.
|
||||
get_root_raw([RootName | _]) ->
|
||||
#{bin(RootName) => do_get(?RAW_CONF, [RootName], #{})}.
|
||||
#{bin(RootName) => do_get_raw([RootName], #{})}.
|
||||
|
||||
%% @doc Get a config value for the given path.
|
||||
%% The path should at least include root config name.
|
||||
|
@ -173,7 +173,7 @@ find(KeyPath) ->
|
|||
{ok, term()} | {not_found, emqx_map_lib:config_key_path(), term()}.
|
||||
find_raw([]) ->
|
||||
Ref = make_ref(),
|
||||
case do_get(?RAW_CONF, [], Ref) of
|
||||
case do_get_raw([], Ref) of
|
||||
Ref -> {not_found, []};
|
||||
Res -> {ok, Res}
|
||||
end;
|
||||
|
@ -281,10 +281,10 @@ get_default_value([RootName | _] = KeyPath) ->
|
|||
end.
|
||||
|
||||
-spec get_raw(emqx_map_lib:config_key_path()) -> term().
|
||||
get_raw(KeyPath) -> hocon_tconf:remove_env_meta(do_get(?RAW_CONF, KeyPath)).
|
||||
get_raw(KeyPath) -> do_get_raw(KeyPath).
|
||||
|
||||
-spec get_raw(emqx_map_lib:config_key_path(), term()) -> term().
|
||||
get_raw(KeyPath, Default) -> hocon_tconf:remove_env_meta(do_get(?RAW_CONF, KeyPath, Default)).
|
||||
get_raw(KeyPath, Default) -> do_get_raw(KeyPath, Default).
|
||||
|
||||
-spec put_raw(map()) -> ok.
|
||||
put_raw(Config) ->
|
||||
|
@ -398,11 +398,11 @@ include_dirs() ->
|
|||
[filename:join(emqx:data_dir(), "configs")].
|
||||
|
||||
merge_envs(SchemaMod, RawConf) ->
|
||||
%% TODO: evil, remove, required should be declared in schema
|
||||
Opts = #{
|
||||
required => false,
|
||||
format => map,
|
||||
apply_override_envs => true
|
||||
apply_override_envs => true,
|
||||
check_lazy => true
|
||||
},
|
||||
hocon_tconf:merge_env_overrides(SchemaMod, RawConf, all, Opts).
|
||||
|
||||
|
@ -571,6 +571,12 @@ load_hocon_file(FileName, LoadType) ->
|
|||
#{}
|
||||
end.
|
||||
|
||||
do_get_raw(Path) ->
|
||||
hocon_tconf:remove_env_meta(do_get(?RAW_CONF, Path)).
|
||||
|
||||
do_get_raw(Path, Default) ->
|
||||
hocon_tconf:remove_env_meta(do_get(?RAW_CONF, Path, Default)).
|
||||
|
||||
do_get(Type, KeyPath) ->
|
||||
Ref = make_ref(),
|
||||
Res = do_get(Type, KeyPath, Ref),
|
||||
|
|
Loading…
Reference in New Issue