core: don't allow version for old-style box [GH-3260]

This commit is contained in:
Mitchell Hashimoto 2014-04-02 09:32:34 -07:00
parent 2e0142168e
commit 32d86ca42b
5 changed files with 29 additions and 0 deletions

View File

@ -24,6 +24,7 @@ BUG FIXES:
- core: Better error message when adding a box with a malformed version. [GH-3332]
- core: Fix a rare issue where vagrant up would complain it couldn't
check version of a box that doesn't exist. [GH-3326]
- core: Box version constraint can't be specified with old-style box. [GH-3260]
- commands/box: Show versions when listing. [GH-3316]
- commands/box: Outdated check can list local boxes that are newer. [GH-3321]
- commands/status: Machine readable output contains the target. [GH-3218]

View File

@ -119,6 +119,10 @@ module Vagrant
raise Errors::BoxAddNameRequired
end
if env[:box_version]
raise Errors::BoxAddDirectVersion
end
provider = env[:box_provider]
provider = Array(provider) if provider

View File

@ -120,6 +120,10 @@ module Vagrant
error_key(:batch_multi_error)
end
class BoxAddDirectVersion < VagrantError
error_key(:box_add_direct_version)
end
class BoxAddMetadataMultiURL < VagrantError
error_key(:box_add_metadata_multi_url)
end

View File

@ -336,6 +336,11 @@ en:
Name: %{name}
Provider: %{provider}
Version: %{version}
box_add_direct_version: |-
You specified a box version constraint with a direct box file
path. Box version constraints only work with boxes from Vagrant
Cloud or a custom box host. Please remove the version constraint
and try again.
box_add_metadata_multi_url: |-
Multiple URLs for a box can't be specified when adding
versioned boxes. Please specify a single URL to the box

View File

@ -177,6 +177,21 @@ describe Vagrant::Action::Builtin::BoxAdd do
to raise_error(Vagrant::Errors::DownloaderError)
end
it "raises an error if a version was specified" do
box_path = iso_env.box2_file(:virtualbox)
env[:box_name] = "foo"
env[:box_url] = box_path.to_s
env[:box_version] = "1"
expect(box_collection).to receive(:add).never
expect(app).to receive(:call).never
expect { subject.call(env) }.
to raise_error(Vagrant::Errors::BoxAddDirectVersion)
end
it "force adds if exists and specified" do
box_path = iso_env.box2_file(:virtualbox)