core: VAGRANT_VAGRANTFILE affects only project vagrantfile [GH-2130]
This commit is contained in:
parent
933fd8b397
commit
95aba27e59
|
@ -4,6 +4,8 @@ BUG FIXES:
|
|||
|
||||
- core: Fix various issues where using the same options hash in a
|
||||
Vagrantfile can cause errors.
|
||||
- core: `VAGRANT_VAGRANTFILE` env var only applies to the project
|
||||
Vagrantfile name. [GH-2130]
|
||||
- provisioners/puppet: No more "shared folders cannot be found" error.
|
||||
[GH-2134]
|
||||
|
||||
|
|
|
@ -85,9 +85,8 @@ module Vagrant
|
|||
# those continue to work as well, but anything custom will take precedence.
|
||||
opts[:vagrantfile_name] ||= ENV["VAGRANT_VAGRANTFILE"] if \
|
||||
ENV.has_key?("VAGRANT_VAGRANTFILE")
|
||||
opts[:vagrantfile_name] ||= ["Vagrantfile", "vagrantfile"]
|
||||
opts[:vagrantfile_name] = [opts[:vagrantfile_name]] if \
|
||||
!opts[:vagrantfile_name].is_a?(Array)
|
||||
opts[:vagrantfile_name] && !opts[:vagrantfile_name].is_a?(Array)
|
||||
|
||||
# Set instance variables for all the configuration parameters.
|
||||
@cwd = opts[:cwd]
|
||||
|
@ -251,7 +250,7 @@ module Vagrant
|
|||
home_vagrantfile = nil
|
||||
root_vagrantfile = nil
|
||||
home_vagrantfile = find_vagrantfile(home_path) if home_path
|
||||
root_vagrantfile = find_vagrantfile(root_path) if root_path
|
||||
root_vagrantfile = find_vagrantfile(root_path, @vagrantfile_name) if root_path
|
||||
|
||||
# Create the configuration loader and set the sources that are global.
|
||||
# We use this to load the configuration, and the list of machines we are
|
||||
|
@ -539,11 +538,8 @@ module Vagrant
|
|||
root_finder = lambda do |path|
|
||||
# Note: To remain compatible with Ruby 1.8, we have to use
|
||||
# a `find` here instead of an `each`.
|
||||
found = vagrantfile_name.find do |rootfile|
|
||||
File.exist?(File.join(path.to_s, rootfile))
|
||||
end
|
||||
|
||||
return path if found
|
||||
vf = find_vagrantfile(path, @vagrantfile_name)
|
||||
return path if vf
|
||||
return nil if path.root? || !File.exist?(path)
|
||||
root_finder.call(path.parent)
|
||||
end
|
||||
|
@ -715,8 +711,9 @@ module Vagrant
|
|||
#
|
||||
# @param [Pathname] path Path to search in.
|
||||
# @return [Pathname]
|
||||
def find_vagrantfile(search_path)
|
||||
@vagrantfile_name.each do |vagrantfile|
|
||||
def find_vagrantfile(search_path, filenames=nil)
|
||||
filenames ||= ["Vagrantfile", "vagrantfile"]
|
||||
filenames.each do |vagrantfile|
|
||||
current_path = search_path.join(vagrantfile)
|
||||
return current_path if current_path.exist?
|
||||
end
|
||||
|
|
|
@ -581,6 +581,31 @@ VF
|
|||
machine.config.ssh.port.should == 100
|
||||
end
|
||||
|
||||
it "should load the box configuration for a V2 box and custom Vagrantfile name" do
|
||||
register_provider("foo")
|
||||
|
||||
environment = isolated_environment do |env|
|
||||
env.file("some_other_name", <<-VF)
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vm.box = "base"
|
||||
end
|
||||
VF
|
||||
|
||||
env.box2("base", :foo, :vagrantfile => <<-VF)
|
||||
Vagrant.configure("2") do |config|
|
||||
config.ssh.port = 100
|
||||
end
|
||||
VF
|
||||
end
|
||||
|
||||
env = with_temp_env("VAGRANT_VAGRANTFILE" => "some_other_name") do
|
||||
environment.create_vagrant_env
|
||||
end
|
||||
|
||||
machine = env.machine(:default, :foo)
|
||||
machine.config.ssh.port.should == 100
|
||||
end
|
||||
|
||||
it "should load the box configuration for other formats for a V2 box" do
|
||||
register_provider("foo", nil, box_format: "bar")
|
||||
|
||||
|
|
Loading…
Reference in New Issue