Skip to content

Commit

Permalink
added refreshonly support
Browse files Browse the repository at this point in the history
  • Loading branch information
Omer Levi Hevroni committed Jul 13, 2017
1 parent d8587b2 commit 0596975
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
5 changes: 4 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 @@ -108,7 +109,7 @@
exec { $image_remove:
path => ['/bin', '/usr/bin'],
onlyif => $image_find,
timeout => 0,
timeout => 0
}
} elsif $ensure == 'latest' {
exec { "echo 'Update of ${image_arg} complete'":
Expand All @@ -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 @@ -126,6 +128,7 @@
timeout => 0,
returns => ['0', '2'],
require => File['/usr/local/bin/update_docker_image.sh'],
refreshonly => $refreshonly
}
}

Expand Down
23 changes: 21 additions & 2 deletions spec/defines/image_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,17 @@
context 'with ensure => present' do
let(:params) { { 'ensure' => 'present' } }
it { should contain_file('/usr/local/bin/update_docker_image.sh') }
it { should contain_exec('/usr/local/bin/update_docker_image.sh base') }
it { should contain_exec('/usr/local/bin/update_docker_image.sh base').with(
'refreshonly' => 'false'
) }
end

context 'with ensure => present and refreshonly = true' do
let(:params) { { 'ensure' => 'present', 'refreshonly' => 'true' } }
it { should contain_file('/usr/local/bin/update_docker_image.sh') }
it { should contain_exec('/usr/local/bin/update_docker_image.sh base').with(
'refreshonly' => 'true'
) }
end

context 'with docker_file => Dockerfile' do
Expand Down Expand Up @@ -138,7 +148,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

0 comments on commit 0596975

Please sign in to comment.