summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniil Fedotov <dfedotov@pivotal.io>2016-03-23 14:32:45 +0000
committerDaniil Fedotov <dfedotov@pivotal.io>2016-03-24 10:49:23 +0000
commit03a7fdeb073b2aa22d70c45d586c747bb240c4c8 (patch)
treec5c36042fa21bd6cdc2e0d0c8136bd6bcad96763 /src
parenta2222acd34d5b281e66860e3c88f903d6d8d2e01 (diff)
downloadrabbitmq-server-git-03a7fdeb073b2aa22d70c45d586c747bb240c4c8.tar.gz
Plugin versions check
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_plugins.erl50
1 files changed, 40 insertions, 10 deletions
diff --git a/src/rabbit_plugins.erl b/src/rabbit_plugins.erl
index c5d08262d2..81830da6a8 100644
--- a/src/rabbit_plugins.erl
+++ b/src/rabbit_plugins.erl
@@ -162,15 +162,15 @@ list(PluginsDir, IncludeRequiredDeps) ->
case IncludeRequiredDeps orelse
not lists:member(Name, RabbitDeps) of
true ->
- RabbitVersion = case application:get_key(rabbit,
+ RabbitVersion = case application:get_key(rabbit,
vsn) of
undefined -> "0.0.0";
{ok, Val} -> Val
end,
case version_support(RabbitVersion, Versions) of
- ok ->
+ ok ->
{[Plugin|Plugins1], Problems1};
- {error, Err} ->
+ {error, Err} ->
{Plugins1, [Err | Problems1]}
end;
false -> {Plugins1, Problems1}
@@ -187,20 +187,50 @@ list(PluginsDir, IncludeRequiredDeps) ->
ensure_plugins_versions(ensure_dependencies(Plugins)).
ensure_plugins_versions(Plugins) ->
- PluginsVersions = [{Name, Vsn}
+ ExistingVersions = [{Name, Vsn}
|| #plugin{name = Name, version = Vsn} <- Plugins],
- lists:foldl(
- fun(Plugin = #plugin{name = Name, plugins_versions = PluginsVersions},
+ {GoodPlugins, Problems} = lists:foldl(
+ fun(Plugin = #plugin{name = Name, plugins_versions = DepsVersions},
{Plugins1, Problems1}) ->
-
+ case check_plugins_versions(ExistingVersions, DepsVersions) of
+ ok -> {[Plugin | Plugins1], Problems1};
+ {error, Err} -> {Plugins1, [{Name, Err} | Problems1]}
+ end
+ end,
+ {[],[]},
+ Plugins),
+ case Problems of
+ [] -> ok;
+ _ -> rabbit_log:warning("Some plugin veriosns do not match: ~p~n",
+ [Problems])
+ end,
+ GoodPlugins.
+
+check_plugins_versions(ExistingVersions, RequiredVersions) ->
+ Problems = lists:foldl(
+ fun({Name, Versions}, Acc) ->
+ case proplists:get_value(Name, ExistingVersions) of
+ undefined -> [{missing_dependency, Name} | Acc];
+ Version ->
+ case version_support(Version, Versions) of
+ {error, Err} -> [{Err, Name} | Acc];
+ ok -> Acc
+ end
+ end
+ end,
+ [],
+ RequiredVersions),
+ case Problems of
+ [] -> ok;
+ _ -> {error, Problems}
+ end.
- )
version_support(_RabbitVersion, []) -> ok;
version_support(RabbitVersion, Versions) ->
case lists:any(fun(V) ->
rabbit_misc:version_minor_equivalent(V, RabbitVersion)
- andalso
+ andalso
rabbit_misc:version_compare(V, RabbitVersion, lte)
end,
Versions) of
@@ -371,7 +401,7 @@ mkplugin(Name, Props, Type, Location) ->
PluginsVersions = proplists:get_value(plugins_versions, Props, []),
#plugin{name = Name, version = Version, description = Description,
dependencies = Dependencies, location = Location, type = Type,
- rabbitmq_versions = RabbitmqVersions,
+ rabbitmq_versions = RabbitmqVersions,
plugins_versions = PluginsVersions}.
read_app_file(EZ) ->