vagrant_cloud 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +35 -0
- data/bin/vagrant_cloud +5 -0
- data/lib/vagrant_cloud/cli.rb +65 -0
- data/lib/vagrant_cloud/provider.rb +24 -3
- data/lib/vagrant_cloud/version.rb +2 -2
- data/lib/vagrant_cloud.rb +1 -0
- metadata +25 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0aae9f88334654ff9910a7e97d01c654064a4660
|
4
|
+
data.tar.gz: 8ddcd0afd5207d258213585b899ac5b906e962bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 071dcd95dd7900acd92149d6ecee33be5c467d3306aa6aad118facbe6cb71b2e58b66b0482147d83e16ac32a7dedf5bf19e0066e7808f11a5988e0c9fc9ace43
|
7
|
+
data.tar.gz: 2b9a62f4de7b920e1326c46b6651270473e5417457469924acd7a8db1c7599a006504e4b8118c8339514ce3327657ac7e7b0a19ae0cb5849a0a06a21bc9b6219
|
data/README.md
CHANGED
@@ -21,3 +21,38 @@ provider = version.ensure_provider('virtualbox', 'http://example.com/foo.box')
|
|
21
21
|
version.release
|
22
22
|
puts provider.download_url
|
23
23
|
```
|
24
|
+
|
25
|
+
Example CLI usage:
|
26
|
+
Create a version and provider within an existing Box, upload a file to be hosted by Vagrant/Atlas, and release the version
|
27
|
+
```sh
|
28
|
+
vagrant_cloud create_version --username $USERNAME --token $VAGRANT_CLOUD_TOKEN --box $BOX_NAME --version $BOX_VERSION
|
29
|
+
vagrant_cloud create_provider --username $USERNAME --token $VAGRANT_CLOUD_TOKEN --box $BOX_NAME --version $BOX_VERSION
|
30
|
+
vagrant_cloud upload_file --username $USERNAME --token $VAGRANT_CLOUD_TOKEN --box $BOX_NAME --version $BOX_VERSION --provider_file_path $PACKAGE_PATH
|
31
|
+
vagrant_cloud release_version --username $USERNAME --token $VAGRANT_CLOUD_TOKEN --box $BOX_NAME --version $BOX_VERSION
|
32
|
+
```
|
33
|
+
If you installed vagrant_cloud with bundler, then you may have to invoke using `bundle exec vagrant_cloud`
|
34
|
+
|
35
|
+
Development & Contributing
|
36
|
+
--------------------------
|
37
|
+
Pull requests are very welcome!
|
38
|
+
|
39
|
+
Install dependencies:
|
40
|
+
```
|
41
|
+
bundle install
|
42
|
+
```
|
43
|
+
|
44
|
+
Run the tests:
|
45
|
+
```
|
46
|
+
bundle exec rspec
|
47
|
+
```
|
48
|
+
|
49
|
+
Check the code syntax:
|
50
|
+
```
|
51
|
+
bundle exec rubocop
|
52
|
+
```
|
53
|
+
|
54
|
+
Release a new version:
|
55
|
+
|
56
|
+
1. Bump the version in `vagrant_cloud.gemspec`, merge to master.
|
57
|
+
2. Push a new tag to master.
|
58
|
+
3. Release to RubyGems with `bundle exec rake release`.
|
data/bin/vagrant_cloud
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module VagrantCloud
|
4
|
+
class Cli < Thor
|
5
|
+
package_name 'VagrantCloud'
|
6
|
+
|
7
|
+
class_option :username, alias: '-u', required: true, desc: 'Vagrant Cloud username'
|
8
|
+
class_option :token, alias: '-t', required: true, desc: 'Vagrant Cloud access token'
|
9
|
+
class_option :box, alias: '-b', required: true, desc: 'name of the box'
|
10
|
+
class_option :verbose, type: :boolean
|
11
|
+
|
12
|
+
desc 'create_version', 'creates a new version within a given box'
|
13
|
+
method_option :version, alias: '-v', required: true, desc: 'version within the box'
|
14
|
+
def create_version
|
15
|
+
version = current_box.create_version(options[:version])
|
16
|
+
puts "created #{version.version} of box #{options[:box]}; current status is #{version.status}" if options[:verbose]
|
17
|
+
version
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'release_version', 'release the specified version within a given box'
|
21
|
+
method_option :version, alias: '-v', required: true, desc: 'version within the box'
|
22
|
+
def release_version
|
23
|
+
version = current_version
|
24
|
+
version.release
|
25
|
+
puts "Box #{options[:box]} / version: #{version.version}; current status is #{version.status}" if options[:verbose]
|
26
|
+
true
|
27
|
+
end
|
28
|
+
|
29
|
+
desc 'create_provider', 'creates a provider within a given box and version'
|
30
|
+
method_option :version, alias: '-v', required: true, desc: 'version within the box'
|
31
|
+
method_option :provider, alias: '-p', default: 'virtualbox', desc: 'the provider for the box; default: virtualbox'
|
32
|
+
method_option :provider_url, alias: '-pu', desc: 'URL to the file for remote hosting; do not include if you intend to upload a file subsequently'
|
33
|
+
def create_provider
|
34
|
+
provider = current_version.create_provider(options[:provider], options[:provider_url])
|
35
|
+
puts "created #{provider.data['name']} provider within version #{provider.version.version}" if options[:verbose]
|
36
|
+
provider
|
37
|
+
end
|
38
|
+
|
39
|
+
desc 'upload_file', 'upload a file for Atlas to host to an existing version and provider'
|
40
|
+
method_option :version, alias: '-v', required: true, desc: 'version within the box'
|
41
|
+
method_option :provider, alias: '-p', default: 'virtualbox', desc: 'the provider for the box; default: virtualbox'
|
42
|
+
method_option :provider_file_path, alias: '-pfp', required: true, desc: 'path to file to be uploaded for Atlast hosting'
|
43
|
+
def upload_file
|
44
|
+
get_provider(options[:provider]).upload_file(options[:provider_file_path])
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def current_account
|
50
|
+
VagrantCloud::Account.new(options[:username], options[:token])
|
51
|
+
end
|
52
|
+
|
53
|
+
def current_box
|
54
|
+
current_account.get_box(options[:box])
|
55
|
+
end
|
56
|
+
|
57
|
+
def current_version
|
58
|
+
current_box.get_version(options[:version])
|
59
|
+
end
|
60
|
+
|
61
|
+
def get_provider(provider_str)
|
62
|
+
current_version.get_provider(provider_str)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -25,17 +25,34 @@ module VagrantCloud
|
|
25
25
|
|
26
26
|
# @return [Hash]
|
27
27
|
def data
|
28
|
-
@data ||= account.request('get',
|
28
|
+
@data ||= account.request('get', provider_path)
|
29
29
|
end
|
30
30
|
|
31
31
|
# @param [String] url
|
32
32
|
def update(url)
|
33
33
|
params = { url: url }
|
34
|
-
@data = account.request('put',
|
34
|
+
@data = account.request('put', provider_path, provider: params)
|
35
35
|
end
|
36
36
|
|
37
37
|
def delete
|
38
|
-
account.request('delete',
|
38
|
+
account.request('delete', provider_path)
|
39
|
+
end
|
40
|
+
|
41
|
+
# @return [String]
|
42
|
+
def upload_url
|
43
|
+
account.request('get', "#{provider_path}/upload")['upload_path']
|
44
|
+
end
|
45
|
+
|
46
|
+
# @param [String] file_path
|
47
|
+
def upload_file(file_path)
|
48
|
+
url = upload_url
|
49
|
+
payload = File.read(file_path)
|
50
|
+
RestClient::Request.execute(
|
51
|
+
method: :put,
|
52
|
+
url: url,
|
53
|
+
payload: payload,
|
54
|
+
ssl_version: 'TLSv1'
|
55
|
+
)
|
39
56
|
end
|
40
57
|
|
41
58
|
private
|
@@ -49,5 +66,9 @@ module VagrantCloud
|
|
49
66
|
def account
|
50
67
|
box.account
|
51
68
|
end
|
69
|
+
|
70
|
+
def provider_path
|
71
|
+
"/box/#{account.username}/#{box.name}/version/#{version.number}/provider/#{name}"
|
72
|
+
end
|
52
73
|
end
|
53
74
|
end
|
@@ -71,8 +71,8 @@ module VagrantCloud
|
|
71
71
|
# @param [String] name
|
72
72
|
# @param [String] url
|
73
73
|
# @return [Provider]
|
74
|
-
def create_provider(name, url)
|
75
|
-
params = { name: name, url: url }
|
74
|
+
def create_provider(name, url = nil)
|
75
|
+
params = { name: name, url: url }.delete_if { |_k, v| v.nil? }
|
76
76
|
data = account.request('post', "/box/#{account.username}/#{box.name}/version/#{number}/providers", provider: params)
|
77
77
|
get_provider(name, data)
|
78
78
|
end
|
data/lib/vagrant_cloud.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant_cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cargo Media
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -16,14 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.0.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.0.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.19.4
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.19.4
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +72,14 @@ dependencies:
|
|
58
72
|
requirements:
|
59
73
|
- - "~>"
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
75
|
+
version: '3.0'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
80
|
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
82
|
+
version: '3.0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rubocop
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -83,15 +97,18 @@ dependencies:
|
|
83
97
|
description: Minimalistic ruby client for the HashiCorp Atlas API (previously Vagrant
|
84
98
|
Cloud API)
|
85
99
|
email: tech@cargomedia.ch
|
86
|
-
executables:
|
100
|
+
executables:
|
101
|
+
- vagrant_cloud
|
87
102
|
extensions: []
|
88
103
|
extra_rdoc_files: []
|
89
104
|
files:
|
90
105
|
- LICENSE
|
91
106
|
- README.md
|
107
|
+
- bin/vagrant_cloud
|
92
108
|
- lib/vagrant_cloud.rb
|
93
109
|
- lib/vagrant_cloud/account.rb
|
94
110
|
- lib/vagrant_cloud/box.rb
|
111
|
+
- lib/vagrant_cloud/cli.rb
|
95
112
|
- lib/vagrant_cloud/provider.rb
|
96
113
|
- lib/vagrant_cloud/version.rb
|
97
114
|
homepage: https://github.com/cargomedia/vagrant_cloud
|
@@ -114,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
131
|
version: '0'
|
115
132
|
requirements: []
|
116
133
|
rubyforge_project:
|
117
|
-
rubygems_version: 2.
|
134
|
+
rubygems_version: 2.6.11
|
118
135
|
signing_key:
|
119
136
|
specification_version: 4
|
120
137
|
summary: HashiCorp Atlas API client
|