vagrant-mountaineer 0.1.0 → 0.2.0

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
- SHA1:
3
- metadata.gz: e0a3a2995954e1ca95e0374cf005e5570f50035c
4
- data.tar.gz: 399eb3632ee0f1db04ac1498e82c82dd9d444f9e
2
+ SHA256:
3
+ metadata.gz: f358b480e0de95b796c8826290bc505fcde1a79009940492561f073077f79cd2
4
+ data.tar.gz: df09a5ed6049241b926ad1edfe7d34a7aeccb2b4f3585a2577cf0c738baf49bc
5
5
  SHA512:
6
- metadata.gz: ca0cfcded828c97723a3d3ef7db403e73cf6c12b20894e7ef9e0373103ff2d47baf5b563b802d1dc981bf10b939c8cb877bf169e4ef53d103670eb3bf0b379bf
7
- data.tar.gz: bcef4d3585cbf232e480b1efe7d8c353e54ebf924a9d654f8f19278406d2a11b16a49230726e77389ecb6e83bca052e912a4c752b097ff2ec388fa947b711f4c
6
+ metadata.gz: d703380f4903badc053e240870a84f387b911847ea461d6b1ca9b93e00b235db2c3a3b1455eda2aa54c7238acd24330eb6d641fff6ae25029ffc36276de5b964
7
+ data.tar.gz: '074038c6a312607a121e66a2cb7ea5746c6632073818db8595429835cd256d7ba968dc0a069a50bb430750e27b18c3ba285258aa4046989dc68b095e6e22d9a3'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.2.0 (2018-04-22)
4
+
5
+ - Enhancements
6
+ - A list of all mountpoints can be printed by using the info subcommand
7
+ - Projects can be defined as optional
8
+
3
9
  ## v0.1.0 (2017-03-07)
4
10
 
5
11
  - Initial Release
data/README.md CHANGED
@@ -42,12 +42,29 @@ project 'test_nfs',
42
42
  options: {
43
43
  type: :nfs
44
44
  }
