feat: hide relup plugins from APIs and CLIs
This commit is contained in:
parent
fc3405fe4c
commit
862336a2cb
|
@ -104,7 +104,7 @@ schema("/relup/package/upload") ->
|
|||
responses => #{
|
||||
204 => <<"Package is uploaded successfully">>,
|
||||
400 => emqx_dashboard_swagger:error_codes(
|
||||
['UNEXPECTED_ERROR', 'BAD_PLUGIN_INFO']
|
||||
['UNEXPECTED_ERROR', 'ALREADY_INSTALLED', 'BAD_PLUGIN_INFO']
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -590,7 +590,7 @@ get_installed_packages() ->
|
|||
_ -> false
|
||||
end
|
||||
end,
|
||||
emqx_plugins:list()
|
||||
emqx_plugins:list(hidden)
|
||||
).
|
||||
|
||||
target_vsn_from_rel_vsn(Vsn) ->
|
||||
|
|
|
@ -56,7 +56,8 @@
|
|||
ensure_stopped/0,
|
||||
ensure_stopped/1,
|
||||
restart/1,
|
||||
list/0
|
||||
list/0,
|
||||
list/1
|
||||
]).
|
||||
|
||||
%% Plugin config APIs
|
||||
|
@ -378,13 +379,17 @@ restart(NameVsn) ->
|
|||
%% Including the ones that are installed, but not enabled in config.
|
||||
-spec list() -> [plugin_info()].
|
||||
list() ->
|
||||
list(normal).
|
||||
|
||||
-spec list(all | normal | hidden) -> [plugin_info()].
|
||||
list(Type) ->
|
||||
Pattern = filename:join([install_dir(), "*", "release.json"]),
|
||||
All = lists:filtermap(
|
||||
fun(JsonFilePath) ->
|
||||
[_, NameVsn | _] = lists:reverse(filename:split(JsonFilePath)),
|
||||
case read_plugin_info(NameVsn, #{}) of
|
||||
{ok, Info} ->
|
||||
{true, Info};
|
||||
filter_plugin_of_type(Type, Info);
|
||||
{error, Reason} ->
|
||||
?SLOG(warning, Reason#{msg => "failed_to_read_plugin_info"}),
|
||||
false
|
||||
|
@ -394,6 +399,17 @@ list() ->
|
|||
),
|
||||
do_list(configured(), All).
|
||||
|
||||
filter_plugin_of_type(all, Info) ->
|
||||
{true, Info};
|
||||
filter_plugin_of_type(normal, #{<<"hidden">> := true}) ->
|
||||
false;
|
||||
filter_plugin_of_type(normal, Info) ->
|
||||
{true, Info};
|
||||
filter_plugin_of_type(hidden, #{<<"hidden">> := true} = Info) ->
|
||||
{true, Info};
|
||||
filter_plugin_of_type(hidden, _Info) ->
|
||||
false.
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% Package utils
|
||||
|
||||
|
@ -662,10 +678,6 @@ do_list([#{name_vsn := NameVsn} | Rest], All) ->
|
|||
end,
|
||||
case lists:splitwith(SplitF, All) of
|
||||
{_, []} ->
|
||||
?SLOG(warning, #{
|
||||
msg => "configured_plugin_not_installed",
|
||||
name_vsn => NameVsn
|
||||
}),
|
||||
do_list(Rest, All);
|
||||
{Front, [I | Rear]} ->
|
||||
[I | do_list(Rest, Front ++ Rear)]
|
||||
|
|
Loading…
Reference in New Issue