From b7b3bcb3ede9fa7f42ed358ec9f1d2faba297b5a Mon Sep 17 00:00:00 2001 From: John Barbuto Date: Thu, 24 Jul 2014 23:17:32 -0700 Subject: [PATCH] Check if image is set with docker provider If build_dir is set instead for building images on demand, there's no way to know what to set the bucket name to, except perhaps parsing it from Dockerfile. --- lib/vagrant-cachier/action/configure_bucket_root.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/vagrant-cachier/action/configure_bucket_root.rb b/lib/vagrant-cachier/action/configure_bucket_root.rb index 86e87c2..4bd8e67 100644 --- a/lib/vagrant-cachier/action/configure_bucket_root.rb +++ b/lib/vagrant-cachier/action/configure_bucket_root.rb @@ -34,9 +34,15 @@ module VagrantPlugins @cache_root ||= case @env[:machine].config.cache.scope.to_sym when :box @box_name = box_name - # Box is optional with docker provider, so use image name if unset + # Box is optional with docker provider if @box_name.nil? && @env[:machine].provider_name.to_sym == :docker - bucket_name = image_name.gsub(':', '-') + @image_name = image_name + # Use the image name if it's set + if @image_name + bucket_name = @image_name.gsub(':', '-') + else + raise "Cachier plugin only supported with docker provider when image is used" + end else bucket_name = @box_name end