Skip to content
Open
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ You can trigger a rebuild of the image by subscribing to external events like Do
docker::image { 'ubuntu':
docker_file => '/tmp/Dockerfile'
subscribe => File['/tmp/Dockerfile'],
ensure => 'latest',
refreshonly => 'true'
}

file { '/tmp/Dockerfile':
Expand Down
4 changes: 3 additions & 1 deletion manifests/image.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
$docker_file = undef,
$docker_dir = undef,
$docker_tar = undef,
$refreshonly = false
) {
include docker::params
$docker_command = $docker::params::docker_command
Expand Down Expand Up @@ -117,6 +118,7 @@
timeout => 0,
onlyif => $image_install,
require => File['/usr/local/bin/update_docker_image.sh'],
refreshonly => $refreshonly
}
} elsif $ensure == 'present' {
exec { $image_install:
Expand All @@ -125,7 +127,7 @@
path => ['/bin', '/usr/bin'],
timeout => 0,
returns => ['0', '2'],
require => File['/usr/local/bin/update_docker_image.sh'],
require => File['/usr/local/bin/update_docker_image.sh']
}
}

Expand Down
12 changes: 11 additions & 1 deletion spec/defines/image_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
it { should contain_exec('/usr/local/bin/update_docker_image.sh base') }
end


context 'with docker_file => Dockerfile' do
let(:params) { { 'docker_file' => 'Dockerfile' }}
it { should contain_exec('docker build -t base - < Dockerfile') }
Expand Down Expand Up @@ -138,7 +139,16 @@

context 'with ensure => latest' do
let(:params) { { 'ensure' => 'latest' } }
it { should contain_exec("echo 'Update of base complete'").with_onlyif('/usr/local/bin/update_docker_image.sh base') }
it { should contain_exec("echo 'Update of base complete'").with_onlyif('/usr/local/bin/update_docker_image.sh base').with(
'refreshonly' => 'false'
) }
end

context 'with ensure => latest and refreshonly = true' do
let(:params) { { 'ensure' => 'latest', 'refreshonly' => 'true' } }
it { should contain_exec("echo 'Update of base complete'").with_onlyif('/usr/local/bin/update_docker_image.sh base').with(
'refreshonly' => 'true'
) }
end

context 'with ensure => latest and image_tag => precise' do
Expand Down