fix: make static_check happy
This commit is contained in:
parent
3ce091e9d7
commit
87b3b214b9
|
@ -64,6 +64,7 @@
|
||||||
{emqx_node_rebalance_status,2}.
|
{emqx_node_rebalance_status,2}.
|
||||||
{emqx_persistent_session_ds,1}.
|
{emqx_persistent_session_ds,1}.
|
||||||
{emqx_plugins,1}.
|
{emqx_plugins,1}.
|
||||||
|
{emqx_plugins,2}.
|
||||||
{emqx_prometheus,1}.
|
{emqx_prometheus,1}.
|
||||||
{emqx_prometheus,2}.
|
{emqx_prometheus,2}.
|
||||||
{emqx_resource,1}.
|
{emqx_resource,1}.
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
-include_lib("emqx/include/logger.hrl").
|
-include_lib("emqx/include/logger.hrl").
|
||||||
-include_lib("emqx_plugins/include/emqx_plugins.hrl").
|
-include_lib("emqx_plugins/include/emqx_plugins.hrl").
|
||||||
|
|
||||||
|
-dialyzer({no_match, [format_plugin_avsc_and_i18n/1]}).
|
||||||
|
|
||||||
-export([
|
-export([
|
||||||
api_spec/0,
|
api_spec/0,
|
||||||
fields/1,
|
fields/1,
|
||||||
|
@ -534,7 +536,7 @@ update_boot_order(post, #{bindings := #{name := Name}, body := Body}) ->
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
{400, #{code => 'BAD_POSITION', message => Reason}};
|
{400, #{code => 'BAD_POSITION', message => Reason}};
|
||||||
Position ->
|
Position ->
|
||||||
case emqx_plugins:ensure_enabled(Name, Position, _ConfLocation = global) of
|
case emqx_plugins:ensure_enabled(Name, Position, global) of
|
||||||
ok ->
|
ok ->
|
||||||
{204};
|
{204};
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
|
@ -694,16 +696,12 @@ aggregate_status([{Node, Plugins} | List], Acc) ->
|
||||||
),
|
),
|
||||||
aggregate_status(List, NewAcc).
|
aggregate_status(List, NewAcc).
|
||||||
|
|
||||||
|
-if(?EMQX_RELEASE_EDITION == ee).
|
||||||
format_plugin_avsc_and_i18n(NameVsn) ->
|
format_plugin_avsc_and_i18n(NameVsn) ->
|
||||||
case emqx_release:edition() of
|
|
||||||
ee ->
|
|
||||||
#{
|
#{
|
||||||
avsc => try_read_file(fun() -> emqx_plugins:plugin_avsc(NameVsn) end),
|
avsc => try_read_file(fun() -> emqx_plugins:plugin_avsc(NameVsn) end),
|
||||||
i18n => try_read_file(fun() -> emqx_plugins:plugin_i18n(NameVsn) end)
|
i18n => try_read_file(fun() -> emqx_plugins:plugin_i18n(NameVsn) end)
|
||||||
};
|
}.
|
||||||
ce ->
|
|
||||||
#{avsc => null, i18n => null}
|
|
||||||
end.
|
|
||||||
|
|
||||||
try_read_file(Fun) ->
|
try_read_file(Fun) ->
|
||||||
case Fun() of
|
case Fun() of
|
||||||
|
@ -711,6 +709,11 @@ try_read_file(Fun) ->
|
||||||
_ -> null
|
_ -> null
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
-else.
|
||||||
|
format_plugin_avsc_and_i18n(_NameVsn) ->
|
||||||
|
#{avsc => null, i18n => null}.
|
||||||
|
-endif.
|
||||||
|
|
||||||
% running_status: running loaded, stopped
|
% running_status: running loaded, stopped
|
||||||
%% config_status: not_configured disable enable
|
%% config_status: not_configured disable enable
|
||||||
plugin_status(#{running_status := running}) -> running;
|
plugin_status(#{running_status := running}) -> running;
|
||||||
|
|
|
@ -152,8 +152,10 @@ make_name_vsn_string(Name, Vsn) ->
|
||||||
-spec ensure_installed() -> ok.
|
-spec ensure_installed() -> ok.
|
||||||
ensure_installed() ->
|
ensure_installed() ->
|
||||||
Fun = fun(#{name_vsn := NameVsn}) ->
|
Fun = fun(#{name_vsn := NameVsn}) ->
|
||||||
ensure_installed(NameVsn),
|
case ensure_installed(NameVsn) of
|
||||||
[]
|
ok -> [];
|
||||||
|
{error, Reason} -> [{NameVsn, Reason}]
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
ok = for_plugins(Fun).
|
ok = for_plugins(Fun).
|
||||||
|
|
||||||
|
@ -169,8 +171,8 @@ ensure_installed(NameVsn) ->
|
||||||
case ensure_exists_and_installed(NameVsn) of
|
case ensure_exists_and_installed(NameVsn) of
|
||||||
ok ->
|
ok ->
|
||||||
maybe_post_op_after_installed(NameVsn);
|
maybe_post_op_after_installed(NameVsn);
|
||||||
_ ->
|
{error, _Reason} = Err ->
|
||||||
ok
|
Err
|
||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -280,8 +282,10 @@ ensure_started(NameVsn) ->
|
||||||
-spec ensure_stopped() -> ok.
|
-spec ensure_stopped() -> ok.
|
||||||
ensure_stopped() ->
|
ensure_stopped() ->
|
||||||
Fun = fun(#{name_vsn := NameVsn, enable := true}) ->
|
Fun = fun(#{name_vsn := NameVsn, enable := true}) ->
|
||||||
ensure_stopped(NameVsn),
|
case ensure_stopped(NameVsn) of
|
||||||
[]
|
ok -> [];
|
||||||
|
{error, Reason} -> [{NameVsn, Reason}]
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
ok = for_plugins(Fun).
|
ok = for_plugins(Fun).
|
||||||
|
|
||||||
|
@ -314,7 +318,7 @@ get_config(NameVsn, #{format := ?CONFIG_FORMAT_AVRO}) ->
|
||||||
{ok, _AvroJson} = Res -> Res;
|
{ok, _AvroJson} = Res -> Res;
|
||||||
{error, _Reason} = Err -> Err
|
{error, _Reason} = Err -> Err
|
||||||
end;
|
end;
|
||||||
get_config(NameVsn, Options = #{format := ?CONFIG_FORMAT_MAP}) ->
|
get_config(NameVsn, #{format := ?CONFIG_FORMAT_MAP} = Options) ->
|
||||||
get_config(NameVsn, Options, #{}).
|
get_config(NameVsn, Options, #{}).
|
||||||
|
|
||||||
%% Present default config value only in map format.
|
%% Present default config value only in map format.
|
||||||
|
@ -714,7 +718,7 @@ ensure_exists_and_installed(NameVsn) ->
|
||||||
case get_tar(NameVsn) of
|
case get_tar(NameVsn) of
|
||||||
{ok, TarContent} ->
|
{ok, TarContent} ->
|
||||||
ok = file:write_file(pkg_file_path(NameVsn), TarContent),
|
ok = file:write_file(pkg_file_path(NameVsn), TarContent),
|
||||||
ok = do_ensure_installed(NameVsn);
|
do_ensure_installed(NameVsn);
|
||||||
_ ->
|
_ ->
|
||||||
%% If not, try to get it from the cluster.
|
%% If not, try to get it from the cluster.
|
||||||
do_get_from_cluster(NameVsn)
|
do_get_from_cluster(NameVsn)
|
||||||
|
@ -733,13 +737,13 @@ do_get_from_cluster(NameVsn) ->
|
||||||
name_vsn => NameVsn,
|
name_vsn => NameVsn,
|
||||||
node_errors => NodeErrors
|
node_errors => NodeErrors
|
||||||
}),
|
}),
|
||||||
{error, plugin_not_found};
|
{error, #{reason => not_found, name_vsn => NameVsn}};
|
||||||
{error, _} ->
|
{error, _} ->
|
||||||
?SLOG(error, #{
|
?SLOG(error, #{
|
||||||
msg => "no_nodes_to_copy_plugin_from",
|
msg => "no_nodes_to_copy_plugin_from",
|
||||||
name_vsn => NameVsn
|
name_vsn => NameVsn
|
||||||
}),
|
}),
|
||||||
{error, plugin_not_found}
|
{error, #{reason => not_found, name_vsn => NameVsn}}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
get_from_any_node([], _NameVsn, Errors) ->
|
get_from_any_node([], _NameVsn, Errors) ->
|
||||||
|
@ -763,7 +767,7 @@ get_avro_config_from_any_node([Node | T], NameVsn, Errors) ->
|
||||||
{ok, _} = Res ->
|
{ok, _} = Res ->
|
||||||
Res;
|
Res;
|
||||||
Err ->
|
Err ->
|
||||||
get_from_any_node(T, NameVsn, [{Node, Err} | Errors])
|
get_avro_config_from_any_node(T, NameVsn, [{Node, Err} | Errors])
|
||||||
end.
|
end.
|
||||||
|
|
||||||
plugins_readme(NameVsn, #{fill_readme := true}, Info) ->
|
plugins_readme(NameVsn, #{fill_readme := true}, Info) ->
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
-export([
|
-export([
|
||||||
introduced_in/0,
|
introduced_in/0,
|
||||||
deprecated_since/0,
|
|
||||||
get_tar/3
|
get_tar/3
|
||||||
]).
|
]).
|
||||||
|
|
||||||
|
@ -31,9 +30,6 @@
|
||||||
introduced_in() ->
|
introduced_in() ->
|
||||||
"5.0.21".
|
"5.0.21".
|
||||||
|
|
||||||
deprecated_since() ->
|
|
||||||
"5.7.0".
|
|
||||||
|
|
||||||
-spec get_tar(node(), name_vsn(), timeout()) -> {ok, binary()} | {error, any}.
|
-spec get_tar(node(), name_vsn(), timeout()) -> {ok, binary()} | {error, any}.
|
||||||
get_tar(Node, NameVsn, Timeout) ->
|
get_tar(Node, NameVsn, Timeout) ->
|
||||||
rpc:call(Node, emqx_plugins, get_tar, [NameVsn], Timeout).
|
rpc:call(Node, emqx_plugins, get_tar, [NameVsn], Timeout).
|
||||||
|
|
|
@ -35,5 +35,6 @@ introduced_in() ->
|
||||||
get_tar(Node, NameVsn, Timeout) ->
|
get_tar(Node, NameVsn, Timeout) ->
|
||||||
rpc:call(Node, emqx_plugins, get_tar, [NameVsn], Timeout).
|
rpc:call(Node, emqx_plugins, get_tar, [NameVsn], Timeout).
|
||||||
|
|
||||||
|
-spec get_config(node(), name_vsn(), map(), any(), timeout()) -> {ok, any()} | {error, any()}.
|
||||||
get_config(Node, NameVsn, Opts, Default, Timeout) ->
|
get_config(Node, NameVsn, Opts, Default, Timeout) ->
|
||||||
rpc:call(Node, emqx_plugins, get_config, [NameVsn, Opts, Default], Timeout).
|
rpc:call(Node, emqx_plugins, get_config, [NameVsn, Opts, Default], Timeout).
|
||||||
|
|
Loading…
Reference in New Issue