vagrant-mountaineer 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +54 -0
- data/lib/vagrant/mountaineer.rb +16 -0
- data/lib/vagrant/mountaineer/action.rb +15 -0
- data/lib/vagrant/mountaineer/action/hook_projects.rb +48 -0
- data/lib/vagrant/mountaineer/config.rb +40 -0
- data/lib/vagrant/mountaineer/plugin.rb +25 -0
- data/lib/vagrant/mountaineer/projectfile.rb +36 -0
- data/lib/vagrant/mountaineer/registry.rb +48 -0
- data/lib/vagrant/mountaineer/synopsis.rb +6 -0
- data/lib/vagrant/mountaineer/util.rb +16 -0
- data/lib/vagrant/mountaineer/version.rb +6 -0
- data/locales/en.yml +5 -0
- metadata +116 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e0a3a2995954e1ca95e0374cf005e5570f50035c
|
4
|
+
data.tar.gz: 399eb3632ee0f1db04ac1498e82c82dd9d444f9e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ca0cfcded828c97723a3d3ef7db403e73cf6c12b20894e7ef9e0373103ff2d47baf5b563b802d1dc981bf10b939c8cb877bf169e4ef53d103670eb3bf0b379bf
|
7
|
+
data.tar.gz: bcef4d3585cbf232e480b1efe7d8c353e54ebf924a9d654f8f19278406d2a11b16a49230726e77389ecb6e83bca052e912a4c752b097ff2ec388fa947b711f4c
|
data/CHANGELOG.md
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015-* Marc Neudert
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# Vagrant Mountaineer
|
2
|
+
|
3
|
+
Mounts projects from a Projectfile.
|
4
|
+
|
5
|
+
__This plugin is experimental and may change unexpectedly.__
|
6
|
+
|
7
|
+
|
8
|
+
## Usage
|
9
|
+
|
10
|
+
### Vagrant Configuration
|
11
|
+
|
12
|
+
The plugin becomes active once you hook one or more projectfiles into
|
13
|
+
your `Vagrantfile`:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
Vagrant.configure("2") do |config|
|
17
|
+
config.mountaineer.projectfiles = [
|
18
|
+
'primary.projectfile',
|
19
|
+
'secondary.projectfile'
|
20
|
+
]
|
21
|
+
end
|
22
|
+
```
|
23
|
+
|
24
|
+
This will look for project definitions in two files
|
25
|
+
(`primary.projectfile` and `secondary.projectfile`). All paths will be
|
26
|
+
expanded by prefixing the vagrant root directory (where your `Vagrantfile`
|
27
|
+
resides) or taken as is if absolute.
|
28
|
+
|
29
|
+
### Project Definition
|
30
|
+
|
31
|
+
Defining a project to be mounted is done by adding its definition to your
|
32
|
+
projectfile:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
project 'lib',
|
36
|
+
guestpath: '/data/plugin-lib',
|
37
|
+
hostpath: './lib'
|
38
|
+
|
39
|
+
project 'test_nfs',
|
40
|
+
guestpath: '/data/plugin-test',
|
41
|
+
hostpath: './test',
|
42
|
+
options: {
|
43
|
+
type: :nfs
|
44
|
+
}
|
45
|
+
```
|
46
|
+
|
47
|
+
Values for `:guestpath ` and `:hostpath` are required. Additional options
|
48
|
+
(like `type`) can be configuring using the `:options` key. The name of the
|
49
|
+
project will be used as the mount identifier.
|
50
|
+
|
51
|
+
|
52
|
+
## License
|
53
|
+
|
54
|
+
Licensed under the [MIT license](http://opensource.org/licenses/MIT).
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'vagrant'
|
2
|
+
|
3
|
+
I18n.load_path << File.expand_path('../../../locales/en.yml', __FILE__)
|
4
|
+
I18n.reload!
|
5
|
+
|
6
|
+
require 'vagrant/mountaineer/synopsis'
|
7
|
+
require 'vagrant/mountaineer/version'
|
8
|
+
|
9
|
+
require 'vagrant/mountaineer/projectfile'
|
10
|
+
require 'vagrant/mountaineer/registry'
|
11
|
+
require 'vagrant/mountaineer/util'
|
12
|
+
|
13
|
+
require 'vagrant/mountaineer/action'
|
14
|
+
require 'vagrant/mountaineer/action/hook_projects'
|
15
|
+
require 'vagrant/mountaineer/config'
|
16
|
+
require 'vagrant/mountaineer/plugin'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Mountaineer
|
3
|
+
# Vagrant plugin definition
|
4
|
+
module Action
|
5
|
+
include Vagrant::Action::Builtin
|
6
|
+
|
7
|
+
def self.hook_projects
|
8
|
+
Vagrant::Action::Builder.new.tap do |builder|
|
9
|
+
builder.use ConfigValidate
|
10
|
+
builder.use HookProjects
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Mountaineer
|
3
|
+
module Action
|
4
|
+
# Vagrant project hook
|
5
|
+
class HookProjects
|
6
|
+
PROJECTFILE = VagrantPlugins::Mountaineer::Projectfile
|
7
|
+
REGISTRY = VagrantPlugins::Mountaineer::Registry
|
8
|
+
|
9
|
+
def initialize(app, env)
|
10
|
+
@app = app
|
11
|
+
@machine = env[:machine]
|
12
|
+
|
13
|
+
@config = @machine.env.vagrantfile.config
|
14
|
+
@registry = REGISTRY.new(@machine.env)
|
15
|
+
end
|
16
|
+
|
17
|
+
def call(env)
|
18
|
+
load_projectfiles
|
19
|
+
mount_projects
|
20
|
+
|
21
|
+
@app.call(env)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def load_projectfiles
|
27
|
+
files_global = @config.mountaineer.projectfiles
|
28
|
+
files_machine = @machine.config.mountaineer.projectfiles
|
29
|
+
files = (files_global + files_machine).uniq
|
30
|
+
|
31
|
+
files.each do |file|
|
32
|
+
@registry.read_projectfile(PROJECTFILE.new(@machine.env, file))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def mount_projects
|
37
|
+
@registry.projects.each do |name, project|
|
38
|
+
@machine.config.vm.synced_folders[name] = project[:options].merge(
|
39
|
+
disabled: false,
|
40
|
+
guestpath: project[:guestpath],
|
41
|
+
hostpath: project[:hostpath]
|
42
|
+
)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Mountaineer
|
3
|
+
# Defines the vagrant configuration
|
4
|
+
class Config < Vagrant.plugin(2, :config)
|
5
|
+
UTIL = VagrantPlugins::Mountaineer::Util
|
6
|
+
|
7
|
+
attr_accessor :projectfiles
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@projectfiles = UNSET_VALUE
|
11
|
+
end
|
12
|
+
|
13
|
+
def finalize!
|
14
|
+
@projectfiles = [] if @projectfiles == UNSET_VALUE
|
15
|
+
end
|
16
|
+
|
17
|
+
def validate(machine)
|
18
|
+
errors = []
|
19
|
+
|
20
|
+
@projectfiles.each do |file|
|
21
|
+
errors << validate_projectfile(file, machine.env)
|
22
|
+
end
|
23
|
+
|
24
|
+
errors.compact!
|
25
|
+
|
26
|
+
{ 'Mountaineer configuration' => errors }
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def validate_projectfile(file, env)
|
32
|
+
file_path = UTIL.env_abspath(file, env)
|
33
|
+
|
34
|
+
return nil if file_path.exist?
|
35
|
+
|
36
|
+
"Project file not found: #{file_path}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Mountaineer
|
3
|
+
# Vagrant plugin definition
|
4
|
+
class Plugin < Vagrant.plugin(2)
|
5
|
+
name 'vagrant-mountaineer'
|
6
|
+
description VagrantPlugins::Mountaineer::SYNOPSIS
|
7
|
+
|
8
|
+
config :mountaineer do
|
9
|
+
Config
|
10
|
+
end
|
11
|
+
|
12
|
+
action_hook(:mountaineer, :machine_action_reload) do |hook|
|
13
|
+
hook.prepend(VagrantPlugins::Mountaineer::Action.hook_projects)
|
14
|
+
end
|
15
|
+
|
16
|
+
action_hook(:mountaineer, :machine_action_resume) do |hook|
|
17
|
+
hook.prepend(VagrantPlugins::Mountaineer::Action.hook_projects)
|
18
|
+
end
|
19
|
+
|
20
|
+
action_hook(:mountaineer, :machine_action_up) do |hook|
|
21
|
+
hook.prepend(VagrantPlugins::Mountaineer::Action.hook_projects)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Mountaineer
|
3
|
+
# Mountaineer project file representation
|
4
|
+
class Projectfile
|
5
|
+
def initialize(env, path)
|
6
|
+
@env = env
|
7
|
+
@path = Pathname.new(path)
|
8
|
+
end
|
9
|
+
|
10
|
+
def exist?
|
11
|
+
nil != path
|
12
|
+
end
|
13
|
+
|
14
|
+
def path
|
15
|
+
locate_projectfile
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def locate_projectfile
|
21
|
+
if @path.absolute?
|
22
|
+
return nil unless @path.exist?
|
23
|
+
return @path
|
24
|
+
end
|
25
|
+
|
26
|
+
return nil unless @env.root_path
|
27
|
+
|
28
|
+
path = @env.root_path.join(@path)
|
29
|
+
|
30
|
+
return nil unless path.exist?
|
31
|
+
|
32
|
+
path
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Mountaineer
|
3
|
+
# Vagrant project registry
|
4
|
+
class Registry
|
5
|
+
I18N_KEY = 'vagrant_mountaineer.registry'.freeze
|
6
|
+
|
7
|
+
attr_accessor :projects
|
8
|
+
|
9
|
+
def initialize(env)
|
10
|
+
@projects = {}
|
11
|
+
@env = env
|
12
|
+
end
|
13
|
+
|
14
|
+
def read_projectfile(projectfile)
|
15
|
+
instance_eval(projectfile.path.read)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def config_warning(name)
|
21
|
+
@env.ui.warn I18n.t("#{I18N_KEY}.err_configuration", name: name)
|
22
|
+
@env.ui.warn I18n.t("#{I18N_KEY}.def_ignored")
|
23
|
+
@env.ui.warn ''
|
24
|
+
end
|
25
|
+
|
26
|
+
def project(name, config = nil)
|
27
|
+
config = {} unless config.is_a?(Hash)
|
28
|
+
config[:options] = {} unless config.is_a?(Hash)
|
29
|
+
|
30
|
+
return config_warning(name) unless valid_config?(config)
|
31
|
+
|
32
|
+
config[:name] = name
|
33
|
+
|
34
|
+
@projects[name] = config
|
35
|
+
end
|
36
|
+
|
37
|
+
def valid_config?(config)
|
38
|
+
return false unless config[:guestpath].is_a?(String)
|
39
|
+
return false unless config[:hostpath].is_a?(String)
|
40
|
+
|
41
|
+
return false if config[:guestpath].empty?
|
42
|
+
return false if config[:hostpath].empty?
|
43
|
+
|
44
|
+
true
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module Mountaineer
|
3
|
+
# Utility module
|
4
|
+
class Util
|
5
|
+
def self.env_abspath(path, env)
|
6
|
+
file_path = Pathname.new(path)
|
7
|
+
|
8
|
+
unless file_path.absolute?
|
9
|
+
file_path = Pathname.new(env.root_path) + file_path
|
10
|
+
end
|
11
|
+
|
12
|
+
file_path
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/locales/en.yml
ADDED
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-mountaineer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Marc Neudert
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-03-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: coveralls
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.8'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.34'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.34'
|
69
|
+
description: Vagrant plugin to mount projects specified in a Projectfile to one of
|
70
|
+
your vagrant boxes
|
71
|
+
email:
|
72
|
+
- marc.neudert@gmail.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- CHANGELOG.md
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- lib/vagrant/mountaineer.rb
|
81
|
+
- lib/vagrant/mountaineer/action.rb
|
82
|
+
- lib/vagrant/mountaineer/action/hook_projects.rb
|
83
|
+
- lib/vagrant/mountaineer/config.rb
|
84
|
+
- lib/vagrant/mountaineer/plugin.rb
|
85
|
+
- lib/vagrant/mountaineer/projectfile.rb
|
86
|
+
- lib/vagrant/mountaineer/registry.rb
|
87
|
+
- lib/vagrant/mountaineer/synopsis.rb
|
88
|
+
- lib/vagrant/mountaineer/util.rb
|
89
|
+
- lib/vagrant/mountaineer/version.rb
|
90
|
+
- locales/en.yml
|
91
|
+
homepage: https://github.com/mneudert/vagrant-mountaineer
|
92
|
+
licenses:
|
93
|
+
- MIT
|
94
|
+
metadata:
|
95
|
+
allowed_push_host: https://rubygems.org
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
requirements: []
|
111
|
+
rubyforge_project:
|
112
|
+
rubygems_version: 2.4.8
|
113
|
+
signing_key:
|
114
|
+
specification_version: 4
|
115
|
+
summary: Mounts projects from a Projectfile
|
116
|
+
test_files: []
|