core: BoxAdd requires name if old-style box
This commit is contained in:
parent
09e8666296
commit
8f0f0506d6
|
@ -35,8 +35,11 @@ module Vagrant
|
||||||
# Adds a box file directly (no metadata component, versioning,
|
# Adds a box file directly (no metadata component, versioning,
|
||||||
# etc.)
|
# etc.)
|
||||||
def add_direct(env)
|
def add_direct(env)
|
||||||
# TODO: what if we have no name
|
|
||||||
name = env[:box_name]
|
name = env[:box_name]
|
||||||
|
if !name || name == ""
|
||||||
|
raise Errors::BoxAddNameRequired
|
||||||
|
end
|
||||||
|
|
||||||
url = env[:box_url]
|
url = env[:box_url]
|
||||||
provider = env[:box_provider]
|
provider = env[:box_provider]
|
||||||
provider = Array(provider) if provider
|
provider = Array(provider) if provider
|
||||||
|
|
|
@ -120,6 +120,10 @@ module Vagrant
|
||||||
error_key(:batch_multi_error)
|
error_key(:batch_multi_error)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class BoxAddNameRequired < VagrantError
|
||||||
|
error_key(:box_add_name_required)
|
||||||
|
end
|
||||||
|
|
||||||
class BoxAddNoMatchingProvider < VagrantError
|
class BoxAddNoMatchingProvider < VagrantError
|
||||||
error_key(:box_add_no_matching_provider)
|
error_key(:box_add_no_matching_provider)
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,13 +4,6 @@ en:
|
||||||
Machine booted and ready!
|
Machine booted and ready!
|
||||||
boot_waiting: |-
|
boot_waiting: |-
|
||||||
Waiting for machine to boot. This may take a few minutes...
|
Waiting for machine to boot. This may take a few minutes...
|
||||||
box_add_exists: |-
|
|
||||||
The box you're attempting to add already exists. Remove it before
|
|
||||||
adding it again or add it with the `--force` flag.
|
|
||||||
|
|
||||||
Name: %{name}
|
|
||||||
Provider: %{provider}
|
|
||||||
Version: %{version}
|
|
||||||
box_add_with_version: |-
|
box_add_with_version: |-
|
||||||
Adding box '%{name}' (v%{version}) for '%{provider}' provider...
|
Adding box '%{name}' (v%{version}) for '%{provider}' provider...
|
||||||
box_added: |-
|
box_added: |-
|
||||||
|
@ -263,6 +256,17 @@ en:
|
||||||
|
|
||||||
If the box appears to be booting properly, you may want to increase
|
If the box appears to be booting properly, you may want to increase
|
||||||
the timeout ("config.vm.boot_timeout") value.
|
the timeout ("config.vm.boot_timeout") value.
|
||||||
|
box_add_exists: |-
|
||||||
|
The box you're attempting to add already exists. Remove it before
|
||||||
|
adding it again or add it with the `--force` flag.
|
||||||
|
|
||||||
|
Name: %{name}
|
||||||
|
Provider: %{provider}
|
||||||
|
Version: %{version}
|
||||||
|
box_add_name_required: |-
|
||||||
|
A name is required when adding a box file directly. Please pass
|
||||||
|
the `--name` parameter to `vagrant box add`. See
|
||||||
|
`vagrant box add -h` for more help.
|
||||||
box_checksum_invalid_type: |-
|
box_checksum_invalid_type: |-
|
||||||
The specified checksum type is not supported by Vagrant: %{type}.
|
The specified checksum type is not supported by Vagrant: %{type}.
|
||||||
Vagrant supports the following checksum types:
|
Vagrant supports the following checksum types:
|
||||||
|
|
|
@ -96,6 +96,18 @@ describe Vagrant::Action::Builtin::BoxAdd do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "raises an error if no name is given" do
|
||||||
|
box_path = iso_env.box2_file(:virtualbox)
|
||||||
|
|
||||||
|
env[:box_url] = box_path.to_s
|
||||||
|
|
||||||
|
box_collection.should_receive(:add).never
|
||||||
|
app.should_receive(:call).never
|
||||||
|
|
||||||
|
expect { subject.call(env) }.
|
||||||
|
to raise_error(Vagrant::Errors::BoxAddNameRequired)
|
||||||
|
end
|
||||||
|
|
||||||
it "raises an error if the box already exists" do
|
it "raises an error if the box already exists" do
|
||||||
box_path = iso_env.box2_file(:virtualbox)
|
box_path = iso_env.box2_file(:virtualbox)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue