Add machine name to error messages

This commit is contained in:
Jeff Bonhag 2020-06-30 16:55:44 -04:00
parent 52c1267b2c
commit 33ef2ca017
No known key found for this signature in database
GPG Key ID: 32966F3FB5AC1129
3 changed files with 10 additions and 9 deletions

View File

@ -911,19 +911,21 @@ module VagrantPlugins
duplicate_names = disk_names.find_all { |d| disk_names.count(d) > 1 }
if duplicate_names.any?
errors << I18n.t("vagrant.config.vm.multiple_disk_names_error",
names: duplicate_names.uniq.join("\n"))
name: machine.name,
disk_names: duplicate_names.uniq.join("\n"))
end
disk_files = @disks.map { |d| d.file }
duplicate_files = disk_files.find_all { |d| d && disk_files.count(d) > 1 }
if duplicate_files.any?
errors << I18n.t("vagrant.config.vm.multiple_disk_files_error",
files: duplicate_files.uniq.join("\n"))
name: machine.name,
disk_files: duplicate_files.uniq.join("\n"))
end
@disks.each do |d|
error = d.validate(machine)
errors.concat error if !error.empty?
errors.concat(error) if !error.empty?
end
# Validate clout_init_configs

View File

@ -1996,16 +1996,16 @@ en:
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: |-
The following disk files are used multiple times in the disk
configuration:
configuration for the VM '%{name}':
%{files}
%{disk_files}
Each disk file may only be attached to a VM once.
multiple_disk_names_error: |-
The following disks names are defined multiple times in the disk
configuration:
configuration for the VM '%{name}':
%{names}
%{disk_names}
Disk names must be unique.
multiple_networks_set_hostname: "Multiple networks have set `:hostname`"
@ -2267,7 +2267,6 @@ en:
configure_disks:
start: "Configuring storage mediums..."
floppy_not_supported: "Floppy disk configuration not yet supported. Skipping disk '%{name}'..."
dvd_not_supported: "DVD disk configuration not yet supported. Skipping disk '%{name}'..."
shrink_size_not_supported: |-
VirtualBox does not support shrinking disk sizes. Cannot shrink '%{name}' disks size.
create_disk: |-

View File

@ -8,7 +8,7 @@ describe VagrantPlugins::Kernel_V2::VMConfig do
subject { described_class.new }
let(:provider) { double("provider") }
let(:machine) { double("machine", provider: provider, provider_name: "provider") }
let(:machine) { double("machine", provider: provider, provider_name: "provider", name: "default") }
def assert_invalid
errors = subject.validate(machine)