Show duplicate values in error messages
This also prevents nil showing up as a duplicate value for disk configs when `file` is undefined.
This commit is contained in:
parent
ff9f9c40e8
commit
52c1267b2c
@ -908,17 +908,17 @@ module VagrantPlugins
|
|||||||
end
|
end
|
||||||
|
|
||||||
disk_names = @disks.map { |d| d.name }
|
disk_names = @disks.map { |d| d.name }
|
||||||
duplicate_names = disk_names.detect{ |d| disk_names.count(d) > 1 }
|
duplicate_names = disk_names.find_all { |d| disk_names.count(d) > 1 }
|
||||||
if duplicate_names && duplicate_names.size
|
if duplicate_names.any?
|
||||||
errors << I18n.t("vagrant.config.vm.multiple_disk_names_error",
|
errors << I18n.t("vagrant.config.vm.multiple_disk_names_error",
|
||||||
name: duplicate_names)
|
names: duplicate_names.uniq.join("\n"))
|
||||||
end
|
end
|
||||||
|
|
||||||
disk_files = @disks.map { |d| d.file }
|
disk_files = @disks.map { |d| d.file }
|
||||||
duplicate_files = disk_files.detect { |d| disk_files.count(d) > 1 }
|
duplicate_files = disk_files.find_all { |d| d && disk_files.count(d) > 1 }
|
||||||
if duplicate_files && duplicate_files.size
|
if duplicate_files.any?
|
||||||
errors << I18n.t("vagrant.config.vm.multiple_disk_files_error",
|
errors << I18n.t("vagrant.config.vm.multiple_disk_files_error",
|
||||||
file: duplicate_files)
|
files: duplicate_files.uniq.join("\n"))
|
||||||
end
|
end
|
||||||
|
|
||||||
@disks.each do |d|
|
@disks.each do |d|
|
||||||
|
|||||||
@ -1995,13 +1995,19 @@ en:
|
|||||||
multiple_primary_disks_error: |-
|
multiple_primary_disks_error: |-
|
||||||
There are more than one primary disks defined for guest '%{name}'. Please ensure that only one disk has been defined as a primary disk.
|
There are more than one primary disks defined for guest '%{name}'. Please ensure that only one disk has been defined as a primary disk.
|
||||||
multiple_disk_files_error: |-
|
multiple_disk_files_error: |-
|
||||||
The following disk file is used multiple times in the disk configuration:
|
The following disk files are used multiple times in the disk
|
||||||
|
configuration:
|
||||||
|
|
||||||
%{file}
|
%{files}
|
||||||
|
|
||||||
Each disk file may only be attached to a VM once.
|
Each disk file may only be attached to a VM once.
|
||||||
multiple_disk_names_error: |-
|
multiple_disk_names_error: |-
|
||||||
Duplicate disk names defined: '%{name}'. Disk names must be unique.
|
The following disks names are defined multiple times in the disk
|
||||||
|
configuration:
|
||||||
|
|
||||||
|
%{names}
|
||||||
|
|
||||||
|
Disk names must be unique.
|
||||||
multiple_networks_set_hostname: "Multiple networks have set `:hostname`"
|
multiple_networks_set_hostname: "Multiple networks have set `:hostname`"
|
||||||
name_invalid: |-
|
name_invalid: |-
|
||||||
The sub-VM name '%{name}' is invalid. Please don't use special characters.
|
The sub-VM name '%{name}' is invalid. Please don't use special characters.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user