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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b61d2c1869c2781c59cce9b501e55fc56ee2dca6
4
- data.tar.gz: 0b6b807477ce3b01e6e133c1153e25331b81aa2c
3
+ metadata.gz: e747df3cbda252cef807ebcad1089cd2b6aa0fad
4
+ data.tar.gz: 2181ff62dd1ebea7177cfb512cf970a663199997
5
5
  SHA512:
6
- metadata.gz: 3e9cf1802217aeccfae0f99107cee0a8115699ed1241b1530670ed9c57c593ac9ab949385b38251e5a14803005bc299e9ead422fa3fe088cc40d153cec115008
7
- data.tar.gz: 30a5948f0055017eceb7d11723da3c4b93d5c99192d65a8e47c7e1f74fb971415af0a87591949e3e5a052cf5bd8af3289c855f184ab235fe5e2762bf13b88b2a
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
- Without any further arguments, vagrant-save will delete old versions, keeping only the last three. You can override this by setting the `-c|--clean` option.
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
- # Keeping the last six versions
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
- 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:
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
- vagrant save -v 1.2.0
39
- ```
36
+ # Keeping the last six versions
37
+ vagrant save -k 6
40
38
 
41
- The parameter must always have all three digits and must be greater than the installed version
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
@@ -1,5 +1,5 @@
1
1
 
2
2
  Vagrant.configure("2") do |config|
3
+ # This must be set
3
4
  config.vm.box_server_url = "http://localhost:8001"
4
- config.vm.box = "base/typo3"
5
5
  end
@@ -16,15 +16,19 @@ module VagrantPlugins
16
16
  def execute
17
17
  options = {}
18
18
  options[:version] = nil
19
- options[:clean] = 3
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('-c', '--clean', 'Set the version of the uploaded box') do |c|
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[:clean] && options[:clean] > 1
73
- up.clean(machine, options[:clean])
76
+ if options[:keep] && options[:keep] > 1
77
+ up.clean(machine, options[:keep])
74
78
  end
75
79
 
76
80
  end
@@ -11,7 +11,7 @@ module VagrantPlugins
11
11
 
12
12
  description <<-EOF
13
13
  Uses vagrant-export to create a.box file from the current machine and
14
- saves it to a boxserver using a HTTP PUT request.
14
+ saves it to a boxserver using a HTTP POST request.
15
15
  EOF
16
16
 
17
17
  command 'save' do
@@ -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
- client.delete(data_url + '/' + v)
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
 
@@ -5,6 +5,6 @@
5
5
 
6
6
  module VagrantPlugins
7
7
  module Save
8
- VERSION = '0.1.0'
8
+ VERSION = '0.2.0'
9
9
  end
10
10
  end
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.1.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: 2014-12-26 00:00:00.000000000 Z
11
+ date: 2015-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: vagrant-export