From 059697550745fe4bb7dfdae1d4188f366a04db65 Mon Sep 17 00:00:00 2001 From: Omer Levi Hevroni Date: Sun, 9 Jul 2017 16:41:31 +0300 Subject: [PATCH] added refreshonly support --- manifests/image.pp | 5 ++++- spec/defines/image_spec.rb | 23 +++++++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/manifests/image.pp b/manifests/image.pp index 35b2b97fd..56fa70a0d 100644 --- a/manifests/image.pp +++ b/manifests/image.pp @@ -32,6 +32,7 @@ $docker_file = undef, $docker_dir = undef, $docker_tar = undef, + $refreshonly = false ) { include docker::params $docker_command = $docker::params::docker_command @@ -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'": @@ -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: @@ -126,6 +128,7 @@ timeout => 0, returns => ['0', '2'], require => File['/usr/local/bin/update_docker_image.sh'], + refreshonly => $refreshonly } } diff --git a/spec/defines/image_spec.rb b/spec/defines/image_spec.rb index e5d190e77..c34be14fb 100644 --- a/spec/defines/image_spec.rb +++ b/spec/defines/image_spec.rb @@ -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 @@ -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