Skip to content
This repository has been archived by the owner on Aug 4, 2020. It is now read-only.

Commit

Permalink
VAGRANT_VAGRANTFILE env var to specify alternate filename for Vfile
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Feb 23, 2013
1 parent 1bda157 commit 499d1ff
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -38,6 +38,8 @@ FEATURES:
VirtualBox provider config. [GH-1126] VirtualBox provider config. [GH-1126]
- `vagrant ssh` will execute an `ssh` binary on Windows if it is on - `vagrant ssh` will execute an `ssh` binary on Windows if it is on
your PATH. [GH-933] your PATH. [GH-933]
- The environmental variable `VAGRANT_VAGRANTFILE` can be used to
specify an alternate Vagrantfile filename.


IMPROVEMENTS / BUG FIXES: IMPROVEMENTS / BUG FIXES:


Expand Down
6 changes: 3 additions & 3 deletions lib/vagrant/environment.rb
Expand Up @@ -81,11 +81,11 @@ def initialize(opts=nil)


# Set the Vagrantfile name up. We append "Vagrantfile" and "vagrantfile" so that # Set the Vagrantfile name up. We append "Vagrantfile" and "vagrantfile" so that
# those continue to work as well, but anything custom will take precedence. # those continue to work as well, but anything custom will take precedence.
opts[:vagrantfile_name] ||= [] 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] = [opts[:vagrantfile_name]] if \
!opts[:vagrantfile_name].is_a?(Array) !opts[:vagrantfile_name].is_a?(Array)
opts[:vagrantfile_name] = ["Vagrantfile", "vagrantfile"] if \
opts[:vagrantfile_name].empty?


# Set instance variables for all the configuration parameters. # Set instance variables for all the configuration parameters.
@cwd = opts[:cwd] @cwd = opts[:cwd]
Expand Down
15 changes: 15 additions & 0 deletions test/unit/vagrant/environment_test.rb
Expand Up @@ -284,6 +284,21 @@
env.config_global.ssh.port.should == 200 env.config_global.ssh.port.should == 200
end end


it "should load from a custom Vagrantfile specified by env var" do
environment = isolated_environment do |env|
env.file("some_other_name", <<-VF)
Vagrant.configure("2") do |config|
config.ssh.port = 400
end
VF
end

env = with_temp_env("VAGRANT_VAGRANTFILE" => "some_other_name") do
environment.create_vagrant_env
end

env.config_global.ssh.port.should == 400
end
end end


describe "ui" do describe "ui" do
Expand Down

0 comments on commit 499d1ff

Please sign in to comment.