Skip to content

Commit

Permalink
Add 'pin' param to plugin
Browse files Browse the repository at this point in the history
Defaults to false, but when set to true sets ensure on the .pinned file
resource to 'file'.
  • Loading branch information
alexjfisher committed Jan 22, 2016
1 parent 0ee47ce commit f4e3fb0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
9 changes: 8 additions & 1 deletion 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,8 +104,13 @@
notify => Service['jenkins'],
}

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

file { "${::jenkins::plugin_dir}/${plugin}.pinned":
ensure => file,
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 f4e3fb0

Please # to comment.