From eb2e142a4747dfd931ee5e32360d15ba9df55a71 Mon Sep 17 00:00:00 2001 From: Iristyle Date: Wed, 6 Jan 2021 08:25:11 -0800 Subject: [PATCH] (REPLATS-101) Update spec helpers for > 1 image - require_test_image can now understand a comma separated list of image names given to PUPPET_TEST_DOCKER_IMAGE and will return an array of image names rather than a string when that happens - pull_images can now accept an array of image names to ignore, rather than just a string both changes are backwards compatible --- gem/lib/pupperware/spec_helper.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/gem/lib/pupperware/spec_helper.rb b/gem/lib/pupperware/spec_helper.rb index 5aa19b1c..c9b95d98 100644 --- a/gem/lib/pupperware/spec_helper.rb +++ b/gem/lib/pupperware/spec_helper.rb @@ -23,6 +23,9 @@ def load_compose_services=(value) @@load_compose_services = value end + # may include multiple comma separated images + # returns a string if only one is present for backward compatibility + # otherwise returns an array of images def require_test_image() image = ENV['PUPPET_TEST_DOCKER_IMAGE'] if image.nil? @@ -33,7 +36,7 @@ def require_test_image() * * * * * MSG end - image + image.include?(',') ? image.split(',') : image end ###################################################################### @@ -366,13 +369,13 @@ def get_service_container(service, timeout = 5) # in the compose file. # Typically the ignored service will be the one under test, since in # that case we want to use the image we just built, not the latest released. - def pull_images(ignore_service = nil) + def pull_images(ignore_services = nil) services = docker_compose('config --services')[:stdout].chomp - if ignore_service.nil? + if ignore_services.nil? puts "Pulling images" else - puts "Pulling images (ignoring image for service #{ignore_service})" - services.sub!(/^#{ignore_service}$/, '') + puts "Pulling images (ignoring image for service(s) #{ignore_services})" + [ignore_services].flatten.each { |s| services.sub!(/^#{s}$/, '') } end services.gsub!("\n", ' ') docker_compose("pull --quiet #{services}", stream: STDOUT)