Skip to content

Commit 813dcbd

Browse files
author
carabasdaniel
authored
Merge pull request #468 from electrofelix/noop-latest-images
Allow images tagged latest to update on each run
2 parents 9b6ea2b + e01a33f commit 813dcbd

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

manifests/image.pp

+15-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,21 @@
140140
timeout => $exec_timeout,
141141
logoutput => true,
142142
}
143-
} elsif $ensure == 'latest' or $image_tag == 'latest' or $ensure == 'present' {
143+
} elsif $ensure == 'latest' or $image_tag == 'latest' {
144+
notify { "Check if image ${image_arg} is in-sync":
145+
noop => false,
146+
}
147+
~> exec { "echo 'Update of ${image_arg} complete'":
148+
environment => $exec_environment,
149+
path => $exec_path,
150+
timeout => $exec_timeout,
151+
onlyif => $image_install,
152+
require => File[$update_docker_image_path],
153+
provider => $exec_provider,
154+
logoutput => true,
155+
refreshonly => true,
156+
}
157+
} elsif $ensure == 'present' {
144158
exec { $image_install:
145159
unless => $_image_find,
146160
environment => $exec_environment,

spec/defines/image_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,17 @@
134134

135135
context 'with ensure => latest' do
136136
let(:params) { { 'ensure' => 'latest' } }
137-
it { should contain_exec("/usr/local/bin/update_docker_image.sh base") }
137+
it { should contain_exec("echo 'Update of base complete'").with_onlyif('/usr/local/bin/update_docker_image.sh base') }
138138
end
139139

140140
context 'with ensure => latest and image_tag => precise' do
141141
let(:params) { { 'ensure' => 'latest', 'image_tag' => 'precise' } }
142-
it { should contain_exec("/usr/local/bin/update_docker_image.sh base:precise") }
142+
it { should contain_exec("echo 'Update of base:precise complete'") }
143143
end
144144

145145
context 'with ensure => latest and image_digest => sha256:deadbeef' do
146146
let(:params) { { 'ensure' => 'latest', 'image_digest' => 'sha256:deadbeef' } }
147-
it { should contain_exec("/usr/local/bin/update_docker_image.sh base@sha256:deadbeef") }
147+
it { should contain_exec("echo 'Update of base@sha256:deadbeef complete'") }
148148
end
149149

150150
context 'with an invalid image name' do

spec/defines/image_windows_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
context 'with ensure => latest' do
5050
let(:params) { { 'ensure' => 'latest' } }
51-
it { should contain_exec("& C:/Users/Administrator/AppData/Local/Temp/update_docker_image.ps1 -DockerImage base") }
51+
it { should contain_exec("echo 'Update of base complete'").with_onlyif('& C:/Users/Administrator/AppData/Local/Temp/update_docker_image.ps1 -DockerImage base') }
5252
end
5353

5454
end

0 commit comments

Comments
 (0)