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

Fixes #28308 - ignore prerelease tags in dependencies #7188

Merged
merged 1 commit into from
Nov 26, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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']))
Copy link
Member

@tbrisker tbrisker Nov 24, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we care about specifying a prerelease version in the template? because if we do this might lead to unexpected result:

[11] pry(main)> Gem::Version.new('1.2.0.rc1').release < Gem::Version.new('1.2.0.rc2')
=> false

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we do. I don't see a template to require a RC release.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, let's keep it simple and only keep versioning on GA versions, technically we may want to depend on something we added only in rc, but in real world, we care about Katello 3.14, not any of it's RC.

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