From a786bb53d091ba1c6891a86acfa00f853042b526 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 23 Jul 2013 12:39:36 -0700 Subject: [PATCH] --provider on box add supports any format of that provider --- CHANGELOG.md | 2 ++ lib/vagrant/action/builtin/box_add.rb | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82844e9b9..1d07ad30b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ IMPROVEMENTS: - Vagrant will show an error if VirtualBox 4.2.14 is running. - Added provider to BoxNotFound error message. [GH-1692] - If Ansible fails to run properly, show an error message. [GH-1699] + - Adding a box with the `--provider` flag will now allow a box for + any of that provider's supported formats. BUG FIXES: diff --git a/lib/vagrant/action/builtin/box_add.rb b/lib/vagrant/action/builtin/box_add.rb index f0813092f..380a2cc39 100644 --- a/lib/vagrant/action/builtin/box_add.rb +++ b/lib/vagrant/action/builtin/box_add.rb @@ -44,12 +44,23 @@ module Vagrant return end + box_formats = env[:box_provider] + if box_formats + # Determine the formats a box can support and allow the box to + # be any of those formats. + provider_plugin = Vagrant.plugin("2").manager.providers[env[:box_provider]] + if provider_plugin + box_formats = provider_plugin[1][:box_format] + box_formats ||= env[:box_provider] + end + end + # Add the box env[:ui].info I18n.t("vagrant.actions.box.add.adding", :name => env[:box_name]) added_box = nil begin added_box = env[:box_collection].add( - @temp_path, env[:box_name], env[:box_provider], env[:box_force]) + @temp_path, env[:box_name], box_formats, env[:box_force]) rescue Vagrant::Errors::BoxUpgradeRequired # Upgrade the box env[:box_collection].upgrade(env[:box_name])