Handle box overrides in provider-specific overrides properly [GH-1617]
This commit is contained in:
parent
780a312fc9
commit
661b982502
|
@ -13,6 +13,8 @@ IMPROVEMENTS:
|
||||||
BUG FIXES:
|
BUG FIXES:
|
||||||
|
|
||||||
- `vagrant package --base` works again. [GH-1615]
|
- `vagrant package --base` works again. [GH-1615]
|
||||||
|
- Box overrides specified in provider config overrides no longer
|
||||||
|
fail to detect the box. [GH-1617]
|
||||||
|
|
||||||
## 1.2.1 (April 17, 2013)
|
## 1.2.1 (April 17, 2013)
|
||||||
|
|
||||||
|
|
|
@ -328,32 +328,16 @@ module Vagrant
|
||||||
config, config_warnings, config_errors = \
|
config, config_warnings, config_errors = \
|
||||||
@config_loader.load([:default, :home, :root, vm_config_key])
|
@config_loader.load([:default, :home, :root, vm_config_key])
|
||||||
|
|
||||||
|
# Determine the possible box formats for any boxes and find the box
|
||||||
|
box_formats = provider_options[:box_format] || provider
|
||||||
box = nil
|
box = nil
|
||||||
if config.vm.box
|
box = find_box(config.vm.box, box_formats) if config.vm.box
|
||||||
# Determine the box formats we support
|
|
||||||
formats = provider_options[:box_format]
|
|
||||||
formats ||= provider
|
|
||||||
formats = [formats] if !formats.is_a?(Array)
|
|
||||||
|
|
||||||
@logger.info("Provider-supported box formats: #{formats.inspect}")
|
# Set this variable in order to keep track of if the box changes
|
||||||
formats.each do |format|
|
# too many times.
|
||||||
begin
|
original_box = config.vm.box
|
||||||
box = boxes.find(config.vm.box, format.to_s)
|
|
||||||
rescue Errors::BoxUpgradeRequired
|
|
||||||
# Upgrade the box if we must
|
|
||||||
@logger.info("Upgrading box during config load: #{config.vm.box}")
|
|
||||||
boxes.upgrade(config.vm.box)
|
|
||||||
retry
|
|
||||||
end
|
|
||||||
|
|
||||||
# If a box was found, we exit
|
|
||||||
if box
|
|
||||||
@logger.info("Box found with format: #{format}")
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
load_box_and_overrides = lambda do
|
||||||
# If a box was found, then we attempt to load the Vagrantfile for
|
# If a box was found, then we attempt to load the Vagrantfile for
|
||||||
# that box. We don't require a box since we allow providers to download
|
# that box. We don't require a box since we allow providers to download
|
||||||
# boxes and so on.
|
# boxes and so on.
|
||||||
|
@ -381,6 +365,22 @@ module Vagrant
|
||||||
@config_loader.load([:default, box_config_key, :home, :root, vm_config_key, provider_override_key])
|
@config_loader.load([:default, box_config_key, :home, :root, vm_config_key, provider_override_key])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if config.vm.box && original_box != config.vm.box
|
||||||
|
# The box changed, probably due to the provider override. Let's
|
||||||
|
# run the configuration one more time with the new box.
|
||||||
|
# TODO: previous original box
|
||||||
|
@logger.info("Box changed to: #{config.vm.box}. Reloading configurations.")
|
||||||
|
original_box = config.vm.box
|
||||||
|
box = find_box(config.vm.box, box_formats)
|
||||||
|
|
||||||
|
# Recurse so that we reload all the configurations
|
||||||
|
load_box_and_overrides.call
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Load the box and overrides configuration
|
||||||
|
load_box_and_overrides.call
|
||||||
|
|
||||||
# Get the provider configuration from the final loaded configuration
|
# Get the provider configuration from the final loaded configuration
|
||||||
provider_config = config.vm.get_provider_config(provider)
|
provider_config = config.vm.get_provider_config(provider)
|
||||||
|
|
||||||
|
@ -686,6 +686,39 @@ module Vagrant
|
||||||
Pathname.new(path)
|
Pathname.new(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# This finds a box for the given name and formats, or returns nil
|
||||||
|
# if the box isn't found.
|
||||||
|
#
|
||||||
|
# @param [String] name Name of the box
|
||||||
|
# @param [Array<Symbol>] formats The formats to search for the box.
|
||||||
|
# @return [Box]
|
||||||
|
def find_box(name, formats)
|
||||||
|
# Determine the box formats we support
|
||||||
|
formats = [formats] if !formats.is_a?(Array)
|
||||||
|
|
||||||
|
@logger.info("Provider-supported box formats: #{formats.inspect}")
|
||||||
|
formats.each do |format|
|
||||||
|
box = nil
|
||||||
|
|
||||||
|
begin
|
||||||
|
box = boxes.find(name, format.to_s)
|
||||||
|
rescue Errors::BoxUpgradeRequired
|
||||||
|
# Upgrade the box if we must
|
||||||
|
@logger.info("Upgrading box during config load: #{name}")
|
||||||
|
boxes.upgrade(name)
|
||||||
|
retry
|
||||||
|
end
|
||||||
|
|
||||||
|
# If a box was found, we exit
|
||||||
|
if box
|
||||||
|
@logger.info("Box found with format: #{format}")
|
||||||
|
return box
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
# Finds the Vagrantfile in the given directory.
|
# Finds the Vagrantfile in the given directory.
|
||||||
#
|
#
|
||||||
# @param [Pathname] path Path to search in.
|
# @param [Pathname] path Path to search in.
|
||||||
|
|
Loading…
Reference in New Issue