diff --git a/lib/vagrant/action/builtin/synced_folders.rb b/lib/vagrant/action/builtin/synced_folders.rb index 0d0eb9356..25ef6e68c 100644 --- a/lib/vagrant/action/builtin/synced_folders.rb +++ b/lib/vagrant/action/builtin/synced_folders.rb @@ -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]) diff --git a/test/unit/vagrant/action/builtin/synced_folders_test.rb b/test/unit/vagrant/action/builtin/synced_folders_test.rb index 2cb123096..94d199df5 100644 --- a/test/unit/vagrant/action/builtin/synced_folders_test.rb +++ b/test/unit/vagrant/action/builtin/synced_folders_test.rb @@ -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