vagrant-boxinfo 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +37 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +101 -0
- data/LICENSE +22 -0
- data/README.md +93 -0
- data/Rakefile +3 -0
- data/lib/vagrant-boxinfo/command.rb +92 -0
- data/lib/vagrant-boxinfo/errors.rb +14 -0
- data/lib/vagrant-boxinfo/plugin.rb +15 -0
- data/lib/vagrant-boxinfo/version.rb +5 -0
- data/lib/vagrant-boxinfo.rb +13 -0
- data/vagrant-boxinfo.gemspec +23 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8d17c7d166224fe11b33109f8569425d8f0d7bfe
|
4
|
+
data.tar.gz: 9737944f6f2e95220a4cd446addc73eebeef896d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3d4fa96c09fbe78b938fff5f46b24ed2b265156d6819d938d3c887ecfc7e9dadc07b7423c11be1c933ed239be6e76849d5ddddbc3b635ddb617c777643e2087e
|
7
|
+
data.tar.gz: 19860a5a86893c827ea34f4374d92b40ad69792074e7fb6a489446637557e657c9025467456bc9b697bfdcbf2a81a91e0632ec10c0fdf8ce9a107488d6dc6a40
|
data/.gitignore
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/lib/bundler/man/
|
26
|
+
|
27
|
+
# for a library or gem, you might want to ignore these files since the code is
|
28
|
+
# intended to run in multiple environments; otherwise, check them in:
|
29
|
+
# Gemfile.lock
|
30
|
+
# .ruby-version
|
31
|
+
# .ruby-gemset
|
32
|
+
|
33
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
34
|
+
.rvmrc
|
35
|
+
|
36
|
+
# Rubymine project files
|
37
|
+
.idea
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
GIT
|
2
|
+
remote: https://github.com/mitchellh/vagrant.git
|
3
|
+
revision: a8dcf92f14d8bb8828a43b91804334673508f467
|
4
|
+
specs:
|
5
|
+
vagrant (1.7.2)
|
6
|
+
bundler (>= 1.5.2, < 1.8.0)
|
7
|
+
childprocess (~> 0.5.0)
|
8
|
+
erubis (~> 2.7.0)
|
9
|
+
hashicorp-checkpoint (~> 0.1.1)
|
10
|
+
i18n (>= 0.6.0, <= 0.8.0)
|
11
|
+
listen (~> 2.8.0)
|
12
|
+
log4r (~> 1.1.9, < 1.1.11)
|
13
|
+
net-scp (~> 1.1.0)
|
14
|
+
net-sftp (~> 2.1)
|
15
|
+
net-ssh (>= 2.6.6, < 2.10.0)
|
16
|
+
nokogiri (= 1.6.3.1)
|
17
|
+
rb-kqueue (~> 0.2.0)
|
18
|
+
rest-client (>= 1.6.0, < 2.0)
|
19
|
+
wdm (~> 0.1.0)
|
20
|
+
winrm (~> 1.3)
|
21
|
+
winrm-fs (~> 0.1.0)
|
22
|
+
|
23
|
+
PATH
|
24
|
+
remote: .
|
25
|
+
specs:
|
26
|
+
vagrant-boxinfo (0.0.1)
|
27
|
+
|
28
|
+
GEM
|
29
|
+
remote: https://rubygems.org/
|
30
|
+
specs:
|
31
|
+
builder (3.2.2)
|
32
|
+
celluloid (0.16.0)
|
33
|
+
timers (~> 4.0.0)
|
34
|
+
childprocess (0.5.5)
|
35
|
+
ffi (~> 1.0, >= 1.0.11)
|
36
|
+
erubis (2.7.0)
|
37
|
+
ffi (1.9.6)
|
38
|
+
gssapi (1.2.0)
|
39
|
+
ffi (>= 1.0.1)
|
40
|
+
gyoku (1.2.2)
|
41
|
+
builder (>= 2.1.2)
|
42
|
+
hashicorp-checkpoint (0.1.4)
|
43
|
+
hitimes (1.2.2)
|
44
|
+
httpclient (2.6.0.1)
|
45
|
+
i18n (0.7.0)
|
46
|
+
listen (2.8.5)
|
47
|
+
celluloid (>= 0.15.2)
|
48
|
+
rb-fsevent (>= 0.9.3)
|
49
|
+
rb-inotify (>= 0.9)
|
50
|
+
little-plugger (1.1.3)
|
51
|
+
log4r (1.1.10)
|
52
|
+
logging (1.8.2)
|
53
|
+
little-plugger (>= 1.1.3)
|
54
|
+
multi_json (>= 1.8.4)
|
55
|
+
mime-types (2.4.3)
|
56
|
+
mini_portile (0.6.0)
|
57
|
+
multi_json (1.11.0)
|
58
|
+
net-scp (1.1.2)
|
59
|
+
net-ssh (>= 2.6.5)
|
60
|
+
net-sftp (2.1.2)
|
61
|
+
net-ssh (>= 2.6.5)
|
62
|
+
net-ssh (2.9.2)
|
63
|
+
netrc (0.10.3)
|
64
|
+
nokogiri (1.6.3.1)
|
65
|
+
mini_portile (= 0.6.0)
|
66
|
+
nori (2.4.0)
|
67
|
+
rb-fsevent (0.9.4)
|
68
|
+
rb-inotify (0.9.5)
|
69
|
+
ffi (>= 0.5.0)
|
70
|
+
rb-kqueue (0.2.3)
|
71
|
+
ffi (>= 0.5.0)
|
72
|
+
rest-client (1.7.3)
|
73
|
+
mime-types (>= 1.16, < 3.0)
|
74
|
+
netrc (~> 0.7)
|
75
|
+
rubyntlm (0.4.0)
|
76
|
+
rubyzip (1.1.7)
|
77
|
+
timers (4.0.1)
|
78
|
+
hitimes
|
79
|
+
uuidtools (2.1.5)
|
80
|
+
wdm (0.1.0)
|
81
|
+
winrm (1.3.0)
|
82
|
+
builder (>= 2.1.2)
|
83
|
+
gssapi (~> 1.2)
|
84
|
+
gyoku (~> 1.0)
|
85
|
+
httpclient (~> 2.2, >= 2.2.0.2)
|
86
|
+
logging (~> 1.6, >= 1.6.1)
|
87
|
+
nori (~> 2.0)
|
88
|
+
rubyntlm (~> 0.4.0)
|
89
|
+
uuidtools (~> 2.1.2)
|
90
|
+
winrm-fs (0.1.0)
|
91
|
+
erubis (~> 2.7)
|
92
|
+
logging (~> 1.6, >= 1.6.1)
|
93
|
+
rubyzip (~> 1.1)
|
94
|
+
winrm (~> 1.3.0)
|
95
|
+
|
96
|
+
PLATFORMS
|
97
|
+
ruby
|
98
|
+
|
99
|
+
DEPENDENCIES
|
100
|
+
vagrant!
|
101
|
+
vagrant-boxinfo!
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 kuboj
|
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 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,
|
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 THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
# Vagrant-boxinfo
|
2
|
+
|
3
|
+
Vagrant plugin for displaying custom box info in vagrant self-hosted environments
|
4
|
+
via metadata. (more on Vagrant metadata file
|
5
|
+
[here](http://docs.vagrantup.com/v2/boxes/format.html)).
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```
|
12
|
+
$ vagrant plugin install vagrant-boxinfo
|
13
|
+
```
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
```
|
18
|
+
$ vagrant boxinfo <url or box_name>
|
19
|
+
```
|
20
|
+
|
21
|
+
## Example
|
22
|
+
|
23
|
+
Imagine you host vagrant boxes which are used for LAMP development. Different box
|
24
|
+
versions can have different versions of MySQL, PHP, etc.
|
25
|
+
|
26
|
+
Suppose you have `metadata.json` with following content on your server:
|
27
|
+
|
28
|
+
```json
|
29
|
+
{
|
30
|
+
"name": "lampbox",
|
31
|
+
"description": "Vagrant box for LAMP development based on Ubuntu 14.04",
|
32
|
+
"versions": [
|
33
|
+
{
|
34
|
+
"version": "1.0.1",
|
35
|
+
"php_version": "5.5.22",
|
36
|
+
"mysql_version": "5.6.23",
|
37
|
+
"apache_version": "2.4.12",
|
38
|
+
"providers": [
|
39
|
+
{
|
40
|
+
"name": "virtualbox",
|
41
|
+
"url": "http://myvagranthost.com/lambox-1.0.1.box",
|
42
|
+
}
|
43
|
+
]
|
44
|
+
},
|
45
|
+
{
|
46
|
+
"version": "1.0.0",
|
47
|
+
"php_version": "5.5.21",
|
48
|
+
"mysql_version": "5.6.22",
|
49
|
+
"apache_version": "2.4.12",
|
50
|
+
"providers": [
|
51
|
+
{
|
52
|
+
"name": "virtualbox",
|
53
|
+
"url": "http://myvagranthost.com/lambox-1.0.0.box",
|
54
|
+
}
|
55
|
+
]
|
56
|
+
}
|
57
|
+
]
|
58
|
+
}
|
59
|
+
```
|
60
|
+
|
61
|
+
|
62
|
+
```
|
63
|
+
$ vagrant box list
|
64
|
+
lampbox (virtualbox, 1.0.0)
|
65
|
+
|
66
|
+
$ vagrant boxinfo lambox
|
67
|
+
|
68
|
+
Reading url http://myvagranthost.com/metadata.json...
|
69
|
+
Box name: lampbox
|
70
|
+
Description: Vagrant box for LAMP development based on Ubuntu 14.04
|
71
|
+
|
72
|
+
1.0.1
|
73
|
+
php_version: 5.5.22
|
74
|
+
mysql_version: 5.6.23
|
75
|
+
apache_version: 2.4.12
|
76
|
+
downloaded: false
|
77
|
+
1.0.0
|
78
|
+
php_version: 5.5.21
|
79
|
+
mysql_version: 5.6.22
|
80
|
+
apache_version: 2.4.12
|
81
|
+
downloaded: true
|
82
|
+
```
|
83
|
+
|
84
|
+
If you currently don't have downloaded any version of *lampbox*, you have to pass
|
85
|
+
full url of `metadata.json` to *boxinfo* command.
|
86
|
+
|
87
|
+
## Contributing
|
88
|
+
|
89
|
+
1. Fork it ( https://github.com/[my-github-username]/vagrant-boxinfo/fork )
|
90
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
91
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
92
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
93
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module Boxinfo
|
3
|
+
class Command < Vagrant.plugin('2', :command)
|
4
|
+
def self.synopsis
|
5
|
+
'The `boxinfo` command provides information about boxes based on metadata.json.'
|
6
|
+
end
|
7
|
+
|
8
|
+
def execute
|
9
|
+
options = {}
|
10
|
+
|
11
|
+
opts = OptionParser.new do |o|
|
12
|
+
o.banner = 'Usage: vagrant boxinfo <name or url>'
|
13
|
+
o.separator ''
|
14
|
+
end
|
15
|
+
|
16
|
+
# Parse the options
|
17
|
+
argv = parse_options(opts)
|
18
|
+
return if !argv
|
19
|
+
|
20
|
+
if argv.empty? || argv.length > 1
|
21
|
+
raise Vagrant::Errors::CLIInvalidUsage,
|
22
|
+
help: opts.help.chomp
|
23
|
+
end
|
24
|
+
|
25
|
+
arg = argv[0]
|
26
|
+
url = if arg.start_with?('http://', 'https://')
|
27
|
+
arg
|
28
|
+
else
|
29
|
+
get_metadata_url(arg)
|
30
|
+
end
|
31
|
+
|
32
|
+
@env.ui.info("Reading url #{url}...")
|
33
|
+
|
34
|
+
print_info(download(url))
|
35
|
+
|
36
|
+
0
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def get_metadata_url(box_name)
|
41
|
+
fail BoxinfoError, "Box '#{box_name}' not found" unless local_box_exists?(box_name)
|
42
|
+
filename = @env.boxes.directory.join(box_name).join('metadata_url')
|
43
|
+
|
44
|
+
fail BoxinfoError, "Local metadata file '#{filename}' does not exist. " +
|
45
|
+
"Maybe this box was not downloaded via metadata " +
|
46
|
+
"json ...?" unless File.exists?(filename)
|
47
|
+
|
48
|
+
File.read(filename).strip
|
49
|
+
end
|
50
|
+
|
51
|
+
def print_info(remote_boxes_metadata)
|
52
|
+
box_name = remote_boxes_metadata[:name]
|
53
|
+
|
54
|
+
@env.ui.info("Box name: #{box_name}")
|
55
|
+
@env.ui.info("Description: #{remote_boxes_metadata[:description]}")
|
56
|
+
@env.ui.info("\n")
|
57
|
+
|
58
|
+
remote_boxes_metadata[:versions].each do |box|
|
59
|
+
@env.ui.info("#{box[:version]}")
|
60
|
+
box.each do |k, v|
|
61
|
+
next if %i(providers version).include?(k)
|
62
|
+
|
63
|
+
@env.ui.info("\t #{k}: #{v}")
|
64
|
+
end
|
65
|
+
|
66
|
+
@env.ui.info("\t downloaded: #{local_box_version_exists?(box_name, box[:version])}")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def local_box_exists?(name)
|
71
|
+
@env.boxes.all.map(&:first).include?(name)
|
72
|
+
end
|
73
|
+
|
74
|
+
def local_box_version_exists?(name, version)
|
75
|
+
@env.boxes.all.map { |b| [b[0], b[1]]}.include?([name, version])
|
76
|
+
end
|
77
|
+
|
78
|
+
def download(url)
|
79
|
+
uri = URI.parse(url)
|
80
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
81
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
82
|
+
response = http.request(request)
|
83
|
+
|
84
|
+
fail BoxinfoError, "Error downloading #{url}" if response.code != '200'
|
85
|
+
|
86
|
+
JSON.parse(response.body, symbolize_names: true)
|
87
|
+
rescue JSON::ParserError
|
88
|
+
raise BoxinfoError, "Error parsing downloaded JSON from #{url}"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'vagrant'
|
2
|
+
|
3
|
+
module Vagrant
|
4
|
+
module Boxinfo
|
5
|
+
class Plugin < Vagrant.plugin('2')
|
6
|
+
name 'boxinfo command'
|
7
|
+
description 'The `boxinfo` command provides information about boxes based on metadata.json.'
|
8
|
+
|
9
|
+
command 'boxinfo' do
|
10
|
+
require_relative 'command'
|
11
|
+
Command
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'vagrant-boxinfo/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "vagrant-boxinfo"
|
8
|
+
spec.version = Vagrant::Boxinfo::VERSION
|
9
|
+
spec.authors = ["Jakub Jursa"]
|
10
|
+
spec.email = ["jju@rsd.com"]
|
11
|
+
spec.summary = %q{Vagrant plugin for getting metadata for self-hosted boxes}
|
12
|
+
spec.description = %q{Vagrant plugin for getting metadata for self-hosted boxes}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-boxinfo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jakub Jursa
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
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
|
+
description: Vagrant plugin for getting metadata for self-hosted boxes
|
42
|
+
email:
|
43
|
+
- jju@rsd.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- Gemfile.lock
|
51
|
+
- LICENSE
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- lib/vagrant-boxinfo.rb
|
55
|
+
- lib/vagrant-boxinfo/command.rb
|
56
|
+
- lib/vagrant-boxinfo/errors.rb
|
57
|
+
- lib/vagrant-boxinfo/plugin.rb
|
58
|
+
- lib/vagrant-boxinfo/version.rb
|
59
|
+
- vagrant-boxinfo.gemspec
|
60
|
+
homepage: ''
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.4.5
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: Vagrant plugin for getting metadata for self-hosted boxes
|
84
|
+
test_files: []
|