knife-cleanup 0.0.1 → 0.0.2
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.
- data/README.md +0 -0
- data/lib/chef/knife/cleanup_versions.rb +21 -0
- data/lib/knife-cleanup/version.rb +1 -1
- metadata +3 -2
data/README.md
ADDED
File without changes
|
@@ -19,7 +19,10 @@ module ServerCleanup
|
|
19
19
|
class CleanupVersions < Chef::Knife
|
20
20
|
|
21
21
|
deps do
|
22
|
+
require 'fileutils'
|
22
23
|
require 'chef/api_client'
|
24
|
+
require 'chef/cookbook_loader'
|
25
|
+
require 'chef/knife/cookbook_download'
|
23
26
|
end
|
24
27
|
|
25
28
|
banner "knife cleanup versions (options)"
|
@@ -77,6 +80,8 @@ module ServerCleanup
|
|
77
80
|
cbv[cb].each do |cb_ver|
|
78
81
|
print "#{cb_ver} "
|
79
82
|
if config[:delete]
|
83
|
+
dir = ".cleanup/#{cb}/"
|
84
|
+
backup_cookbook(cb,cb_ver,dir)
|
80
85
|
delete_cookbook(cb, cb_ver)
|
81
86
|
end
|
82
87
|
end
|
@@ -90,8 +95,24 @@ module ServerCleanup
|
|
90
95
|
end
|
91
96
|
|
92
97
|
def delete_cookbook(cb, cb_ver)
|
98
|
+
ui.msg "Deleting cookbook #{cb} version #{cb_ver}"
|
93
99
|
rest.delete_rest("cookbooks/#{cb}/#{cb_ver}")
|
94
100
|
print ". "
|
95
101
|
end
|
102
|
+
|
103
|
+
def backup_cookbook(cb,cb_ver,dir)
|
104
|
+
ui.msg "\nFist backing up cookbook #{cb} version #{cb_ver}"
|
105
|
+
FileUtils.mkdir_p(dir)
|
106
|
+
dld = Chef::Knife::CookbookDownload.new
|
107
|
+
dld.name_args = [cb, cb_ver]
|
108
|
+
dld.config[:download_directory] = dir
|
109
|
+
dld.config[:force] = true
|
110
|
+
begin
|
111
|
+
dld.run
|
112
|
+
rescue
|
113
|
+
ui.msg "Failed to download cookbook #{cb} version #{cb_ver}... Skipping"
|
114
|
+
FileUtils.rm_r(File.join(dir, cb + "-" + cb_ver))
|
115
|
+
end
|
116
|
+
end
|
96
117
|
end
|
97
118
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-cleanup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: chef
|
@@ -53,6 +53,7 @@ extra_rdoc_files: []
|
|
53
53
|
files:
|
54
54
|
- .gitignore
|
55
55
|
- Gemfile
|
56
|
+
- README.md
|
56
57
|
- Rakefile
|
57
58
|
- knife-cleanup.gemspec
|
58
59
|
- lib/chef/knife/cleanup_versions.rb
|