Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 43 additions & 10 deletions deps/rabbit/src/rabbit_plugins.erl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
-export([which_plugin/1]).

% Export for testing purpose.
-export([does_bundle_dependencies/1, does_not_bundle_dependencies/1]).
-export([is_version_supported/2, validate_plugins/2]).
%%----------------------------------------------------------------------------

Expand Down Expand Up @@ -216,10 +217,18 @@ read_enabled(PluginsFile) ->

dependencies(Reverse, Sources, AllPlugins) ->
{ok, G} = rabbit_misc:build_acyclic_graph(
fun ({App, _Deps}) -> [{App, App}] end,
fun ({App, Deps}) -> [{App, Dep} || Dep <- Deps] end,
[{Name, Deps} || #plugin{name = Name,
dependencies = Deps} <- AllPlugins]),
%% Every plugin becomes a DAG vertex
fun ({App, _BundlesDeps, _Deps}) -> [{App, App}] end,
%% Only those plugins that do not bundle their dependencies are used to populate the
%% edges of the dependency DAG
fun ({App, BundlesDeps, Deps}) -> [{App, Dep} || Dep <- Deps, not BundlesDeps] end,
%% the value returned here are passed to the VertexFun and EdgeFun functions
[{Name, BundlesDeps, Deps} ||
#plugin{
name = Name,
ez_bundles_dependencies = BundlesDeps,
dependencies = Deps
} <- AllPlugins]),
Dests = case Reverse of
false -> digraph_utils:reachable(Sources, G);
true -> digraph_utils:reaching(Sources, G)
Expand Down Expand Up @@ -261,9 +270,21 @@ is_plugin_provided_by_otp(#plugin{name = eldap}) ->
is_plugin_provided_by_otp(_) ->
false.

does_bundle_dependencies(#plugin{ez_bundles_dependencies = true}) ->
true;
does_bundle_dependencies(_) ->
false.

does_not_bundle_dependencies(Plugin) ->
not does_bundle_dependencies(Plugin).

%% Make sure we don't list OTP apps in here, and also that we detect
%% missing dependencies.
ensure_dependencies(Plugins) ->
ensure_dependencies(Plugins0) ->
%% Filter out plugins marked as bundling dependencies: they
%% are packaged as single EZ files and this dependency validation
%% does not make sense for them. MK.
Plugins = lists:filter(fun does_not_bundle_dependencies/1, Plugins0),
Names = plugin_names(Plugins),
NotThere = [Dep || #plugin{dependencies = Deps} <- Plugins,
Dep <- Deps,
Expand All @@ -278,9 +299,10 @@ ensure_dependencies(Plugins) ->
end, Deps)],
throw({error, {missing_dependencies, Missing, Blame}})
end,
%% Unlike with the validation above, all plugins must be considered here. MK.
[P#plugin{dependencies = Deps -- OTP,
extra_dependencies = Deps -- (Deps -- OTP)}
|| P = #plugin{dependencies = Deps} <- Plugins].
|| P = #plugin{dependencies = Deps} <- Plugins0].

is_loadable(App) ->
case application:load(App) of
Expand Down Expand Up @@ -594,10 +616,21 @@ mkplugin(Name, Props, Type, Location) ->
Dependencies = proplists:get_value(applications, Props, []),
BrokerVersions = proplists:get_value(broker_version_requirements, Props, []),
DepsVersions = proplists:get_value(dependency_version_requirements, Props, []),
#plugin{name = Name, version = Version, description = Description,
dependencies = Dependencies, location = Location, type = Type,
broker_version_requirements = BrokerVersions,
dependency_version_requirements = DepsVersions}.
%% Plugins that bundle their dependencies (into the same .ez file)
%% are supposed to set this field to `true`. MK.
BundlesDependencies = proplists:get_value(ez_bundles_dependencies, Props, false),

#plugin{
name = Name,
version = Version,
description = Description,
dependencies = Dependencies,
location = Location,
type = Type,
broker_version_requirements = BrokerVersions,
dependency_version_requirements = DepsVersions,
ez_bundles_dependencies = BundlesDependencies
}.

read_app_file(EZ) ->
case zip:list_dir(EZ) of
Expand Down
9 changes: 7 additions & 2 deletions deps/rabbit_common/include/rabbit.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,13 @@
%% e.g. [{rabbitmq_management, ["3.5.7", "3.6.1"]},
%% {rabbitmq_federation, ["3.5.7", "3.6.1"]},
%% {rabbitmq_email, ["0.1.0"]}]
dependency_version_requirements, %% [{atom(), [string()]}]
extra_dependencies %% string()
%%
%% [{atom(), [string()]}]
dependency_version_requirements,
%% string()
extra_dependencies,
%% boolean()
ez_bundles_dependencies = false
}).

%% used to track connections across virtual hosts
Expand Down
Loading