vagrant-protobox 0.0.1
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 +7 -0
- data/.gitignore +22 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +53 -0
- data/LICENSE +20 -0
- data/README.md +30 -0
- data/Vagrantfile +15 -0
- data/bin/protobox +5 -0
- data/lib/vagrant-protobox.rb +31 -0
- data/lib/vagrant-protobox/action.rb +27 -0
- data/lib/vagrant-protobox/action/config_exists_check.rb +29 -0
- data/lib/vagrant-protobox/action/install.rb +122 -0
- data/lib/vagrant-protobox/action/switch_config.rb +33 -0
- data/lib/vagrant-protobox/command/install.rb +70 -0
- data/lib/vagrant-protobox/command/root.rb +70 -0
- data/lib/vagrant-protobox/command/switch.rb +39 -0
- data/lib/vagrant-protobox/errors.rb +19 -0
- data/lib/vagrant-protobox/plugin.rb +44 -0
- data/lib/vagrant-protobox/version.rb +5 -0
- data/locales/en.yml +13 -0
- data/vagrant-protobox.gemspec +68 -0
- metadata +75 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 54594875a579b910380428ccbc1e0c8e2600527a
|
|
4
|
+
data.tar.gz: b83d59464d62bb5570c47a0c9fe053af73de922b
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ec36471e9f6874ff412b913342864c1a6fa439628fd97d3c0701e386b63c45fdda3d02b3524eff9a770192d1a3ed0ba325c959a3d077d62b58ecc0dbc6ad5ab2
|
|
7
|
+
data.tar.gz: c086d369144c4fb11c37c62bc3afc795b90a7a01b7a30235addb6a651ce24514c2ac8c3c95eca0ea987292967527e0ee001d0ef1e0dea28a397dd8dd5f8b1e81
|
data/.gitignore
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
*.gem
|
|
2
|
+
*.rbc
|
|
3
|
+
.bundle
|
|
4
|
+
.config
|
|
5
|
+
coverage
|
|
6
|
+
InstalledFiles
|
|
7
|
+
lib/bundler/man
|
|
8
|
+
pkg
|
|
9
|
+
rdoc
|
|
10
|
+
spec/reports
|
|
11
|
+
test/tmp
|
|
12
|
+
test/version_tmp
|
|
13
|
+
tmp
|
|
14
|
+
|
|
15
|
+
# YARD artifacts
|
|
16
|
+
.yardoc
|
|
17
|
+
_yardoc
|
|
18
|
+
doc/
|
|
19
|
+
|
|
20
|
+
# Protobox files
|
|
21
|
+
.protobox
|
|
22
|
+
data
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
GIT
|
|
2
|
+
remote: https://github.com/mitchellh/vagrant.git
|
|
3
|
+
revision: 240523b1aa9f328c09060cff34a211bd3f93f7ca
|
|
4
|
+
specs:
|
|
5
|
+
vagrant (1.5.1.dev)
|
|
6
|
+
bundler (~> 1.5.2)
|
|
7
|
+
childprocess (~> 0.5.0)
|
|
8
|
+
erubis (~> 2.7.0)
|
|
9
|
+
i18n (~> 0.6.0)
|
|
10
|
+
listen (~> 2.4.0)
|
|
11
|
+
log4r (~> 1.1.9, < 1.1.11)
|
|
12
|
+
net-scp (~> 1.1.0)
|
|
13
|
+
net-ssh (>= 2.6.6, < 2.8.0)
|
|
14
|
+
rb-kqueue (~> 0.2.0)
|
|
15
|
+
wdm (~> 0.1.0)
|
|
16
|
+
|
|
17
|
+
PATH
|
|
18
|
+
remote: .
|
|
19
|
+
specs:
|
|
20
|
+
vagrant-protobox (0.0.1)
|
|
21
|
+
|
|
22
|
+
GEM
|
|
23
|
+
remote: https://rubygems.org/
|
|
24
|
+
specs:
|
|
25
|
+
celluloid (0.15.2)
|
|
26
|
+
timers (~> 1.1.0)
|
|
27
|
+
childprocess (0.5.1)
|
|
28
|
+
ffi (~> 1.0, >= 1.0.11)
|
|
29
|
+
erubis (2.7.0)
|
|
30
|
+
ffi (1.9.3)
|
|
31
|
+
i18n (0.6.9)
|
|
32
|
+
listen (2.4.1)
|
|
33
|
+
celluloid (>= 0.15.2)
|
|
34
|
+
rb-fsevent (>= 0.9.3)
|
|
35
|
+
rb-inotify (>= 0.9)
|
|
36
|
+
log4r (1.1.10)
|
|
37
|
+
net-scp (1.1.2)
|
|
38
|
+
net-ssh (>= 2.6.5)
|
|
39
|
+
net-ssh (2.7.0)
|
|
40
|
+
rb-fsevent (0.9.4)
|
|
41
|
+
rb-inotify (0.9.3)
|
|
42
|
+
ffi (>= 0.5.0)
|
|
43
|
+
rb-kqueue (0.2.2)
|
|
44
|
+
ffi (>= 0.5.0)
|
|
45
|
+
timers (1.1.0)
|
|
46
|
+
wdm (0.1.0)
|
|
47
|
+
|
|
48
|
+
PLATFORMS
|
|
49
|
+
ruby
|
|
50
|
+
|
|
51
|
+
DEPENDENCIES
|
|
52
|
+
vagrant!
|
|
53
|
+
vagrant-protobox!
|
data/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014 Patrick Heeney
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
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, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# vagrant-protobox
|
|
2
|
+
|
|
3
|
+
Vagrant Protobox Plugin
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Make sure you have downloaded and installed Vagrant 1.5 or newer from the [Vagrant downloads page](http://downloads.vagrantup.com/).
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
vagrant plugin install vagrant-protobox
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Development
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
bundle
|
|
17
|
+
bundle exec vagrant up
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Contributing
|
|
21
|
+
|
|
22
|
+
1. Fork it
|
|
23
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
24
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
25
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
26
|
+
5. Create new Pull Request
|
|
27
|
+
|
|
28
|
+
## Authors
|
|
29
|
+
|
|
30
|
+
[Patrick Heeney](https://github.com/patrickheeney)
|
data/Vagrantfile
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# -*- mode: ruby -*-
|
|
2
|
+
# vi: set ft=ruby :
|
|
3
|
+
|
|
4
|
+
# Check for protobox plugin
|
|
5
|
+
if !Vagrant.has_plugin?('vagrant-protobox')
|
|
6
|
+
puts "Protobox vagrant plugin missing, run the following:"
|
|
7
|
+
puts "bundle"
|
|
8
|
+
puts "bundle exec vagrant up"
|
|
9
|
+
exit
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
Vagrant.configure("2") do |config|
|
|
13
|
+
config.vm.box = "hashicorp/precise64"
|
|
14
|
+
config.vm.synced_folder "./", "/vagrant", id: 'vagrant-root', nfs: true
|
|
15
|
+
end
|
data/bin/protobox
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require "pathname"
|
|
2
|
+
|
|
3
|
+
require 'vagrant-protobox/version'
|
|
4
|
+
require 'vagrant-protobox/plugin'
|
|
5
|
+
|
|
6
|
+
module VagrantPlugins
|
|
7
|
+
module Protobox
|
|
8
|
+
lib_path = Pathname.new(File.expand_path("../vagrant-protobox", __FILE__))
|
|
9
|
+
autoload :Action, lib_path.join("action")
|
|
10
|
+
autoload :Errors, lib_path.join("errors")
|
|
11
|
+
|
|
12
|
+
def self.logo
|
|
13
|
+
return <<-LOGOBLOCK
|
|
14
|
+
__ __
|
|
15
|
+
.-----.----.-----| |_.-----| |--.-----.--.--.
|
|
16
|
+
| _ | _| _ | _| _ | _ | _ |_ _|
|
|
17
|
+
| __|__| |_____|____|_____|_____|_____|__.__|
|
|
18
|
+
|__|
|
|
19
|
+
LOGOBLOCK
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.system_dir(path)
|
|
23
|
+
@system_dir ||= path.join('.protobox')
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# This returns the path to the source of this plugin.
|
|
27
|
+
def self.source_root
|
|
28
|
+
@source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require 'vagrant/action/builder'
|
|
2
|
+
|
|
3
|
+
module VagrantPlugins
|
|
4
|
+
module Protobox
|
|
5
|
+
module Action
|
|
6
|
+
|
|
7
|
+
def self.action_install
|
|
8
|
+
Vagrant::Action::Builder.new.tap do |b|
|
|
9
|
+
b.use Install
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.action_switch
|
|
14
|
+
Vagrant::Action::Builder.new.tap do |b|
|
|
15
|
+
b.use ConfigExistsCheck
|
|
16
|
+
b.use SwitchConfig
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# The autoload farm
|
|
21
|
+
action_root = Pathname.new(File.expand_path("../action", __FILE__))
|
|
22
|
+
autoload :Install, action_root.join("install")
|
|
23
|
+
autoload :ConfigExistsCheck, action_root.join("config_exists_check")
|
|
24
|
+
autoload :SwitchConfig, action_root.join("switch_config")
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require "vagrant/plugin/manager"
|
|
2
|
+
|
|
3
|
+
module VagrantPlugins
|
|
4
|
+
module Protobox
|
|
5
|
+
module Action
|
|
6
|
+
class ConfigExistsCheck
|
|
7
|
+
def initialize(app, env)
|
|
8
|
+
@app = app
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def call(env)
|
|
12
|
+
system_dir = Protobox.system_dir(env[:root_path])
|
|
13
|
+
config_name = env[:config_name]
|
|
14
|
+
config_dir = system_dir.join("config")
|
|
15
|
+
data_dir = env[:root_path].join("data", "config")
|
|
16
|
+
config_path = data_dir.join(config_name + ".yml")
|
|
17
|
+
|
|
18
|
+
if !File.exist?(config_path)
|
|
19
|
+
raise Protobox::Errors::ConfigNotFound,
|
|
20
|
+
name: config_name,
|
|
21
|
+
path: config_path
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
@app.call(env)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
require "digest/sha1"
|
|
2
|
+
require "log4r"
|
|
3
|
+
require "pathname"
|
|
4
|
+
require "uri"
|
|
5
|
+
|
|
6
|
+
require 'net/http'
|
|
7
|
+
require 'yaml'
|
|
8
|
+
|
|
9
|
+
#
|
|
10
|
+
# TODO:
|
|
11
|
+
# - switch downloading to vagrant util
|
|
12
|
+
# - move yaml to a protobox/util folder
|
|
13
|
+
# - add meta verification
|
|
14
|
+
#
|
|
15
|
+
|
|
16
|
+
#require "vagrant/box_metadata"
|
|
17
|
+
#require "vagrant/util/downloader"
|
|
18
|
+
#require "vagrant/util/file_checksum"
|
|
19
|
+
#require "vagrant/util/platform"
|
|
20
|
+
|
|
21
|
+
module VagrantPlugins
|
|
22
|
+
module Protobox
|
|
23
|
+
module Action
|
|
24
|
+
class Install
|
|
25
|
+
# This is the size in bytes that if a file exceeds, is considered
|
|
26
|
+
# to NOT be metadata.
|
|
27
|
+
METADATA_SIZE_LIMIT = 20971520
|
|
28
|
+
|
|
29
|
+
def initialize(app, env)
|
|
30
|
+
@app = app
|
|
31
|
+
@logger = Log4r::Logger.new("protobox::action::install")
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def call(env)
|
|
35
|
+
|
|
36
|
+
url_name = env[:install_url]
|
|
37
|
+
|
|
38
|
+
@logger.info("Downloading config: #{url_name} => config/name")
|
|
39
|
+
|
|
40
|
+
env[:ui].info("Downloading config: #{url_name} => config/name")
|
|
41
|
+
|
|
42
|
+
# Build http
|
|
43
|
+
uri = URI.parse(url_name.to_s)
|
|
44
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
45
|
+
|
|
46
|
+
# Build request
|
|
47
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
|
48
|
+
request["User-Agent"] = "Protobox"
|
|
49
|
+
|
|
50
|
+
# Get response
|
|
51
|
+
response = http.request(request)
|
|
52
|
+
|
|
53
|
+
# Check for invalid resonse code
|
|
54
|
+
if response.code != "200"
|
|
55
|
+
puts "Could not fetch url: #{url_name}"
|
|
56
|
+
exit(-1)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Store response
|
|
60
|
+
body = response.body.to_s
|
|
61
|
+
|
|
62
|
+
# Convert tabs to spaces
|
|
63
|
+
body = body.gsub!(/(?:^ {2})|\G {2}/m, " ")
|
|
64
|
+
|
|
65
|
+
# Check for yaml document starter
|
|
66
|
+
#if !!yaml[/^---/m]
|
|
67
|
+
# body = "---\n" + body
|
|
68
|
+
#end
|
|
69
|
+
|
|
70
|
+
# Validate response
|
|
71
|
+
begin
|
|
72
|
+
yaml_data = YAML.load(body)
|
|
73
|
+
rescue Exception
|
|
74
|
+
puts "Failed parse yaml for #{url_name}: #{$!}"
|
|
75
|
+
#puts "Failed parse yaml for #{url_name}"
|
|
76
|
+
exit(-1)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Validate yaml
|
|
80
|
+
if !yaml_data.instance_of?(Hash)
|
|
81
|
+
puts "Invalid yaml for #{url_name}"
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# Check for protobox data
|
|
85
|
+
if yaml_data['protobox'].nil? or yaml_data['protobox']['version'].nil? or yaml_data['protobox']['document'].nil?
|
|
86
|
+
puts "Document is missing protobox information"
|
|
87
|
+
exit(-1)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
document = yaml_data['protobox']['document']
|
|
91
|
+
|
|
92
|
+
# Check for bad document name
|
|
93
|
+
if document == 'common'
|
|
94
|
+
puts "Invalid protobox document name"
|
|
95
|
+
exit(-1)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
system_dir = Protobox.system_dir(env[:root_path])
|
|
99
|
+
config_dir = system_dir.join("config")
|
|
100
|
+
data_dir = env[:root_path].join("data", "config")
|
|
101
|
+
config_path = data_dir.join(document + ".yml")
|
|
102
|
+
config_local_path = File.join("data", "config", document + ".yml")
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
# Save document to file system
|
|
106
|
+
File.open(config_path, 'w') do |file|
|
|
107
|
+
file.write(body)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# Write the boot file
|
|
111
|
+
File.open(config_dir, 'w') do |file|
|
|
112
|
+
file.write(config_local_path)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
env[:ui].info("You can now 'vagrant up' using the '#{document}' configuration")
|
|
116
|
+
|
|
117
|
+
@app.call(env)
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module VagrantPlugins
|
|
2
|
+
module Protobox
|
|
3
|
+
module Action
|
|
4
|
+
class SwitchConfig
|
|
5
|
+
def initialize(app, env)
|
|
6
|
+
@app = app
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def call(env)
|
|
10
|
+
system_dir = Protobox.system_dir(env[:root_path])
|
|
11
|
+
config_name = env[:config_name]
|
|
12
|
+
config_dir = system_dir.join("config")
|
|
13
|
+
config_local_path = File.join("data", "config", config_name + ".yml")
|
|
14
|
+
|
|
15
|
+
# Create protobox dir if it doesn't exist
|
|
16
|
+
if !File.directory?(system_dir)
|
|
17
|
+
Dir.mkdir(system_dir)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Write the config file
|
|
21
|
+
File.open(config_dir, 'w') do |file|
|
|
22
|
+
file.write(config_local_path)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
env[:ui].info(I18n.t("vagrant_protobox.actions.switch_config.switched",
|
|
26
|
+
:name => config_name))
|
|
27
|
+
|
|
28
|
+
@app.call(env)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
require 'optparse'
|
|
2
|
+
|
|
3
|
+
module VagrantPlugins
|
|
4
|
+
module Protobox
|
|
5
|
+
module Command
|
|
6
|
+
class Install < Vagrant.plugin("2", :command)
|
|
7
|
+
def execute
|
|
8
|
+
options = { verbose: false }
|
|
9
|
+
|
|
10
|
+
opts = OptionParser.new do |o|
|
|
11
|
+
o.banner = "Usage: vagrant protobox install [options] <url>"
|
|
12
|
+
o.separator ""
|
|
13
|
+
o.separator "Options:"
|
|
14
|
+
o.separator ""
|
|
15
|
+
|
|
16
|
+
o.on("-c", "--clean", "Clean any temporary download files") do |c|
|
|
17
|
+
options[:clean] = c
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
o.on("-f", "--force", "Overwrite an existing box if it exists") do |f|
|
|
21
|
+
options[:force] = f
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
o.on("--verbose", "Enable verbose output for the installation") do |v|
|
|
25
|
+
options[:verbose] = v
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
o.separator ""
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Parse the options
|
|
32
|
+
argv = parse_options(opts)
|
|
33
|
+
return if !argv
|
|
34
|
+
|
|
35
|
+
if argv.empty? || argv.length > 2
|
|
36
|
+
raise Vagrant::Errors::CLIInvalidUsage,
|
|
37
|
+
help: opts.help.chomp
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
url = argv[0]
|
|
41
|
+
if argv.length == 2
|
|
42
|
+
options[:name] = argv[0]
|
|
43
|
+
url = argv[1]
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Install the gem
|
|
47
|
+
#argv.each do |name|
|
|
48
|
+
# action(Action.action_install, {
|
|
49
|
+
# :plugin_entry_point => options[:entry_point],
|
|
50
|
+
# :plugin_version => options[:plugin_version],
|
|
51
|
+
# :plugin_sources => options[:plugin_sources],
|
|
52
|
+
# :plugin_name => name,
|
|
53
|
+
# :plugin_verbose => options[:verbose]
|
|
54
|
+
# })
|
|
55
|
+
#end
|
|
56
|
+
|
|
57
|
+
@env.action_runner.run(Protobox::Action.action_install, {
|
|
58
|
+
install_url: url,
|
|
59
|
+
install_name: options[:name],
|
|
60
|
+
install_verbose: options[:verbose],
|
|
61
|
+
ui: Vagrant::UI::Prefixed.new(@env.ui, "protobox"),
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
# Success, exit status 0
|
|
65
|
+
0
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
require 'optparse'
|
|
2
|
+
|
|
3
|
+
module VagrantPlugins
|
|
4
|
+
module Protobox
|
|
5
|
+
module Command
|
|
6
|
+
class Root < Vagrant.plugin("2", :command)
|
|
7
|
+
def self.synopsis
|
|
8
|
+
"manages protobox: installation, config, etc."
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def initialize(argv, env)
|
|
12
|
+
super
|
|
13
|
+
|
|
14
|
+
@main_args, @sub_command, @sub_args = split_main_and_subcommand(argv)
|
|
15
|
+
|
|
16
|
+
@subcommands = Vagrant::Registry.new
|
|
17
|
+
|
|
18
|
+
@subcommands.register(:install) do
|
|
19
|
+
require_relative "install"
|
|
20
|
+
Install
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
@subcommands.register(:switch) do
|
|
24
|
+
require_relative "switch"
|
|
25
|
+
Switch
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def execute
|
|
30
|
+
if @main_args.include?("-h") || @main_args.include?("--help")
|
|
31
|
+
# Print the help for all the box commands.
|
|
32
|
+
return help
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# If we reached this far then we must have a subcommand. If not,
|
|
36
|
+
# then we also just print the help and exit.
|
|
37
|
+
command_class = @subcommands.get(@sub_command.to_sym) if @sub_command
|
|
38
|
+
return help if !command_class || !@sub_command
|
|
39
|
+
@logger.debug("Invoking command class: #{command_class} #{@sub_args.inspect}")
|
|
40
|
+
|
|
41
|
+
# Initialize and execute the command class
|
|
42
|
+
command_class.new(@sub_args, @env).execute
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Prints the help out for this command
|
|
46
|
+
def help
|
|
47
|
+
opts = OptionParser.new do |opts|
|
|
48
|
+
opts.banner = "Usage: vagrant protobox <subcommand> [<args>]"
|
|
49
|
+
opts.separator ""
|
|
50
|
+
opts.separator "Available subcommands:"
|
|
51
|
+
|
|
52
|
+
# Add the available subcommands as separators in order to print them
|
|
53
|
+
# out as well.
|
|
54
|
+
keys = []
|
|
55
|
+
@subcommands.each { |key, value| keys << key.to_s }
|
|
56
|
+
|
|
57
|
+
keys.sort.each do |key|
|
|
58
|
+
opts.separator " #{key}"
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
opts.separator ""
|
|
62
|
+
opts.separator "For help on any individual subcommand run `vagrant protobox <subcommand> -h`"
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
@env.ui.info(opts.help, :prefix => false)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require 'optparse'
|
|
2
|
+
|
|
3
|
+
module VagrantPlugins
|
|
4
|
+
module Protobox
|
|
5
|
+
module Command
|
|
6
|
+
class Switch < Vagrant.plugin("2", :command)
|
|
7
|
+
def execute
|
|
8
|
+
options = { verbose: false }
|
|
9
|
+
|
|
10
|
+
opts = OptionParser.new do |o|
|
|
11
|
+
o.banner = "Usage: vagrant protobox switch <config>"
|
|
12
|
+
#o.separator ""
|
|
13
|
+
#o.separator "Options:"
|
|
14
|
+
#o.separator ""
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Parse the options
|
|
18
|
+
argv = parse_options(opts)
|
|
19
|
+
return if !argv
|
|
20
|
+
|
|
21
|
+
if argv.empty? || argv.length > 1
|
|
22
|
+
raise Vagrant::Errors::CLIInvalidUsage,
|
|
23
|
+
help: opts.help.chomp
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
config = argv[0]
|
|
27
|
+
|
|
28
|
+
@env.action_runner.run(Protobox::Action.action_switch, {
|
|
29
|
+
config_name: config,
|
|
30
|
+
ui: Vagrant::UI::Prefixed.new(@env.ui, "protobox"),
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
# Success, exit status 0
|
|
34
|
+
0
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require "vagrant"
|
|
2
|
+
|
|
3
|
+
module VagrantPlugins
|
|
4
|
+
module Protobox
|
|
5
|
+
module Errors
|
|
6
|
+
class VagrantError < Vagrant::Errors::VagrantError
|
|
7
|
+
error_namespace("vagrant_protobox.errors")
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
class VersionError < VagrantError
|
|
11
|
+
error_key(:version_error)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
class ConfigNotFound < VagrantError
|
|
15
|
+
error_key(:config_not_found)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
begin
|
|
2
|
+
require 'vagrant'
|
|
3
|
+
rescue LoadError
|
|
4
|
+
raise 'The protobox plugin must be run within Vagrant.'
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
# sanity check
|
|
8
|
+
if Vagrant::VERSION < "1.5.0"
|
|
9
|
+
raise 'The protobox plugin is only compatible with Vagrant 1.5+'
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Add our custom translations to the load path
|
|
13
|
+
I18n.load_path << File.expand_path("../../../locales/en.yml", __FILE__)
|
|
14
|
+
|
|
15
|
+
module VagrantPlugins
|
|
16
|
+
module Protobox
|
|
17
|
+
|
|
18
|
+
def initialize
|
|
19
|
+
puts "here"
|
|
20
|
+
exit
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
class Plugin < Vagrant.plugin("2")
|
|
24
|
+
name "vagrant-protobox"
|
|
25
|
+
description <<-DESC
|
|
26
|
+
The `protobox` plugin allows you to interact with your getprotobox.com install.
|
|
27
|
+
DESC
|
|
28
|
+
|
|
29
|
+
command("protobox") do
|
|
30
|
+
require_relative 'command/root'
|
|
31
|
+
Command::Root
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# This initializes the internationalization strings.
|
|
37
|
+
#def self.setup_i18n
|
|
38
|
+
# I18n.load_path << File.expand_path("locales/en.yml", Protobox.source_root)
|
|
39
|
+
# I18n.reload!
|
|
40
|
+
#end
|
|
41
|
+
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
data/locales/en.yml
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.unshift File.expand_path("../lib", __FILE__)
|
|
3
|
+
require "vagrant-protobox/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = "vagrant-protobox"
|
|
7
|
+
s.version = VagrantPlugins::Protobox::VERSION
|
|
8
|
+
s.platform = Gem::Platform::RUBY
|
|
9
|
+
s.authors = ['Patrick Heeney']
|
|
10
|
+
s.email = ["patrickheeney@gmail.com"]
|
|
11
|
+
s.homepage = "https://getprotobox.com"
|
|
12
|
+
s.license = "MIT"
|
|
13
|
+
s.summary = "The official getprotobox.com command line helper."
|
|
14
|
+
s.description = "The official getprotobox.com command line helper."
|
|
15
|
+
|
|
16
|
+
s.rubyforge_project = s.name
|
|
17
|
+
s.post_install_message =<<eos
|
|
18
|
+
********************************************************************************
|
|
19
|
+
|
|
20
|
+
Web GUI: http://getprotobox.com/
|
|
21
|
+
|
|
22
|
+
Follow @getprotobox on Twitter for announcements, updates, and news.
|
|
23
|
+
https://twitter.com/getprotobox
|
|
24
|
+
|
|
25
|
+
********************************************************************************
|
|
26
|
+
eos
|
|
27
|
+
|
|
28
|
+
#s.files = `git ls-files`.split("\n")
|
|
29
|
+
#s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
30
|
+
#s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
31
|
+
#s.require_paths = ["lib"]
|
|
32
|
+
|
|
33
|
+
root_path = File.dirname(__FILE__)
|
|
34
|
+
all_files = Dir.chdir(root_path) { Dir.glob("**/{*,.*}") }
|
|
35
|
+
all_files.reject! { |file| [".", ".."].include?(File.basename(file)) }
|
|
36
|
+
|
|
37
|
+
gitignore_path = File.join(root_path, ".gitignore")
|
|
38
|
+
gitignore = File.readlines(gitignore_path)
|
|
39
|
+
gitignore.map! { |line| line.chomp.strip }
|
|
40
|
+
gitignore.reject! { |line| line.empty? || line =~ /^(#|!)/ }
|
|
41
|
+
|
|
42
|
+
unignored_files = all_files.reject do |file|
|
|
43
|
+
# Ignore any directories, the gemspec only cares about files
|
|
44
|
+
next true if File.directory?(file)
|
|
45
|
+
|
|
46
|
+
# Ignore any paths that match anything in the gitignore. We do
|
|
47
|
+
# two tests here:
|
|
48
|
+
#
|
|
49
|
+
# - First, test to see if the entire path matches the gitignore.
|
|
50
|
+
# - Second, match if the basename does, this makes it so that things
|
|
51
|
+
# like '.DS_Store' will match sub-directories too (same behavior
|
|
52
|
+
# as git).
|
|
53
|
+
#
|
|
54
|
+
gitignore.any? do |ignore|
|
|
55
|
+
File.fnmatch(ignore, file, File::FNM_PATHNAME) ||
|
|
56
|
+
File.fnmatch(ignore, File.basename(file), File::FNM_PATHNAME)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
s.files = unignored_files
|
|
61
|
+
s.executables = unignored_files.map { |f| f[/^bin\/(.*)/, 1] }.compact
|
|
62
|
+
s.require_path = 'lib'
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
#s.add_development_dependency "bundler", "~> 1.3"
|
|
66
|
+
#s.add_development_dependency "rake"
|
|
67
|
+
#s.add_development_dependency "rspec"
|
|
68
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: vagrant-protobox
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Patrick Heeney
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-03-12 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: The official getprotobox.com command line helper.
|
|
14
|
+
email:
|
|
15
|
+
- patrickheeney@gmail.com
|
|
16
|
+
executables:
|
|
17
|
+
- protobox
|
|
18
|
+
extensions: []
|
|
19
|
+
extra_rdoc_files: []
|
|
20
|
+
files:
|
|
21
|
+
- .gitignore
|
|
22
|
+
- Gemfile
|
|
23
|
+
- Gemfile.lock
|
|
24
|
+
- LICENSE
|
|
25
|
+
- README.md
|
|
26
|
+
- Vagrantfile
|
|
27
|
+
- bin/protobox
|
|
28
|
+
- data/config/DZq.yml
|
|
29
|
+
- data/config/protobox.yml
|
|
30
|
+
- lib/vagrant-protobox.rb
|
|
31
|
+
- lib/vagrant-protobox/action.rb
|
|
32
|
+
- lib/vagrant-protobox/action/config_exists_check.rb
|
|
33
|
+
- lib/vagrant-protobox/action/install.rb
|
|
34
|
+
- lib/vagrant-protobox/action/switch_config.rb
|
|
35
|
+
- lib/vagrant-protobox/command/install.rb
|
|
36
|
+
- lib/vagrant-protobox/command/root.rb
|
|
37
|
+
- lib/vagrant-protobox/command/switch.rb
|
|
38
|
+
- lib/vagrant-protobox/errors.rb
|
|
39
|
+
- lib/vagrant-protobox/plugin.rb
|
|
40
|
+
- lib/vagrant-protobox/version.rb
|
|
41
|
+
- locales/en.yml
|
|
42
|
+
- vagrant-protobox.gemspec
|
|
43
|
+
homepage: https://getprotobox.com
|
|
44
|
+
licenses:
|
|
45
|
+
- MIT
|
|
46
|
+
metadata: {}
|
|
47
|
+
post_install_message: |
|
|
48
|
+
********************************************************************************
|
|
49
|
+
|
|
50
|
+
Web GUI: http://getprotobox.com/
|
|
51
|
+
|
|
52
|
+
Follow @getprotobox on Twitter for announcements, updates, and news.
|
|
53
|
+
https://twitter.com/getprotobox
|
|
54
|
+
|
|
55
|
+
********************************************************************************
|
|
56
|
+
rdoc_options: []
|
|
57
|
+
require_paths:
|
|
58
|
+
- lib
|
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
60
|
+
requirements:
|
|
61
|
+
- - '>='
|
|
62
|
+
- !ruby/object:Gem::Version
|
|
63
|
+
version: '0'
|
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - '>='
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
requirements: []
|
|
70
|
+
rubyforge_project: vagrant-protobox
|
|
71
|
+
rubygems_version: 2.2.2
|
|
72
|
+
signing_key:
|
|
73
|
+
specification_version: 4
|
|
74
|
+
summary: The official getprotobox.com command line helper.
|
|
75
|
+
test_files: []
|