vagrant-bindfs 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d13154638cd8b30fd9176833e1ef4f6cb5ddeadb
4
- data.tar.gz: f31ef1b0f0acaf804dd57835821f5fcd822d5719
3
+ metadata.gz: 66fe9ef2425e37e0bebdab608de94fff8db26bbd
4
+ data.tar.gz: 214689732bf62da3d98d6a0f767ed96ba2c3920d
5
5
  SHA512:
6
- metadata.gz: 1927235815d2abc9845d84912e262da5742d7bdabe3d43d9164b3214a055a7bddc5b11e74445a9930e3d36b7e85e1f1a6815d8151deedd2486bd189c1e8cca95
7
- data.tar.gz: 137621a5c4fddb75d3e2b7f9294bd822bc17ecbabdc45d797153935c3ad2609ddff731cef6969d916ce3cc2fdc6d30e37443eca653242463c36d547cdde547f8
6
+ metadata.gz: 7b6352b4b24398070c2da137e14dbf90cfd5253b9bcf6fd64cc486291b5d38aee58466d4a4c6f06b0c88acb700a08b7fa9632810a8d4cab9de2a422ba422270f
7
+ data.tar.gz: 887b967d2d3e89911b91ef731bb4e8204bdd057c3283656bf2ce1a058329dd38d12fc6d9cb4151a40ebe2405050286c8e15ebec037a5b787d0b6f5ca18cfd93f
data/README.md CHANGED
@@ -42,6 +42,12 @@ The format is:
42
42
  config.bindfs.bind_folder "/path/to/source", "/path/to/destination", options
43
43
  ```
44
44
 
45
+ By default, all folders are binded after folders syncing between host and guest machines.
46
+ You can pass a special `:after` (or `:hook`) option to the bind_folder method to choose when a folder should be binded.
47
+ Supported values are :
48
+
49
+ * `:synced_folders` (default)
50
+ * `:provision`, to bind a folder after provisioning occured.
45
51
 
46
52
  ### Example
47
53
 
@@ -77,11 +83,13 @@ Vagrant.configure("2") do |config|
77
83
  config.vm.synced_folder ".", "/vagrant", type: :nfs
78
84
  config.bindfs.bind_folder "/vagrant", "/vagrant"
79
85
 
86
+ # Bind a folder after provisioning
87
+ config.bindfs.bind_folder "/vagrant-after-provision", "another/guest/mount/point", after: :provision
88
+
80
89
  end
81
90
  ```
82
91
 
83
-
84
- ### Supported options
92
+ ### bindfs support
85
93
 
86
94
  The `bind_folder` config accept any option you can pass to bindfs.
87
95
  vagrant-bindfs is compatible with bindfs from version 1.9 to 1.12.6.
@@ -4,9 +4,10 @@ module VagrantPlugins
4
4
  module Bindfs
5
5
  module Action
6
6
  class Bind
7
- def initialize(app, env)
8
- @app = app
9
- @env = env
7
+ def initialize(app, env, hook)
8
+ @app = app
9
+ @env = env
10
+ @hook = hook
10
11
  end
11
12
 
12
13
  def call(env)
@@ -22,7 +23,12 @@ module VagrantPlugins
22
23
  end
23
24
 
24
25
  def binded_folders
25
- @machine.config.bindfs.bind_folders
26
+ @binded_folders ||= begin
27
+ @machine.config.bindfs.bind_folders.reduce({}) do |binded, (name, options)|
28
+ binded[name] = options if options[:hook] == @hook
29
+ binded
30
+ end
31
+ end
26
32
  end
27
33
 
28
34
  def bind_folders
@@ -40,6 +46,22 @@ module VagrantPlugins
40
46
  next
41
47
  end
42
48
 
49
+ unless @machine.communicate.test("getent passwd #{command.user.shellescape}")
50
+ @env[:ui].error I18n.t(
51
+ "vagrant.config.bindfs.errors.user_not_exist",
52
+ user: command.user
53
+ )
54
+ next
55
+ end
56
+
57
+ unless @machine.communicate.test("getent group #{command.group.shellescape}")
58
+ @env[:ui].error I18n.t(
59
+ "vagrant.config.bindfs.errors.group_not_exist",
60
+ group: command.group
61
+ )
62
+ next
63
+ end
64
+
43
65
  if @machine.communicate.test("mount | grep bindfs | grep #{command.destination}")
