Skip to content

Commit 54d3c6e

Browse files
committed
rabbit_plugins: Add list/0 to get the list of plugins
... without having to pass a plugins path. [Why] It's painful to have to get the plugins path, then pass it to `list/1` every time. It's also more difficult to discover how to use `rabbit_plugins` to get that list of plugins. (cherry picked from commit 6d3d297)
1 parent bc281d5 commit 54d3c6e

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

deps/rabbit/src/rabbit_plugins.erl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
-module(rabbit_plugins).
99
-include_lib("rabbit_common/include/rabbit.hrl").
10-
-export([setup/0, active/0, read_enabled/1, list/1, list/2, dependencies/3, running_plugins/0]).
10+
-export([setup/0, active/0, read_enabled/1, list/0, list/1, list/2, dependencies/3, running_plugins/0]).
1111
-export([ensure/1]).
1212
-export([validate_plugins/1, format_invalid_plugins/1]).
1313
-export([is_strictly_plugin/1, strictly_plugins/2, strictly_plugins/1]).
@@ -129,7 +129,7 @@ setup() ->
129129
-spec active() -> [plugin_name()].
130130

131131
active() ->
132-
InstalledPlugins = plugin_names(list(plugins_dir())),
132+
InstalledPlugins = plugin_names(list()),
133133
[App || {App, _, _} <- rabbit_misc:which_applications(),
134134
lists:member(App, InstalledPlugins)].
135135

@@ -156,6 +156,13 @@ is_enabled_on_node(Name, Node) ->
156156
_Class:_Reason:_Stacktrace -> false
157157
end.
158158

159+
-spec list() -> [#plugin{}].
160+
%% @doc Get the list of plugins from the configured plugin path.
161+
162+
list() ->
163+
PluginsPath = plugins_dir(),
164+
list(PluginsPath).
165+
159166
%% @doc Get the list of plugins which are ready to be enabled.
160167

161168
-spec list(string()) -> [#plugin{}].
@@ -227,7 +234,7 @@ strictly_plugins(Plugins, AllPlugins) ->
227234
-spec strictly_plugins([plugin_name()]) -> [plugin_name()].
228235

229236
strictly_plugins(Plugins) ->
230-
AllPlugins = list(plugins_dir()),
237+
AllPlugins = list(),
231238
lists:filter(
232239
fun(Name) ->
233240
is_strictly_plugin(lists:keyfind(Name, #plugin.name, AllPlugins))
@@ -282,7 +289,7 @@ running_plugins() ->
282289

283290
prepare_plugins(Enabled) ->
284291
ExpandDir = plugins_expand_dir(),
285-
AllPlugins = list(plugins_dir()),
292+
AllPlugins = list(),
286293
Wanted = dependencies(false, Enabled, AllPlugins),
287294
WantedPlugins = lookup_plugins(Wanted, AllPlugins),
288295
{ValidPlugins, Problems} = validate_plugins(WantedPlugins),

0 commit comments

Comments
 (0)