Skip to content

Commit

Permalink
Merge pull request #313 from test-kitchen/robb/fix-turning-off-cachin…
Browse files Browse the repository at this point in the history
…g-with-bentos

turn off caching, even for bento boxes
  • Loading branch information
Seth Thomas authored Jul 25, 2017
2 parents cad37e8 + 629691e commit 027b98c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
15 changes: 8 additions & 7 deletions lib/kitchen/driver/vagrant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ class Vagrant < Kitchen::Driver::Base
driver.windows_os? ? nil : "#{driver.instance.name}.vagrantup.com"
end

default_config :cache_directory, false
default_config(:cache_directory) do |driver|
driver.windows_os? ? "/omnibus/cache" : "/tmp/omnibus/cache"
end

default_config :kitchen_cache_directory,
File.expand_path("~/.kitchen/cache")
Expand Down Expand Up @@ -197,10 +199,10 @@ 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
if enable_cache? && !config[:cache_directory]
windows_os? ? "/omnibus/cache" : "/tmp/omnibus/cache"
else
if enable_cache?
config[:cache_directory]
else
false
end
end

Expand Down Expand Up @@ -244,9 +246,8 @@ def safe_share?(box)
# Return true if we found the criteria to enable the cache_directory
# functionality
def enable_cache?
if safe_share?(config[:box])
return true
end
return false unless config[:cache_directory]
return true if safe_share?(config[:box])
# Otherwise
false
end
Expand Down
11 changes: 10 additions & 1 deletion spec/kitchen/driver/vagrant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,12 @@ def run_command(_cmd, options = {})
expect(driver[:synced_folders]).to eq([cache_directory_array])
end

it "does not set :synced_folders when cache_directory is false" do
config[:box] = "bento/centos-99"
config[:cache_directory] = false
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-99")
expect(driver[:synced_folders]).to eq([])
Expand Down Expand Up @@ -484,7 +490,10 @@ def run_command(_cmd, options = {})
]
end

before { config[:cache_directory] = 'Z:\\awesome\\cache' }
before do
config[:box] = "bento/centos-99"
config[:cache_directory] = "Z:\\awesome\\cache"
end

it "sets :synced_folders with the custom cache_directory" do
expect(driver[:synced_folders]).to eq([custom_cache_directory_array])
Expand Down

0 comments on commit 027b98c

Please sign in to comment.