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.
This commit is contained in:
John Barbuto 2014-07-24 23:17:32 -07:00
parent c7c47782cb
commit b7b3bcb3ed

View file

@ -34,9 +34,15 @@ module VagrantPlugins
@cache_root ||= case @env[:machine].config.cache.scope.to_sym @cache_root ||= case @env[:machine].config.cache.scope.to_sym
when :box when :box
@box_name = box_name @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 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 else
bucket_name = @box_name bucket_name = @box_name
end end