kernel/v2: boxes can be optional if a provider says so

/cc @fgrehm - For the DOcker provider, we can now make boxes optional. :)
No more dummy boxes!
This commit is contained in:
Mitchell Hashimoto 2014-04-09 20:13:38 -07:00
parent 316aaa69fe
commit 61ffa53134
2 changed files with 21 additions and 1 deletions

View File

@ -469,7 +469,11 @@ module VagrantPlugins
def validate(machine)
errors = _detected_errors
errors << I18n.t("vagrant.config.vm.box_missing") if !box
if !box && !machine.provider_options[:box_optional]
errors << I18n.t("vagrant.config.vm.box_missing")
end
errors << I18n.t("vagrant.config.vm.hostname_invalid_characters") if \
@hostname && @hostname !~ /^[a-z0-9][-.a-z0-9]+$/i

View File

@ -28,6 +28,7 @@ describe VagrantPlugins::Kernel_V2::VMConfig do
env.stub(root_path: nil)
machine.stub(env: env)
machine.stub(provider_config: nil)
machine.stub(provider_options: {})
subject.box = "foo"
end
@ -44,6 +45,21 @@ describe VagrantPlugins::Kernel_V2::VMConfig do
end
end
describe "#box" do
it "is required" do
subject.box = nil
subject.finalize!
assert_invalid
end
it "is not required if the provider says so" do
machine.provider_options[:box_optional] = true
subject.box = nil
subject.finalize!
assert_valid
end
end
context "#box_check_update" do
it "defaults to true" do
subject.finalize!