From b7f2c6661c35b81e4db37fe85763b564c5f7f15c Mon Sep 17 00:00:00 2001 From: Salim Afiune Date: Mon, 5 Dec 2016 16:41:08 -0500 Subject: [PATCH] Exclude freebsd and ability to disable cache dir We are excluding FreeBSD systems and also adding the ability to disable the `cache_directory` by setting it up to `false` in the `kitchen.yml` file. Example: ``` platforms: - name: ubuntu-12.04 driver: cache_directory: false ``` Closes https://github.com/test-kitchen/kitchen-vagrant/issues/260 Closes https://github.com/test-kitchen/kitchen-vagrant/issues/256 Closes https://github.com/test-kitchen/kitchen-vagrant/issues/257 Signed-off-by: Salim Afiune --- lib/kitchen/driver/vagrant.rb | 18 +++++++++++++++++- spec/kitchen/driver/vagrant_spec.rb | 7 ++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/kitchen/driver/vagrant.rb b/lib/kitchen/driver/vagrant.rb index 0503bea0..3a51f4ea 100644 --- a/lib/kitchen/driver/vagrant.rb +++ b/lib/kitchen/driver/vagrant.rb @@ -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 @@ -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 diff --git a/spec/kitchen/driver/vagrant_spec.rb b/spec/kitchen/driver/vagrant_spec.rb index e28041bc..192f03d7 100644 --- a/spec/kitchen/driver/vagrant_spec.rb +++ b/spec/kitchen/driver/vagrant_spec.rb @@ -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 @@ -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"]