Skip to content
New issue

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

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

Already on GitHub? # to your account

attempt to determine the correct gem provider #530

Merged
merged 1 commit into from
Mar 8, 2016
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
14 changes: 13 additions & 1 deletion manifests/cli/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,22 @@
if $cli_try_sleep { validate_numeric($cli_try_sleep) }
validate_string($ssh_private_key_content)

if str2bool($::is_pe) {
$gem_provider = 'pe_gem'
} elsif $::puppetversion
and (versioncmp($::puppetversion, '4.0.0') >= 0)
and $::rubysitedir
and ('/opt/puppetlabs/puppet/lib/ruby' in $::rubysitedir) {
# AIO puppet
$gem_provider = 'puppet_gem'
} else {
$gem_provider = 'gem'
}

# required by PuppetX::Jenkins::Provider::Clihelper base
if ! defined(Package['retries']) {
package { 'retries':
provider => 'gem',
provider => $gem_provider,
}
}

Expand Down
37 changes: 36 additions & 1 deletion spec/classes/cli/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,41 @@
end # ssh_private_key_content
end # parameters

it { should contain_package('retries').with(:provider => 'gem') }
describe 'package gem provider' do
context 'is_pe fact' do
context 'true' do
let(:facts) {{ :is_pe => true }}
it { should contain_package('retries').with(:provider => 'pe_gem') }
end

context 'false' do
let(:facts) {{ :is_pe => false }}
it { should contain_package('retries').with(:provider => 'gem') }
end
end # 'is_pe fact' do

context 'puppetversion facts' do
context '=> 3.8.4' do
let(:facts) {{ :puppetversion => '3.8.4' }}
it { should contain_package('retries').with(:provider => 'gem') }
end

context '=> 4.0.0' do
let(:facts) {{ :puppetversion => '4.0.0' }}
it { should contain_package('retries').with(:provider => 'gem') }

context 'rubysitedir fact' do
context '=> /foo/bar' do
before { facts[:rubysitedir] = '/foo/bar' }
it { should contain_package('retries').with(:provider => 'gem') }
end

context '=> /opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0' do
before { facts[:rubysitedir] = '/opt/puppetlabs/puppet/lib/ruby/site_ruby/2.1.0' }
it { should contain_package('retries').with(:provider => 'puppet_gem') }
end
end
end
end # 'puppetversion facts' do
end # 'package gem provider' do
end