From 5a0b2f0f1a5c3fb4e86afcb7713d1b1df6f02ce7 Mon Sep 17 00:00:00 2001 From: Erno Aapa Date: Sat, 25 Jan 2014 06:20:39 +0200 Subject: [PATCH] Support for extra synced_folder options Added ability to pass extra synced_folder options through new config.cache.sync_opts -configuration. --- README.md | 2 ++ lib/vagrant-cachier/config.rb | 4 +++- lib/vagrant-cachier/provision_ext.rb | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 27b0394..b077d21 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,8 @@ Vagrant.configure("2") do |config| config.cache.auto_detect = true # If you are using VirtualBox, you might want to enable NFS for shared folders # config.cache.enable_nfs = true + # You can pass extra mount options, for example: + # config.cache.sync_opts = {:create = true} end end ``` diff --git a/lib/vagrant-cachier/config.rb b/lib/vagrant-cachier/config.rb index a450505..f06883b 100644 --- a/lib/vagrant-cachier/config.rb +++ b/lib/vagrant-cachier/config.rb @@ -1,7 +1,7 @@ module VagrantPlugins module Cachier class Config < Vagrant.plugin(2, :config) - attr_accessor :scope, :auto_detect, :enable_nfs + attr_accessor :scope, :auto_detect, :enable_nfs, :sync_opts attr_reader :buckets ALLOWED_SCOPES = %w( box machine ) @@ -10,6 +10,7 @@ module VagrantPlugins @scope = UNSET_VALUE @auto_detect = UNSET_VALUE @enable_nfs = UNSET_VALUE + @sync_opts = UNSET_VALUE end def enable(bucket, opts = {}) @@ -34,6 +35,7 @@ module VagrantPlugins @scope = :box if @scope == UNSET_VALUE @auto_detect = false if @auto_detect == UNSET_VALUE @enable_nfs = false if @enable_nfs == UNSET_VALUE + @sync_opts = {} if @sync_opts == UNSET_VALUE @buckets = @buckets ? @buckets.dup : {} end diff --git a/lib/vagrant-cachier/provision_ext.rb b/lib/vagrant-cachier/provision_ext.rb index a04b266..bcdb3d4 100644 --- a/lib/vagrant-cachier/provision_ext.rb +++ b/lib/vagrant-cachier/provision_ext.rb @@ -18,6 +18,8 @@ module VagrantPlugins FileUtils.mkdir_p(cache_root.to_s) unless cache_root.exist? synced_folder_opts = {id: "vagrant-cache"} + synced_folder_opts.merge!(env[:machine].config.cache.sync_opts) + if env[:machine].config.cache.enable_nfs # REFACTOR: Drop the `nfs: true` argument once we drop support for Vagrant < 1.4 synced_folder_opts.merge!({ nfs: true, type: 'nfs' })