From 9024f97323d01bc6b4788719b2a33c56f8df3c94 Mon Sep 17 00:00:00 2001 From: Greg Dubicki Date: Tue, 13 Jun 2017 15:25:25 +0200 Subject: [PATCH] When not given any tag, remove all tags --- manifests/image.pp | 2 +- spec/defines/image_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/image.pp b/manifests/image.pp index 35b2b97fd..c70c5e0fc 100644 --- a/manifests/image.pp +++ b/manifests/image.pp @@ -90,7 +90,7 @@ $image_find = "${docker_command} images --digests | egrep '^(docker.io/)?${image} ' | awk '{ print \$3 }' | grep ^${image_digest}$" } else { $image_arg = $image - $image_remove = "${docker_command} rmi ${image_force}${image}" + $image_remove = "${docker_command} rmi ${image_force}(${docker_command} images | egrep '^(docker.io/)?${image} ' | awk '{ print \$3 }')" $image_find = "${docker_command} images | cut -d ' ' -f 1 | egrep '^(docker\\.io/)?${image}$'" } diff --git a/spec/defines/image_spec.rb b/spec/defines/image_spec.rb index e5d190e77..240da6f34 100644 --- a/spec/defines/image_spec.rb +++ b/spec/defines/image_spec.rb @@ -13,12 +13,12 @@ context 'with ensure => absent' do let(:params) { { 'ensure' => 'absent' } } - it { should contain_exec('docker rmi base') } + it { should contain_exec('docker rmi $(docker images | egrep '^(docker.io/)?base ' | awk '{ print $3 }')') } end context 'with ensure => absent and force => true' do let(:params) { { 'ensure' => 'absent', 'force' => true } } - it { should contain_exec('docker rmi -f base') } + it { should contain_exec('docker rmi -f $(docker images | egrep '^(docker.io/)?base ' | awk '{ print $3 }')') } end context 'with ensure => absent and image_tag => precise' do