Skip to content

Commit

Permalink
Fixes #28308 - ignore prerelease tags in dependencies
Browse files Browse the repository at this point in the history
Templates with requirements specifying plugins that contains .rc in their
versions are skipped. E.g. a template needs katello 3.14.0 but 3.14.0.rc1
s installed. The comparison does not work and template is ignored.

We should ignore the .rc tag as 3.14.0.rc1 has all functionality already
and should be only receiving bug fixes. That makes tester life easier,
they don't have to hack templates in order to seed them.

(cherry picked from commit 258b2a6)
  • Loading branch information
ares authored and tbrisker committed Nov 26, 2019
1 parent 8e714bf commit f98ccd2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/seed_helper.rb
Expand Up @@ -169,7 +169,7 @@ def test_template_requirements(template_name, requirements)
if plugin.nil?
logger.info("Template #{template_name} requires plugin #{r['plugin']}, skipping import.")
return false
elsif r['version'] && (Gem::Version.new(plugin.version) < Gem::Version.new(r['version']))
elsif r['version'] && (Gem::Version.new(plugin.version).release < Gem::Version.new(r['version']))
logger.info("Template #{template_name} requires plugin #{r['plugin']} >= #{r['version']}, skipping import.")
return false
end
Expand Down
11 changes: 11 additions & 0 deletions test/unit/seed_helper_test.rb
Expand Up @@ -152,6 +152,17 @@ def mock_taxonomies(type, taxonomies)
assert_nil SeedHelper.import_raw_template(get_template(metadata.merge(requirements)))
end

it 'accepts prereleases to satisty version condition ' do
requirements = {
'require' => [{
'plugin' => 'some_plugin',
'version' => '2.0.1',
}],
}
Foreman::Plugin.expects(:find).with('some_plugin').returns(mock(:version => '2.0.1.rc2'))
refute_nil SeedHelper.import_raw_template(get_template(metadata.merge(requirements)))
end

it 'imports the template and sets taxonomies' do
orgs = [taxonomies(:organization1), taxonomies(:organization2)]
locs = [taxonomies(:location1), taxonomies(:location2)]
Expand Down

0 comments on commit f98ccd2

Please sign in to comment.