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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b7f8cd82c1128a57a08b0f4d566b6f4c0fab57e0
4
- data.tar.gz: '00768c3e853bb6bdbde3d183f84094a933e6b08f'
3
+ metadata.gz: 86a06790188fb399074453b78a289aa193e8bbfe
4
+ data.tar.gz: 01cb25a9b19338ce0cbaa5f121295d32f785fdf4
5
5
  SHA512:
6
- metadata.gz: 10ae87a0e2bc3248cc63aa67817e61567ea631df7bb5e644947e97aae7f43db29c3bfec3ef7f78ab4e52aeaf5f690d2d03d1d51bd5e3d41646083eecd1895eb1
7
- data.tar.gz: 9719b04e58c3c9227a6c2839bbb3e0b02e21487885fcb94f7c20a15d5279754c431cff97f4988fa369b4e42710cb6b004c7f4ea898f34db565170971283df5c2
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
@@ -1,4 +1,4 @@
1
1
  module KnifeTidy
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  MAJOR, MINOR, TINY = VERSION.split('.')
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-tidy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Miller