core: MixinSyncedFolders#synced_folders does scoped hash override
This commit is contained in:
parent
b4b62daf5c
commit
ae9b74464d
|
@ -1,7 +1,11 @@
|
||||||
|
require 'vagrant/util/scoped_hash_override'
|
||||||
|
|
||||||
module Vagrant
|
module Vagrant
|
||||||
module Action
|
module Action
|
||||||
module Builtin
|
module Builtin
|
||||||
module MixinSyncedFolders
|
module MixinSyncedFolders
|
||||||
|
include Vagrant::Util::ScopedHashOverride
|
||||||
|
|
||||||
# This goes over all the registered synced folder types and returns
|
# This goes over all the registered synced folder types and returns
|
||||||
# the highest priority implementation that is usable for this machine.
|
# the highest priority implementation that is usable for this machine.
|
||||||
def default_synced_folder_type(machine, plugins)
|
def default_synced_folder_type(machine, plugins)
|
||||||
|
@ -96,6 +100,13 @@ module Vagrant
|
||||||
folders.delete("")
|
folders.delete("")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Apply the scoped hash overrides to get the options
|
||||||
|
folders.each do |impl_name, fs|
|
||||||
|
fs.each do |id, data|
|
||||||
|
fs[id] = scoped_hash_override(data, impl_name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return folders
|
return folders
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
require "log4r"
|
require "log4r"
|
||||||
|
|
||||||
require 'vagrant/util/platform'
|
require 'vagrant/util/platform'
|
||||||
require 'vagrant/util/scoped_hash_override'
|
|
||||||
|
|
||||||
require_relative "mixin_synced_folders"
|
require_relative "mixin_synced_folders"
|
||||||
|
|
||||||
|
@ -12,7 +11,6 @@ module Vagrant
|
||||||
# the appropriate synced folder plugin.
|
# the appropriate synced folder plugin.
|
||||||
class SyncedFolders
|
class SyncedFolders
|
||||||
include MixinSyncedFolders
|
include MixinSyncedFolders
|
||||||
include Vagrant::Util::ScopedHashOverride
|
|
||||||
|
|
||||||
def initialize(app, env)
|
def initialize(app, env)
|
||||||
@app = app
|
@app = app
|
||||||
|
@ -28,9 +26,6 @@ module Vagrant
|
||||||
fs.each do |id, data|
|
fs.each do |id, data|
|
||||||
# Log every implementation and their paths
|
# Log every implementation and their paths
|
||||||
@logger.info(" - #{id}: #{data[:hostpath]} => #{data[:guestpath]}")
|
@logger.info(" - #{id}: #{data[:hostpath]} => #{data[:guestpath]}")
|
||||||
|
|
||||||
# Scope hash override
|
|
||||||
fs[id] = scoped_hash_override(data, impl_name)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -98,5 +98,16 @@ describe Vagrant::Action::Builtin::MixinSyncedFolders do
|
||||||
result.length.should == 1
|
result.length.should == 1
|
||||||
result[:default].length.should == 1
|
result[:default].length.should == 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should scope hash override the settings" do
|
||||||
|
folders["root"] = {
|
||||||
|
hostpath: "foo",
|
||||||
|
type: "nfs",
|
||||||
|
nfs__foo: "bar",
|
||||||
|
}
|
||||||
|
|
||||||
|
result = subject.synced_folders(machine)
|
||||||
|
expect(result[:nfs]["root"][:foo]).to eql("bar")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -90,27 +90,5 @@ describe Vagrant::Action::Builtin::SyncedFolders do
|
||||||
|
|
||||||
order.should == [:prepare, :enable]
|
order.should == [:prepare, :enable]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should scope hash override the settings" do
|
|
||||||
actual = nil
|
|
||||||
tracker = Class.new(impl(true, "good")) do
|
|
||||||
define_method(:prepare) do |machine, folders, opts|
|
|
||||||
actual = folders
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
plugins[:tracker] = [tracker, 15]
|
|
||||||
|
|
||||||
synced_folders["tracker"] = {
|
|
||||||
"root" => {
|
|
||||||
hostpath: "foo",
|
|
||||||
tracker__foo: "bar",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
subject.call(env)
|
|
||||||
|
|
||||||
actual["root"][:foo].should == "bar"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue