berkshelf 5.2.0 → 8.0.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (216) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +19 -47
  3. data/Rakefile +14 -4
  4. data/berkshelf.gemspec +61 -40
  5. data/bin/berks +2 -2
  6. data/lib/berkshelf/api-client.rb +1 -0
  7. data/lib/berkshelf/api_client/chef_server_connection.rb +29 -0
  8. data/lib/berkshelf/api_client/connection.rb +57 -0
  9. data/lib/berkshelf/api_client/errors.rb +10 -0
  10. data/lib/berkshelf/api_client/remote_cookbook.rb +56 -0
  11. data/lib/berkshelf/api_client/version.rb +5 -0
  12. data/lib/berkshelf/api_client.rb +24 -0
  13. data/lib/berkshelf/berksfile.rb +149 -122
  14. data/lib/berkshelf/cached_cookbook.rb +127 -24
  15. data/lib/berkshelf/chef_config_compat.rb +51 -0
  16. data/lib/berkshelf/chef_repo_universe.rb +47 -0
  17. data/lib/berkshelf/cli.rb +143 -174
  18. data/lib/berkshelf/commands/shelf.rb +20 -19
  19. data/lib/berkshelf/community_rest.rb +59 -94
  20. data/lib/berkshelf/config.rb +97 -127
  21. data/lib/berkshelf/cookbook_store.rb +7 -6
  22. data/lib/berkshelf/core_ext/file.rb +1 -1
  23. data/lib/berkshelf/core_ext/file_utils.rb +4 -4
  24. data/lib/berkshelf/core_ext.rb +1 -1
  25. data/lib/berkshelf/dependency.rb +25 -32
  26. data/lib/berkshelf/downloader.rb +66 -39
  27. data/lib/berkshelf/errors.rb +23 -17
  28. data/lib/berkshelf/file_syncer.rb +24 -47
  29. data/lib/berkshelf/formatters/human.rb +7 -5
  30. data/lib/berkshelf/formatters/json.rb +6 -6
  31. data/lib/berkshelf/installer.rb +120 -111
  32. data/lib/berkshelf/location.rb +14 -14
  33. data/lib/berkshelf/locations/base.rb +1 -1
  34. data/lib/berkshelf/locations/git.rb +16 -24
  35. data/lib/berkshelf/locations/github.rb +2 -2
  36. data/lib/berkshelf/locations/path.rb +2 -2
  37. data/lib/berkshelf/lockfile.rb +326 -328
  38. data/lib/berkshelf/logger.rb +64 -1
  39. data/lib/berkshelf/mixin/git.rb +6 -5
  40. data/lib/berkshelf/packager.rb +44 -10
  41. data/lib/berkshelf/resolver/graph.rb +1 -1
  42. data/lib/berkshelf/resolver.rb +4 -4
  43. data/lib/berkshelf/ridley_compat.rb +109 -0
  44. data/lib/berkshelf/shell.rb +2 -1
  45. data/lib/berkshelf/shell_out.rb +18 -0
  46. data/lib/berkshelf/source.rb +77 -33
  47. data/lib/berkshelf/source_uri.rb +4 -4
  48. data/lib/berkshelf/ssl_policies.rb +38 -0
  49. data/lib/berkshelf/thor.rb +1 -1
  50. data/lib/berkshelf/thor_ext/hash_with_indifferent_access.rb +1 -1
  51. data/lib/berkshelf/thor_ext.rb +1 -1
  52. data/lib/berkshelf/uploader.rb +106 -70
  53. data/lib/berkshelf/validator.rb +13 -5
  54. data/lib/berkshelf/version.rb +1 -1
  55. data/lib/berkshelf/visualizer.rb +16 -11
  56. data/lib/berkshelf.rb +106 -81
  57. data/spec/config/knife.rb +4 -4
  58. data/spec/data/trusted_certs/example.crt +22 -0
  59. data/spec/fixtures/Berksfile +3 -3
  60. data/spec/fixtures/complex-cookbook-path/cookbooks/app/metadata.rb +2 -0
  61. data/spec/fixtures/complex-cookbook-path/cookbooks/jenkins/metadata.rb +2 -0
  62. data/spec/fixtures/complex-cookbook-path/cookbooks/jenkins-config/metadata.rb +4 -0
  63. data/spec/fixtures/cookbook-path/jenkins-config/metadata.rb +3 -3
  64. data/spec/fixtures/cookbook-path-uploader/apt-2.3.6/metadata.rb +2 -0
  65. data/spec/fixtures/cookbook-path-uploader/build-essential-1.4.2/metadata.rb +2 -0
  66. data/spec/fixtures/cookbook-path-uploader/jenkins-2.0.3/metadata.rb +5 -0
  67. data/spec/fixtures/cookbook-path-uploader/jenkins-config-0.1.0/metadata.rb +4 -0
  68. data/spec/fixtures/cookbook-path-uploader/runit-1.5.8/metadata.rb +5 -0
  69. data/spec/fixtures/cookbook-path-uploader/yum-3.0.6/metadata.rb +2 -0
  70. data/spec/fixtures/cookbook-path-uploader/yum-epel-0.2.0/metadata.rb +3 -0
  71. data/spec/fixtures/cookbook-store/jenkins-2.0.3/metadata.rb +5 -5
  72. data/spec/fixtures/cookbook-store/jenkins-2.0.4/metadata.rb +4 -4
  73. data/spec/fixtures/cookbooks/example_cookbook/metadata.rb +3 -3
  74. data/spec/fixtures/cookbooks/example_cookbook-0.5.0/metadata.rb +3 -3
  75. data/spec/spec_helper.rb +56 -64
  76. data/spec/support/chef_api.rb +15 -16
  77. data/spec/support/chef_server.rb +71 -69
  78. data/spec/support/git.rb +59 -58
  79. data/spec/support/kitchen.rb +0 -14
  80. data/spec/support/matchers/file_system_matchers.rb +4 -5
  81. data/spec/support/matchers/filepath_matchers.rb +2 -2
  82. data/spec/support/path_helpers.rb +17 -17
  83. data/spec/support/shared_examples/formatter.rb +1 -1
  84. data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/attributes/default.rb +0 -0
  85. data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/files/default/file.h +0 -0
  86. data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/metadata.rb +2 -0
  87. data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/recipes/default.rb +0 -0
  88. data/spec/tmp/berkshelf/cookbooks/fake-0.1.0/templates/default/template.erb +0 -0
  89. data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/attributes/default.rb +0 -0
  90. data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/files/default/file.h +0 -0
  91. data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/metadata.rb +2 -0
  92. data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/recipes/default.rb +0 -0
  93. data/spec/tmp/berkshelf/cookbooks/fake-0.2.0/templates/default/template.erb +0 -0
  94. data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/attributes/default.rb +0 -0
  95. data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/files/default/file.h +0 -0
  96. data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/metadata.rb +2 -0
  97. data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/recipes/default.rb +0 -0
  98. data/spec/tmp/berkshelf/cookbooks/fake-1.0.0/templates/default/template.erb +0 -0
  99. data/spec/unit/berkshelf/berksfile_spec.rb +84 -105
  100. data/spec/unit/berkshelf/berkshelf/api_client/chef_server_connection_spec.rb +65 -0
  101. data/spec/unit/berkshelf/berkshelf/api_client/connection_spec.rb +157 -0
  102. data/spec/unit/berkshelf/berkshelf/api_client/remote_cookbook_spec.rb +23 -0
  103. data/spec/unit/berkshelf/berkshelf/api_client_spec.rb +9 -0
  104. data/spec/unit/berkshelf/cached_cookbook_spec.rb +45 -47
  105. data/spec/unit/berkshelf/chef_repo_universe_spec.rb +37 -0
  106. data/spec/unit/berkshelf/cli_spec.rb +7 -8
  107. data/spec/unit/berkshelf/community_rest_spec.rb +82 -90
  108. data/spec/unit/berkshelf/config_spec.rb +51 -22
  109. data/spec/unit/berkshelf/cookbook_store_spec.rb +41 -41
  110. data/spec/unit/berkshelf/core_ext/file_utils_spec.rb +7 -8
  111. data/spec/unit/berkshelf/core_ext/pathname_spec.rb +1 -1
  112. data/spec/unit/berkshelf/dependency_spec.rb +48 -48
  113. data/spec/unit/berkshelf/downloader_spec.rb +191 -34
  114. data/spec/unit/berkshelf/errors_spec.rb +3 -3
  115. data/spec/unit/berkshelf/file_syncer_spec.rb +87 -87
  116. data/spec/unit/berkshelf/formatters/base_spec.rb +23 -23
  117. data/spec/unit/berkshelf/formatters/human_spec.rb +2 -2
  118. data/spec/unit/berkshelf/formatters/json_spec.rb +2 -2
  119. data/spec/unit/berkshelf/formatters/null_spec.rb +3 -3
  120. data/spec/unit/berkshelf/installer_spec.rb +8 -8
  121. data/spec/unit/berkshelf/location_spec.rb +11 -11
  122. data/spec/unit/berkshelf/locations/base_spec.rb +35 -36
  123. data/spec/unit/berkshelf/locations/git_spec.rb +90 -93
  124. data/spec/unit/berkshelf/locations/path_spec.rb +40 -41
  125. data/spec/unit/berkshelf/lockfile_parser_spec.rb +71 -71
  126. data/spec/unit/berkshelf/lockfile_spec.rb +205 -211
  127. data/spec/unit/berkshelf/logger_spec.rb +3 -3
  128. data/spec/unit/berkshelf/mixin/logging_spec.rb +5 -5
  129. data/spec/unit/berkshelf/packager_spec.rb +2 -2
  130. data/spec/unit/berkshelf/resolver/graph_spec.rb +10 -8
  131. data/spec/unit/berkshelf/resolver_spec.rb +17 -17
  132. data/spec/unit/berkshelf/ridley_compat_spec.rb +16 -0
  133. data/spec/unit/berkshelf/shell_spec.rb +34 -34
  134. data/spec/unit/berkshelf/source_spec.rb +186 -20
  135. data/spec/unit/berkshelf/source_uri_spec.rb +1 -1
  136. data/spec/unit/berkshelf/ssl_policies_spec.rb +86 -0
  137. data/spec/unit/berkshelf/uploader_spec.rb +146 -64
  138. data/spec/unit/berkshelf/validator_spec.rb +23 -16
  139. data/spec/unit/berkshelf/visualizer_spec.rb +24 -15
  140. data/spec/unit/berkshelf_spec.rb +18 -18
  141. metadata +138 -289
  142. data/.gitignore +0 -29
  143. data/.travis.yml +0 -64
  144. data/CHANGELOG.legacy.md +0 -307
  145. data/CHANGELOG.md +0 -1358
  146. data/CONTRIBUTING.md +0 -64
  147. data/Gemfile.lock +0 -399
  148. data/Guardfile +0 -23
  149. data/PLUGINS.md +0 -25
  150. data/README.md +0 -70
  151. data/Thorfile +0 -61
  152. data/appveyor.yml +0 -31
  153. data/docs/berkshelf_for_newcomers.md +0 -65
  154. data/features/berksfile.feature +0 -46
  155. data/features/commands/apply.feature +0 -41
  156. data/features/commands/contingent.feature +0 -48
  157. data/features/commands/cookbook.feature +0 -35
  158. data/features/commands/info.feature +0 -99
  159. data/features/commands/init.feature +0 -27
  160. data/features/commands/install.feature +0 -636
  161. data/features/commands/list.feature +0 -78
  162. data/features/commands/outdated.feature +0 -130
  163. data/features/commands/package.feature +0 -17
  164. data/features/commands/search.feature +0 -17
  165. data/features/commands/shelf/list.feature +0 -32
  166. data/features/commands/shelf/show.feature +0 -143
  167. data/features/commands/shelf/uninstall.feature +0 -96
  168. data/features/commands/show.feature +0 -83
  169. data/features/commands/update.feature +0 -142
  170. data/features/commands/upload.feature +0 -426
  171. data/features/commands/vendor.feature +0 -111
  172. data/features/commands/verify.feature +0 -29
  173. data/features/commands/viz.feature +0 -66
  174. data/features/community_site.feature +0 -37
  175. data/features/config.feature +0 -111
  176. data/features/help.feature +0 -11
  177. data/features/json_formatter.feature +0 -161
  178. data/features/lifecycle.feature +0 -378
  179. data/features/lockfile.feature +0 -378
  180. data/features/step_definitions/berksfile_steps.rb +0 -39
  181. data/features/step_definitions/chef/config_steps.rb +0 -12
  182. data/features/step_definitions/chef_server_steps.rb +0 -60
  183. data/features/step_definitions/cli_steps.rb +0 -18
  184. data/features/step_definitions/config_steps.rb +0 -46
  185. data/features/step_definitions/environment_steps.rb +0 -7
  186. data/features/step_definitions/filesystem_steps.rb +0 -269
  187. data/features/step_definitions/gem_steps.rb +0 -13
  188. data/features/step_definitions/json_steps.rb +0 -23
  189. data/features/step_definitions/utility_steps.rb +0 -11
  190. data/features/support/aruba.rb +0 -12
  191. data/features/support/env.rb +0 -82
  192. data/generator_files/Berksfile.erb +0 -11
  193. data/generator_files/CHANGELOG.md.erb +0 -3
  194. data/generator_files/Gemfile.erb +0 -8
  195. data/generator_files/README.md.erb +0 -42
  196. data/generator_files/Thorfile.erb +0 -11
  197. data/generator_files/Vagrantfile.erb +0 -117
  198. data/generator_files/chefignore +0 -94
  199. data/generator_files/default_recipe.erb +0 -6
  200. data/generator_files/default_test.rb.erb +0 -11
  201. data/generator_files/gitignore.erb +0 -23
  202. data/generator_files/helpers.rb.erb +0 -7
  203. data/generator_files/licenses/apachev2.erb +0 -13
  204. data/generator_files/licenses/gplv2.erb +0 -15
  205. data/generator_files/licenses/gplv3.erb +0 -14
  206. data/generator_files/licenses/mit.erb +0 -20
  207. data/generator_files/licenses/reserved.erb +0 -3
  208. data/generator_files/metadata.rb.erb +0 -11
  209. data/lib/berkshelf/base_generator.rb +0 -43
  210. data/lib/berkshelf/commands/test_command.rb +0 -13
  211. data/lib/berkshelf/cookbook_generator.rb +0 -133
  212. data/lib/berkshelf/init_generator.rb +0 -195
  213. data/spec/fixtures/cookbooks/example_cookbook/.gitignore +0 -2
  214. data/spec/fixtures/cookbooks/example_cookbook/.kitchen.yml +0 -26
  215. data/spec/unit/berkshelf/cookbook_generator_spec.rb +0 -110
  216. data/spec/unit/berkshelf/init_generator_spec.rb +0 -263
