Fix read plugin configuration not find schema file
This commit is contained in:
parent
7260b17cb5
commit
85f9a8cb70
|
@ -90,20 +90,25 @@ get(App, Par, Def) ->
|
||||||
read_(App) ->
|
read_(App) ->
|
||||||
Configs = emqttd_cli_config:read_config(App),
|
Configs = emqttd_cli_config:read_config(App),
|
||||||
Path = lists:concat([code:priv_dir(App), "/", App, ".schema"]),
|
Path = lists:concat([code:priv_dir(App), "/", App, ".schema"]),
|
||||||
{_, Mappings, _} = cuttlefish_schema:files([Path]),
|
case filelib:is_file(Path) of
|
||||||
OptionalCfg = lists:foldl(fun(Map, Acc) ->
|
false ->
|
||||||
Key = cuttlefish_mapping:variable(Map),
|
[];
|
||||||
case proplists:get_value(Key, Configs) of
|
true ->
|
||||||
undefined ->
|
{_, Mappings, _} = cuttlefish_schema:files([Path]),
|
||||||
[{cuttlefish_variable:format(Key), "", cuttlefish_mapping:doc(Map), false} | Acc];
|
OptionalCfg = lists:foldl(fun(Map, Acc) ->
|
||||||
_ -> Acc
|
Key = cuttlefish_mapping:variable(Map),
|
||||||
end
|
case proplists:get_value(Key, Configs) of
|
||||||
end, [], Mappings),
|
undefined ->
|
||||||
RequiredCfg = lists:foldl(fun({Key, Val}, Acc) ->
|
[{cuttlefish_variable:format(Key), "", cuttlefish_mapping:doc(Map), false} | Acc];
|
||||||
case lists:keyfind(Key, 2, Mappings) of
|
_ -> Acc
|
||||||
false -> Acc;
|
end
|
||||||
Map ->
|
end, [], Mappings),
|
||||||
[{cuttlefish_variable:format(Key), Val, cuttlefish_mapping:doc(Map), true} | Acc]
|
RequiredCfg = lists:foldl(fun({Key, Val}, Acc) ->
|
||||||
end
|
case lists:keyfind(Key, 2, Mappings) of
|
||||||
end, [], Configs),
|
false -> Acc;
|
||||||
RequiredCfg ++ OptionalCfg.
|
Map ->
|
||||||
|
[{cuttlefish_variable:format(Key), Val, cuttlefish_mapping:doc(Map), true} | Acc]
|
||||||
|
end
|
||||||
|
end, [], Configs),
|
||||||
|
RequiredCfg ++ OptionalCfg
|
||||||
|
end.
|
||||||
|
|
Loading…
Reference in New Issue