core: Vagrantfile#machine_config returns more info now
This commit is contained in:
parent
d40dc919d8
commit
506e1a433f
|
@ -300,14 +300,15 @@ module Vagrant
|
|||
end
|
||||
|
||||
@logger.info("Uncached load of machine.")
|
||||
provider_plugin = Vagrant.plugin("2").manager.providers[provider]
|
||||
if !provider_plugin
|
||||
raise Errors::ProviderNotFound, :machine => name, :provider => provider
|
||||
end
|
||||
|
||||
# Extra the provider class and options from the plugin data
|
||||
provider_cls = provider_plugin[0]
|
||||
provider_options = provider_plugin[1]
|
||||
# Load the actual configuration for the machine
|
||||
results = vagrantfile.machine_config(name, provider, boxes)
|
||||
box = results[:box]
|
||||
config = results[:config]
|
||||
config_errors = results[:config_errors]
|
||||
config_warnings = results[:config_warnings]
|
||||
provider_cls = results[:provider_cls]
|
||||
provider_options = results[:provider_options]
|
||||
|
||||
# Determine the machine data directory and pass it to the machine.
|
||||
# XXX: Permissions error here.
|
||||
|
@ -315,10 +316,6 @@ module Vagrant
|
|||
"machines/#{name}/#{provider}")
|
||||
FileUtils.mkdir_p(machine_data_path)
|
||||
|
||||
# Load the actual configuration for the machine
|
||||
config, config_warnings, config_errors, box =
|
||||
vagrantfile.machine_config(name, provider, boxes)
|
||||
|
||||
# If there were warnings or errors we want to output them
|
||||
if !config_warnings.empty? || !config_errors.empty?
|
||||
# The color of the output depends on whether we have warnings
|
||||
|
|
|
@ -58,7 +58,9 @@ module Vagrant
|
|||
:machine => name, :provider => provider
|
||||
end
|
||||
|
||||
box_formats = provider_plugin[1][:box_format] || provider
|
||||
provider_cls = provider_plugin[0]
|
||||
provider_options = provider_plugin[1]
|
||||
box_formats = provider_options[:box_format] || provider
|
||||
|
||||
# Add the sub-machine configuration to the loader and keys
|
||||
vm_config_key = "#{object_id}_machine_#{name}"
|
||||
|
@ -115,7 +117,14 @@ module Vagrant
|
|||
# Load the box and provider overrides
|
||||
load_box_proc.call
|
||||
|
||||
return config, config_warnings, config_errors, box
|
||||
return {
|
||||
box: box,
|
||||
provider_cls: provider_cls,
|
||||
provider_options: provider_options,
|
||||
config: config,
|
||||
config_warnings: config_warnings,
|
||||
config_errors: config_errors,
|
||||
}
|
||||
end
|
||||
|
||||
# Returns a list of the machines that are defined within this
|
||||
|
|
|
@ -59,15 +59,18 @@ describe Vagrant::Vagrantfile do
|
|||
end
|
||||
|
||||
it "should return a basic configured machine" do
|
||||
register_provider("foo")
|
||||
provider_cls = register_provider("foo")
|
||||
|
||||
configure do |config|
|
||||
config.vm.box = "foo"
|
||||
end
|
||||
|
||||
config, _, _, box = subject.machine_config(:default, :foo, boxes)
|
||||
results = subject.machine_config(:default, :foo, boxes)
|
||||
box = results[:box]
|
||||
config = results[:config]
|
||||
expect(config.vm.box).to eq("foo")
|
||||
expect(box).to be_nil
|
||||
expect(results[:provider_cls]).to equal(provider_cls)
|
||||
end
|
||||
|
||||
it "configures with sub-machine config" do
|
||||
|
@ -82,7 +85,8 @@ describe Vagrant::Vagrantfile do
|
|||
end
|
||||
end
|
||||
|
||||
config, _ = subject.machine_config(:foo, :foo, boxes)
|
||||
results = subject.machine_config(:foo, :foo, boxes)
|
||||
config = results[:config]
|
||||
expect(config.vm.box).to eq("base")
|
||||
expect(config.ssh.port).to eq(100)
|
||||
end
|
||||
|
@ -100,7 +104,9 @@ describe Vagrant::Vagrantfile do
|
|||
end
|
||||
VF
|
||||
|
||||
config, _, _, box = subject.machine_config(:default, :foo, boxes)
|
||||
results = subject.machine_config(:default, :foo, boxes)
|
||||
box = results[:box]
|
||||
config = results[:config]
|
||||
expect(config.vm.box).to eq("base")
|
||||
expect(config.ssh.port).to eq(123)
|
||||
expect(box).to_not be_nil
|
||||
|
@ -127,7 +133,9 @@ describe Vagrant::Vagrantfile do
|
|||
end
|
||||
VF
|
||||
|
||||
config, _, _, box = subject.machine_config(:default, :foo, boxes)
|
||||
results = subject.machine_config(:default, :foo, boxes)
|
||||
box = results[:box]
|
||||
config = results[:config]
|
||||
expect(config.vm.box).to eq("base")
|
||||
expect(config.ssh.port).to eq(245)
|
||||
expect(box).to_not be_nil
|
||||
|
@ -148,7 +156,8 @@ describe Vagrant::Vagrantfile do
|
|||
end
|
||||
VF
|
||||
|
||||
config, _ = subject.machine_config(:default, :foo, boxes)
|
||||
results = subject.machine_config(:default, :foo, boxes)
|
||||
config = results[:config]
|
||||
expect(config.vm.box).to eq("base")
|
||||
expect(config.ssh.port).to eq(123)
|
||||
end
|
||||
|
@ -167,12 +176,14 @@ describe Vagrant::Vagrantfile do
|
|||
end
|
||||
|
||||
# Test with the override
|
||||
config, _ = subject.machine_config(:default, :foo, boxes)
|
||||
results = subject.machine_config(:default, :foo, boxes)
|
||||
config = results[:config]
|
||||
expect(config.vm.box).to eq("base")
|
||||
expect(config.ssh.port).to eq(100)
|
||||
|
||||
# Test without the override
|
||||
config, _ = subject.machine_config(:default, :bar, boxes)
|
||||
results = subject.machine_config(:default, :bar, boxes)
|
||||
config = results[:config]
|
||||
expect(config.vm.box).to eq("base")
|
||||
expect(config.ssh.port).to eq(1)
|
||||
end
|
||||
|
@ -200,7 +211,9 @@ describe Vagrant::Vagrantfile do
|
|||
end
|
||||
VF
|
||||
|
||||
config, _, _, box = subject.machine_config(:default, :foo, boxes)
|
||||
results = subject.machine_config(:default, :foo, boxes)
|
||||
config = results[:config]
|
||||
box = results[:box]
|
||||
expect(config.vm.box).to eq("foobox")
|
||||
expect(config.ssh.port).to eq(234)
|
||||
expect(box).to_not be_nil
|
||||
|
|
Loading…
Reference in New Issue