Skip to content

Instantly share code, notes, and snippets.

@yyamano
Last active December 28, 2015 09:19
Show Gist options
  • Save yyamano/7477933 to your computer and use it in GitHub Desktop.
Save yyamano/7477933 to your computer and use it in GitHub Desktop.
vagrant-cachier (https://github.com/fgrehm/vagrant-cachier) support patch for kitchen-vagrant-0.11.3. This is just for temporary local hack, because Seth, the author of kitchen-vagrant want more generic implementation to support flexible configuration. See https://github.com/test-kitchen/kitchen-vagrant/issues/51
diff --git a/.kitchen.yml b/.kitchen.yml
index 1e3fa53..8a55bf5 100644
--- a/.kitchen.yml
+++ b/.kitchen.yml
@@ -2,6 +2,8 @@
driver_plugin: vagrant
driver_config:
require_chef_omnibus: true
+ cache:
+ auto_detect: true
customize:
memory: 1024
diff -u -r kitchen-vagrant-0.11.3.orig/lib/kitchen/driver/vagrant.rb kitchen-vagrant-0.11.3/lib/kitchen/driver/vagrant.rb
--- kitchen-vagrant-0.11.3.orig/lib/kitchen/driver/vagrant.rb 2013-11-15 10:11:27.000000000 +0900
+++ kitchen-vagrant-0.11.3/lib/kitchen/driver/vagrant.rb 2013-11-15 10:42:08.000000000 +0900
@@ -119,7 +119,7 @@
end
def creator
- Kitchen::Vagrant::VagrantfileCreator.new(instance, config)
+ Kitchen::Vagrant::VagrantfileCreator.new(instance, config, vagrant_plugins)
end
def set_ssh_state(state)
@@ -155,6 +155,15 @@
" Please upgrade to version #{MIN_VER} or higher from #{WEBSITE}."
end
end
+
+ def vagrant_plugins
+ output = run("vagrant plugin list", :live_stream => nil)
+ lines = output.split("\n").map do |line|
+ tokens = line.strip.partition(" ")
+ [tokens.first, tokens.last.gsub(/[()]/, '')]
+ end
+ Hash[lines]
+ end
end
end
end
diff -u -r kitchen-vagrant-0.11.3.orig/lib/kitchen/vagrant/vagrantfile_creator.rb kitchen-vagrant-0.11.3/lib/kitchen/vagrant/vagrantfile_creator.rb
--- kitchen-vagrant-0.11.3.orig/lib/kitchen/vagrant/vagrantfile_creator.rb 2013-11-15 10:11:27.000000000 +0900
+++ kitchen-vagrant-0.11.3/lib/kitchen/vagrant/vagrantfile_creator.rb 2013-11-15 10:41:31.000000000 +0900
@@ -25,9 +25,10 @@
# @author Fletcher Nichol <fnichol@nichol.ca>
class VagrantfileCreator
- def initialize(instance, config)
+ def initialize(instance, config, plugins = {})
@instance = instance
@config = config
+ @plugins = plugins
end
def render
@@ -39,6 +40,7 @@
provider_block(arr)
chef_block(arr) if config[:use_vagrant_provision]
synced_folders_block(arr)
+ cache_block(arr)
arr << %{end}
arr.join("\n")
end
@@ -108,6 +110,11 @@
end
end
+ def cache_block(arr)
+ return if config[:cache].nil? || @plugins['vagrant-cachier'].nil?
+ arr << %{ c.cache.auto_detect = "#{config[:cache][:auto_detect]}"} if config[:cache][:auto_detect]
+ end
+
def vagrant_logger_level
if instance.logger.debug?
":debug"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment