Skip to content

Commit

Permalink
Implement the Driver::cache_directory interface
Browse files Browse the repository at this point in the history
Signed-off-by: Salim Afiune <[email protected]>
  • Loading branch information
Salim Afiune committed Nov 22, 2016
1 parent 589ef04 commit f986e9e
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions lib/kitchen/driver/vagrant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ def winrm_transport?
instance.transport.name.downcase =~ /win_?rm/
end

# Setting up the `cache_directory` to store omnibus packages in cache
# and share a local folder to that directory so that we don't pull them
# down every single time
def cache_directory
windows_os? ? "$env:TEMP\\omnibus\\cache" : "/tmp/omnibus/cache"
end

protected

WEBSITE = "http://www.vagrantup.com/downloads.html".freeze
Expand Down Expand Up @@ -251,26 +258,20 @@ def finalize_synced_folders!
add_extra_synced_folders!
end

# Verify if we are using the Provisioner::ChefBase that now has a
# config parameter for the Chef omnibus cache, if that is set then
# we would like to sync a local folder to the instance so we can
# take advantage of the cache packages that we might have,
# therefore we wont download a package we already have in the cache
# We would like to sync a local folder to the instance so we can
# take advantage of the packages that we might have in cache,
# therefore we wont download a package we already have
def add_extra_synced_folders!
if chef_omnibus_cache
if cache_directory
FileUtils.mkdir_p(local_kitchen_cache)
config[:synced_folders].push([
local_kitchen_cache,
chef_omnibus_cache,
cache_directory,
"create: true"
])
end
end

def chef_omnibus_cache
instance.provisioner[:chef_omnibus_cache] if instance
end

# Truncates the length of `:vm_hostname` to 12 characters for
# Windows-based operating systems.
#
Expand Down

0 comments on commit f986e9e

Please sign in to comment.