bourdain 1.3.2 → 1.3.3
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/lib/bourdain/helpers.rb +1 -1
- data/lib/bourdain/resources/generators/cookbook.rb +16 -4
- data/lib/bourdain/resources/generators/recipe.rb +1 -1
- data/templates/cookbook/Berksfile +2 -1
- data/templates/cookbook/Rakefile +164 -0
- data/templates/cookbook/Vagrantfile +1 -0
- data/templates/cookbook/attributes/example.rb +25 -24
- data/templates/cookbook/gitignore +2 -0
- data/templates/cookbook/{busser_minitest.rb → minitest.rb} +1 -1
- data/templates/cookbook/recipes/example.rb +20 -20
- 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: 117b60c641b6c056e3e29697f9e12656f237a3de
|
4
|
+
data.tar.gz: 9dab833b7832fce0c41a462006794697547bbc22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0fcff7bf0d08bee9bee2ada6bf3002a4df2a7449fba5b6744dad6567f28abf0e782becae7e46bebba5d39d34f50e0eacec055ab48a6d055de9bb0a5f0022e32
|
7
|
+
data.tar.gz: e16eb27cb9d80efe02a63620e87d2ae2164e2fdedd1ef494e41bd511e553da3aa2fb0c4105cd0b4c6395df3a911f2ef9196c779aabfcd21815c1e423d2b23407
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.
|
1
|
+
1.3.3
|
data/lib/bourdain/helpers.rb
CHANGED
@@ -14,7 +14,7 @@ def apply_template file, opts
|
|
14
14
|
template_name, locals = opts[:template], opts[:locals]
|
15
15
|
locals = Bourdain::Helpers::Locals.new(locals).bind unless locals.nil?
|
16
16
|
template_path = gem_path('templates', *template_name)
|
17
|
-
template = ERB.new File.read(template_path)
|
17
|
+
template = ERB.new File.read(template_path), nil, '-'
|
18
18
|
contents = template.result(locals).strip
|
19
19
|
File.open(file, 'w') { |f| f.write contents }
|
20
20
|
end
|
@@ -14,6 +14,7 @@ module Bourdain
|
|
14
14
|
--recipe :: Generate a default recipe (default: true)
|
15
15
|
--berksfile :: Generate a Berksfile (default: true)
|
16
16
|
--gitignore (-i) :: Generate a .gitignore (default: true)
|
17
|
+
--rakefile (-r) :: Generate a Rakefile (default: true)
|
17
18
|
--metadata :: Generate cookbook metadata (default: true)
|
18
19
|
--readme (-m) :: Generate a Readme (default: true)
|
19
20
|
--kitchenfile :: Generate a Test Kitchen file (default: true)
|
@@ -37,6 +38,12 @@ module Bourdain
|
|
37
38
|
return
|
38
39
|
end
|
39
40
|
|
41
|
+
type = case path
|
42
|
+
when /apps/ then :app
|
43
|
+
when /realms/ then :realm
|
44
|
+
when /bases/ then :base
|
45
|
+
when /forks/ then :fork
|
46
|
+
end
|
40
47
|
name = File.basename(normalized(path))
|
41
48
|
|
42
49
|
FileUtils.mkdir_p path
|
@@ -69,7 +76,12 @@ module Bourdain
|
|
69
76
|
|
70
77
|
if opts[:gitignore]
|
71
78
|
apply_template File.join(path, '.gitignore'), \
|
72
|
-
template: %w[ cookbook gitignore ]
|
79
|
+
template: %w[ cookbook gitignore ], locals: { type: type }
|
80
|
+
end
|
81
|
+
|
82
|
+
if opts[:rakefile]
|
83
|
+
apply_template File.join(path, 'Rakefile'), \
|
84
|
+
template: %w[ cookbook Rakefile ]
|
73
85
|
end
|
74
86
|
|
75
87
|
if opts[:metadata]
|
@@ -83,10 +95,10 @@ module Bourdain
|
|
83
95
|
end
|
84
96
|
|
85
97
|
if opts[:kitchenfile]
|
86
|
-
minitest_path = File.join(path, '
|
98
|
+
minitest_path = File.join(path, 'files', 'default', 'test')
|
87
99
|
FileUtils.mkdir_p minitest_path
|
88
|
-
apply_template File.join(minitest_path, '
|
89
|
-
template: %w[ cookbook
|
100
|
+
apply_template File.join(minitest_path, 'default_test.rb'), \
|
101
|
+
template: %w[ cookbook minitest.rb ], locals: {
|
90
102
|
cookbook_name: name, recipe_name: 'default'
|
91
103
|
}
|
92
104
|
apply_template File.join(path, '.kitchen.yml'), \
|
@@ -37,7 +37,7 @@ module Bourdain
|
|
37
37
|
}
|
38
38
|
|
39
39
|
if opts[:minitest]
|
40
|
-
minitest_path = File.join('
|
40
|
+
minitest_path = File.join('files', 'default', 'test', "#{name}_test.rb")
|
41
41
|
FileUtils.mkdir_p File.dirname(minitest_path)
|
42
42
|
apply_template minitest_path, \
|
43
43
|
template: %w[ cookbook busser_minitest.rb ], locals: {
|
@@ -0,0 +1,164 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
require 'rake'
|
4
|
+
|
5
|
+
|
6
|
+
def master?
|
7
|
+
`git rev-parse --abbrev-ref HEAD`.strip == 'master'
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
def test_kitchen?
|
12
|
+
File.exist? '.kitchen.yml'
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def realm?
|
17
|
+
`git ls-files` =~ /\bBerksfile\.lock\b/
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
def current_version
|
22
|
+
File.read('VERSION').strip
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
def youre_dirty?
|
27
|
+
dirty = `git diff HEAD --numstat`.split("\n").length > 0
|
28
|
+
raise unless $?.exitstatus.zero?
|
29
|
+
dirty
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
def youre_dirty!
|
34
|
+
if youre_dirty?
|
35
|
+
raise "You you have uncommitted changes! Commit or stash before continuing."
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
def youre_behind?
|
41
|
+
`git fetch >/dev/null 2>&1`
|
42
|
+
`git pull --tags >/dev/null 2>&1`
|
43
|
+
behind = `git log ..origin/master --oneline`.split("\n").length > 0
|
44
|
+
raise unless $?.exitstatus.zero?
|
45
|
+
return behind
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
def youre_behind!
|
50
|
+
if youre_behind?
|
51
|
+
raise "You're out of sync with the remote! Try 'git pull --rebase'"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
def bump component
|
57
|
+
youre_dirty!
|
58
|
+
youre_behind!
|
59
|
+
`tony bump #{component}`
|
60
|
+
if realm?
|
61
|
+
`berks`
|
62
|
+
`git add Berksfile.lock`
|
63
|
+
end
|
64
|
+
version = current_version
|
65
|
+
`git add VERSION`
|
66
|
+
`git commit -m "Version bump to #{version}"`
|
67
|
+
`git tag -a v#{version} -m v#{version}`
|
68
|
+
raise 'Could not add tag' unless $?.exitstatus.zero?
|
69
|
+
puts 'Version is now "%s"' % version
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
def bump_and_release component
|
74
|
+
lint
|
75
|
+
bump component
|
76
|
+
youre_dirty!
|
77
|
+
youre_behind!
|
78
|
+
`git push`
|
79
|
+
raise 'Push failed' unless $?.exitstatus.zero?
|
80
|
+
`git push --tag`
|
81
|
+
raise 'Tag push failed' unless $?.exitstatus.zero?
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
def repo_root_dir
|
86
|
+
`git rev-parse --show-toplevel`.strip
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
def lint
|
91
|
+
system "knife cookbook test #{File.basename repo_root_dir} -o .."
|
92
|
+
raise 'Failed "knife cookbook test"' unless $?.exitstatus.zero?
|
93
|
+
system 'foodcritic .' # Merely a suggestion
|
94
|
+
|
95
|
+
unless realm?
|
96
|
+
if Dir.exist? File.join(repo_root_dir, 'environments')
|
97
|
+
raise "Hey, I found environments, but this isn't realm!"
|
98
|
+
end
|
99
|
+
|
100
|
+
if Dir.exist? File.join(repo_root_dir, 'roles')
|
101
|
+
raise "Hey, I found roles, but this isn't realm!"
|
102
|
+
end
|
103
|
+
|
104
|
+
if Dir.exist? File.join(repo_root_dir, 'data_bags')
|
105
|
+
raise "Hey, I found data bags--this isn't realm!"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
desc 'Perform syntax check and linting'
|
114
|
+
task :lint do
|
115
|
+
lint
|
116
|
+
end
|
117
|
+
|
118
|
+
|
119
|
+
if test_kitchen?
|
120
|
+
desc 'Execute default Test Kitchen test suite'
|
121
|
+
task test: :lint do
|
122
|
+
system 'kitchen test'
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
|
127
|
+
desc 'Print the current version'
|
128
|
+
task :version do
|
129
|
+
puts current_version
|
130
|
+
end
|
131
|
+
|
132
|
+
|
133
|
+
if master?
|
134
|
+
namespace :release do
|
135
|
+
desc 'Release new major version'
|
136
|
+
task :major do
|
137
|
+
bump_and_release :major
|
138
|
+
end
|
139
|
+
|
140
|
+
desc 'Release new minor version'
|
141
|
+
task :minor do
|
142
|
+
bump_and_release :minor
|
143
|
+
end
|
144
|
+
|
145
|
+
task :patch do
|
146
|
+
bump_and_release :patch
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
desc 'Release a new patch version'
|
151
|
+
task release: %w[ release:patch ]
|
152
|
+
|
153
|
+
|
154
|
+
if realm?
|
155
|
+
desc 'Apply Berksfile lock to an environment'
|
156
|
+
task :constrain, [ :env ] do |_, args|
|
157
|
+
lint
|
158
|
+
youre_dirty!
|
159
|
+
youre_behind!
|
160
|
+
`git tag -a #{args[:env]} -m #{args[:env]} --force`
|
161
|
+
`git push --tag --force`
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
@@ -1,24 +1,25 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
#
|
6
|
-
|
7
|
-
|
8
|
-
#
|
9
|
-
|
10
|
-
|
11
|
-
#
|
12
|
-
|
13
|
-
|
14
|
-
#
|
15
|
-
|
16
|
-
|
17
|
-
#
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
#
|
22
|
-
|
23
|
-
|
24
|
-
|
1
|
+
<%- if name == 'default' -%>
|
2
|
+
<%- attribute_ns = cookbook_name.gsub(/^(bjn|app|base|fork|realm)_/, '') -%>
|
3
|
+
# # User for <%= attribute_ns %> directories, files, and services
|
4
|
+
# default['<%= attribute_ns %>']['user'] = '<%= attribute_ns %>'
|
5
|
+
#
|
6
|
+
# # Directory to install the <%= attribute_ns %> source
|
7
|
+
# default['<%= attribute_ns %>']['home'] = '/opt/<%= attribute_ns %>'
|
8
|
+
#
|
9
|
+
# # Directory to store the <%= attribute_ns %> logs
|
10
|
+
# default['<%= attribute_ns %>']['logs'] = '/var/log/<%= attribute_ns %>'
|
11
|
+
#
|
12
|
+
# # Directory to store the <%= attribute_ns %> data
|
13
|
+
# default['<%= attribute_ns %>']['data'] = '/var/data/<%= attribute_ns %>'
|
14
|
+
#
|
15
|
+
# # Version of <%= attribute_ns %> to install
|
16
|
+
# default['<%= attribute_ns %>']['version'] = '1.0.0'
|
17
|
+
#
|
18
|
+
# # Full URL (%pattern-sensitive) for <%= attribute_ns %> releases
|
19
|
+
# default['<%= attribute_ns %>']['url'] = \
|
20
|
+
# 'http://example.com/<%= attribute_ns %>%{version}.tar.gz'
|
21
|
+
#
|
22
|
+
# # SHA-256 checksum for the bundled release
|
23
|
+
# default['<%= attribute_ns %>']['checksum'] = \
|
24
|
+
# '...'
|
25
|
+
<%- end -%>
|
@@ -2,37 +2,37 @@
|
|
2
2
|
# Cookbook Name:: <%= cookbook_name %>
|
3
3
|
# Recipe:: <%= name %>
|
4
4
|
#
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
# group node['<%=
|
5
|
+
<%- attribute_ns = cookbook_name.gsub(/^(bjn|app|base|fork|realm)_/, '') -%>
|
6
|
+
|
7
|
+
<%- if name == 'default' -%>
|
8
|
+
# group node['<%= attribute_ns %>']['user'] do
|
9
9
|
# system true
|
10
10
|
# end
|
11
11
|
|
12
|
-
# user node['<%=
|
13
|
-
# gid node['<%=
|
12
|
+
# user node['<%= attribute_ns %>']['user'] do
|
13
|
+
# gid node['<%= attribute_ns %>']['user']
|
14
14
|
# shell '/bin/false'
|
15
15
|
# system true
|
16
16
|
# end
|
17
17
|
|
18
|
-
# directory node['<%=
|
19
|
-
# owner node['<%=
|
20
|
-
# group node['<%=
|
18
|
+
# directory node['<%= attribute_ns %>']['logs'] do
|
19
|
+
# owner node['<%= attribute_ns %>']['user']
|
20
|
+
# group node['<%= attribute_ns %>']['user']
|
21
21
|
# recursive true
|
22
22
|
# end
|
23
23
|
|
24
|
-
# directory node['<%=
|
25
|
-
# owner node['<%=
|
26
|
-
# group node['<%=
|
24
|
+
# directory node['<%= attribute_ns %>']['data'] do
|
25
|
+
# owner node['<%= attribute_ns %>']['user']
|
26
|
+
# group node['<%= attribute_ns %>']['user']
|
27
27
|
# recursive true
|
28
28
|
# end
|
29
29
|
|
30
|
-
# ark '<%=
|
31
|
-
# url node['<%=
|
32
|
-
# checksum node['<%=
|
33
|
-
# version node['<%=
|
34
|
-
# home_dir node['<%=
|
35
|
-
# owner node['<%=
|
36
|
-
# group node['<%=
|
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
37
|
# end
|
38
|
-
|
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.3.
|
4
|
+
version: 1.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Clemmer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pmap
|
@@ -128,14 +128,15 @@ files:
|
|
128
128
|
- templates/chef/knife_plugin_node_log.rb
|
129
129
|
- templates/chef/role.json
|
130
130
|
- templates/cookbook/Berksfile
|
131
|
+
- templates/cookbook/Rakefile
|
131
132
|
- templates/cookbook/Readme.md
|
132
133
|
- templates/cookbook/VERSION
|
133
134
|
- templates/cookbook/Vagrantfile
|
134
135
|
- templates/cookbook/attributes/example.rb
|
135
|
-
- templates/cookbook/busser_minitest.rb
|
136
136
|
- templates/cookbook/gitignore
|
137
137
|
- templates/cookbook/kitchen.yml
|
138
138
|
- templates/cookbook/metadata.rb
|
139
|
+
- templates/cookbook/minitest.rb
|
139
140
|
- templates/cookbook/pre-commit
|
140
141
|
- templates/cookbook/recipes/example.rb
|
141
142
|
homepage: https://github.com/sczizzo/bourdain
|