From 5a4eead4bc2483b440ead06982e42e5d282d62b4 Mon Sep 17 00:00:00 2001 From: Antonio Osorio Date: Fri, 15 Nov 2013 18:27:22 -0500 Subject: [PATCH 1/6] Enabled passing options to the synced folders --- README.md | 4 +++- lib/kitchen/vagrant/vagrantfile_creator.rb | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 83008b09..24a29630 100644 --- a/README.md +++ b/README.md @@ -200,7 +200,8 @@ The default is an empty Array, or `[]`. The example: ```ruby driver_config: - synced_folders: [["/Users/mray/ws/cookbooks/pxe_dust/.kitchen/kitchen-vagrant/opt/chef", "/opt/chef"]] + synced_folders: [["/Users/mray/ws/cookbooks/pxe_dust/.kitchen/kitchen-vagrant/opt/chef", "/opt/chef"], + ["/host_path", "/vm_path", "create: true, disabled: false"]] ``` will generate a Vagrantfile configuration similar to: @@ -210,6 +211,7 @@ Vagrant.configure("2") do |config| # ... c.vm.synced_folder "/Users/mray/ws/cookbooks/pxe_dust/.kitchen/kitchen-vagrant/opt/chef", "/opt/chef" + c.vm.synced_folder "/host_path", "/vm_path", create: true, disabled: false end ``` diff --git a/lib/kitchen/vagrant/vagrantfile_creator.rb b/lib/kitchen/vagrant/vagrantfile_creator.rb index 0c8bf961..44303b32 100644 --- a/lib/kitchen/vagrant/vagrantfile_creator.rb +++ b/lib/kitchen/vagrant/vagrantfile_creator.rb @@ -103,8 +103,8 @@ def chef_block(arr) end def synced_folders_block(arr) - config[:synced_folders].each do |source, destination| - arr << %{ c.vm.synced_folder "#{source}", "#{destination}" } + config[:synced_folders].each do |source, destination, options| + arr << %{ c.vm.synced_folder "#{source}", "#{destination}"#{(options.nil? ? '' : ", #{options}")} } end end From 0cb05a63009e619423bd387a4a361ff1161d25f4 Mon Sep 17 00:00:00 2001 From: Antonio Osorio Date: Fri, 15 Nov 2013 19:15:57 -0500 Subject: [PATCH 2/6] Cosmetic change, line over 80 chars --- lib/kitchen/vagrant/vagrantfile_creator.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/kitchen/vagrant/vagrantfile_creator.rb b/lib/kitchen/vagrant/vagrantfile_creator.rb index 44303b32..0ebd0445 100644 --- a/lib/kitchen/vagrant/vagrantfile_creator.rb +++ b/lib/kitchen/vagrant/vagrantfile_creator.rb @@ -104,7 +104,8 @@ def chef_block(arr) def synced_folders_block(arr) config[:synced_folders].each do |source, destination, options| - arr << %{ c.vm.synced_folder "#{source}", "#{destination}"#{(options.nil? ? '' : ", #{options}")} } + opt = (options.nil? ? '' : ", #{options}") + arr << %{ c.vm.synced_folder "#{source}", "#{destination}"#{opt} } end end From b4a26f7d44024f40a361a83a7d577350bb79c49f Mon Sep 17 00:00:00 2001 From: Antonio Osorio Date: Mon, 25 Nov 2013 15:30:44 -0500 Subject: [PATCH 3/6] Enabled the use of the instance name on the synchef_folders source and destination strings --- lib/kitchen/vagrant/vagrantfile_creator.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/kitchen/vagrant/vagrantfile_creator.rb b/lib/kitchen/vagrant/vagrantfile_creator.rb index 0ebd0445..e5ae461f 100644 --- a/lib/kitchen/vagrant/vagrantfile_creator.rb +++ b/lib/kitchen/vagrant/vagrantfile_creator.rb @@ -103,7 +103,10 @@ def chef_block(arr) end def synced_folders_block(arr) + instance_name = instance[:name] config[:synced_folders].each do |source, destination, options| + source = source.gsub!("%{instance_name}", instance_name) + destination = destination.gsub!("%{instance_name}", instance_name) opt = (options.nil? ? '' : ", #{options}") arr << %{ c.vm.synced_folder "#{source}", "#{destination}"#{opt} } end From 72f09d731b559528d709579f326bc55cdda105e9 Mon Sep 17 00:00:00 2001 From: Antonio Osorio Date: Mon, 25 Nov 2013 15:41:09 -0500 Subject: [PATCH 4/6] Fixed access to instance.name --- lib/kitchen/vagrant/vagrantfile_creator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/kitchen/vagrant/vagrantfile_creator.rb b/lib/kitchen/vagrant/vagrantfile_creator.rb index e5ae461f..d2156ab1 100644 --- a/lib/kitchen/vagrant/vagrantfile_creator.rb +++ b/lib/kitchen/vagrant/vagrantfile_creator.rb @@ -103,7 +103,7 @@ def chef_block(arr) end def synced_folders_block(arr) - instance_name = instance[:name] + instance_name = instance.name config[:synced_folders].each do |source, destination, options| source = source.gsub!("%{instance_name}", instance_name) destination = destination.gsub!("%{instance_name}", instance_name) From 157364aef1f5ff9de8612e4a952e2760c2cf45d9 Mon Sep 17 00:00:00 2001 From: Antonio Osorio Date: Mon, 25 Nov 2013 15:45:18 -0500 Subject: [PATCH 5/6] Fixed string substitution in synced_folders --- lib/kitchen/vagrant/vagrantfile_creator.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/kitchen/vagrant/vagrantfile_creator.rb b/lib/kitchen/vagrant/vagrantfile_creator.rb index d2156ab1..fbd688d4 100644 --- a/lib/kitchen/vagrant/vagrantfile_creator.rb +++ b/lib/kitchen/vagrant/vagrantfile_creator.rb @@ -105,8 +105,8 @@ def chef_block(arr) def synced_folders_block(arr) instance_name = instance.name config[:synced_folders].each do |source, destination, options| - source = source.gsub!("%{instance_name}", instance_name) - destination = destination.gsub!("%{instance_name}", instance_name) + source.gsub!("%{instance_name}", instance_name) + destination.gsub!("%{instance_name}", instance_name) opt = (options.nil? ? '' : ", #{options}") arr << %{ c.vm.synced_folder "#{source}", "#{destination}"#{opt} } end From b31bf20cba815121ba133aa9e3a11e287b0b123a Mon Sep 17 00:00:00 2001 From: Antonio Osorio Date: Mon, 25 Nov 2013 17:53:15 -0500 Subject: [PATCH 6/6] Fixed bug that caused intance_name not to be correctly updated when running multiple tests in synched_folders --- lib/kitchen/vagrant/vagrantfile_creator.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/kitchen/vagrant/vagrantfile_creator.rb b/lib/kitchen/vagrant/vagrantfile_creator.rb index fbd688d4..75094c19 100644 --- a/lib/kitchen/vagrant/vagrantfile_creator.rb +++ b/lib/kitchen/vagrant/vagrantfile_creator.rb @@ -105,10 +105,10 @@ def chef_block(arr) def synced_folders_block(arr) instance_name = instance.name config[:synced_folders].each do |source, destination, options| - source.gsub!("%{instance_name}", instance_name) - destination.gsub!("%{instance_name}", instance_name) + l_source = source.gsub("%{instance_name}", instance_name) + l_destination = destination.gsub("%{instance_name}", instance_name) opt = (options.nil? ? '' : ", #{options}") - arr << %{ c.vm.synced_folder "#{source}", "#{destination}"#{opt} } + arr << %{ c.vm.synced_folder "#{l_source}", "#{l_destination}"#{opt} } end end