core: scope hash override synced folder settings

This commit is contained in:
Mitchell Hashimoto 2013-11-23 13:38:15 -08:00
parent de9d38de21
commit 1b8c3b62af
2 changed files with 33 additions and 5 deletions

View File

@ -1,6 +1,7 @@
require "log4r"
require 'vagrant/util/platform'
require 'vagrant/util/scoped_hash_override'
module Vagrant
module Action
@ -8,6 +9,8 @@ module Vagrant
# This middleware will setup the synced folders for the machine using
# the appropriate synced folder plugin.
class SyncedFolders
include Vagrant::Util::ScopedHashOverride
def initialize(app, env)
@app = app
@logger = Log4r::Logger.new("vagrant::action::builtin::synced_folders")
@ -16,18 +19,21 @@ module Vagrant
def call(env)
folders = synced_folders(env[:machine])
# Log all the folders that we have enabled and with what
# implementation...
folders.each do |impl, fs|
@logger.info("Synced Folder Implementation: #{impl}")
folders.each do |impl_name, fs|
@logger.info("Synced Folder Implementation: #{impl_name}")
fs.each do |id, data|
# Log every implementation and their paths
@logger.info(" - #{id}: #{data[:hostpath]} => #{data[:guestpath]}")
# Scope hash override
fs[id] = scoped_hash_override(data, impl_name)
end
end
# Go through each folder and make sure to create it if
# it does not exist on host
folders.each do |impl, fs|
folders.each do |_, fs|
fs.each do |id, data|
data[:hostpath] = File.expand_path(data[:hostpath], env[:root_path])

View File

@ -101,6 +101,28 @@ describe Vagrant::Action::Builtin::SyncedFolders do
order.should == [:prepare, :enable]
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
describe "default_synced_folder_type" do