core: disallow brackets in VM names [GH-4319]
This commit is contained in:
parent
e198652e75
commit
b675be383b
|
@ -36,6 +36,8 @@ BUG FIXES:
|
|||
- core: Cleanup all temp files. [GH-4103]
|
||||
- core: User curlrc is not loaded, preventing strange download issues.
|
||||
[GH-4328]
|
||||
- core: VM names may no longer contain brackets, since they cause
|
||||
issues with some providers. [GH-4319]
|
||||
- commands/package: base package won't crash with exception [GH-4017]
|
||||
- commands/rsync-auto: Destroyed machines won't raise exceptions. [GH-4031]
|
||||
- communicators/ssh: Nicer error if remote unexpectedly disconects. [GH-4038]
|
||||
|
|
|
@ -660,6 +660,15 @@ module VagrantPlugins
|
|||
end
|
||||
end
|
||||
|
||||
# Validate sub-VMs if there are any
|
||||
@__defined_vms.each do |name, _|
|
||||
if name =~ /[\[\]\{\}]/
|
||||
errors["vm"] << I18n.t(
|
||||
"vagrant.config.vm.name_invalid",
|
||||
name: name)
|
||||
end
|
||||
end
|
||||
|
||||
errors
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1250,6 +1250,8 @@ en:
|
|||
hostname_invalid_characters: |-
|
||||
The hostname set for the VM should only contain letters, numbers,
|
||||
hyphens or dots. It cannot start with a hyphen or dot.
|
||||
name_invalid: |-
|
||||
The sub-VM name '%{name}' is invalid. Please don't use special characters.
|
||||
network_ip_ends_in_one: |-
|
||||
You assigned a static IP ending in ".1" to this machine.
|
||||
This is very often used by the router and can cause the
|
||||
|
|
|
@ -121,6 +121,27 @@ describe VagrantPlugins::Kernel_V2::VMConfig do
|
|||
end
|
||||
end
|
||||
|
||||
describe "#define" do
|
||||
it "should allow regular names" do
|
||||
subject.define "foo"
|
||||
subject.finalize!
|
||||
|
||||
assert_valid
|
||||
end
|
||||
|
||||
[
|
||||
"foo [1]",
|
||||
"bar {2}",
|
||||
].each do |name|
|
||||
it "should disallow names with brackets" do
|
||||
subject.define name
|
||||
subject.finalize!
|
||||
|
||||
assert_invalid
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#guest" do
|
||||
it "is nil by default" do
|
||||
subject.finalize!
|
||||
|
|
Loading…
Reference in New Issue