core: Environment#config_global is gone!
This commit is contained in:
parent
e3a67f7ab6
commit
7549704c5b
|
@ -23,7 +23,8 @@ module Vagrant
|
||||||
@app = app
|
@app = app
|
||||||
|
|
||||||
env["package.files"] ||= {}
|
env["package.files"] ||= {}
|
||||||
env["package.output"] ||= env[:global_config].package.name
|
env["package.output"] ||= env[:machine].package.name
|
||||||
|
env["package.output"] ||= "package.box"
|
||||||
end
|
end
|
||||||
|
|
||||||
def call(env)
|
def call(env)
|
||||||
|
|
|
@ -236,39 +236,25 @@ module Vagrant
|
||||||
@_boxes ||= BoxCollection.new(boxes_path, temp_dir_root: tmp_path)
|
@_boxes ||= BoxCollection.new(boxes_path, temp_dir_root: tmp_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
# This is the global config, comprised of loading configuration from
|
# Returns the {Config::Loader} that can be used to load Vagrantflies
|
||||||
# the default, home, and root Vagrantfiles. This configuration is only
|
# given the settings of this environment.
|
||||||
# really useful for reading the list of virtual machines, since each
|
|
||||||
# individual VM can override _most_ settings.
|
|
||||||
#
|
#
|
||||||
# This is lazy-loaded upon first use.
|
# @return [Config::Loader]
|
||||||
#
|
def config_loader
|
||||||
# @return [Object]
|
return @config_loader if @config_loader
|
||||||
def config_global
|
|
||||||
return @config_global if @config_global
|
|
||||||
|
|
||||||
@logger.info("Initializing config...")
|
|
||||||
|
|
||||||
home_vagrantfile = nil
|
home_vagrantfile = nil
|
||||||
root_vagrantfile = nil
|
root_vagrantfile = nil
|
||||||
home_vagrantfile = find_vagrantfile(home_path) if home_path
|
home_vagrantfile = find_vagrantfile(home_path) if home_path
|
||||||
root_vagrantfile = find_vagrantfile(root_path, @vagrantfile_name) if root_path
|
if root_path
|
||||||
|
root_vagrantfile = find_vagrantfile(root_path, @vagrantfile_name)
|
||||||
|
end
|
||||||
|
|
||||||
# Create the configuration loader and set the sources that are global.
|
@config_loader = Config::Loader.new(
|
||||||
# We use this to load the configuration, and the list of machines we are
|
Config::VERSIONS, Config::VERSIONS_ORDER)
|
||||||
# managing. Then, the actual individual configuration is loaded for
|
|
||||||
# each {#machine} call.
|
|
||||||
@config_loader = Config::Loader.new(Config::VERSIONS, Config::VERSIONS_ORDER)
|
|
||||||
@config_loader.set(:home, home_vagrantfile) if home_vagrantfile
|
@config_loader.set(:home, home_vagrantfile) if home_vagrantfile
|
||||||
@config_loader.set(:root, root_vagrantfile) if root_vagrantfile
|
@config_loader.set(:root, root_vagrantfile) if root_vagrantfile
|
||||||
|
@config_loader
|
||||||
# Make the initial call to get the "global" config. This is mostly
|
|
||||||
# only useful to get the list of machines that we are managing.
|
|
||||||
# Because of this, we ignore any warnings or errors.
|
|
||||||
@config_global, _ = @config_loader.load([:home, :root])
|
|
||||||
|
|
||||||
# Return the config
|
|
||||||
@config_global
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# This defines a hook point where plugin action hooks that are registered
|
# This defines a hook point where plugin action hooks that are registered
|
||||||
|
@ -379,7 +365,7 @@ module Vagrant
|
||||||
end
|
end
|
||||||
|
|
||||||
def vagrantfile
|
def vagrantfile
|
||||||
@vagrantfile ||= Vagrantfile.new(@config_loader, [:home, :root])
|
@vagrantfile ||= Vagrantfile.new(config_loader, [:home, :root])
|
||||||
end
|
end
|
||||||
|
|
||||||
# Unload the environment, running completion hooks. The environment
|
# Unload the environment, running completion hooks. The environment
|
||||||
|
@ -413,7 +399,7 @@ module Vagrant
|
||||||
# that shouldn't be valid anymore, but we respect it here by assuming
|
# that shouldn't be valid anymore, but we respect it here by assuming
|
||||||
# its old behavior. No need to deprecate this because I thin it is
|
# its old behavior. No need to deprecate this because I thin it is
|
||||||
# fairly harmless.
|
# fairly harmless.
|
||||||
host_klass = config_global.vagrant.host
|
host_klass = vagrantfile.config.vagrant.host
|
||||||
host_klass = nil if host_klass == :detect
|
host_klass = nil if host_klass == :detect
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
@ -447,7 +433,6 @@ module Vagrant
|
||||||
{
|
{
|
||||||
:action_runner => action_runner,
|
:action_runner => action_runner,
|
||||||
:box_collection => boxes,
|
:box_collection => boxes,
|
||||||
:global_config => config_global,
|
|
||||||
:hook => method(:hook),
|
:hook => method(:hook),
|
||||||
:host => host,
|
:host => host,
|
||||||
:gems_path => gems_path,
|
:gems_path => gems_path,
|
||||||
|
|
|
@ -9,6 +9,10 @@ module Vagrant
|
||||||
# loading the configuration of a specific machine/provider combo,
|
# loading the configuration of a specific machine/provider combo,
|
||||||
# etc.
|
# etc.
|
||||||
class Vagrantfile
|
class Vagrantfile
|
||||||
|
# This is the configuration loaded as-is given the loader and
|
||||||
|
# keys to #initialize.
|
||||||
|
attr_reader :config
|
||||||
|
|
||||||
# Initializes by loading a Vagrantfile.
|
# Initializes by loading a Vagrantfile.
|
||||||
#
|
#
|
||||||
# @param [Config::Loader] loader Configuration loader that should
|
# @param [Config::Loader] loader Configuration loader that should
|
||||||
|
|
|
@ -13,6 +13,24 @@ describe Vagrant::Vagrantfile do
|
||||||
|
|
||||||
subject { described_class.new(loader, keys) }
|
subject { described_class.new(loader, keys) }
|
||||||
|
|
||||||
|
describe "#config" do
|
||||||
|
before do
|
||||||
|
keys << :test
|
||||||
|
end
|
||||||
|
|
||||||
|
def configure(&block)
|
||||||
|
loader.set(:test, [["2", block]])
|
||||||
|
end
|
||||||
|
|
||||||
|
it "exposes the global configuration" do
|
||||||
|
configure do |config|
|
||||||
|
config.vm.box = "what"
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(subject.config.vm.box).to eq("what")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "#machine_config" do
|
describe "#machine_config" do
|
||||||
let(:iso_env) { isolated_environment }
|
let(:iso_env) { isolated_environment }
|
||||||
let(:boxes) { Vagrant::BoxCollection.new(iso_env.boxes_dir) }
|
let(:boxes) { Vagrant::BoxCollection.new(iso_env.boxes_dir) }
|
||||||
|
|
Loading…
Reference in New Issue