Use image for bucket name with docker, if box is unset

This allows multiple machines using the image to share the cache
and avoids the following error:

    /Applications/Vagrant/embedded/lib/ruby/2.0.0/pathname.rb:389:in
    `initialize': no implicit conversion of nil into String (TypeError)
This commit is contained in:
John Barbuto 2014-07-22 22:53:29 -07:00
parent d94f08a048
commit c7c47782cb

View file

@ -33,7 +33,14 @@ module VagrantPlugins
def cache_root
@cache_root ||= case @env[:machine].config.cache.scope.to_sym
when :box
@env[:home_path].join('cache', box_name)
@box_name = box_name
# Box is optional with docker provider, so use image name if unset
if @box_name.nil? && @env[:machine].provider_name.to_sym == :docker
bucket_name = image_name.gsub(':', '-')
else
bucket_name = @box_name
end
@env[:home_path].join('cache', bucket_name)
when :machine
@env[:machine].data_dir.parent.join('cache')
else
@ -44,6 +51,10 @@ module VagrantPlugins
def box_name
@env[:machine].config.vm.box
end
def image_name
@env[:machine].provider_config.image
end
end
end
end