Skip to content

Commit

Permalink
Merge pull request #56 from schrodinger/synced-folders-options
Browse files Browse the repository at this point in the history
Enabled passing options to the synced folders
  • Loading branch information
fnichol committed Nov 29, 2013
2 parents 4a60977 + b31bf20 commit f0d3819
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
```

Expand Down
8 changes: 6 additions & 2 deletions lib/kitchen/vagrant/vagrantfile_creator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,12 @@ def chef_block(arr)
end

def synced_folders_block(arr)
config[:synced_folders].each do |source, destination|
arr << %{ c.vm.synced_folder "#{source}", "#{destination}" }
instance_name = instance.name
config[:synced_folders].each do |source, destination, options|
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 "#{l_source}", "#{l_destination}"#{opt} }
end
end

Expand Down

0 comments on commit f0d3819

Please sign in to comment.