45
+
46
+ project 'optional',
47
+ guestpath: '/data/plugin-optional',
48
+ hostpath: './may-not-exist',
49
+ optional: true
45
50
  ```
46
51
 
47
52
  Values for `:guestpath ` and `:hostpath` are required. Additional options
48
53
  (like `type`) can be configuring using the `:options` key. The name of the
49
54
  project will be used as the mount identifier.
50
55
 
56
+ If a project is defined as `optional` it will not be mounted if the host
57
+ path is missing. For the time being this is done silently.
58
+
59
+
60
+ ### Mountpoint Listing
61
+
62
+ You can list all known mountpoints in all machines:
63
+
64
+ ```shell
65
+ vagrant mountaineer info
66
+ ```
67
+
51
68
 
52
69
  ## License
53
70
 
@@ -1,6 +1,6 @@
1
1
  require 'vagrant'
2
2
 
3
- I18n.load_path << File.expand_path('../../../locales/en.yml', __FILE__)
3
+ I18n.load_path << File.expand_path('../../locales/en.yml', __dir__)
4
4
  I18n.reload!
5
5
 
6
6
  require 'vagrant/mountaineer/synopsis'
@@ -12,5 +12,6 @@ require 'vagrant/mountaineer/util'
12
12
 
13
13
  require 'vagrant/mountaineer/action'
14
14
  require 'vagrant/mountaineer/action/hook_projects'
15
+ require 'vagrant/mountaineer/command'
15
16
  require 'vagrant/mountaineer/config'
16
17
  require 'vagrant/mountaineer/plugin'
@@ -1,12 +1,11 @@
1
1
  module VagrantPlugins
2
2
  module Mountaineer
3
- # Vagrant plugin definition
3
+ # Action hook definition
4
4
  module Action
5
5
  include Vagrant::Action::Builtin
6
6
 
7
7
  def self.hook_projects
8
8
  Vagrant::Action::Builder.new.tap do |builder|
9
- builder.use ConfigValidate
10
9
  builder.use HookProjects
11
10
  end
12
11
  end
@@ -1,7 +1,7 @@
1
1
  module VagrantPlugins
2
2
  module Mountaineer
3
3
  module Action
4
- # Vagrant project hook
4
+ # Project hook to load and mount projectfile contents
5
5
  class HookProjects
6
6
  PROJECTFILE = VagrantPlugins::Mountaineer::Projectfile
7
7
  REGISTRY = VagrantPlugins::Mountaineer::Registry
@@ -35,6 +35,8 @@ module VagrantPlugins
35
35
 
36
36
  def mount_projects
37
37
  @registry.projects.each do |name, project|
38
+ next if skip_mount?(project)
39
+
38
40
  @machine.config.vm.synced_folders[name] = project[:options].merge(
39
41
  disabled: false,
40
42
  guestpath: project[:guestpath],
@@ -42,6 +44,12 @@ module VagrantPlugins
42
44
  )
43
45
  end
44
46
  end
47
+
48
+ def skip_mount?(project)
49
+ project.key?(:optional) &&
50
+ project[:optional] == true &&
51
+ !File.directory?(project[:hostpath])
52
+ end
45
53
  end
46
54
  end
47
55
  end
@@ -0,0 +1,66 @@
1
+ module VagrantPlugins
2
+ module Mountaineer
3
+ # Defines the mountaineer command
4
+ class Command < Vagrant.plugin(2, :command)
5
+ HOOK_PROJECTS = VagrantPlugins::Mountaineer::Action::HookProjects
6
+ UTIL = VagrantPlugins::Mountaineer::Util
7
+
8
+ def self.synopsis
9
+ 'mountaineer utility commands'
10
+ end
11
+
12
+ def execute
13
+ send(select_command(@argv))
14
+ end
15
+
16
+ private
17
+
18
+ def display_help
19
+ @env.ui.info('Available commands:')
20
+ @env.ui.info(' - help')
21
+ @env.ui.info(' - info')
22
+ end
23
+
24
+ def display_info
25
+ first_vm = true
26
+
27
+ with_target_vms do |vm|
28
+ vm.action_raw(:mountaineer_command, HOOK_PROJECTS)
29
+
30
+ vm.env.ui.info("Machine: #{vm.name}")
31
+ display_machine_mounts(vm)
32
+
33
+ vm.env.ui.info('') if first_vm
34
+
35
+ first_vm = false
36
+ end
37
+ end
38
+
39
+ def display_machine_mounts(machine)
40
+ mounts = get_machine_mounts(machine)
41
+ pad_to = UTIL.pad_to(mounts)
42
+
43
+ mounts.each do |guestpath, hostpath|
44
+ guestpath = guestpath.ljust(pad_to)
45
+ hostpath = Pathname.new(machine.env.root_path) + hostpath
46
+
47
+ machine.env.ui.info(" - #{guestpath} (Host: #{hostpath})")
48
+ end
49
+ end
50
+
51
+ def get_machine_mounts(machine)
52
+ machine.config.vm.synced_folders.sort.map do |_name, sf|
53
+ [sf[:guestpath], sf[:hostpath]]
54
+ end.to_h
55
+ end
56
+
57
+ def select_command(argv)
58
+ case argv[0]
59
+ when 'help' then :display_help
60
+ when 'info' then :display_info
61
+ else :display_help
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -1,6 +1,6 @@
1
1
  module VagrantPlugins
2
2
  module Mountaineer
3
- # Defines the vagrant configuration
3
+ # Vagrant configuration definition
4
4
  class Config < Vagrant.plugin(2, :config)
5
5
  UTIL = VagrantPlugins::Mountaineer::Util
6
6
 
@@ -5,6 +5,10 @@ module VagrantPlugins
5
5
  name 'vagrant-mountaineer'
6
6
  description VagrantPlugins::Mountaineer::SYNOPSIS
7
7
 
8
+ command :mountaineer do
9
+ Command
10
+ end
11
+
8
12
  config :mountaineer do
9
13
  Config
10
14
  end
@@ -8,7 +8,7 @@ module VagrantPlugins
8
8
  end
9
9
 
10
10
  def exist?
11
- nil != path
11
+ !path.nil?
12
12
  end
13
13
 
14
14
  def path
@@ -1,6 +1,6 @@
1
1
  module VagrantPlugins
2
2
  module Mountaineer
3
- # Vagrant project registry
3
+ # Project registry
4
4
  class Registry
5
5
  I18N_KEY = 'vagrant_mountaineer.registry'.freeze
6
6
 
@@ -25,7 +25,7 @@ module VagrantPlugins
25
25
 
26
26
  def project(name, config = nil)
27
27
  config = {} unless config.is_a?(Hash)
28
- config[:options] = {} unless config.is_a?(Hash)
28
+ config[:options] = {} unless config[:options].is_a?(Hash)
29
29
 
30
30
  return config_warning(name) unless valid_config?(config)
31
31
 
@@ -11,6 +11,12 @@ module VagrantPlugins
11
11
 
12
12
  file_path
13
13
  end
14
+
15
+ def self.pad_to(items)
16
+ items = items.keys unless items.is_a?(Array)
17
+
18
+ items.map(&:length).max
19
+ end
14
20
  end
15
21
  end
16
22
  end
@@ -1,6 +1,6 @@
1
1
  module VagrantPlugins
2
2
  # Defines the current plugin version
3
3
  module Mountaineer
4
- VERSION = '0.1.0'.freeze
4
+ VERSION = '0.2.0'.freeze
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-mountaineer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc Neudert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-07 00:00:00.000000000 Z
11
+ date: 2018-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coveralls
@@ -30,42 +30,42 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '12.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '12.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.3'
47
+ version: '3.7'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3.3'
54
+ version: '3.7'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rubocop
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0.34'
61
+ version: '0.55'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0.34'
68
+ version: '0.55'
69
69
  description: Vagrant plugin to mount projects specified in a Projectfile to one of
70
70
  your vagrant boxes
71
71
  email:
@@ -80,6 +80,7 @@ files:
80
80
  - lib/vagrant/mountaineer.rb
81
81
  - lib/vagrant/mountaineer/action.rb
82
82
  - lib/vagrant/mountaineer/action/hook_projects.rb
83
+ - lib/vagrant/mountaineer/command.rb
83
84
  - lib/vagrant/mountaineer/config.rb
84
85
  - lib/vagrant/mountaineer/plugin.rb
85
86
  - lib/vagrant/mountaineer/projectfile.rb
@@ -109,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
110
  version: '0'
110
111
  requirements: []
111
112
  rubyforge_project:
112
- rubygems_version: 2.4.8
113
+ rubygems_version: 2.7.6
113
114
  signing_key:
114
115
  specification_version: 4
115
116
  summary: Mounts projects from a Projectfile