From 06f8595bc05646fec4534d010f05815037fa14ce Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 8 Oct 2015 11:37:35 -0400 Subject: [PATCH] kernel/v2: clone option --- plugins/kernel_v2/config/vm.rb | 7 +++++++ templates/locales/en.yml | 1 + test/unit/plugins/kernel_v2/config/vm_test.rb | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index 2de1b343f..acd21f20d 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -29,6 +29,7 @@ module VagrantPlugins attr_accessor :box_download_client_cert attr_accessor :box_download_insecure attr_accessor :box_download_location_trusted + attr_accessor :clone attr_accessor :communicator attr_accessor :graceful_halt_timeout attr_accessor :guest @@ -54,6 +55,7 @@ module VagrantPlugins @box_download_location_trusted = UNSET_VALUE @box_url = UNSET_VALUE @box_version = UNSET_VALUE + @clone = UNSET_VALUE @communicator = UNSET_VALUE @graceful_halt_timeout = UNSET_VALUE @guest = UNSET_VALUE @@ -367,6 +369,7 @@ module VagrantPlugins @box_download_location_trusted = false if @box_download_location_trusted == UNSET_VALUE @box_url = nil if @box_url == UNSET_VALUE @box_version = nil if @box_version == UNSET_VALUE + @clone = nil if @clone == UNSET_VALUE @communicator = nil if @communicator == UNSET_VALUE @graceful_halt_timeout = 60 if @graceful_halt_timeout == UNSET_VALUE @guest = nil if @guest == UNSET_VALUE @@ -558,6 +561,10 @@ module VagrantPlugins errors << I18n.t("vagrant.config.vm.box_missing") end + if box && clone + errors << I18n.t("vagrant.config.vm.clone_and_box") + end + errors << I18n.t("vagrant.config.vm.hostname_invalid_characters") if \ @hostname && @hostname !~ /^[a-z0-9][-.a-z0-9]*$/i diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 929962453..ff2f1fac1 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -1404,6 +1404,7 @@ en: box_download_checksum_notblank: |- Checksum specified but must also specify "box_download_checksum_type" box_missing: "A box must be specified." + clone_and_box: "Only one of clone or box can be specified." hostname_invalid_characters: |- The hostname set for the VM should only contain letters, numbers, hyphens or dots. It cannot start with a hyphen or dot. diff --git a/test/unit/plugins/kernel_v2/config/vm_test.rb b/test/unit/plugins/kernel_v2/config/vm_test.rb index 3d9b01213..146b3f344 100644 --- a/test/unit/plugins/kernel_v2/config/vm_test.rb +++ b/test/unit/plugins/kernel_v2/config/vm_test.rb @@ -65,6 +65,12 @@ describe VagrantPlugins::Kernel_V2::VMConfig do subject.finalize! assert_valid end + + it "is invalid if clone is set" do + subject.clone = "foo" + subject.finalize! + assert_invalid + end end context "#box_check_update" do