From 0ee47ce1c9943ac4fff1b36c45511b5ecd771c8e Mon Sep 17 00:00:00 2001 From: Alexander Fisher Date: Thu, 21 Jan 2016 09:57:57 +0000 Subject: [PATCH 1/2] Add ensure=>file to pinning file --- manifests/plugin.pp | 1 + 1 file changed, 1 insertion(+) diff --git a/manifests/plugin.pp b/manifests/plugin.pp index 277178c09..f194da7de 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -103,6 +103,7 @@ } file { "${::jenkins::plugin_dir}/${plugin}.pinned": + ensure => file, owner => $::jenkins::user, group => $::jenkins::group, require => Archive::Download[$plugin], From f4e3fb03dc302a1548f18a588304b13141a6ed16 Mon Sep 17 00:00:00 2001 From: Alexander Fisher Date: Fri, 22 Jan 2016 10:28:19 +0000 Subject: [PATCH 2/2] Add 'pin' param to plugin Defaults to false, but when set to true sets ensure on the .pinned file resource to 'file'. --- manifests/plugin.pp | 9 ++++++++- spec/defines/jenkins_plugin_spec.rb | 22 +++++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/manifests/plugin.pp b/manifests/plugin.pp index f194da7de..677225cf5 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -26,6 +26,7 @@ $digest_string = '', $digest_type = 'sha1', $timeout = 120, + $pin = false, # deprecated $plugin_dir = undef, $username = undef, @@ -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) @@ -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], diff --git a/spec/defines/jenkins_plugin_spec.rb b/spec/defines/jenkins_plugin_spec.rb index 0e7c097f4..6ca8b934e 100644 --- a/spec/defines/jenkins_plugin_spec.rb +++ b/spec/defines/jenkins_plugin_spec.rb @@ -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', ) @@ -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