Skip to content

Commit

Permalink
Merge pull request #475 from alexjfisher/issue-465
Browse files Browse the repository at this point in the history
Add ensure=>file to pinning file
  • Loading branch information
R. Tyler Croy committed Feb 8, 2016
2 parents 6a6925e + f4e3fb0 commit 00ea19d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
8 changes: 8 additions & 0 deletions manifests/plugin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
$digest_string = '',
$digest_type = 'sha1',
$timeout = 120,
$pin = false,
# deprecated
$plugin_dir = undef,
$username = undef,
Expand All @@ -36,6 +37,7 @@

validate_bool($manage_config)
validate_bool($enabled)
validate_bool($pin)
# TODO: validate_str($update_url)
validate_string($source)
validate_string($digest_string)
Expand Down Expand Up @@ -102,7 +104,13 @@
notify => Service['jenkins'],
}

$pinned_ensure = $pin ? {
true => file,
default => undef,
}

file { "${::jenkins::plugin_dir}/${plugin}.pinned":
ensure => $pinned_ensure,
owner => $::jenkins::user,
group => $::jenkins::group,
require => Archive::Download[$plugin],
Expand Down
22 changes: 21 additions & 1 deletion spec/defines/jenkins_plugin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
describe 'source' do
shared_examples 'should download from $source url' do
it 'should download from $source url' do
should contain_archive__download('myplug.hpi').with(
should contain_archive__download('myplug.hpi').with(
:url => 'http://e.org/myplug.hpi',
:user => 'jenkins',
)
Expand Down Expand Up @@ -205,6 +205,26 @@
).that_requires('Archive::Download[foo.jpi]')
end
end

describe 'pin parameter' do
context 'with pin => true' do
let(:params) {{ :pin => true } }
it do
should contain_file('/var/lib/jenkins/plugins/foo.hpi.pinned').with_ensure('file')
end
end
context 'with pin => false' do
let(:params) {{ :pin => false } }
it do
should contain_file('/var/lib/jenkins/plugins/foo.hpi.pinned').without_ensure
end
end
context 'with default pin param' do
it do
should contain_file('/var/lib/jenkins/plugins/foo.hpi.pinned').without_ensure
end
end
end
end # pinned file extension name


Expand Down

0 comments on commit 00ea19d

Please # to comment.