Only grab provider_config if provider key exists and config isn't empty

This commit is contained in:
Brian Cain 2020-05-18 15:10:53 -07:00
parent 1579ac9c3a
commit 13c91d68a6
No known key found for this signature in database
GPG Key ID: 9FC4639B2E4510A0
2 changed files with 7 additions and 4 deletions

View File

@ -143,8 +143,11 @@ module VagrantPlugins
def self.create_disk(machine, disk_config)
machine.ui.detail(I18n.t("vagrant.cap.configure_disks.create_disk", name: disk_config.name))
disk_provider_config = {}
disk_provider_config = disk_config.provider_config[:hyperv] if disk_config.provider_config
# Convert any shortcut options for powershell commands
if disk_config.provider_config && disk_config.provider_config.key?(:hyperv)
disk_provider_config = disk_config.provider_config[:hyperv]
end
if !disk_provider_config.empty?
disk_provider_config = convert_size_vars!(disk_provider_config)
end

View File

@ -207,10 +207,10 @@ describe VagrantPlugins::HyperV::Cap::ConfigureDisks do
it "creates a disk and attaches it to a guest" do
expect(machine).to receive(:data_dir).and_return(data_dir)
expect(driver).to receive(:create_disk).with(disk_file, disk_config.size, nil)
expect(driver).to receive(:create_disk).with(disk_file, disk_config.size, {})
expect(driver).to receive(:get_disk).with(disk_file).and_return(disk)
expect(driver).to receive(:attach_disk).with(disk_file, nil)
expect(driver).to receive(:attach_disk).with(disk_file, {})
subject.create_disk(machine, disk_config)
end