Darwin: put each NFS export on its own line (#11216)

This commit introduces a Darwin-specific template for NFS exports.  This is almost identical to the standard BSD template except it puts each NFS export on its own line.

This resolves NFS issues discovered in macOS Catalina.
This commit is contained in:
Jeff Bonhag 2019-11-25 15:41:05 -05:00 committed by GitHub
parent 9fc155bf75
commit c6ee1049aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 108 additions and 0 deletions

View File

@ -0,0 +1,11 @@
module VagrantPlugins
module HostDarwin
module Cap
class NFS
def self.nfs_exports_template(environment)
"nfs/exports_darwin"
end
end
end
end
end

View File

@ -55,6 +55,11 @@ module VagrantPlugins
require_relative "cap/configured_ip_addresses"
Cap::ConfiguredIPAddresses
end
host_capability("darwin", "nfs_exports_template") do
require_relative "cap/nfs"
Cap::NFS
end
end
end
end

View File

@ -0,0 +1,7 @@
# VAGRANT-BEGIN: <%= user %> <%= uuid %>
<% folders.each do |dirs, opts| %>
<% dirs.each do |d| %>
<%= d %> <%=opts[:bsd__compiled_nfs_options] %> <%= ips.join(" ") %>
<% end %>
<% end %>
# VAGRANT-END: <%= user %> <%= uuid %>

View File

@ -0,0 +1,17 @@
require_relative "../../../../base"
require_relative "../../../../../../plugins/hosts/darwin/cap/nfs"
describe VagrantPlugins::HostDarwin::Cap::NFS do
include_context "unit"
let(:subject){ VagrantPlugins::HostDarwin::Cap::NFS }
it "exists" do
expect(subject).to_not be(nil)
end
it "should use nfs/exports_darwin as its template" do
expect(subject.nfs_exports_template(nil)).to eq("nfs/exports_darwin")
end
end

View File

@ -0,0 +1,68 @@
require_relative "../../base"
require "vagrant/util/template_renderer"
describe "templates/nfs/exports_darwin" do
let(:template) { "nfs/exports_darwin" }
let(:user) { "501" }
let(:uuid) { "UUID" }
let(:opts) { {:bsd__compiled_nfs_options => "-alldirs -mapall=501:80"} }
let(:ips) { ["172.16.0.2"] }
it "renders the template" do
result = Vagrant::Util::TemplateRenderer.render(template, {
user: user,
uuid: uuid,
folders: []
})
expect(result).to eq <<-EOH.gsub(/^ {6}/, "")
# VAGRANT-BEGIN: 501 UUID
# VAGRANT-END: 501 UUID
EOH
end
context "one nfs mount" do
let(:folders) {
{
["/vagrant"] => opts
}
}
it "renders the template" do
result = Vagrant::Util::TemplateRenderer.render(template, {
user: user,
uuid: uuid,
folders: folders,
ips: ips
})
expect(result).to eq <<-EOH.gsub(/^ {8}/, "")
# VAGRANT-BEGIN: 501 UUID
/vagrant -alldirs -mapall=501:80 172.16.0.2
# VAGRANT-END: 501 UUID
EOH
end
end
context "subdirectory that should also be exported" do
let(:folders) {
{
["/vagrant", "/vagrant/other"] => opts
}
}
it "puts each directory on its own line" do
result = Vagrant::Util::TemplateRenderer.render(template, {
user: user,
uuid: uuid,
folders: folders,
ips: ips
})
expect(result).to eq <<-EOH.gsub(/^ {8}/, "")
# VAGRANT-BEGIN: 501 UUID
/vagrant -alldirs -mapall=501:80 172.16.0.2
/vagrant/other -alldirs -mapall=501:80 172.16.0.2
# VAGRANT-END: 501 UUID
EOH
end
end
end