vagrant-save 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 +4 -4
- data/README.md +11 -10
- data/Vagrantfile +1 -1
- data/lib/vagrant-save/command.rb +8 -4
- data/lib/vagrant-save/plugin.rb +1 -1
- data/lib/vagrant-save/uploader.rb +15 -1
- data/lib/vagrant-save/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e747df3cbda252cef807ebcad1089cd2b6aa0fad
|
4
|
+
data.tar.gz: 2181ff62dd1ebea7177cfb512cf970a663199997
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8a6179385eafd7ab945ecaa0ce16a35ff6fcb12f87155e1e1d0faec76b662f1bb329d971ad231d37ede6c877c27cee438bfbd82f307ac45d346b6f2321b916a
|
7
|
+
data.tar.gz: 03397a1fe3e97ccb71b9fd8331e99bb6fbe15a158e837cf3c4df99fc792e54d3c19d0f81078ab9e0098bae77b0348462accc66a64c4ce352e9eac1e1b1c22eed
|
data/README.md
CHANGED
@@ -22,23 +22,24 @@ vagrant save
|
|
22
22
|
|
23
23
|
to release a new version of your box.
|
24
24
|
|
25
|
-
|
25
|
+
By default, it increases the bugfix version number by one. So an installed 1.0.0 becomes 1.0.1. You can specify the version yourself using the parameter `-v|--version`, like this:
|
26
26
|
|
27
27
|
```bash
|
28
|
-
|
29
|
-
vagrant save -c 6
|
30
|
-
|
31
|
-
# Keeping all versions
|
32
|
-
vagrant save -c 0
|
28
|
+
vagrant save -v 1.2.0
|
33
29
|
```
|
34
30
|
|
35
|
-
|
31
|
+
The parameter must always have all three digits and must be greater than the installed version.
|
32
|
+
|
33
|
+
You may want to clean up the boxserver by deleting old versions. The `-k|--keep` parameter sets how many versions to keep. The versions are sorted in descending order, older than the newest X will be deleted:
|
36
34
|
|
37
35
|
```bash
|
38
|
-
|
39
|
-
|
36
|
+
# Keeping the last six versions
|
37
|
+
vagrant save -k 6
|
40
38
|
|
41
|
-
|
39
|
+
# Keeping all versions
|
40
|
+
# Does not need to be written, as it is the default setting
|
41
|
+
vagrant save -k 0
|
42
|
+
```
|
42
43
|
|
43
44
|
## License
|
44
45
|
|
data/Vagrantfile
CHANGED
data/lib/vagrant-save/command.rb
CHANGED
@@ -16,15 +16,19 @@ module VagrantPlugins
|
|
16
16
|
def execute
|
17
17
|
options = {}
|
18
18
|
options[:version] = nil
|
19
|
-
options[:
|
19
|
+
options[:keep] = 0
|
20
20
|
|
21
21
|
opts = OptionParser.new do |o|
|
22
22
|
o.banner = 'Usage: vagrant save [version]'
|
23
23
|
o.separator ''
|
24
24
|
|
25
|
-
o.on('-
|
25
|
+
o.on('-v', '--version', 'Set the version of the uploaded box. Defaults to next bugfix version') do |c|
|
26
26
|
options[:clean] = c.to_i
|
27
27
|
end
|
28
|
+
|
29
|
+
o.on('-k', '--keep', 'Number of versions to keep, older will be removed. Must be >= 1. Defaults to 0.') do |c|
|
30
|
+
options[:keep] = c.to_i
|
31
|
+
end
|
28
32
|
end
|
29
33
|
|
30
34
|
argv = parse_options(opts)
|
@@ -69,8 +73,8 @@ module VagrantPlugins
|
|
69
73
|
|
70
74
|
FileUtils.remove(file)
|
71
75
|
|
72
|
-
if options[:
|
73
|
-
up.clean(machine, options[:
|
76
|
+
if options[:keep] && options[:keep] > 1
|
77
|
+
up.clean(machine, options[:keep])
|
74
78
|
end
|
75
79
|
|
76
80
|
end
|
data/lib/vagrant-save/plugin.rb
CHANGED
@@ -24,15 +24,21 @@ module VagrantPlugins
|
|
24
24
|
|
25
25
|
@env.ui.info('Uploading now')
|
26
26
|
|
27
|
+
@logger.debug("Preparing to send file #{file}")
|
28
|
+
|
27
29
|
provider = machine.provider_name.to_s
|
28
30
|
ping_url = make_url(machine)
|
29
31
|
post_url = ping_url + '/' + version + '/' + provider
|
30
32
|
|
33
|
+
@logger.debug("Pinging #{ping_url}")
|
34
|
+
|
31
35
|
client = HTTPClient.new
|
32
36
|
res = client.options(ping_url)
|
33
37
|
|
34
38
|
raise VagrantPlugins::Save::Errors::CannotContactBoxServer unless res.http_header.status_code == 200
|
35
39
|
|
40
|
+
@logger.debug("Sending file to #{post_url}")
|
41
|
+
|
36
42
|
File.open(file) do |f|
|
37
43
|
body = {'box' => f}
|
38
44
|
res = client.post(post_url, body)
|
@@ -53,16 +59,24 @@ module VagrantPlugins
|
|
53
59
|
|
54
60
|
data_url = make_url(machine)
|
55
61
|
|
62
|
+
@logger.debug("Load versions from #{data_url}")
|
63
|
+
|
56
64
|
res = client.get(data_url)
|
57
65
|
data = JSON.parse(res.http_body)
|
58
66
|
|
59
67
|
client = HTTPClient.new
|
60
68
|
saved_versions = data['versions'].map{ |v| v.version}
|
61
69
|
|
70
|
+
@logger.debug("Received #{saved_versions.length} versions")
|
71
|
+
|
62
72
|
if saved_versions.length > keep
|
63
73
|
saved_versions = saved_versions.sort.reverse
|
64
74
|
saved_versions.slice(keep, saved_versions.length).each { |v|
|
65
|
-
|
75
|
+
delete_url = data_url + '/' + v
|
76
|
+
|
77
|
+
@logger.debug("Sending delete #{delete_url}")
|
78
|
+
|
79
|
+
client.delete(delete_url)
|
66
80
|
}
|
67
81
|
end
|
68
82
|
|
data/lib/vagrant-save/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-save
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Georg Großberger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: vagrant-export
|