Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore pre-release version part in plugin version requirement validation #1091

Merged
merged 2 commits into from
Feb 2, 2017
Merged
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
9 changes: 8 additions & 1 deletion src/rabbit_plugins.erl
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,10 @@ check_plugins_versions(PluginName, AllPlugins, RequiredVersions) ->
is_version_supported("", _) -> true;
is_version_supported("0.0.0", _) -> true;
is_version_supported(_Version, []) -> true;
is_version_supported(Version, ExpectedVersions) ->
is_version_supported(VersionFull, ExpectedVersions) ->
%% Pre-release version should be supported in plugins,
%% therefore preview part should be removed
Version = remove_version_preview_part(VersionFull),
case lists:any(fun(ExpectedVersion) ->
rabbit_misc:version_minor_equivalent(ExpectedVersion, Version)
andalso
Expand All @@ -351,6 +354,10 @@ is_version_supported(Version, ExpectedVersions) ->
false -> false
end.

remove_version_preview_part(Version) ->
{Ver, _Preview} = rabbit_semver:parse(Version),
iolist_to_binary(rabbit_semver:format({Ver, {[], []}})).

clean_plugins(Plugins) ->
{ok, ExpandDir} = application:get_env(rabbit, plugins_expand_dir),
[clean_plugin(Plugin, ExpandDir) || Plugin <- Plugins].
Expand Down
2 changes: 2 additions & 0 deletions test/plugin_versioning_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ version_support(_Config) ->
,{["3.5.2", "3.6.1"], "3.6.2.999", true} %% x.y.z.p values are supported
,{["3.5.2", "3.6.2.333"], "3.6.2.999", true} %% x.y.z.p values are supported
,{["3.5.2", "3.6.2.333"], "3.6.2.222", false} %% x.y.z.p values are supported
,{["3.6.0", "3.7.0"], "3.6.3-alpha.1", true} %% Pre-release versions handled like semver part
,{["3.6.0", "3.7.0"], "3.7.0-alpha.89", true}
],

lists:foreach(
Expand Down