44
66
  @env[:ui].info I18n.t(
45
67
  "vagrant.config.bindfs.already_mounted",
@@ -19,6 +19,14 @@ module VagrantPlugins
19
19
  [ "bindfs", arguments.join(" "), source, destination ].compact.join(" ")
20
20
  end
21
21
 
22
+ def user
23
+ @arguments.join(' ')[/--(?:force-)?user=([^\s]+)/, 1]
24
+ end
25
+
26
+ def group
27
+ @arguments.join(' ')[/--(?:force-)?group=([^\s]+)/, 1]
28
+ end
29
+
22
30
  protected
23
31
 
24
32
  def arguments_for(options)
@@ -22,6 +22,7 @@ module VagrantPlugins
22
22
  def bind_folder(source_path, dest_path, options = {})
23
23
  options[:source_path] = source_path
24
24
  options[:dest_path] = dest_path
25
+ options[:hook] ||= options.delete(:after) || VagrantPlugins::Bindfs::Plugin.hook_names.first
25
26
 
26
27
  @bind_folders[options[:dest_path]] = options
27
28
  end
@@ -54,6 +55,13 @@ module VagrantPlugins
54
55
  bind_folders.each do |id, options|
55
56
  next if options[:disabled]
56
57
 
58
+ unless VagrantPlugins::Bindfs::Plugin.hook_names.include?(options[:hook].to_sym)
59
+ errors << I18n.t(
60
+ "vagrant.config.bindfs.errors.invalid_hook",
61
+ hooks: VagrantPlugins::Bindfs::Plugin.hook_names
62
+ )
63
+ end
64
+
57
65
  if options[:dest_path].nil? or options[:source_path].nil?
58
66
  errors << I18n.t(
59
67
  "vagrant.config.bindfs.errors.no_path_supplied",
@@ -63,14 +63,33 @@ module VagrantPlugins
63
63
 
64
64
  %w{up reload}.each do |action|
65
65
  action_hook(:bindfs, "machine_action_#{action}".to_sym) do |hook|
66
- target = if Vagrant::Action::Builtin.const_defined? :NFS
67
- Vagrant::Action::Builtin::NFS
68
- else
69
- Vagrant::Action::Builtin::SyncedFolders
66
+ hooks.each do |(name, action)|
67
+ hook.before(action, Action::Bind, name)
70
68
  end
69
+ end
70
+ end
71
71
 
72
- hook.before(target, Action::Bind)
72
+ class << self
73
+
74
+ def hooks
75
+ @hooks ||= begin
76
+ synced_folders = if Vagrant::Action::Builtin.const_defined? :NFS
77
+ Vagrant::Action::Builtin::NFS
78
+ else
79
+ Vagrant::Action::Builtin::SyncedFolders
80
+ end
81
+
82
+ {
83
+ :synced_folders => synced_folders,
84
+ :provision => Vagrant::Action::Builtin::Provision
85
+ }
86
+ end
87
+ end
88
+
89
+ def hook_names
90
+ hooks.keys
73
91
  end
92
+
74
93
  end
75
94
 
76
95
  end
@@ -1,6 +1,6 @@
1
1
  module VagrantPlugins
2
2
  module Bindfs
3
- VERSION = "0.4.1"
3
+ VERSION = "0.4.2"
4
4
  SOURCE_VERSION = "1.12.6"
5
5
  end
6
6
  end
data/locales/en.yml CHANGED
@@ -9,9 +9,13 @@ en:
9
9
  binding_all: "Creating bind mounts for selected devices"
10
10
  binding_entry: "Creating bind mount from %{source} to %{dest}"
11
11
  errors:
12
+ invalid_hook: "Invalid hook specified. Must use one of %{hooks}"
13
+ no_path_supplied: "You must pass a destination and a source path as arguments"
12
14
  destination_path_relative: "Destination path is relative for bind whatever"
13
15
  source_path_relative: "Source path is relative for bind whatever"
14
16
  source_path_not_exist: "Cannot bind source path %{path} because it doesn't exist"
17
+ user_not_exist: "Cannot bind to user '%{user}' because it doesn't exist"
18
+ group_not_exist: "Cannot bind to group '%{group}' because it doesn't exist"
15
19
  cannot_enable_fuse: "The fuse kernel module seems to not be loadable on the virtual machine"
16
20
  binding_failed: |-
17
21
  The bind command `%{command}` failed to run!
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-bindfs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gaël-Ian Havard
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-06-17 00:00:00.000000000 Z
13
+ date: 2015-07-22 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: A Vagrant plugin to automate bindfs mount in the VM. This allow you to
16
16
  change owner, group and permissions on files and, for example, work around NFS share
@@ -22,9 +22,6 @@ executables: []
22
22
  extensions: []
23
23
  extra_rdoc_files: []
24
24
  files:
25
- - MIT-LICENSE
26
- - README.md
27
- - lib/vagrant-bindfs.rb
28
25
  - lib/vagrant-bindfs/bind.rb
29
26
  - lib/vagrant-bindfs/cap/debian/install_bindfs.rb
30
27
  - lib/vagrant-bindfs/cap/fedora/install_bindfs.rb
@@ -39,7 +36,10 @@ files:
39
36
  - lib/vagrant-bindfs/errors.rb
40
37
  - lib/vagrant-bindfs/plugin.rb
41
38
  - lib/vagrant-bindfs/version.rb
39
+ - lib/vagrant-bindfs.rb
42
40
  - locales/en.yml
41
+ - README.md
42
+ - MIT-LICENSE
43
43
  homepage: https://github.com/gael-ian/vagrant-bindfs
44
44
  licenses:
45
45
  - MIT
@@ -50,17 +50,17 @@ require_paths:
50
50
  - lib
51
51
  required_ruby_version: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ">="
53
+ - - '>='
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
56
  required_rubygems_version: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - ">="
58
+ - - '>='
59
59
  - !ruby/object:Gem::Version
60
60
  version: '0'
61
61
  requirements: []
62
62
  rubyforge_project:
63
- rubygems_version: 2.2.2
63
+ rubygems_version: 2.0.14
64
64
  signing_key:
65
65
  specification_version: 4
66
66
  summary: A Vagrant plugin to automate bindfs mount in the VM