vagrant-remove-old-box-versions 1.0.0 → 1.1.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/LICENSE +21 -0
- data/README.md +46 -33
- data/lib/vagrant-remove-old-box-versions.rb +22 -22
- data/lib/vagrant-remove-old-box-versions/command.rb +24 -11
- data/lib/vagrant-remove-old-box-versions/plugin.rb +17 -17
- data/lib/vagrant-remove-old-box-versions/version.rb +4 -4
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c1fe3a3664ab41b568684fcd58923d8a0406674
|
4
|
+
data.tar.gz: ec2bdcba66bf7cb4d28fc4c425a358f6ae26e546
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 487247b89a8f651d0fd93d4b25a41bc627faacd6ee9ae0a816dd5aff25580c64da6fe57604d8e963f44708388e70b968385a90dfc93436ccd146592e01724d02
|
7
|
+
data.tar.gz: 1aa6a2ba045d60e0f599ed31fa95fe9b8fbb1448ddb9de3542733af8d98058d3d6df079af52b0f8b6050743c5afe51f72b90a40aefe0c64b319b89accd1497f3
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 SWIS
|
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.
|
data/README.md
CHANGED
@@ -1,33 +1,46 @@
|
|
1
|
-
# Vagrant remove old box versions plugin
|
2
|
-
|
3
|
-
This plugin enables you to automatically remove old vagrant boxes from you host. Just run ``vagrant remove-old-versions`` and it will check your
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
```
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
1
|
+
# Vagrant remove old box versions plugin
|
2
|
+
|
3
|
+
This plugin enables you to automatically remove old vagrant boxes from you host. Just run ``vagrant remove-old-versions`` and it will check your downloaded boxes and remove every box that is not the lastest downloaded version.
|
4
|
+
|
5
|
+
Internally it uses ```vagrant box list``` to get a list of boxes, and ```vagrant box remove --box-version xxx --provider xxx``` so it still has all safeguards you expect from vagrant.
|
6
|
+
|
7
|
+
[](https://badge.fury.io/rb/vagrant-remove-old-box-versions)
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
```
|
12
|
+
vagrant plugin install vagrant-remove-old-box-versions
|
13
|
+
```
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
```
|
18
|
+
Usage: vagrant remove-old-versions [options]
|
19
|
+
|
20
|
+
Options:
|
21
|
+
|
22
|
+
-p, --provider PROVIDER The specific provider type for the boxes to destroy.
|
23
|
+
-n, --dry-run Only print the boxes that would be removed.
|
24
|
+
--name NAME The specific box name to destroy.
|
25
|
+
-f, --force Destroy without confirmation even when box is in use.
|
26
|
+
```
|
27
|
+
|
28
|
+
## Contributing
|
29
|
+
|
30
|
+
This plugin is built and maintained by [Björn Brala](https://www.swis.nl/over-ons/bjorn-brala)
|
31
|
+
Bug reports and pull requests are welcome on GitHub at [swisnl/vagrant-remove-old-box-versions](https://github.com/swisnl/vagrant-remove-old-box-versions).
|
32
|
+
|
33
|
+
|
34
|
+
## License
|
35
|
+
|
36
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
37
|
+
|
38
|
+
## Changelog
|
39
|
+
|
40
|
+
### [1.1.0] 2016-03-16
|
41
|
+
|
42
|
+
* `---dry-run` and `--name` option added by @danielpanteleit
|
43
|
+
|
44
|
+
### [1.0.0] 2016-01-13
|
45
|
+
|
46
|
+
* Initial release.
|
@@ -1,23 +1,23 @@
|
|
1
|
-
require "pathname"
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'vagrant'
|
5
|
-
rescue LoadError
|
6
|
-
Bundler.require(:default, :development)
|
7
|
-
end
|
8
|
-
require "vagrant-remove-old-box-versions/plugin"
|
9
|
-
require "vagrant-remove-old-box-versions/command"
|
10
|
-
|
11
|
-
|
12
|
-
module VagrantPlugins
|
13
|
-
module RemoveOldBoxVersions
|
14
|
-
lib_path = Pathname.new(File.expand_path("../vagrant-remove-old-box-versions", __FILE__))
|
15
|
-
|
16
|
-
# This returns the path to the source of this plugin.
|
17
|
-
#
|
18
|
-
# @return [Pathname]
|
19
|
-
def self.source_root
|
20
|
-
@source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
|
21
|
-
end
|
22
|
-
end
|
1
|
+
require "pathname"
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'vagrant'
|
5
|
+
rescue LoadError
|
6
|
+
Bundler.require(:default, :development)
|
7
|
+
end
|
8
|
+
require "vagrant-remove-old-box-versions/plugin"
|
9
|
+
require "vagrant-remove-old-box-versions/command"
|
10
|
+
|
11
|
+
|
12
|
+
module VagrantPlugins
|
13
|
+
module RemoveOldBoxVersions
|
14
|
+
lib_path = Pathname.new(File.expand_path("../vagrant-remove-old-box-versions", __FILE__))
|
15
|
+
|
16
|
+
# This returns the path to the source of this plugin.
|
17
|
+
#
|
18
|
+
# @return [Pathname]
|
19
|
+
def self.source_root
|
20
|
+
@source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
|
21
|
+
end
|
22
|
+
end
|
23
23
|
end
|
@@ -10,6 +10,7 @@ module VagrantPlugins
|
|
10
10
|
def execute
|
11
11
|
options = {}
|
12
12
|
options[:force] = false
|
13
|
+
options[:dry_run] = false
|
13
14
|
|
14
15
|
opts = OptionParser.new do |o|
|
15
16
|
o.banner = "Usage: vagrant remove-old-versions [options]"
|
@@ -21,6 +22,14 @@ module VagrantPlugins
|
|
21
22
|
options[:provider] = p
|
22
23
|
end
|
23
24
|
|
25
|
+
o.on("-n", "--dry-run", "Only print the boxes that would be removed.") do |f|
|
26
|
+
options[:dry_run] = f
|
27
|
+
end
|
28
|
+
|
29
|
+
o.on("--name NAME", String, "The specific box name to destroy.") do |name|
|
30
|
+
options[:name] = name
|
31
|
+
end
|
32
|
+
|
24
33
|
o.on("-f", "--force", "Destroy without confirmation even when box is in use.") do |f|
|
25
34
|
options[:force] = f
|
26
35
|
end
|
@@ -35,7 +44,7 @@ module VagrantPlugins
|
|
35
44
|
return @env.ui.warn(I18n.t("vagrant.commands.box.no_installed_boxes"), prefix: false)
|
36
45
|
end
|
37
46
|
|
38
|
-
delete_oldest_boxes(boxes, options[:provider], options[:force])
|
47
|
+
delete_oldest_boxes(boxes, options[:provider], options[:force], options[:name], options[:dry_run])
|
39
48
|
|
40
49
|
# Success, exit status 0
|
41
50
|
0
|
@@ -43,7 +52,7 @@ module VagrantPlugins
|
|
43
52
|
|
44
53
|
private
|
45
54
|
|
46
|
-
def delete_oldest_boxes(boxes, only_provider, skip_confirm)
|
55
|
+
def delete_oldest_boxes(boxes, only_provider, skip_confirm, only_name, dry_run)
|
47
56
|
# Find the longest box name
|
48
57
|
longest_box = boxes.max_by { |x| x[0].length }
|
49
58
|
longest_box_length = longest_box[0].length
|
@@ -54,6 +63,7 @@ module VagrantPlugins
|
|
54
63
|
# First find the newest version for every installed box
|
55
64
|
boxes.each do |name, version, provider|
|
56
65
|
next if only_provider and only_provider != provider.to_s
|
66
|
+
next if only_name and only_name != name
|
57
67
|
|
58
68
|
# Nested to make sure it works for boxes with different providers
|
59
69
|
if newest_boxes.has_key?(name)
|
@@ -97,14 +107,17 @@ module VagrantPlugins
|
|
97
107
|
removed_any_box = true
|
98
108
|
|
99
109
|
# Use the remove box action
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
110
|
+
if dry_run
|
111
|
+
@env.ui.info("would remove #{name} #{provider} #{version}")
|
112
|
+
else
|
113
|
+
@env.action_runner.run(Vagrant::Action.action_box_remove, {
|
114
|
+
box_name: name,
|
115
|
+
box_provider: provider,
|
116
|
+
box_version: version,
|
117
|
+
force_confirm_box_remove: skip_confirm,
|
118
|
+
box_remove_all_versions: false,
|
119
|
+
})
|
120
|
+
end
|
108
121
|
end
|
109
122
|
end
|
110
123
|
|
@@ -114,4 +127,4 @@ module VagrantPlugins
|
|
114
127
|
end
|
115
128
|
end
|
116
129
|
end
|
117
|
-
end
|
130
|
+
end
|
@@ -1,18 +1,18 @@
|
|
1
|
-
require "vagrant"
|
2
|
-
|
3
|
-
module VagrantPlugins
|
4
|
-
module RemoveOldVersions
|
5
|
-
class Plugin < Vagrant.plugin("2")
|
6
|
-
name "remove-old-versions"
|
7
|
-
description <<-DESC
|
8
|
-
This plugin enables you top remove all but the latest installed boxes.
|
9
|
-
DESC
|
10
|
-
|
11
|
-
command("remove-old-versions") do
|
12
|
-
require_relative 'command'
|
13
|
-
Command
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
17
|
-
end
|
1
|
+
require "vagrant"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module RemoveOldVersions
|
5
|
+
class Plugin < Vagrant.plugin("2")
|
6
|
+
name "remove-old-versions"
|
7
|
+
description <<-DESC
|
8
|
+
This plugin enables you top remove all but the latest installed boxes.
|
9
|
+
DESC
|
10
|
+
|
11
|
+
command("remove-old-versions") do
|
12
|
+
require_relative 'command'
|
13
|
+
Command
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
18
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
module VagrantPlugins
|
2
|
-
module RemoveOldVersions
|
3
|
-
VERSION = '1.
|
4
|
-
end
|
1
|
+
module VagrantPlugins
|
2
|
+
module RemoveOldVersions
|
3
|
+
VERSION = '1.1.0'
|
4
|
+
end
|
5
5
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-remove-old-box-versions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bjorn Brala
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -51,6 +51,7 @@ files:
|
|
51
51
|
- ".travis.yml"
|
52
52
|
- Gemfile
|
53
53
|
- Gemfile.lock
|
54
|
+
- LICENSE
|
54
55
|
- LICENSE.txt
|
55
56
|
- README.md
|
56
57
|
- Rakefile
|
@@ -62,6 +63,7 @@ files:
|
|
62
63
|
- lib/vagrant-remove-old-box-versions/version.rb
|
63
64
|
- pkg/vagrant-remove-old-box-versions-0.0.1.gem
|
64
65
|
- pkg/vagrant-remove-old-box-versions-0.0.2.gem
|
66
|
+
- pkg/vagrant-remove-old-box-versions-1.0.0.gem
|
65
67
|
- vagrant-remove-old-box-versions.gemspec
|
66
68
|
homepage: https://github.com/swisnl/vagrant-remove-old-box-versions
|
67
69
|
licenses:
|