Skip to content

Commit eeb35fb

Browse files
dumbbellmergify[bot]
authored andcommitted
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) # Conflicts: # deps/rabbit/src/rabbit_plugins.erl
1 parent bc281d5 commit eeb35fb

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

deps/rabbit/src/rabbit_plugins.erl

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77

88
-module(rabbit_plugins).
99
-include_lib("rabbit_common/include/rabbit.hrl").
10+
<<<<<<< HEAD
1011
-export([setup/0, active/0, read_enabled/1, list/1, list/2, dependencies/3, running_plugins/0]).
12+
=======
13+
-include_lib("kernel/include/logger.hrl").
14+
-export([setup/0, active/0, read_enabled/1, list/0, list/1, list/2, dependencies/3, running_plugins/0]).
15+
>>>>>>> 6d3d29759 (rabbit_plugins: Add `list/0` to get the list of plugins)
1116
-export([ensure/1]).
1217
-export([validate_plugins/1, format_invalid_plugins/1]).
1318
-export([is_strictly_plugin/1, strictly_plugins/2, strictly_plugins/1]).
@@ -129,7 +134,7 @@ setup() ->
129134
-spec active() -> [plugin_name()].
130135

131136
active() ->
132-
InstalledPlugins = plugin_names(list(plugins_dir())),
137+
InstalledPlugins = plugin_names(list()),
133138
[App || {App, _, _} <- rabbit_misc:which_applications(),
134139
lists:member(App, InstalledPlugins)].
135140

@@ -156,6 +161,13 @@ is_enabled_on_node(Name, Node) ->
156161
_Class:_Reason:_Stacktrace -> false
157162
end.
158163

164+
-spec list() -> [#plugin{}].
165+
%% @doc Get the list of plugins from the configured plugin path.
166+
167+
list() ->
168+
PluginsPath = plugins_dir(),
169+
list(PluginsPath).
170+
159171
%% @doc Get the list of plugins which are ready to be enabled.
160172

161173
-spec list(string()) -> [#plugin{}].
@@ -227,7 +239,7 @@ strictly_plugins(Plugins, AllPlugins) ->
227239
-spec strictly_plugins([plugin_name()]) -> [plugin_name()].
228240

229241
strictly_plugins(Plugins) ->
230-
AllPlugins = list(plugins_dir()),
242+
AllPlugins = list(),
231243
lists:filter(
232244
fun(Name) ->
233245
is_strictly_plugin(lists:keyfind(Name, #plugin.name, AllPlugins))
@@ -282,7 +294,7 @@ running_plugins() ->
282294

283295
prepare_plugins(Enabled) ->
284296
ExpandDir = plugins_expand_dir(),
285-
AllPlugins = list(plugins_dir()),
297+
AllPlugins = list(),
286298
Wanted = dependencies(false, Enabled, AllPlugins),
287299
WantedPlugins = lookup_plugins(Wanted, AllPlugins),
288300
{ValidPlugins, Problems} = validate_plugins(WantedPlugins),

0 commit comments

Comments
 (0)