Merge pull request #10592 from ichesnokov/master

Make sure that ips array contains unique values
This commit is contained in:
Sophia Castellarin 2020-03-30 10:31:48 -04:00 committed by GitHub
commit 54972c045b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -67,6 +67,7 @@ module VagrantPlugins
nfs_opts_setup(folders)
folders = folder_dupe_check(folders)
ips = ips.uniq
output = Vagrant::Util::TemplateRenderer.render('nfs/exports_linux',
uuid: id,
ips: ips,

View File

@ -132,16 +132,16 @@ describe VagrantPlugins::HostLinux::Cap::NFS do
end
it "should export new entries" do
cap.nfs_export(env, ui, SecureRandom.uuid, ["127.0.0.1"], "tmp" => {:hostpath => "/tmp"})
cap.nfs_export(env, ui, SecureRandom.uuid, ["127.0.0.1", "127.0.0.1"], "tmp" => {:hostpath => "/tmp"})
exports_content = File.read(exports_path)
expect(exports_content).to match(/\/tmp.*127\.0\.0\.1/)
expect(exports_content.scan(/\/tmp.*127\.0\.0\.1/).length).to be(1)
end
it "should not remove existing entries" do
File.write(exports_path, "/custom/directory hostname1(rw,sync,no_subtree_check)")
cap.nfs_export(env, ui, SecureRandom.uuid, ["127.0.0.1"], "tmp" => {:hostpath => "/tmp"})
cap.nfs_export(env, ui, SecureRandom.uuid, ["127.0.0.1", "127.0.0.1"], "tmp" => {:hostpath => "/tmp"})
exports_content = File.read(exports_path)
expect(exports_content).to match(/\/tmp.*127\.0\.0\.1/)
expect(exports_content.scan(/\/tmp.*127\.0\.0\.1/).length).to be(1)
expect(exports_content).to match(/\/custom\/directory.*hostname1/)
end