Human friendly error when metadata.json is missing from a box
This commit is contained in:
parent
d40ba7968c
commit
9464796c6d
|
@ -11,6 +11,7 @@ BUG FIXES:
|
|||
so on work properly.
|
||||
- When there is no route to host for SSH, re-establish a new connection.
|
||||
- `vagrant package` once again works, no more nil error. [GH-1423]
|
||||
- Human friendly error when "metadata.json" is missing in a box.
|
||||
|
||||
## 1.1.0 (March 14, 2013)
|
||||
|
||||
|
|
|
@ -43,7 +43,10 @@ module Vagrant
|
|||
@name = name
|
||||
@provider = provider
|
||||
@directory = directory
|
||||
@metadata = JSON.parse(directory.join("metadata.json").read)
|
||||
|
||||
metadata_file = directory.join("metadata.json")
|
||||
raise Errors::BoxMetadataFileNotFound, :name => @name if !metadata_file.file?
|
||||
@metadata = JSON.parse(directory.join("metadata.json").read)
|
||||
|
||||
@logger = Log4r::Logger.new("vagrant::box")
|
||||
end
|
||||
|
|
|
@ -99,6 +99,10 @@ module Vagrant
|
|||
error_key(:unknown_type, "vagrant.actions.box.download")
|
||||
end
|
||||
|
||||
class BoxMetadataFileNotFound < VagrantError
|
||||
error_key(:box_metadata_file_not_found)
|
||||
end
|
||||
|
||||
class BoxNotFound < VagrantError
|
||||
error_key(:box_not_found)
|
||||
end
|
||||
|
|
|
@ -52,6 +52,15 @@ en:
|
|||
Active provider: %{active_provider}
|
||||
Requested provider: %{requested_provider}
|
||||
base_vm_not_found: The base VM with the name '%{name}' was not found.
|
||||
box_metadata_file_not_found: |-
|
||||
The "metadata.json" file for the box '%{name}' was not found.
|
||||
Boxes require this file in order for Vagrant to determine the
|
||||
provider it was made for. If you made the box, please add a
|
||||
"metadata.json" file to it. If someone else made the box, please
|
||||
notify the box creator that the box is corrupt. Documentation for
|
||||
box file format can be found at the URL below:
|
||||
|
||||
http://docs.vagrantup.com/v2/boxes/format.html
|
||||
box_not_found: Box '%{name}' could not be found.
|
||||
box_provider_doesnt_match: |-
|
||||
The box you attempted to add doesn't match the provider you specified.
|
||||
|
|
|
@ -14,6 +14,8 @@ describe Vagrant::Box do
|
|||
let(:directory) { environment.box2("foo", :virtualbox) }
|
||||
let(:instance) { described_class.new(name, provider, directory) }
|
||||
|
||||
subject { described_class.new(name, provider, directory) }
|
||||
|
||||
it "provides the name" do
|
||||
instance.name.should == name
|
||||
end
|
||||
|
@ -38,6 +40,17 @@ describe Vagrant::Box do
|
|||
instance.metadata.should == data
|
||||
end
|
||||
|
||||
context "without a metadata file" do
|
||||
before :each do
|
||||
directory.join("metadata.json").delete
|
||||
end
|
||||
|
||||
it "should raise an exception" do
|
||||
expect { subject }.
|
||||
to raise_error(Vagrant::Errors::BoxMetadataFileNotFound)
|
||||
end
|
||||
end
|
||||
|
||||
describe "destroying" do
|
||||
it "should destroy an existing box" do
|
||||
# Verify that our "box" exists
|
||||
|
|
Loading…
Reference in New Issue