summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniil Fedotov <dfedotov@pivotal.io>2016-02-22 16:07:51 +0000
committerDaniil Fedotov <dfedotov@pivotal.io>2016-03-24 10:49:23 +0000
commitde353f83314c38a2aa64aa6f97b72ed7839b5add (patch)
tree29ff8d290cce7260cff5c42f50c41c1cc44dc04c
parentb40dd3708c211f0bea90985a3e7a7a548a576c99 (diff)
downloadrabbitmq-server-git-de353f83314c38a2aa64aa6f97b72ed7839b5add.tar.gz
Clean version check function
-rw-r--r--src/rabbit_plugins.erl61
1 files changed, 32 insertions, 29 deletions
diff --git a/src/rabbit_plugins.erl b/src/rabbit_plugins.erl
index a56c98b3d8..46abb9860c 100644
--- a/src/rabbit_plugins.erl
+++ b/src/rabbit_plugins.erl
@@ -21,6 +21,7 @@
-export([setup/0, active/0, read_enabled/1, list/1, list/2, dependencies/3]).
-export([ensure/1]).
-export([extract_schemas/1]).
+-export([version_support/2]).
%%----------------------------------------------------------------------------
@@ -147,29 +148,35 @@ list(PluginsDir, IncludeRequiredDeps) ->
application:load(rabbit),
{ok, RabbitDeps} = application:get_key(rabbit, applications),
{AvailablePlugins, Problems} =
- lists:foldl(fun ({error, EZ, Reason}, {Plugins1, Problems1}) ->
- {Plugins1, [{EZ, Reason} | Problems1]};
- (Plugin = #plugin{name = Name,
- rabbitmq_versions = Versions},
- {Plugins1, Problems1}) ->
- %% Applications RabbitMQ depends on (eg.
- %% "rabbit_common") can't be considered
- %% plugins, otherwise rabbitmq-plugins would
- %% list them and the user may believe he can
- %% disable them.
- case IncludeRequiredDeps orelse
- not lists:member(Name, RabbitDeps) of
- true ->
- case check_rabbit_version(Versions) of
- ok ->
- {[Plugin|Plugins1], Problems1};
- {error, Err} ->
- {Plugins1, [Err | Problems1]}
- end;
- false -> {Plugins1, Problems1}
- end
- end, {[], []},
- [plugin_info(PluginsDir, Plug) || Plug <- EZs ++ FreeApps]),
+ lists:foldl(
+ fun ({error, EZ, Reason}, {Plugins1, Problems1}) ->
+ {Plugins1, [{EZ, Reason} | Problems1]};
+ (Plugin = #plugin{name = Name,
+ rabbitmq_versions = Versions},
+ {Plugins1, Problems1}) ->
+ %% Applications RabbitMQ depends on (eg.
+ %% "rabbit_common") can't be considered
+ %% plugins, otherwise rabbitmq-plugins would
+ %% list them and the user may believe he can
+ %% disable them.
+ case IncludeRequiredDeps orelse
+ not lists:member(Name, RabbitDeps) of
+ true ->
+ RabbitVersion = case application:get_key(rabbit,
+ vsn) of
+ undefined -> "0.0.0";
+ {ok, Val} -> Val
+ end,
+ case version_support(RabbitVersion, Versions) of
+ ok ->
+ {[Plugin|Plugins1], Problems1};
+ {error, Err} ->
+ {Plugins1, [Err | Problems1]}
+ end;
+ false -> {Plugins1, Problems1}
+ end
+ end, {[], []},
+ [plugin_info(PluginsDir, Plug) || Plug <- EZs ++ FreeApps]),
case Problems of
[] -> ok;
_ -> rabbit_log:warning(
@@ -179,12 +186,8 @@ list(PluginsDir, IncludeRequiredDeps) ->
AvailablePlugins),
ensure_dependencies(Plugins).
-check_rabbit_version([]) -> ok;
-check_rabbit_version(Versions) ->
- RabbitVersion = case application:get_key(rabbit, vsn) of
- undefined -> "0.0.0";
- {ok, Val} -> Val
- end,
+version_support(_RabbitVersion, []) -> ok;
+version_support(RabbitVersion, Versions) ->
case lists:any(fun(V) ->
rabbit_misc:version_minor_equivalent(V, RabbitVersion)
andalso