core: scope hash override synced folder settings
This commit is contained in:
parent
de9d38de21
commit
1b8c3b62af
|
@ -1,6 +1,7 @@
|
||||||
require "log4r"
|
require "log4r"
|
||||||
|
|
||||||
require 'vagrant/util/platform'
|
require 'vagrant/util/platform'
|
||||||
|
require 'vagrant/util/scoped_hash_override'
|
||||||
|
|
||||||
module Vagrant
|
module Vagrant
|
||||||
module Action
|
module Action
|
||||||
|
@ -8,6 +9,8 @@ module Vagrant
|
||||||
# This middleware will setup the synced folders for the machine using
|
# This middleware will setup the synced folders for the machine using
|
||||||
# the appropriate synced folder plugin.
|
# the appropriate synced folder plugin.
|
||||||
class SyncedFolders
|
class SyncedFolders
|
||||||
|
include Vagrant::Util::ScopedHashOverride
|
||||||
|
|
||||||
def initialize(app, env)
|
def initialize(app, env)
|
||||||
@app = app
|
@app = app
|
||||||
@logger = Log4r::Logger.new("vagrant::action::builtin::synced_folders")
|
@logger = Log4r::Logger.new("vagrant::action::builtin::synced_folders")
|
||||||
|
@ -16,18 +19,21 @@ module Vagrant
|
||||||
def call(env)
|
def call(env)
|
||||||
folders = synced_folders(env[:machine])
|
folders = synced_folders(env[:machine])
|
||||||
|
|
||||||
# Log all the folders that we have enabled and with what
|
folders.each do |impl_name, fs|
|
||||||
# implementation...
|
@logger.info("Synced Folder Implementation: #{impl_name}")
|
||||||
folders.each do |impl, fs|
|
|
||||||
@logger.info("Synced Folder Implementation: #{impl}")
|
|
||||||
fs.each do |id, data|
|
fs.each do |id, data|
|
||||||
|
# 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
|
||||||
|
|
||||||
# Go through each folder and make sure to create it if
|
# Go through each folder and make sure to create it if
|
||||||
# it does not exist on host
|
# it does not exist on host
|
||||||
folders.each do |impl, fs|
|
folders.each do |_, fs|
|
||||||
fs.each do |id, data|
|
fs.each do |id, data|
|
||||||
data[:hostpath] = File.expand_path(data[:hostpath], env[:root_path])
|
data[:hostpath] = File.expand_path(data[:hostpath], env[:root_path])
|
||||||
|
|
||||||
|
|
|
@ -101,6 +101,28 @@ 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
|
||||||
|
|
||||||
describe "default_synced_folder_type" do
|
describe "default_synced_folder_type" do
|
||||||
|
|
Loading…
Reference in New Issue