diff --git a/lib/vagrant/action/builtin/mixin_synced_folders.rb b/lib/vagrant/action/builtin/mixin_synced_folders.rb index 0710ca883..7ffa64d03 100644 --- a/lib/vagrant/action/builtin/mixin_synced_folders.rb +++ b/lib/vagrant/action/builtin/mixin_synced_folders.rb @@ -1,7 +1,11 @@ +require 'vagrant/util/scoped_hash_override' + module Vagrant module Action module Builtin module MixinSyncedFolders + include Vagrant::Util::ScopedHashOverride + # This goes over all the registered synced folder types and returns # the highest priority implementation that is usable for this machine. def default_synced_folder_type(machine, plugins) @@ -96,6 +100,13 @@ module Vagrant folders.delete("") 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 end end diff --git a/lib/vagrant/action/builtin/synced_folders.rb b/lib/vagrant/action/builtin/synced_folders.rb index 7c7802ca2..ce6a1cc85 100644 --- a/lib/vagrant/action/builtin/synced_folders.rb +++ b/lib/vagrant/action/builtin/synced_folders.rb @@ -1,7 +1,6 @@ require "log4r" require 'vagrant/util/platform' -require 'vagrant/util/scoped_hash_override' require_relative "mixin_synced_folders" @@ -12,7 +11,6 @@ module Vagrant # the appropriate synced folder plugin. class SyncedFolders include MixinSyncedFolders - include Vagrant::Util::ScopedHashOverride def initialize(app, env) @app = app @@ -28,9 +26,6 @@ module Vagrant 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 diff --git a/test/unit/vagrant/action/builtin/mixin_synced_folders_test.rb b/test/unit/vagrant/action/builtin/mixin_synced_folders_test.rb index 97b64b168..6d96990f7 100644 --- a/test/unit/vagrant/action/builtin/mixin_synced_folders_test.rb +++ b/test/unit/vagrant/action/builtin/mixin_synced_folders_test.rb @@ -98,5 +98,16 @@ describe Vagrant::Action::Builtin::MixinSyncedFolders do result.length.should == 1 result[:default].length.should == 1 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 diff --git a/test/unit/vagrant/action/builtin/synced_folders_test.rb b/test/unit/vagrant/action/builtin/synced_folders_test.rb index e09ae181b..23c77f2c9 100644 --- a/test/unit/vagrant/action/builtin/synced_folders_test.rb +++ b/test/unit/vagrant/action/builtin/synced_folders_test.rb @@ -90,27 +90,5 @@ 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 end