diff options
| author | Daniil Fedotov <dfedotov@pivotal.io> | 2016-02-22 15:02:44 +0000 |
|---|---|---|
| committer | Daniil Fedotov <dfedotov@pivotal.io> | 2016-03-24 10:48:45 +0000 |
| commit | b40dd3708c211f0bea90985a3e7a7a548a576c99 (patch) | |
| tree | 5d05007f20bd77fb463dd21fa92317210e007ba9 /src | |
| parent | 117a20bc2383d6ee841547468fb615f34e4916f5 (diff) | |
| download | rabbitmq-server-git-b40dd3708c211f0bea90985a3e7a7a548a576c99.tar.gz | |
Rabbit broker version check in plugins
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_plugins.erl | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/src/rabbit_plugins.erl b/src/rabbit_plugins.erl index 2f084ed28a..a56c98b3d8 100644 --- a/src/rabbit_plugins.erl +++ b/src/rabbit_plugins.erl @@ -149,7 +149,9 @@ list(PluginsDir, IncludeRequiredDeps) -> {AvailablePlugins, Problems} = lists:foldl(fun ({error, EZ, Reason}, {Plugins1, Problems1}) -> {Plugins1, [{EZ, Reason} | Problems1]}; - (Plugin = #plugin{name = Name}, {Plugins1, 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 @@ -157,7 +159,13 @@ list(PluginsDir, IncludeRequiredDeps) -> %% disable them. case IncludeRequiredDeps orelse not lists:member(Name, RabbitDeps) of - true -> {[Plugin|Plugins1], Problems1}; + true -> + case check_rabbit_version(Versions) of + ok -> + {[Plugin|Plugins1], Problems1}; + {error, Err} -> + {Plugins1, [Err | Problems1]} + end; false -> {Plugins1, Problems1} end end, {[], []}, @@ -171,6 +179,22 @@ 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, + case lists:any(fun(V) -> + rabbit_misc:version_minor_equivalent(V, RabbitVersion) + andalso + rabbit_misc:version_compare(V, RabbitVersion, lte) + end, + Versions) of + true -> ok; + false -> {error, {version_mismatch, {RabbitVersion, Versions}}} + end. + %% @doc Read the list of enabled plugins from the supplied term file. read_enabled(PluginsFile) -> case rabbit_file:read_term_file(PluginsFile) of @@ -330,8 +354,10 @@ mkplugin(Name, Props, Type, Location) -> Version = proplists:get_value(vsn, Props, "0"), Description = proplists:get_value(description, Props, ""), Dependencies = proplists:get_value(applications, Props, []), + RabbitmqVersions = proplists:get_value(rabbitmq_versions, Props, []), #plugin{name = Name, version = Version, description = Description, - dependencies = Dependencies, location = Location, type = Type}. + dependencies = Dependencies, location = Location, type = Type, + rabbitmq_versions = RabbitmqVersions}. read_app_file(EZ) -> case zip:list_dir(EZ) of |