@@ -1,269 +0,0 @@
1
- require 'aruba/api'
2
-
3
- World(Aruba::Api)
4
- World(Berkshelf::RSpec::ChefAPI)
5
- World(Berkshelf::RSpec::FileSystemMatchers)
6
-
7
- Given /^a cookbook named "(.*?)"$/ do |name|
8
- create_directory(name)
9
- write_file(File.join(name, "metadata.rb"), "name '#{name}'")
10
- end
11
-
12
- Given /^the cookbook "(.*?)" has the file "(.*?)" with:$/ do |cookbook_name, file_name, content|
13
- write_file(::File.join(cookbook_name, file_name), content)
14
- end
15
-
16
- Given /^the cookbook store has the cookbooks:$/ do |cookbooks|
17
- cookbooks.raw.each do |name, version, license|
18
- generate_cookbook(cookbook_store.storage_path, name, version, license: license)
19
- end
20
- end
21
-
22
- Given /^the cookbook store has the git cookbooks:$/ do |cookbooks|
23
- cookbooks.raw.each do |name, version, sha|
24
- folder = "#{name}-#{sha}"
25
- metadata = File.join(folder, 'metadata.rb')
26
-
27
- create_directory(folder)
28
- write_file(metadata, [
29
- "name '#{name}'",
30
- "version '#{version}'"
31
- ].join("\n"))
32
- end
33
- end
34
-
35
- Given /^the cookbook store contains a cookbook "(.*?)" "(.*?)" with dependencies:$/ do |name, version, dependencies|
36
- generate_cookbook(cookbook_store.storage_path, name, version, dependencies: dependencies.raw)
37
- end
38
-
39
- Given(/^the cookbook store is empty$/) do
40
- Berkshelf::CookbookStore.instance.clean!
41
- end
42
-
43
- Then /^the cookbook store should have the cookbooks:$/ do |cookbooks|
44
- cookbooks.raw.each do |name, version|
45
- expect(cookbook_store.storage_path).to have_structure {
46
- directory "#{name}-#{version}" do
47
- file "metadata.rb" do
48
- contains version
49
- end
50
- end
51
- }
52
- end
53
- end
54
-
55
- Then /^the cookbook store should have the git cookbooks:$/ do |cookbooks|
56
- cookbooks.raw.each do |name, version, sha1|
57
- expect(cookbook_store.storage_path).to have_structure {
58
- directory "#{name}-#{sha1}" do
59
- file "metadata.rb" do
60
- contains version
61
- end
62
- end
63
- }
64
- end
65
- end
66
-
67
- Then /^the cookbook store should not have the cookbooks:$/ do |cookbooks|
68
- cookbooks.raw.each do |name, version|
69
- expect(cookbook_store.storage_path).to_not have_structure {
70
- directory "#{name}-#{version}"
71
- }
72
- end
73
- end
74
-
75
- Then /^I should have a new cookbook skeleton "(.*?)"$/ do |name|
76
- cb_path = Pathname.new(current_dir).join(name)
77
- expect(cb_path).to have_structure {
78
- directory "attributes"
79
- directory "files" do
80
- directory "default"
81
- end
82
- directory "libraries"
83
- directory "providers"
84
- directory "recipes" do
85
- file "default.rb"
86
- end
87
- directory "resources"
88
- directory "templates" do
89
- directory "default"
90
- end
91
- file ".gitignore"
92
- file "chefignore"
93
- file "Berksfile" do
94
- contains "metadata"
95
- end
96
- file "Gemfile"
97
- file "metadata.rb"
98
- file "README.md"
99
- file "Vagrantfile" do
100
- contains "recipe[#{name}::default]"
101
- end
102
- }
103
- end
104
-
105
- Then /^I should have a new cookbook skeleton "(.*?)" with Chef-Minitest support$/ do |name|
106
- steps %Q{ Then I should have a new cookbook skeleton "#{name}" }
107
-
108
- cb_path = Pathname.new(current_dir).join(name)
109
- expect(cb_path).to have_structure {
110
- file "Berksfile" do
111
- contains "cookbook 'minitest-handler'"
112
- end
113
- file "Vagrantfile" do
114
- contains "recipe[minitest-handler::default]"
115
- end
116
- directory "files" do
117
- directory "default" do
118
- directory "tests" do
119
- directory "minitest" do
120
- file "default_test.rb" do
121
- contains "describe '#{name}::default' do"
122
- contains "include Helpers::#{name.capitalize}"
123
- end
124
- directory "support" do
125
- file "helpers.rb" do
126
- contains "module #{name.capitalize}"
127
- end
128
- end
129
- end
130
- end
131
- end
132
- end
133
- }
134
- end
135
-
136
-
137
- Then /^I should have a new cookbook skeleton "(.*?)" with Foodcritic support$/ do |name|
138
- steps %Q{ Then I should have a new cookbook skeleton "#{name}" }
139
-
140
- cb_path = Pathname.new(current_dir).join(name)
141
- expect(cb_path).to have_structure {
142
- file "Gemfile" do
143
- contains "gem 'thor-foodcritic'"
144
- end
145
- file "Thorfile" do
146
- contains "require 'thor/foodcritic'"
147
- end
148
- }
149
- end
150
-
151
- Then /^I should have a new cookbook skeleton "(.*?)" with SCMVersion support$/ do |name|
152
- steps %Q{ Then I should have a new cookbook skeleton "#{name}" }
153
-
154
- cb_path = Pathname.new(current_dir).join(name)
155
- expect(cb_path).to have_structure {
156
- file "Gemfile" do
157
- contains "gem 'thor-scmversion'"
158
- end
159
- file "Thorfile" do
160
- contains "require 'thor/scmversion'"
161
- end
162
- }
163
- end
164
-
165
- Then /^I should have a new cookbook skeleton "(.*?)" with no Bundler support$/ do |name|
166
- cb_path = Pathname.new(current_dir).join(name)
167
- expect(cb_path).to have_structure {
168
- directory "attributes"
169
- directory "files" do
170
- directory "default"
171
- end
172
- directory "libraries"
173
- directory "providers"
174
- directory "recipes" do
175
- file "default.rb"
176
- end
177
- directory "resources"
178
- directory "templates" do
179
- directory "default"
180
- end
181
- file "README.md"
182
- file "metadata.rb"
183
- file "Berksfile" do
184
- contains "metadata"
185
- end
186
- file "chefignore"
187
- file "Berksfile"
188
- no_file "Gemfile"
189
- }
190
- end
191
-
192
- Then /^I should have a new cookbook skeleton "(.*?)" with no Git support$/ do |name|
193
- expect(Pathname.new(current_dir).join(name)).to have_structure {
194
- no_file ".gitignore"
195
- }
196
- end
197
-
198
- Then /^I should have a new cookbook skeleton "(.*?)" with no Vagrant support$/ do |name|
199
- expect(Pathname.new(current_dir).join(name)).to have_structure {
200
- file "Gemfile" do
201
- does_not_contain "gem 'vagrant'"
202
- end
203
- no_file "Vagrantfile"
204
- }
205
- end
206
-
207
- Then(/^I should have a new cookbook skeleton "(.*?)" with no Test Kitchen support$/) do |name|
208
- expect(Pathname.new(current_dir).join(name)).to have_structure {
209
- file "Gemfile" do
210
- does_not_contain "gem 'test-kitchen'"
211
- end
212
- no_file ".kitchen.yml"
213
- no_file ".kitchen.yml.local"
214
- }
215
- end
216
-
217
- Then /^the cookbook "(.*?)" should have the following files:$/ do |name, files|
218
- check_file_presence(files.raw.map{|file_row| ::File.join(name, file_row[0])}, true)
219
- end
220
-
221
- Then /^the cookbook "(.*?)" should not have the following files:$/ do |name, files|
222
- check_file_presence(files.raw.map{|file_row| ::File.join(name, file_row[0])}, false)
223
- end
224
-
225
- Then /^the git cookbook "(.*?)" should not have the following directories:$/ do |name, directories|
226
- check_directory_presence(directories.raw.map{|directory_row| ::File.join(cookbook_store.storage_path.to_path, name, directory_row[0])}, false)
227
- end
228
-
229
- Then /^the file "(.*?)" in the cookbook "(.*?)" should contain:$/ do |file_name, cookbook_name, content|
230
- expect(Pathname.new(current_dir).join(cookbook_name)).to have_structure {
231
- file "Berksfile" do
232
- contains content
233
- end
234
- file "chefignore"
235
- }
236
- end
237
-
238
- Then /^the resulting "(.+)" Vagrantfile should contain:$/ do |cookbook_name, content|
239
- expect(Pathname.new(current_dir).join(cookbook_name)).to have_structure {
240
- file "Vagrantfile" do
241
- content.respond_to?(:raw) ?
242
- content.raw.flatten.each { |string| contains string } :
243
- contains(content)
244
- end
245
- }
246
- end
247
-
248
- Then /^the directory "(.*?)" should have the following files:$/ do |name, files|
249
- check_file_presence(files.raw.map{|file_row| ::File.join(name, file_row[0])}, true)
250
- end
251
-
252
- Then /^the directory "(.*?)" should not have the following files:$/ do |name, files|
253
- check_file_presence(files.raw.map{|file_row| ::File.join(name, file_row[0])}, false)
254
- end
255
-
256
- Then /^the file "(.*?)" in the directory "(.*?)" should not contain:$/ do |file_name, directory_name, content|
257
- Pathname.new(current_dir).join(directory_name).should_not have_structure {
258
- file "Berksfile" do
259
- contains content
260
- end
261
- }
262
- end
263
-
264
- Then(/^the directory "(.*?)" should contain version "(.*?)" of the "(.*?)" cookbook$/) do |path, version, name|
265
- cookbook_path = File.join(current_dir, path)
266
- cookbook = Berkshelf::CachedCookbook.from_path(cookbook_path)
267
- expect(cookbook.version).to eq(version)
268
- expect(cookbook.cookbook_name).to eq(name)
269
- end
@@ -1,13 +0,0 @@
1
- Given /^the gem "(.*)" is not installed$/ do |gem_name|
2
- allow(Gem::Specification).to receive(:find_by_name)
3
- .with(gem_name)
4
- .and_raise(Gem::LoadError)
5
- end
6
-
7
- Then /^the output should contain a warning to suggest supporting the option "(.*?)" by installing "(.*?)"$/ do |option, gem_name|
8
- step "the output should contain \"This cookbook was generated with --#{option}, however, #{gem_name} is not installed.\nTo make use of --#{option}: gem install #{gem_name}\""
9
- end
10
-
11
- Then /^the output should contain a warning to suggest supporting the default for "(.*?)" by installing "(.*?)"$/ do |option, gem_name|
12
- step "the output should contain \"By default, this cookbook was generated to support #{gem_name}, however, #{gem_name} is not installed.\nTo skip support for #{gem_name}, use --no-#{option}\"\nTo install #{gem_name}: gem install #{gem_name}"
13
- end
@@ -1,23 +0,0 @@
1
- class Hash
2
- def sort_by_key(&block)
3
- self.keys.sort(&block).reduce({}) do |seed, key|
4
- seed[key] = self[key]
5
- if seed[key].is_a?(Hash)
6
- seed[key] = seed[key].sort_by_key(&block)
7
- elsif seed[key].is_a?(Array)
8
- seed[key] = seed[key].map do |i|
9
- i.respond_to?(:sort_by_key) ? i.sort_by_key(&block) : i
10
- end
11
- end
12
- seed
13
- end
14
- end
15
- end
16
-
17
- Then /^the output should contain JSON:$/ do |data|
18
- parsed = ERB.new(data).result
19
- target = JSON.pretty_generate(JSON.parse(parsed).sort_by_key)
20
- actual = JSON.pretty_generate(JSON.parse(all_commands.map { |c| c.output }.join("\n")).sort_by_key)
21
-
22
- expect(actual).to eq(target)
23
- end
@@ -1,11 +0,0 @@
1
- Given /^skip\s+"([^\"]+)"$/ do |msg|
2
- skip
3
- end
4
-
5
- Then /the output from \`(.+)\` should be the same as \`(.+)\`/ do |actual, expected|
6
- run(actual)
7
- actual_output = last_command_started.stdout
8
- run(expected)
9
- expected_output = last_command_started.stdout
10
- expect(actual_output).to eql(expected_output)
11
- end
@@ -1,12 +0,0 @@
1
- module Aruba
2
- # Force Aruba to behave like the SpawnProcess Aruba class.
3
- class InProcess
4
- def stdin
5
- @stdin
6
- end
7
-
8
- def output
9
- stdout + stderr
10
- end
11
- end
12
- end
@@ -1,82 +0,0 @@
1
- require 'spork'
2
-
3
- def windows?
4
- !!(RUBY_PLATFORM =~ /mswin|mingw|windows/)
5
- end
6
-
7
- Spork.prefork do
8
- require 'aruba/cucumber'
9
- require 'aruba/in_process'
10
- require 'aruba/spawn_process'
11
- require 'cucumber/rspec/doubles'
12
- require 'berkshelf/api/rspec' unless windows?
13
- require 'berkshelf/api/cucumber' unless windows?
14
-
15
- Dir['spec/support/**/*.rb'].each { |f| require File.expand_path(f) }
16
-
17
- World(Berkshelf::RSpec::PathHelpers)
18
- World(Berkshelf::RSpec::Kitchen)
19
-
20
- CHEF_SERVER_PORT = 26310
21
- BERKS_API_PORT = 26210
22
-
23
- at_exit do
24
- Berkshelf::RSpec::ChefServer.stop
25
- Berkshelf::API::RSpec::Server.stop unless windows?
26
- end
27
-
28
- Before do
29
-
30
- # Legacy ENV variables until we can move over to all InProcess
31
- Berkshelf.instance_variable_set(:@berkshelf_path, nil)
32
- ENV['BERKSHELF_PATH'] = berkshelf_path.to_s
33
- ENV['BERKSHELF_CONFIG'] = Berkshelf.config.path.to_s
34
- ENV['BERKSHELF_CHEF_CONFIG'] = chef_config_path.to_s
35
-
36
- aruba.config.command_launcher = :in_process
37
- aruba.config.main_class = Berkshelf::Cli::Runner
38
- @dirs = ["spec/tmp/aruba"] # set aruba's temporary directory
39
-
40
- stub_kitchen!
41
- clean_tmp_path
42
- Berkshelf.initialize_filesystem
43
- Berkshelf::CookbookStore.instance.initialize_filesystem
44
- reload_configs
45
- Berkshelf::CachedCookbook.instance_variable_set(:@loaded_cookbooks, nil)
46
-
47
- endpoints = [
48
- {
49
- type: "chef_server",
50
- options: {
51
- url: "http://localhost:#{CHEF_SERVER_PORT}",
52
- client_name: "reset",
53
- client_key: File.expand_path("spec/config/berkshelf.pem")
54
- }
55
- }
56
- ]
57
-
58
- Berkshelf::RSpec::ChefServer.start(port: CHEF_SERVER_PORT)
59
- Berkshelf::API::RSpec::Server.start(port: BERKS_API_PORT, endpoints: endpoints) unless windows?
60
-
61
- aruba.config.io_wait_timeout = Cucumber::JRUBY ? 7 : 5
62
- @aruba_timeout_seconds = Cucumber::JRUBY ? 35 : 15
63
- end
64
-
65
- Before('@spawn') do
66
- aruba.config.command_launcher = :spawn
67
-
68
- Berkshelf.instance_variable_set(:@berkshelf_path, nil)
69
- set_environment_variable('BERKSHELF_PATH', berkshelf_path.to_s)
70
- set_environment_variable('BERKSHELF_CONFIG', Berkshelf.config.path.to_s)
71
- set_environment_variable('BERKSHELF_CHEF_CONFIG', chef_config_path.to_s)
72
- end
73
-
74
- Before('@slow_process') do
75
- aruba.config.io_wait_timeout = Cucumber::JRUBY ? 70 : 30
76
- @aruba_timeout_seconds = Cucumber::JRUBY ? 140 : 60
77
- end
78
- end
79
-
80
- Spork.each_run do
81
- require 'berkshelf/cli'
82
- end
@@ -1,11 +0,0 @@
1
- source "https://supermarket.chef.io"
2
- <% if options[:chef_minitest] -%>
3
-
4
- group :integration do
5
- cookbook 'minitest-handler'
6
- end
7
- <% end -%>
8
- <% if options[:metadata_entry] -%>
9
-
10
- metadata
11
- <% end -%>
@@ -1,3 +0,0 @@
1
- # 0.1.0
2
-
3
- Initial release of <%= name %>
@@ -1,8 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- <% if options[:foodcritic] -%>
4
- gem 'thor-foodcritic'
5
- <% end -%>
6
- <% if options[:scmversion] -%>
7
- gem 'thor-scmversion'
8
- <% end -%>
@@ -1,42 +0,0 @@
1
- # <%= name %>-cookbook
2
-
3
- TODO: Enter the cookbook description here.
4
-
5
- ## Supported Platforms
6
-
7
- TODO: List your supported platforms.
8
-
9
- ## Attributes
10
-
11
- <table>
12
- <tr>
13
- <th>Key</th>
14
- <th>Type</th>
15
- <th>Description</th>
16
- <th>Default</th>
17
- </tr>
18
- <tr>
19
- <td><tt>['<%= name %>']['bacon']</tt></td>
20
- <td>Boolean</td>
21
- <td>whether to include bacon</td>
22
- <td><tt>true</tt></td>
23
- </tr>
24
- </table>
25
-
26
- ## Usage
27
-
28
- ### <%= name %>::default
29
-
30
- Include `<%= name %>` in your node's `run_list`:
31
-
32
- ```json
33
- {
34
- "run_list": [
35
- "recipe[<%= name %>::default]"
36
- ]
37
- }
38
- ```
39
-
40
- ## License and Authors
41
-
42
- Author:: <%= maintainer %> (<<%= maintainer_email %>>)
@@ -1,11 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'bundler'
4
- require 'bundler/setup'
5
- <% if options[:foodcritic] -%>
6
- require 'thor/foodcritic'
7
- <% end -%>
8
- <% if options[:scmversion] -%>
9
- require 'thor/scmversion'
10
- <% end -%>
11
- require 'berkshelf/thor'
@@ -1,117 +0,0 @@
1
- # -*- mode: ruby -*-
2
- # vi: set ft=ruby :
3
-
4
- # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
5
- VAGRANTFILE_API_VERSION = '2'
6
-
7
- Vagrant.require_version '>= 1.5.0'
8
-
9
- Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
10
- # All Vagrant configuration is done here. The most common configuration
11
- # options are documented and commented below. For a complete reference,
12
- # please see the online documentation at vagrantup.com.
13
-
14
- config.vm.hostname = '<%= "#{cookbook_name.gsub('_','-')}-berkshelf" %>'
15
-
16
- # Set the version of chef to install using the vagrant-omnibus plugin
17
- # NOTE: You will need to install the vagrant-omnibus plugin:
18
- #
19
- # $ vagrant plugin install vagrant-omnibus
20
- #
21
- if Vagrant.has_plugin?("vagrant-omnibus")
22
- config.omnibus.chef_version = '<%= berkshelf_config.vagrant.omnibus.version %>'
23
- end
24
-
25
- # Every Vagrant virtual environment requires a box to build off of.
26
- # If this value is a shorthand to a box in Vagrant Cloud then
27
- # config.vm.box_url doesn't need to be specified.
28
- config.vm.box = '<%= berkshelf_config.vagrant.vm.box %>'
29
-
30
- <% unless berkshelf_config.vagrant.vm.box_url.nil? -%>
31
- # The url from where the 'config.vm.box' box will be fetched if it
32
- # is not a Vagrant Cloud box and if it doesn't already exist on the
33
- # user's system.
34
- config.vm.box_url = '<%= berkshelf_config.vagrant.vm.box_url %>'
35
- <% end -%>
36
-
37
- # Assign this VM to a host-only network IP, allowing you to access it
38
- # via the IP. Host-only networks can talk to the host machine as well as
39
- # any other machines on the same network, but cannot be accessed (through this
40
- # network interface) by any external networks.
41
- config.vm.network :private_network, type: 'dhcp'
42
-
43
- # Create a forwarded port mapping which allows access to a specific port
44
- # within the machine from a port on the host machine. In the example below,
45
- # accessing "localhost:8080" will access port 80 on the guest machine.
46
- <% berkshelf_config.vagrant.vm.forward_port.each do |guest, host| %>
47
- config.vm.network :forwarded_port, guest: <%= guest %>, host: <%= host %>
48
- <% end -%>
49
-
50
- # Share an additional folder to the guest VM. The first argument is
51
- # the path on the host to the actual folder. The second argument is
52
- # the path on the guest to mount the folder. And the optional third
53
- # argument is a set of non-required options.
54
- # config.vm.synced_folder "../data", "/vagrant_data"
55
-
56
- # Provider-specific configuration so you can fine-tune various
57
- # backing providers for Vagrant. These expose provider-specific options.
58
- # Example for VirtualBox:
59
- #
60
- # config.vm.provider :virtualbox do |vb|
61
- # # Don't boot with headless mode
62
- # vb.gui = true
63
- #
64
- # # Use VBoxManage to customize the VM. For example to change memory:
65
- # vb.customize ["modifyvm", :id, "--memory", "1024"]
66
- # end
67
- #
68
- # View the documentation for the provider you're using for more
69
- # information on available options.
70
-
71
- # The path to the Berksfile to use with Vagrant Berkshelf
72
- # config.berkshelf.berksfile_path = "./Berksfile"
73
-
74
- # Enabling the Berkshelf plugin. To enable this globally, add this configuration
75
- # option to your ~/.vagrant.d/Vagrantfile file
76
- config.berkshelf.enabled = true
77
-
78
- # An array of symbols representing groups of cookbook described in the Vagrantfile
79
- # to exclusively install and copy to Vagrant's shelf.
80
- # config.berkshelf.only = []
81
-
82
- # An array of symbols representing groups of cookbook described in the Vagrantfile
83
- # to skip installing and copying to Vagrant's shelf.
84
- # config.berkshelf.except = []
85
-
86
- <% if berkshelf_config.vagrant.vm.provision == 'chef_client' -%>
87
- config.vm.provision :chef_client do |chef|
88
- chef.chef_server_url = '<%= berkshelf_config.chef.chef_server_url %>'
89
- chef.validation_client_name = '<%= berkshelf_config.chef.validation_client_name %>'
90
- chef.validation_key_path = '<%= berkshelf_config.chef.validation_key_path %>'
91
-
92
- chef.run_list = [
93
- <% if options[:chef_minitest] %>
94
- 'recipe[minitest-handler::default]',
95
- <% end -%>
96
- 'recipe[<%= cookbook_name %>::default]'
97
- ]
98
- end
99
- <% elsif berkshelf_config.vagrant.vm.provision == 'chef_solo' -%>
100
- config.vm.provision :chef_solo do |chef|
101
- chef.json = {
102
- mysql: {
103
- server_root_password: 'rootpass',
104
- server_debian_password: 'debpass',
105
- server_repl_password: 'replpass'
106
- }
107
- }
108
-
109
- chef.run_list = [
110
- <% if options[:chef_minitest] %>
111
- 'recipe[minitest-handler::default]',
112
- <% end -%>
113
- 'recipe[<%= cookbook_name %>::default]'
114
- ]
115
- end
116
- <% end -%>
117
- end