vagrantfile now is lowercase. backwards compatible, though. [closes GH-399]
This commit is contained in:
parent
1cf379a1f0
commit
24337b0ca4
|
@ -24,6 +24,8 @@
|
||||||
needs to be downloaded during an `up`. [GH-308]
|
needs to be downloaded during an `up`. [GH-308]
|
||||||
- Multiple Chef provisioners no longer overwrite cookbook folders. [GH-407]
|
- Multiple Chef provisioners no longer overwrite cookbook folders. [GH-407]
|
||||||
- `package` won't delete previously existing file. [GH-408]
|
- `package` won't delete previously existing file. [GH-408]
|
||||||
|
- Vagrantfile by default is lowercase now and Vagrant properly finds old
|
||||||
|
uppercase Vagrantfiles. [GH-399]
|
||||||
|
|
||||||
## 0.7.6 (July 2, 2011)
|
## 0.7.6 (July 2, 2011)
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ module Vagrant
|
||||||
register "init [box_name] [box_url]", "Initializes the current folder for Vagrant usage"
|
register "init [box_name] [box_url]", "Initializes the current folder for Vagrant usage"
|
||||||
|
|
||||||
def execute
|
def execute
|
||||||
template "Vagrantfile.erb", "Vagrantfile"
|
template "vagrantfile.erb", "vagrantfile"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,7 +6,6 @@ module Vagrant
|
||||||
# defined as basically a folder with a "Vagrantfile." This class allows
|
# defined as basically a folder with a "Vagrantfile." This class allows
|
||||||
# access to the VMs, CLI, etc. all in the scope of this environment.
|
# access to the VMs, CLI, etc. all in the scope of this environment.
|
||||||
class Environment
|
class Environment
|
||||||
ROOTFILE_NAME = "Vagrantfile"
|
|
||||||
HOME_SUBDIRS = ["tmp", "boxes", "logs"]
|
HOME_SUBDIRS = ["tmp", "boxes", "logs"]
|
||||||
DEFAULT_VM = :default
|
DEFAULT_VM = :default
|
||||||
DEFAULT_HOME = "~/.vagrant"
|
DEFAULT_HOME = "~/.vagrant"
|
||||||
|
@ -17,6 +16,9 @@ module Vagrant
|
||||||
# The `cwd` that this environment represents
|
# The `cwd` that this environment represents
|
||||||
attr_reader :cwd
|
attr_reader :cwd
|
||||||
|
|
||||||
|
# The valid name for a Vagrantfile for this environment.
|
||||||
|
attr_reader :vagrantfile_name
|
||||||
|
|
||||||
# The single VM that this environment represents, in the case of
|
# The single VM that this environment represents, in the case of
|
||||||
# multi-VM.
|
# multi-VM.
|
||||||
attr_accessor :vm
|
attr_accessor :vm
|
||||||
|
@ -58,11 +60,18 @@ module Vagrant
|
||||||
:parent => nil,
|
:parent => nil,
|
||||||
:vm => nil,
|
:vm => nil,
|
||||||
:cwd => nil,
|
:cwd => nil,
|
||||||
|
:vagrantfile_name => nil
|
||||||
}.merge(opts || {})
|
}.merge(opts || {})
|
||||||
|
|
||||||
|
# Set the default working directory to look for the vagrantfile
|
||||||
opts[:cwd] ||= Dir.pwd
|
opts[:cwd] ||= Dir.pwd
|
||||||
opts[:cwd] = Pathname.new(opts[:cwd])
|
opts[:cwd] = Pathname.new(opts[:cwd])
|
||||||
|
|
||||||
|
# Set the default vagrantfile name, which can be either Vagrantfile
|
||||||
|
# or vagrantfile (capital for backwards compatibility)
|
||||||
|
opts[:vagrantfile_name] ||= ["Vagrantfile", "vagrantfile"]
|
||||||
|
opts[:vagrantfile_name] = [opts[:vagrantfile_name]] if !opts[:vagrantfile_name].is_a?(Array)
|
||||||
|
|
||||||
opts.each do |key, value|
|
opts.each do |key, value|
|
||||||
instance_variable_set("@#{key}".to_sym, opts[key])
|
instance_variable_set("@#{key}".to_sym, opts[key])
|
||||||
end
|
end
|
||||||
|
@ -261,7 +270,10 @@ module Vagrant
|
||||||
return @root_path if defined?(@root_path)
|
return @root_path if defined?(@root_path)
|
||||||
|
|
||||||
root_finder = lambda do |path|
|
root_finder = lambda do |path|
|
||||||
return path if File.exist?(File.join(path.to_s, ROOTFILE_NAME))
|
vagrantfile_name.each do |rootfile|
|
||||||
|
return path if File.exist?(File.join(path.to_s, rootfile))
|
||||||
|
end
|
||||||
|
|
||||||
return nil if path.root? || !File.exist?(path)
|
return nil if path.root? || !File.exist?(path)
|
||||||
root_finder.call(path.parent)
|
root_finder.call(path.parent)
|
||||||
end
|
end
|
||||||
|
@ -327,9 +339,12 @@ module Vagrant
|
||||||
@config_loader ||= Config.new(parent ? parent.config_loader : nil)
|
@config_loader ||= Config.new(parent ? parent.config_loader : nil)
|
||||||
@config_loader.load_order = [:default, :box, :home, :root, :sub_vm]
|
@config_loader.load_order = [:default, :box, :home, :root, :sub_vm]
|
||||||
@config_loader.set(:default, File.expand_path("config/default.rb", Vagrant.source_root))
|
@config_loader.set(:default, File.expand_path("config/default.rb", Vagrant.source_root))
|
||||||
@config_loader.set(:box, File.join(box.directory, ROOTFILE_NAME)) if !first_run && vm && box
|
|
||||||
@config_loader.set(:home, File.join(home_path, ROOTFILE_NAME)) if !first_run && home_path
|
vagrantfile_name.each do |rootfile|
|
||||||
@config_loader.set(:root, File.join(root_path, ROOTFILE_NAME)) if root_path
|
@config_loader.set(:box, File.join(box.directory, rootfile)) if !first_run && vm && box
|
||||||
|
@config_loader.set(:home, File.join(home_path, rootfile)) if !first_run && home_path
|
||||||
|
@config_loader.set(:root, File.join(root_path, rootfile)) if root_path
|
||||||
|
end
|
||||||
|
|
||||||
# If this environment is representing a sub-VM, then we push that
|
# If this environment is representing a sub-VM, then we push that
|
||||||
# proc on as the last configuration.
|
# proc on as the last configuration.
|
||||||
|
|
|
@ -248,20 +248,23 @@ class EnvironmentTest < Test::Unit::TestCase
|
||||||
Pathname.new("/")
|
Pathname.new("/")
|
||||||
]
|
]
|
||||||
|
|
||||||
|
rootfile = "Foo"
|
||||||
|
|
||||||
search_seq = sequence("search_seq")
|
search_seq = sequence("search_seq")
|
||||||
paths.each do |path|
|
paths.each do |path|
|
||||||
File.expects(:exist?).with(path.join(@klass::ROOTFILE_NAME).to_s).returns(false).in_sequence(search_seq)
|
File.expects(:exist?).with(path.join(rootfile).to_s).returns(false).in_sequence(search_seq)
|
||||||
File.expects(:exist?).with(path).returns(true).in_sequence(search_seq) if !path.root?
|
File.expects(:exist?).with(path).returns(true).in_sequence(search_seq) if !path.root?
|
||||||
end
|
end
|
||||||
|
|
||||||
assert !@klass.new(:cwd => paths.first).root_path
|
assert !@klass.new(:cwd => paths.first, :vagrantfile_name => rootfile).root_path
|
||||||
end
|
end
|
||||||
|
|
||||||
should "should set the path for the rootfile" do
|
should "should set the path for the rootfile" do
|
||||||
|
rootfile = "Foo"
|
||||||
path = Pathname.new(File.expand_path("/foo"))
|
path = Pathname.new(File.expand_path("/foo"))
|
||||||
File.expects(:exist?).with(path.join(@klass::ROOTFILE_NAME).to_s).returns(true)
|
File.expects(:exist?).with(path.join(rootfile).to_s).returns(true)
|
||||||
|
|
||||||
assert_equal path, @klass.new(:cwd => path).root_path
|
assert_equal path, @klass.new(:cwd => path, :vagrantfile_name => rootfile).root_path
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not infinite loop on relative paths" do
|
should "not infinite loop on relative paths" do
|
||||||
|
@ -269,8 +272,9 @@ class EnvironmentTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "only load the root path once" do
|
should "only load the root path once" do
|
||||||
env = @klass.new
|
rootfile = "foo"
|
||||||
File.expects(:exist?).with(env.cwd.join(@klass::ROOTFILE_NAME).to_s).returns(true).once
|
env = @klass.new(:vagrantfile_name => rootfile)
|
||||||
|
File.expects(:exist?).with(env.cwd.join(rootfile).to_s).returns(true).once
|
||||||
|
|
||||||
assert_equal env.cwd, env.root_path
|
assert_equal env.cwd, env.root_path
|
||||||
assert_equal env.cwd, env.root_path
|
assert_equal env.cwd, env.root_path
|
||||||
|
|
Loading…
Reference in New Issue