DVD attachments should never be primary

This commit is contained in:
Jeff Bonhag 2020-06-01 15:43:39 -04:00
parent 4480eb0d88
commit e21fb59380
No known key found for this signature in database
GPG Key ID: 32966F3FB5AC1129
3 changed files with 17 additions and 4 deletions

View File

@ -180,6 +180,10 @@ module VagrantPlugins
errors << I18n.t("vagrant.config.disk.dvd_type_file_required", name: @name, machine: machine.name) errors << I18n.t("vagrant.config.disk.dvd_type_file_required", name: @name, machine: machine.name)
end end
if @type == :dvd && @primary
errors << I18n.t("vagrant.config.disk.dvd_type_primary", name: @name, machine: machine.name)
end
if @file if @file
if !@file.is_a?(String) if !@file.is_a?(String)
errors << I18n.t("vagrant.config.disk.invalid_file_type", file: @file, machine: machine.name) errors << I18n.t("vagrant.config.disk.invalid_file_type", file: @file, machine: machine.name)

View File

@ -1846,6 +1846,9 @@ en:
disk: disk:
dvd_type_file_required: dvd_type_file_required:
A 'file' option is required when defining a disk of type `:dvd` for guest '%{machine}'. A 'file' option is required when defining a disk of type `:dvd` for guest '%{machine}'.
dvd_type_primary: |-
Disks of type ':dvd' cannot be defined as a primary disks. Please
remove the 'primary' argument for disk '%{name}' on guest '%{machine}'.
invalid_ext: |- invalid_ext: |-
Disk type '%{ext}' is not a valid disk extention for '%{name}'. Please pick one of the following supported disk types: %{exts} Disk type '%{ext}' is not a valid disk extention for '%{name}'. Please pick one of the following supported disk types: %{exts}
invalid_type: |- invalid_type: |-

View File

@ -85,18 +85,24 @@ describe VagrantPlugins::Kernel_V2::VagrantConfigDisk do
before do before do
subject.type = :dvd subject.type = :dvd
subject.name = "untitled" subject.name = "untitled"
end
it "is valid with file path set" do
allow(File).to receive(:file?).with(iso_path).and_return(true) allow(File).to receive(:file?).with(iso_path).and_return(true)
subject.file = iso_path subject.file = iso_path
end
it "is valid with test defaults" do
subject.finalize! subject.finalize!
assert_valid assert_valid
end end
it "is invalid if file path is unset" do it "is invalid if file path is unset" do
subject.file = nil
subject.finalize!
assert_invalid
end
it "is invalid if primary" do
subject.primary = true
subject.finalize! subject.finalize!
errors = subject.validate(machine)
assert_invalid assert_invalid
end end
end end