knife-tidy 0.3.0 → 0.3.1
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/lib/chef/knife/tidy_backup_clean.rb +27 -2
- data/lib/knife-tidy/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86a06790188fb399074453b78a289aa193e8bbfe
|
4
|
+
data.tar.gz: 01cb25a9b19338ce0cbaa5f121295d32f785fdf4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8f7c576dce15f9a36e78b53249245e247c89244e8a3cb325bc17ddbe168b9b374ac8001283463062093df9818a3750555cb62974ef47ce89e544c84a25efc6d
|
7
|
+
data.tar.gz: 34660b3e329937c01977c4dd901d3818cabed14f4a7025fbe4d52d9be58441328229c5621a9e2dba154717f901c19c58acbc2ff701c4349d906cfecfd30e8df7
|
@@ -108,7 +108,7 @@ class Chef
|
|
108
108
|
puts "INFO: Loading #{cookbook}"
|
109
109
|
ret = cl.load_cookbook(cookbook)
|
110
110
|
if ret.nil?
|
111
|
-
action_needed("ACTION NEEDED: Something's wrong with the #{cookbook} cookbook - cannot load it! Moving to cookbooks.broken folder.")
|
111
|
+
action_needed("ACTION NEEDED: Something's wrong with the #{cookbook} cookbook in org #{org} - cannot load it! Moving to cookbooks.broken folder.")
|
112
112
|
broken_cookooks_add(org, cookbook)
|
113
113
|
end
|
114
114
|
end
|
@@ -148,6 +148,10 @@ class Chef
|
|
148
148
|
|
149
149
|
def generate_metadata_from_file(cookbook, path)
|
150
150
|
md_path = ::File.join(path, 'metadata.rb')
|
151
|
+
json_path = ::File.join(path, 'metadata.json')
|
152
|
+
if !::File.exist?(md_path) && !::File.exist?(json_path)
|
153
|
+
create_minimal_metadata(path)
|
154
|
+
end
|
151
155
|
unless ::File.exist?(md_path)
|
152
156
|
puts "INFO: No metadata.rb in #{path} - skipping"
|
153
157
|
return
|
@@ -168,6 +172,27 @@ class Chef
|
|
168
172
|
exit 1
|
169
173
|
end
|
170
174
|
|
175
|
+
def create_minimal_metadata(cookbook_path)
|
176
|
+
name = tidy.cookbook_name_from_path(cookbook_path)
|
177
|
+
components = cookbook_path.split(File::SEPARATOR)
|
178
|
+
name_version = components[components.index('cookbooks')+1]
|
179
|
+
version = name_version.match(/\d+\.\d+\.\d+/).to_s
|
180
|
+
metadata = {}
|
181
|
+
metadata['name'] = name
|
182
|
+
metadata['version'] = version
|
183
|
+
metadata['description'] = 'the description'
|
184
|
+
metadata['long_description'] = 'the long description'
|
185
|
+
metadata['maintainer'] = 'the maintainer'
|
186
|
+
metadata['maintainer_email'] = 'the maintainer email'
|
187
|
+
rb_file = ::File.join(cookbook_path, 'metadata.rb')
|
188
|
+
puts "REPAIRING: no metadata files exist for #{cookbook_path}, creating #{rb_file}"
|
189
|
+
::File.open(rb_file, 'w') do |f|
|
190
|
+
metadata.each_pair do |key, value|
|
191
|
+
f.write("#{key} '#{value}'\n")
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
171
196
|
def substitutions_file
|
172
197
|
sub_file_path = ::File.expand_path(config[:gsub_file])
|
173
198
|
ui.error "Subtitutions file #{sub_file_path} does not exist!" unless ::File.exist?(sub_file_path)
|
@@ -205,7 +230,7 @@ class Chef
|
|
205
230
|
|
206
231
|
def action_needed(msg)
|
207
232
|
::File.open(action_needed_file_path, 'a') do |f|
|
208
|
-
f.write(msg)
|
233
|
+
f.write(msg + "\n")
|
209
234
|
end
|
210
235
|
end
|
211
236
|
end
|
data/lib/knife-tidy/version.rb
CHANGED