mirror of
https://github.com/hashicorp/vagrant.git
synced 2026-06-04 22:32:49 -04:00
Update how disk_ext default is set
Prior to this commit, the default value of disk_ext was set in the finalize! method, and was really only valid for the virtualbox provider. This commit updates that by moving the step into the validate function, which has access to the machines provider.
This commit is contained in:
parent
a7a779586a
commit
fe7705e694
2 changed files with 13 additions and 4 deletions
|
|
@ -107,8 +107,6 @@ module VagrantPlugins
|
|||
@size = nil if @size == UNSET_VALUE
|
||||
@file = nil if @file == UNSET_VALUE
|
||||
|
||||
@disk_ext = "vdi" if @disk_ext == UNSET_VALUE
|
||||
|
||||
if @primary == UNSET_VALUE
|
||||
@primary = false
|
||||
end
|
||||
|
|
@ -135,7 +133,18 @@ module VagrantPlugins
|
|||
types: DEFAULT_DISK_TYPES.join(', '))
|
||||
end
|
||||
|
||||
if @disk_ext
|
||||
if @disk_ext == UNSET_VALUE
|
||||
# Work around to finalize disk_ext with a valid default per-provider
|
||||
if machine.provider_name == :virtualbox
|
||||
@disk_ext = "vdi"
|
||||
elsif machine.provider_name == :vmware_desktop
|
||||
@disk_ext = nil
|
||||
elsif machine.provider_name == :hyperv
|
||||
@disk_ext = "vhdx"
|
||||
else
|
||||
@disk_ext = "vdi"
|
||||
end
|
||||
elsif @disk_ext
|
||||
@disk_ext = @disk_ext.downcase
|
||||
|
||||
if machine.provider.capability?(:validate_disk_ext)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ describe VagrantPlugins::Kernel_V2::VagrantConfigDisk do
|
|||
subject { described_class.new(type) }
|
||||
|
||||
let(:provider) { double("provider") }
|
||||
let(:machine) { double("machine", provider: provider) }
|
||||
let(:machine) { double("machine", provider: provider, provider_name: :virtualbox) }
|
||||
|
||||
|
||||
def assert_invalid
|
||||
|
|
|
|||
Loading…
Reference in a new issue