Use scoped hash overrides for high-level config
This commit is contained in:
parent
0c612f695f
commit
102e8f23d6
|
@ -18,6 +18,11 @@ module Vagrant
|
||||||
#
|
#
|
||||||
module ScopedHashOverride
|
module ScopedHashOverride
|
||||||
def scoped_hash_override(original, scope)
|
def scoped_hash_override(original, scope)
|
||||||
|
# Convert the scope to a string in case a symbol was given since
|
||||||
|
# we use string comparisons for everything.
|
||||||
|
scope = scope.to_s
|
||||||
|
|
||||||
|
# Shallow copy the hash for the result
|
||||||
result = original.dup
|
result = original.dup
|
||||||
|
|
||||||
original.each do |key, value|
|
original.each do |key, value|
|
||||||
|
|
|
@ -3,6 +3,7 @@ require "set"
|
||||||
require "log4r"
|
require "log4r"
|
||||||
|
|
||||||
require "vagrant/util/network_ip"
|
require "vagrant/util/network_ip"
|
||||||
|
require "vagrant/util/scoped_hash_override"
|
||||||
|
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module ProviderVirtualBox
|
module ProviderVirtualBox
|
||||||
|
@ -14,6 +15,7 @@ module VagrantPlugins
|
||||||
# This handles all the `config.vm.network` configurations.
|
# This handles all the `config.vm.network` configurations.
|
||||||
class Network
|
class Network
|
||||||
include Vagrant::Util::NetworkIP
|
include Vagrant::Util::NetworkIP
|
||||||
|
include Vagrant::Util::ScopedHashOverride
|
||||||
|
|
||||||
def initialize(app, env)
|
def initialize(app, env)
|
||||||
@logger = Log4r::Logger.new("vagrant::plugins::virtualbox::network")
|
@logger = Log4r::Logger.new("vagrant::plugins::virtualbox::network")
|
||||||
|
@ -43,9 +45,10 @@ module VagrantPlugins
|
||||||
options = nil
|
options = nil
|
||||||
options = args.last if args.last.is_a?(Hash)
|
options = args.last if args.last.is_a?(Hash)
|
||||||
options ||= {}
|
options ||= {}
|
||||||
|
options = scoped_hash_override(options, :virtualbox)
|
||||||
|
|
||||||
# Figure out the slot that this adapter will go into
|
# Figure out the slot that this adapter will go into
|
||||||
slot = options[:virtualbox__adapter]
|
slot = options[:adapter]
|
||||||
if !slot
|
if !slot
|
||||||
if available_slots.empty?
|
if available_slots.empty?
|
||||||
# TODO: Error that we have no room for this adapter
|
# TODO: Error that we have no room for this adapter
|
||||||
|
@ -59,13 +62,13 @@ module VagrantPlugins
|
||||||
if type == :private_network
|
if type == :private_network
|
||||||
# private_network = hostonly
|
# private_network = hostonly
|
||||||
|
|
||||||
config_args = [args[0]]
|
config_args = [args[0], options]
|
||||||
data = [:hostonly, config_args]
|
data = [:hostonly, config_args]
|
||||||
elsif type == :public_network
|
elsif type == :public_network
|
||||||
# public_network = bridged
|
# public_network = bridged
|
||||||
|
|
||||||
config_args = []
|
config_args = [options]
|
||||||
data = [:bridged, config_args]
|
data = [:bridged, config_args]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Store it!
|
# Store it!
|
||||||
|
|
Loading…
Reference in New Issue