fix(emqx_schema): call new hocon_schema API to get field value

This commit is contained in:
Zaiming Shi 2021-07-26 20:17:28 +02:00
parent c1cbd8ece4
commit 0ab713050d
3 changed files with 5 additions and 7 deletions

View File

@ -15,7 +15,7 @@
, {esockd, {git, "https://github.com/emqx/esockd", {tag, "5.8.2"}}} , {esockd, {git, "https://github.com/emqx/esockd", {tag, "5.8.2"}}}
, {ekka, {git, "https://github.com/emqx/ekka", {tag, "0.10.4"}}} , {ekka, {git, "https://github.com/emqx/ekka", {tag, "0.10.4"}}}
, {gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.5.1"}}} , {gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.5.1"}}}
, {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.10.3"}}} , {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.10.4"}}}
, {pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {tag, "2.0.4"}}} , {pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {tag, "2.0.4"}}}
, {recon, {git, "https://github.com/ferd/recon", {tag, "2.5.1"}}} , {recon, {git, "https://github.com/ferd/recon", {tag, "2.5.1"}}}
, {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "0.13.0"}}} , {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "0.13.0"}}}

View File

@ -638,7 +638,7 @@ formatter(text, CharsLimit, SingleLine) ->
%% utils %% utils
-spec(conf_get(string() | [string()], hocon:config()) -> term()). -spec(conf_get(string() | [string()], hocon:config()) -> term()).
conf_get(Key, Conf) -> conf_get(Key, Conf) ->
V = hocon_schema:deep_get(Key, Conf, value), V = hocon_schema:get_value(Key, Conf),
case is_binary(V) of case is_binary(V) of
true -> true ->
binary_to_list(V); binary_to_list(V);
@ -647,7 +647,7 @@ conf_get(Key, Conf) ->
end. end.
conf_get(Key, Conf, Default) -> conf_get(Key, Conf, Default) ->
V = hocon_schema:deep_get(Key, Conf, value, Default), V = hocon_schema:get_value(Key, Conf, Default),
case is_binary(V) of case is_binary(V) of
true -> true ->
binary_to_list(V); binary_to_list(V);
@ -863,11 +863,9 @@ options(k8s, Conf) ->
options(manual, _Conf) -> options(manual, _Conf) ->
[]. [].
to_atom(#{value := Val}= _RichMap) ->
to_atom(Val);
to_atom(Atom) when is_atom(Atom) -> to_atom(Atom) when is_atom(Atom) ->
Atom; Atom;
to_atom(Str) when is_list(Str) -> to_atom(Str) when is_list(Str) ->
list_to_atom(Str); list_to_atom(Str);
to_atom(Bin) when is_binary(Bin) -> to_atom(Bin) when is_binary(Bin) ->
list_to_atom(binary_to_list(Bin)). binary_to_atom(Bin, utf8).

View File

@ -60,7 +60,7 @@
, {observer_cli, "1.6.1"} % NOTE: depends on recon 2.5.1 , {observer_cli, "1.6.1"} % NOTE: depends on recon 2.5.1
, {getopt, "1.0.1"} , {getopt, "1.0.1"}
, {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "0.13.0"}}} , {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "0.13.0"}}}
, {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.10.3"}}} , {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.10.4"}}}
, {emqx_http_lib, {git, "https://github.com/emqx/emqx_http_lib.git", {tag, "0.3.0"}}} , {emqx_http_lib, {git, "https://github.com/emqx/emqx_http_lib.git", {tag, "0.3.0"}}}
, {esasl, {git, "https://github.com/emqx/esasl", {tag, "0.1.0"}}} , {esasl, {git, "https://github.com/emqx/esasl", {tag, "0.1.0"}}}
]}. ]}.