bourdain 1.6.0 → 1.6.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/VERSION +1 -1
- data/templates/cookbook/Rakefile +267 -43
- data/templates/cookbook/recipes/example.rb +0 -34
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce8924ef181043fcb63aac82f0bdb47411352ab3
|
4
|
+
data.tar.gz: 0bf26f7f20f2fc7d769101c38b6e89555c66fc1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f30fe73cda0c2a81d7efb27fc6061aa0876c17e2c1eb4df6768dbbaf6a1f7d0c2d5f3a2b2d5e506b5be230d4d8051e4f6512ab0e5550016254cf13e22f185542
|
7
|
+
data.tar.gz: ed5b93a7697822f9a50a4a7a7ee50b780a925b4ef2383a8b2fbfe03ddd4decc764854e65ee3531f980cb924534276abeaa43fbc94208988779fa9f9cf8073ffa
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.6.
|
1
|
+
1.6.1
|
data/templates/cookbook/Rakefile
CHANGED
@@ -1,6 +1,15 @@
|
|
1
|
-
|
2
|
-
require '
|
3
|
-
require '
|
1
|
+
begin
|
2
|
+
require 'rubygems'
|
3
|
+
require 'bundler'
|
4
|
+
require 'rake'
|
5
|
+
require 'json'
|
6
|
+
require 'jsonlint/rake_task'
|
7
|
+
rescue LoadError
|
8
|
+
puts "\e[31mCouldn't load required gems, have you run \e[35m`bundle exec tony check`\e[31m recently?\e[0m"
|
9
|
+
puts "\e[31mYou prolly need to \e[35m`bundle update`\e[31m with the latest Kitchen...\e[0m"
|
10
|
+
exit 2
|
11
|
+
end
|
12
|
+
|
4
13
|
|
5
14
|
|
6
15
|
def master?
|
@@ -14,7 +23,17 @@ end
|
|
14
23
|
|
15
24
|
|
16
25
|
def realm?
|
17
|
-
`git ls-files` =~ /\bBerksfile\.lock\b/
|
26
|
+
!kitchen? && `git ls-files` =~ /\bBerksfile\.lock\b/
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
def kitchen?
|
31
|
+
`git ls-files` =~ /\bGemfile\b/
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
def versioned?
|
36
|
+
File.exist? 'VERSION'
|
18
37
|
end
|
19
38
|
|
20
39
|
|
@@ -25,7 +44,7 @@ end
|
|
25
44
|
|
26
45
|
def youre_dirty?
|
27
46
|
dirty = `git diff HEAD --numstat`.split("\n").length > 0
|
28
|
-
raise unless $?.exitstatus.zero?
|
47
|
+
raise '`git diff` failed' unless $?.exitstatus.zero?
|
29
48
|
dirty
|
30
49
|
end
|
31
50
|
|
@@ -38,10 +57,10 @@ end
|
|
38
57
|
|
39
58
|
|
40
59
|
def youre_behind?
|
41
|
-
`git fetch
|
42
|
-
`git
|
60
|
+
`git fetch --tags`
|
61
|
+
raise '`git fetch --tags` failed' unless $?.exitstatus.zero?
|
43
62
|
behind = `git log ..origin/master --oneline`.split("\n").length > 0
|
44
|
-
raise unless $?.exitstatus.zero?
|
63
|
+
raise '`git log` failed' unless $?.exitstatus.zero?
|
45
64
|
return behind
|
46
65
|
end
|
47
66
|
|
@@ -56,41 +75,107 @@ end
|
|
56
75
|
def bump component
|
57
76
|
youre_dirty!
|
58
77
|
youre_behind!
|
59
|
-
`tony bump #{component}`
|
78
|
+
`bundle exec tony bump #{component}`
|
79
|
+
raise '`tony bump` failed' unless $?.exitstatus.zero?
|
60
80
|
if realm?
|
61
|
-
`berks`
|
81
|
+
`bundle exec berks`
|
82
|
+
raise '`berks` failed' unless $?.exitstatus.zero?
|
62
83
|
`git add Berksfile.lock`
|
84
|
+
raise '`git add` failed' unless $?.exitstatus.zero?
|
63
85
|
end
|
64
86
|
version = current_version
|
65
87
|
`git add VERSION`
|
88
|
+
raise '`git add` failed' unless $?.exitstatus.zero?
|
66
89
|
`git commit -m "Version bump to #{version}"`
|
90
|
+
raise '`git commit` failed' unless $?.exitstatus.zero?
|
67
91
|
`git tag -a v#{version} -m v#{version}`
|
68
|
-
raise '
|
92
|
+
raise '`git tag` failed' unless $?.exitstatus.zero?
|
69
93
|
puts 'Version is now "%s"' % version
|
70
94
|
end
|
71
95
|
|
72
96
|
|
73
|
-
def bump_and_release component
|
74
|
-
|
75
|
-
bump component
|
97
|
+
def bump_and_release component=nil
|
98
|
+
bump component unless component == :nop
|
76
99
|
youre_dirty!
|
77
100
|
youre_behind!
|
78
101
|
`git push`
|
79
|
-
raise '
|
80
|
-
`git push --
|
81
|
-
raise '
|
102
|
+
raise '`git push` failed' unless $?.exitstatus.zero?
|
103
|
+
`git push --tags`
|
104
|
+
raise '`git push --tags` failed' unless $?.exitstatus.zero?
|
82
105
|
end
|
83
106
|
|
84
107
|
|
85
108
|
def repo_root_dir
|
86
|
-
`git rev-parse --show-toplevel`.strip
|
109
|
+
root_dir = `git rev-parse --show-toplevel`.strip
|
110
|
+
raise '`git rev-parse` failed' unless $?.exitstatus.zero?
|
111
|
+
root_dir
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
def json_files kind
|
116
|
+
Dir[File.join(repo_root_dir, kind, '**', '*.json')]
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
def check_items kind
|
121
|
+
json_files(kind).each do |item_path|
|
122
|
+
item_name = File.basename(item_path, '.json')
|
123
|
+
item_file = File.read item_path
|
124
|
+
item = JSON.parse item_file
|
125
|
+
item_id = item['id'] || item['name']
|
126
|
+
if item_id && item_name != item_id
|
127
|
+
raise 'Invalid %s: %s' % [ kind, item_name ]
|
128
|
+
end
|
129
|
+
end
|
87
130
|
end
|
88
131
|
|
89
132
|
|
90
|
-
def
|
91
|
-
|
92
|
-
|
93
|
-
|
133
|
+
def check_role_and_environment_naming
|
134
|
+
cookbook_name = File.basename repo_root_dir
|
135
|
+
|
136
|
+
env_names = json_files('environments').map { |f| File.basename(f, '.json') }
|
137
|
+
|
138
|
+
es = env_names.select { |n| !(n =~ /^#{cookbook_name}/) }
|
139
|
+
unless es.empty?
|
140
|
+
raise 'Hey, I found an environment not named after the realm! (%s)' % es.join(', ')
|
141
|
+
end
|
142
|
+
|
143
|
+
role_names = json_files('roles').map { |f| File.basename(f, '.json') }
|
144
|
+
|
145
|
+
rs = role_names.select { |n| !(n =~ /^#{cookbook_name}/) }
|
146
|
+
unless rs.empty?
|
147
|
+
raise 'Hey, I found a role not named after the realm! (%s)' % rs.join(', ')
|
148
|
+
end
|
149
|
+
|
150
|
+
cs = role_names & env_names
|
151
|
+
|
152
|
+
unless cs.empty?
|
153
|
+
raise "Hey, I found a role with the same name as an environment! (%s)" % cs.join(', ')
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
|
158
|
+
def prettify_json_files commit=false
|
159
|
+
puts 'Prettifying JSON files'
|
160
|
+
json_files('*').each do |path|
|
161
|
+
reformatted = JSON.pretty_generate(JSON.parse(File.read(path)))
|
162
|
+
File.open(path, 'w') { |f| f.puts reformatted }
|
163
|
+
`git add #{path} >/dev/null 2>&1`
|
164
|
+
end
|
165
|
+
`git commit -m 'Prettify JSON files [automated]'` if commit
|
166
|
+
end
|
167
|
+
|
168
|
+
|
169
|
+
def lint commit=false
|
170
|
+
if kitchen? # skip most linting
|
171
|
+
check_items 'data_bags'
|
172
|
+
prettify_json_files commit
|
173
|
+
return
|
174
|
+
end
|
175
|
+
|
176
|
+
system "bundle exec knife cookbook test #{File.basename repo_root_dir} -o .."
|
177
|
+
raise '`knife cookbook test` failed' unless $?.exitstatus.zero?
|
178
|
+
system 'bundle exec foodcritic .' # Merely a suggestion, no "raise" here
|
94
179
|
|
95
180
|
unless realm?
|
96
181
|
if Dir.exist? File.join(repo_root_dir, 'environments')
|
@@ -102,63 +187,202 @@ def lint
|
|
102
187
|
end
|
103
188
|
|
104
189
|
if Dir.exist? File.join(repo_root_dir, 'data_bags')
|
105
|
-
raise "Hey, I found data bags
|
190
|
+
raise "Hey, I found data bags, but this isn't realm!"
|
191
|
+
end
|
192
|
+
|
193
|
+
else # realm
|
194
|
+
check_items 'environments'
|
195
|
+
check_items 'roles'
|
196
|
+
check_items 'data_bags'
|
197
|
+
check_role_and_environment_naming
|
198
|
+
prettify_json_files commit
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
|
203
|
+
CHEFDK_PATH = '/opt/chefdk'
|
204
|
+
REQUIRE_RUBY_VERSION = '2.1'
|
205
|
+
RECOMMEND_RUBY_VERSION = '2.3'
|
206
|
+
|
207
|
+
def which cmd ; `which #{cmd}`.strip end
|
208
|
+
|
209
|
+
def shebang cmd
|
210
|
+
File.read(which(cmd)).lines.first.strip
|
211
|
+
rescue
|
212
|
+
puts "\e[31mCould not calculate shebang for %s\e[0m" % cmd.inspect
|
213
|
+
nil
|
214
|
+
end
|
215
|
+
|
216
|
+
def shebangs cmds ; Hash[cmds.map { |c| [ c, shebang(c) ] }] end
|
217
|
+
|
218
|
+
def check_installation
|
219
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new(REQUIRE_RUBY_VERSION)
|
220
|
+
puts "\e[31mWhoa! Looks like you got an old version of Ruby!\e[0m"
|
221
|
+
puts
|
222
|
+
puts <<-END.gsub(/^ +/,'').strip
|
223
|
+
Your Ruby installation is a little too old to support. We ask that
|
224
|
+
users upgrade to at least v#{REQUIRE_RUBY_VERSION}. We recommend at least v#{RECOMMEND_RUBY_VERSION} for best
|
225
|
+
results. There are lots of ways to accomplish this:
|
226
|
+
|
227
|
+
- Homebrew: `brew install ruby`
|
228
|
+
- Source: https://www.ruby-lang.org/en/documentation/installation#building-from-source
|
229
|
+
- chruby+ruby-install: https://github.com/postmodern/chruby#readme
|
230
|
+
- rbenv+ruby-build: https://github.com/rbenv/rbenv#readme
|
231
|
+
- RVM: https://rvm.io
|
232
|
+
|
233
|
+
Make sure you update Bundler, too (`gem install bundler`)
|
234
|
+
|
235
|
+
You should fix this ASAP.
|
236
|
+
END
|
237
|
+
raise
|
238
|
+
end
|
239
|
+
|
240
|
+
unless File.exist? CHEFDK_PATH
|
241
|
+
puts "\e[31mWhoa! Looks like you don't have ChefDK installed!\e[0m"
|
242
|
+
puts
|
243
|
+
puts <<-END.gsub(/^ +/,'').strip
|
244
|
+
While the Kitchen distributes all the Chef-related tooling you need,
|
245
|
+
some tools like Vagrant expect ChefDK to be installed. Chef provides
|
246
|
+
omnibus packages for most platforms:
|
247
|
+
|
248
|
+
- https://downloads.chef.io/chef-dk
|
249
|
+
|
250
|
+
Note that although ChefDK should be installed, it should not be on
|
251
|
+
your PATH, as the embedded tools may conflict with those provided by
|
252
|
+
the Kitchen. The Kitchen will use ChefDK as necessary.
|
253
|
+
|
254
|
+
You should fix this ASAP.
|
255
|
+
END
|
256
|
+
raise
|
257
|
+
end
|
258
|
+
|
259
|
+
if ENV['PATH'] =~ /chefdk/
|
260
|
+
puts "\e[31mWhoa! Looks like you got ChefDK on your PATH!\e[0m"
|
261
|
+
puts
|
262
|
+
puts <<-END.gsub(/^ +/,'').strip
|
263
|
+
The Kitchen distributes all the Chef-related tooling you need,
|
264
|
+
acting as a kind of ChefDK tailored for Blue Jeans. Unfortunately,
|
265
|
+
ChefDK sometimes distributes conflicting tooling, so we ask users
|
266
|
+
to avoid putting ChefDK on their PATH but leave it installed. The
|
267
|
+
Kitchen will use ChefDK as necessary.
|
268
|
+
|
269
|
+
You should fix this ASAP.
|
270
|
+
END
|
271
|
+
raise
|
272
|
+
end
|
273
|
+
|
274
|
+
err = false
|
275
|
+
{ # Which commands important for what tooling
|
276
|
+
'Ruby' => %w[ gem bundle ],
|
277
|
+
'Chef' => %w[ rake berks tony foodcritic kitchen ]
|
278
|
+
}.each do |tooling, check_commands|
|
279
|
+
check_shebangs = shebangs check_commands
|
280
|
+
unless check_shebangs.values.uniq.size == 1
|
281
|
+
puts "\e[33mHead's up: I seem some conflicting shebang lines.\e[0m"
|
282
|
+
puts
|
283
|
+
puts <<-END.gsub(/^ +/,'')
|
284
|
+
The Kitchen depends on a stable, clean installation of #{tooling}
|
285
|
+
tooling. We expect that all these Gems are managed by the same
|
286
|
+
installation, but it's easy for things to get messy:
|
287
|
+
END
|
288
|
+
check_shebangs.each do |cmd, shebang|
|
289
|
+
puts '- %s: %s' % [
|
290
|
+
cmd, shebang ? shebang.inspect : 'missing?'
|
291
|
+
]
|
292
|
+
end
|
293
|
+
puts <<-END.gsub(/^ +/,'').rstrip
|
294
|
+
|
295
|
+
Depending on your Ruby install method, this may not actually be an
|
296
|
+
issue at all, but it could aid in debugging. You might also try simply
|
297
|
+
prefixing your command with `bundle exec` to execute within the context
|
298
|
+
of the current gem bundle.
|
299
|
+
END
|
300
|
+
err = true
|
106
301
|
end
|
107
302
|
end
|
303
|
+
|
304
|
+
puts "\e[32mYour Kitchen installation looks good\e[0m" unless err
|
108
305
|
end
|
109
306
|
|
110
307
|
|
111
308
|
|
309
|
+
JsonLint::RakeTask.new do |t|
|
310
|
+
t.paths = %w[ **/*.json ]
|
311
|
+
end
|
312
|
+
|
313
|
+
desc 'Check your Kitchen installation'
|
314
|
+
task :check do
|
315
|
+
check_installation
|
316
|
+
end
|
317
|
+
|
112
318
|
|
113
319
|
desc 'Perform syntax check and linting'
|
114
|
-
task :
|
320
|
+
task lint: :jsonlint do
|
115
321
|
lint
|
116
322
|
end
|
323
|
+
task full_lint: :jsonlint do
|
324
|
+
lint true
|
325
|
+
end
|
117
326
|
|
118
327
|
|
119
328
|
if test_kitchen?
|
120
329
|
desc 'Execute default Test Kitchen test suite'
|
121
330
|
task test: :lint do
|
122
|
-
system 'kitchen test'
|
331
|
+
system 'bundle exec kitchen test'
|
123
332
|
end
|
124
333
|
end
|
125
334
|
|
126
335
|
|
127
|
-
|
128
|
-
|
129
|
-
|
336
|
+
if versioned?
|
337
|
+
desc 'Print the current version'
|
338
|
+
task :version do
|
339
|
+
puts current_version
|
340
|
+
end
|
130
341
|
end
|
131
342
|
|
132
343
|
|
344
|
+
|
133
345
|
if master?
|
134
|
-
|
135
|
-
desc 'Release
|
136
|
-
task :
|
137
|
-
bump_and_release :
|
346
|
+
if kitchen?
|
347
|
+
desc 'Release a Kitchen update'
|
348
|
+
task release: %w[ check full_lint ] do
|
349
|
+
bump_and_release :nop
|
138
350
|
end
|
139
351
|
|
140
|
-
|
141
|
-
|
142
|
-
|
352
|
+
else
|
353
|
+
namespace :release do
|
354
|
+
desc 'Release new major version'
|
355
|
+
task major: %w[ check full_lint ] do
|
356
|
+
bump_and_release :major
|
357
|
+
end
|
358
|
+
|
359
|
+
desc 'Release new minor version'
|
360
|
+
task minor: %w[ check full_lint ] do
|
361
|
+
bump_and_release :minor
|
362
|
+
end
|
363
|
+
|
364
|
+
task patch: %w[ check full_lint ] do
|
365
|
+
bump_and_release :patch
|
366
|
+
end
|
143
367
|
end
|
144
368
|
|
145
|
-
|
146
|
-
|
147
|
-
end
|
369
|
+
desc 'Release a new patch version'
|
370
|
+
task release: %w[ release:patch ]
|
148
371
|
end
|
149
372
|
|
150
|
-
desc 'Release a new patch version'
|
151
|
-
task release: %w[ release:patch ]
|
152
|
-
|
153
373
|
|
154
374
|
if realm?
|
155
375
|
desc 'Apply Berksfile lock to an environment'
|
156
376
|
task :constrain, [ :env ] do |_, args|
|
157
|
-
|
377
|
+
check_installation
|
158
378
|
youre_dirty!
|
159
379
|
youre_behind!
|
380
|
+
envs = json_files('environments').map { |f| File.basename(f, '.json') }
|
381
|
+
raise 'Could not find local environment "%s"' % args[:env] unless envs.include?(args[:env])
|
160
382
|
`git tag -a #{args[:env]} -m #{args[:env]} --force`
|
161
|
-
`git
|
383
|
+
raise '`git tag` failed' unless $?.exitstatus.zero?
|
384
|
+
`git push origin #{args[:env]} --force`
|
385
|
+
raise '`git push` failed' unless $?.exitstatus.zero?
|
162
386
|
end
|
163
387
|
end
|
164
388
|
end
|
@@ -2,37 +2,3 @@
|
|
2
2
|
# Cookbook Name:: <%= cookbook_name %>
|
3
3
|
# Recipe:: <%= name %>
|
4
4
|
#
|
5
|
-
<%- attribute_ns = cookbook_name.gsub(/^(bjn|app|base|fork|realm)_/, '') -%>
|
6
|
-
|
7
|
-
<%- if name == 'default' -%>
|
8
|
-
# group node['<%= attribute_ns %>']['user'] do
|
9
|
-
# system true
|
10
|
-
# end
|
11
|
-
|
12
|
-
# user node['<%= attribute_ns %>']['user'] do
|
13
|
-
# gid node['<%= attribute_ns %>']['user']
|
14
|
-
# shell '/bin/false'
|
15
|
-
# system true
|
16
|
-
# end
|
17
|
-
|
18
|
-
# directory node['<%= attribute_ns %>']['logs'] do
|
19
|
-
# owner node['<%= attribute_ns %>']['user']
|
20
|
-
# group node['<%= attribute_ns %>']['user']
|
21
|
-
# recursive true
|
22
|
-
# end
|
23
|
-
|
24
|
-
# directory node['<%= attribute_ns %>']['data'] do
|
25
|
-
# owner node['<%= attribute_ns %>']['user']
|
26
|
-
# group node['<%= attribute_ns %>']['user']
|
27
|
-
# recursive true
|
28
|
-
# end
|
29
|
-
|
30
|
-
# ark '<%= attribute_ns %>' do
|
31
|
-
# url node['<%= attribute_ns %>']['url']
|
32
|
-
# checksum node['<%= attribute_ns %>']['checksum']
|
33
|
-
# version node['<%= attribute_ns %>']['version']
|
34
|
-
# home_dir node['<%= attribute_ns %>']['home']
|
35
|
-
# owner node['<%= attribute_ns %>']['user']
|
36
|
-
# group node['<%= attribute_ns %>']['user']
|
37
|
-
# end
|
38
|
-
<%- end -%>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bourdain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Clemmer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pmap
|
@@ -157,8 +157,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
157
|
version: '0'
|
158
158
|
requirements: []
|
159
159
|
rubyforge_project:
|
160
|
-
rubygems_version: 2.5.1
|
160
|
+
rubygems_version: 2.4.5.1
|
161
161
|
signing_key:
|
162
162
|
specification_version: 4
|
163
163
|
summary: Tools for badass chefs
|
164
164
|
test_files: []
|
165
|
+
has_rdoc:
|