Skip to content

Commit f366b06

Browse files
author
Omer Levi Hevroni
committed
added refreshonly support
1 parent d8587b2 commit f366b06

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ You can trigger a rebuild of the image by subscribing to external events like Do
238238
docker::image { 'ubuntu':
239239
docker_file => '/tmp/Dockerfile'
240240
subscribe => File['/tmp/Dockerfile'],
241+
ensure => 'latest',
242+
refreshonly => 'true'
241243
}
242244
243245
file { '/tmp/Dockerfile':

manifests/image.pp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
$docker_file = undef,
3333
$docker_dir = undef,
3434
$docker_tar = undef,
35+
$refreshonly = false
3536
) {
3637
include docker::params
3738
$docker_command = $docker::params::docker_command
@@ -117,6 +118,7 @@
117118
timeout => 0,
118119
onlyif => $image_install,
119120
require => File['/usr/local/bin/update_docker_image.sh'],
121+
refreshonly => $refreshonly
120122
}
121123
} elsif $ensure == 'present' {
122124
exec { $image_install:
@@ -125,7 +127,7 @@
125127
path => ['/bin', '/usr/bin'],
126128
timeout => 0,
127129
returns => ['0', '2'],
128-
require => File['/usr/local/bin/update_docker_image.sh'],
130+
require => File['/usr/local/bin/update_docker_image.sh']
129131
}
130132
}
131133

spec/defines/image_spec.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
it { should contain_exec('/usr/local/bin/update_docker_image.sh base') }
3333
end
3434

35+
3536
context 'with docker_file => Dockerfile' do
3637
let(:params) { { 'docker_file' => 'Dockerfile' }}
3738
it { should contain_exec('docker build -t base - < Dockerfile') }
@@ -138,7 +139,16 @@
138139

139140
context 'with ensure => latest' do
140141
let(:params) { { 'ensure' => 'latest' } }
141-
it { should contain_exec("echo 'Update of base complete'").with_onlyif('/usr/local/bin/update_docker_image.sh base') }
142+
it { should contain_exec("echo 'Update of base complete'").with_onlyif('/usr/local/bin/update_docker_image.sh base').with(
143+
'refreshonly' => 'false'
144+
) }
145+
end
146+
147+
context 'with ensure => latest and refreshonly = true' do
148+
let(:params) { { 'ensure' => 'latest', 'refreshonly' => 'true' } }
149+
it { should contain_exec("echo 'Update of base complete'").with_onlyif('/usr/local/bin/update_docker_image.sh base').with(
150+
'refreshonly' => 'true'
151+
) }
142152
end
143153

144154
context 'with ensure => latest and image_tag => precise' do

0 commit comments

Comments
 (0)