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:
parent
9fc155bf75
commit
c6ee1049aa
11
plugins/hosts/darwin/cap/nfs.rb
Normal file
11
plugins/hosts/darwin/cap/nfs.rb
Normal 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
|
||||
@ -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
|
||||
|
||||
7
templates/nfs/exports_darwin.erb
Normal file
7
templates/nfs/exports_darwin.erb
Normal 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 %>
|
||||
17
test/unit/plugins/hosts/darwin/cap/nfs_test.rb
Normal file
17
test/unit/plugins/hosts/darwin/cap/nfs_test.rb
Normal 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
|
||||
68
test/unit/templates/nfs/exports_darwin_test.rb
Normal file
68
test/unit/templates/nfs/exports_darwin_test.rb
Normal 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
|
||||
Loading…
x
Reference in New Issue
Block a user