Skip to content

Commit

Permalink
Merge pull request #262 from test-kitchen/afiune/disable-shared-cache…
Browse files Browse the repository at this point in the history
…-folder

Exclude freebsd and ability to disable cache dir
  • Loading branch information
Salim Afiune authored Dec 5, 2016
2 parents fb6904a + b7f2c66 commit 3951644
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
18 changes: 17 additions & 1 deletion lib/kitchen/driver/vagrant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def winrm_transport?
# and share a local folder to that directory so that we don't pull them
# down every single time
def cache_directory
return if windows_host? && config[:provider] != "virtualbox"
return if disable_cache?
config[:cache_directory]
end

Expand Down Expand Up @@ -209,6 +209,22 @@ def bento_box?(name)
name =~ /^(centos|debian|fedora|freebsd|opensuse|ubuntu|oracle)-/
end

# Return true if we found the criteria to disable the cache_directory
# functionality
def disable_cache?
# Disable for Windows not using Virtualbox
if windows_host? && config[:provider] != "virtualbox" ||
# Disable for FreeBSD
instance.platform.name == "freebsd" ||
# Disable if cache_directory is set to "false" on .kitchen.yml
!config[:cache_directory]
return true
end

# Otherwise
false
end

# Renders and writes out a Vagrantfile dedicated to this instance.
#
# @api private
Expand Down
7 changes: 6 additions & 1 deletion spec/kitchen/driver/vagrant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def run_command(_cmd, options = {})
]
end

%W[centos debian fedora opensuse ubuntu].each do |name|
%W[centos debian fedora opensuse ubuntu oracle freebsd].each do |name|

context "for known bento platform names starting with #{name}" do

Expand Down Expand Up @@ -337,6 +337,11 @@ def run_command(_cmd, options = {})
expect(driver[:synced_folders]).to eq([])
end

it "does not set :synced_folders to cache_directory on freebsd systems" do
allow(platform).to receive(:name).and_return("freebsd")
expect(driver[:synced_folders]).to eq([])
end

it "sets :synced_folders to a custom value" do
config[:synced_folders] = [
["/host_path", "/vm_path", "create: true, type: :nfs"]
Expand Down

0 comments on commit 3951644

Please sign in to comment.