Skip to content

Commit 6d3d297

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.
1 parent 87c6615 commit 6d3d297

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
@@ -8,7 +8,7 @@
88
-module(rabbit_plugins).
99
-include_lib("rabbit_common/include/rabbit.hrl").
1010
-include_lib("kernel/include/logger.hrl").
11-
-export([setup/0, active/0, read_enabled/1, list/1, list/2, dependencies/3, running_plugins/0]).
11+
-export([setup/0, active/0, read_enabled/1, list/0, list/1, list/2, dependencies/3, running_plugins/0]).
1212
-export([ensure/1]).
1313
-export([validate_plugins/1, format_invalid_plugins/1]).
1414
-export([is_strictly_plugin/1, strictly_plugins/2, strictly_plugins/1]).
@@ -130,7 +130,7 @@ setup() ->
130130
-spec active() -> [plugin_name()].
131131

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

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

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

162169
-spec list(string()) -> [#plugin{}].
@@ -228,7 +235,7 @@ strictly_plugins(Plugins, AllPlugins) ->
228235
-spec strictly_plugins([plugin_name()]) -> [plugin_name()].
229236

230237
strictly_plugins(Plugins) ->
231-
AllPlugins = list(plugins_dir()),
238+
AllPlugins = list(),
232239
lists:filter(
233240
fun(Name) ->
234241
is_strictly_plugin(lists:keyfind(Name, #plugin.name, AllPlugins))
@@ -283,7 +290,7 @@ running_plugins() ->
283290

284291
prepare_plugins(Enabled) ->
285292
ExpandDir = plugins_expand_dir(),
286-
AllPlugins = list(plugins_dir()),
293+
AllPlugins = list(),
287294
Wanted = dependencies(false, Enabled, AllPlugins),
288295
WantedPlugins = lookup_plugins(Wanted, AllPlugins),
289296
{ValidPlugins, Problems} = validate_plugins(WantedPlugins),

0 commit comments

Comments
 (0)