berkshelf 2.0.3 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/CHANGELOG.md +7 -0
  2. data/Gemfile +2 -0
  3. data/berkshelf.gemspec +5 -4
  4. data/features/berksfile.feature +56 -0
  5. data/features/install_command.feature +99 -13
  6. data/features/json_formatter.feature +1 -1
  7. data/features/lockfile.feature +50 -23
  8. data/features/step_definitions/filesystem_steps.rb +14 -1
  9. data/features/step_definitions/json_steps.rb +1 -1
  10. data/features/update_command.feature +2 -2
  11. data/features/upload_command.feature +0 -1
  12. data/lib/berkshelf.rb +1 -15
  13. data/lib/berkshelf/berksfile.rb +27 -21
  14. data/lib/berkshelf/cli.rb +2 -3
  15. data/lib/berkshelf/commands/test_command.rb +4 -2
  16. data/lib/berkshelf/community_rest.rb +6 -0
  17. data/lib/berkshelf/cookbook_source.rb +15 -37
  18. data/lib/berkshelf/core_ext/rbzip2.rb +8 -0
  19. data/lib/berkshelf/downloader.rb +56 -47
  20. data/lib/berkshelf/errors.rb +9 -2
  21. data/lib/berkshelf/formatters/human_readable.rb +10 -3
  22. data/lib/berkshelf/formatters/json.rb +7 -3
  23. data/lib/berkshelf/git.rb +2 -1
  24. data/lib/berkshelf/init_generator.rb +18 -12
  25. data/lib/berkshelf/location.rb +4 -14
  26. data/lib/berkshelf/locations/chef_api_location.rb +0 -1
  27. data/lib/berkshelf/locations/git_location.rb +1 -2
  28. data/lib/berkshelf/locations/path_location.rb +35 -11
  29. data/lib/berkshelf/locations/site_location.rb +0 -1
  30. data/lib/berkshelf/resolver.rb +18 -14
  31. data/lib/berkshelf/version.rb +1 -1
  32. data/spec/fixtures/cookbooks/example_cookbook/Berksfile +1 -0
  33. data/spec/unit/berkshelf/berksfile_spec.rb +30 -2
  34. data/spec/unit/berkshelf/community_rest_spec.rb +49 -11
  35. data/spec/unit/berkshelf/cookbook_source_spec.rb +11 -7
  36. data/spec/unit/berkshelf/downloader_spec.rb +1 -1
  37. data/spec/unit/berkshelf/location_spec.rb +0 -6
  38. data/spec/unit/berkshelf/locations/chef_api_location_spec.rb +0 -4
  39. data/spec/unit/berkshelf/locations/git_location_spec.rb +0 -5
  40. data/spec/unit/berkshelf/locations/path_location_spec.rb +0 -41
  41. data/spec/unit/berkshelf_spec.rb +0 -25
  42. metadata +37 -16
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # 2.0.4
2
+
3
+ * Fix bug where community cookbooks compressed with bzip2 would not download and install
4
+ * Fix bug regression in Git caching which was previously fixed in 1.4.4
5
+ * Fix validation bug where a cookbook would be considered invalid if any spaces were present in the path to the directory containing the cookbook
6
+ * Fix issues with uploading cookbooks on Windows
7
+
1
8
  # 2.0.3
2
9
 
3
10
  * Fix issue where groups defined in the Berksfile would not be evaluated
data/Gemfile CHANGED
@@ -3,6 +3,8 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  group :development do
6
+ gem 'test-kitchen', '>= 1.0.0.alpha7'
7
+
6
8
  require 'rbconfig'
7
9
 
8
10
  if RbConfig::CONFIG['target_os'] =~ /darwin/i
data/berkshelf.gemspec CHANGED
@@ -32,20 +32,21 @@ Gem::Specification.new do |s|
32
32
 
33
33
  s.add_dependency 'activesupport', '>= 3.2.0'
34
34
  s.add_dependency 'addressable', '~> 2.3.4'
35
+ s.add_dependency 'buff-shell_out', '~> 0.1'
35
36
  s.add_dependency 'celluloid', '>= 0.14.0'
36
37
  s.add_dependency 'chozo', '>= 0.6.1'
37
38
  s.add_dependency 'faraday', '>= 0.8.5'
38
39
  s.add_dependency 'hashie', '>= 2.0.2'
39
40
  s.add_dependency 'minitar', '~> 0.5.4'
40
41
  s.add_dependency 'retryable', '~> 1.3.3'
41
- s.add_dependency 'ridley', '~> 1.0.2'
42
- s.add_dependency 'solve', '>= 0.4.4'
43
- s.add_dependency 'test-kitchen', '>= 1.0.0.alpha7'
42
+ s.add_dependency 'ridley', '~> 1.2.1'
43
+ s.add_dependency 'solve', '>= 0.5.0'
44
44
  s.add_dependency 'thor', '~> 0.18.0'
45
+ s.add_dependency 'rbzip2', '~> 0.2.0'
45
46
 
46
47
  s.add_development_dependency 'aruba', '~> 0.5'
47
48
  s.add_development_dependency 'cane', '~> 2.5'
48
- s.add_development_dependency 'chef-zero', '~> 1.1'
49
+ s.add_development_dependency 'chef-zero', '~> 1.5.0'
49
50
  s.add_development_dependency 'fuubar', '~> 1.1'
50
51
  s.add_development_dependency 'rake', '~> 0.9'
51
52
  s.add_development_dependency 'rspec', '~> 2.13'
@@ -0,0 +1,56 @@
1
+ Feature: Evaluating a Berksfile
2
+ As a user with a Berksfile
3
+ I want to evaluate things and see nice errors
4
+ So I can identify my syntax errors and faults
5
+
6
+ Scenario: Containing pure Ruby
7
+ Given I write to "Berksfile" with:
8
+ """
9
+ if ENV['BACON']
10
+ puts "If you don't got bacon..."
11
+ else
12
+ puts "No bacon :'("
13
+ end
14
+ """
15
+ And the environment variable BACON is "1"
16
+ When I successfully run `berks install`
17
+ Then the output should contain:
18
+ """
19
+ If you don't got bacon...
20
+ """
21
+ And the exit status should be 0
22
+
23
+ Scenario: Calling valid DSL methods:
24
+ Given I write to "Berksfile" with:
25
+ """
26
+ site :opscode
27
+ """
28
+ When I successfully run `berks install`
29
+ And the exit status should be 0
30
+
31
+ Scenario: Containing methods I shouldn't be able to call
32
+ Given I write to "Berksfile" with:
33
+ """
34
+ add_location(:foo)
35
+ """
36
+ When I run `berks install`
37
+ Then the output should contain:
38
+ """
39
+ An error occurred while reading the Berksfile:
40
+
41
+ undefined method `add_location' for
42
+ """
43
+ And the CLI should exit with the status code for error "BerksfileReadError"
44
+
45
+ Scenario: Containing Ruby syntax errors
46
+ Given I write to "Berksfile" with:
47
+ """
48
+ ptus "This is a ruby syntax error"
49
+ """
50
+ When I run `berks install`
51
+ Then the output should contain:
52
+ """
53
+ An error occurred while reading the Berksfile:
54
+
55
+ undefined method `ptus' for
56
+ """
@@ -70,7 +70,7 @@ Feature: install cookbooks from a Berksfile
70
70
  When I successfully run `berks install`
71
71
  Then the output should contain:
72
72
  """
73
- Using example_cookbook (0.5.0) at path:
73
+ Using example_cookbook (0.5.0) at '
74
74
  """
75
75
  And the exit status should be 0
76
76
 
@@ -80,7 +80,7 @@ Feature: install cookbooks from a Berksfile
80
80
  cookbook "berkshelf-cookbook-fixture", git: "git://github.com/RiotGames/berkshelf-cookbook-fixture.git"
81
81
  """
82
82
  When I successfully run `berks install`
83
- Then the cookbook store should have the git cookbooks:
83
+ Then the cookbook store should have the cookbooks installed by git:
84
84
  | berkshelf-cookbook-fixture | 1.0.0 | a97b9447cbd41a5fe58eee2026e48ccb503bd3bc |
85
85
  And the output should contain:
86
86
  """
@@ -88,13 +88,54 @@ Feature: install cookbooks from a Berksfile
88
88
  """
89
89
  And the exit status should be 0
90
90
 
91
+ Scenario: installing a Berksfile that contains a Git location that has already been downloaded
92
+ Given I write to "Berksfile" with:
93
+ """
94
+ cookbook "berkshelf-cookbook-fixture", git: "git://github.com/RiotGames/berkshelf-cookbook-fixture.git"
95
+ """
96
+ And the cookbook store has the cookbooks installed by git:
97
+ | berkshelf-cookbook-fixture | 1.0.0 | a97b9447cbd41a5fe58eee2026e48ccb503bd3bc |
98
+ And I successfully run `berks install`
99
+ When I successfully run `berks install`
100
+ Then the exit status should be 0
101
+
102
+ Scenario: installing a Berksfile that contains a Git location with a rel
103
+ Given I write to "Berksfile" with:
104
+ """
105
+ cookbook "berkshelf-cookbook-fixture", github: 'RiotGames/berkshelf-cookbook-fixture', branch: 'rel', rel: 'cookbooks/berkshelf-cookbook-fixture'
106
+ """
107
+ When I successfully run `berks install`
108
+ Then the cookbook store should have the cookbooks installed by git:
109
+ | berkshelf-cookbook-fixture | 1.0.0 | 93f5768b7d14df45e10d16c8bf6fe98ba3ff809a |
110
+ And the output should contain:
111
+ """
112
+ Installing berkshelf-cookbook-fixture (1.0.0)
113
+ """
114
+ And the exit status should be 0
115
+
116
+ Scenario: installing a Berksfile that contains a Git location with a rel that has already been downloaded
117
+ Given I write to "Berksfile" with:
118
+ """
119
+ site :opscode
120
+ cookbook 'berkshelf-cookbook-fixture', github: 'RiotGames/berkshelf-cookbook-fixture', branch: 'rel', rel: 'cookbooks/berkshelf-cookbook-fixture'
121
+ """
122
+ And the cookbook store has the cookbooks installed by git:
123
+ | berkshelf-cookbook-fixture | 1.0.0 | 93f5768b7d14df45e10d16c8bf6fe98ba3ff809a |
124
+ And I successfully run `berks install`
125
+ When I run `berks install`
126
+ Then the output should contain:
127
+ """
128
+ Installing berkshelf-cookbook-fixture (1.0.0)
129
+ """
130
+ And the exit status should be 0
131
+
91
132
  Scenario: installing a Berksfile that contains a Git location with a tag
92
133
  Given I write to "Berksfile" with:
93
134
  """
94
135
  cookbook "berkshelf-cookbook-fixture", git: "git://github.com/RiotGames/berkshelf-cookbook-fixture.git", tag: "v0.2.0"
95
136
  """
96
137
  When I successfully run `berks install`
97
- Then the cookbook store should have the git cookbooks:
138
+ Then the cookbook store should have the cookbooks installed by git:
98
139
  | berkshelf-cookbook-fixture | 0.2.0 | 70a527e17d91f01f031204562460ad1c17f972ee |
99
140
  And the output should contain:
100
141
  """
@@ -108,7 +149,7 @@ Feature: install cookbooks from a Berksfile
108
149
  cookbook "berkshelf-cookbook-fixture", github: "RiotGames/berkshelf-cookbook-fixture", tag: "v0.2.0"
109
150
  """
110
151
  When I successfully run `berks install`
111
- Then the cookbook store should have the git cookbooks:
152
+ Then the cookbook store should have the cookbooks installed by git:
112
153
  | berkshelf-cookbook-fixture | 0.2.0 | 70a527e17d91f01f031204562460ad1c17f972ee |
113
154
  And the output should contain:
114
155
  """
@@ -122,7 +163,7 @@ Feature: install cookbooks from a Berksfile
122
163
  cookbook "berkshelf-cookbook-fixture", github: "RiotGames/berkshelf-cookbook-fixture", tag: "v0.2.0"
123
164
  """
124
165
  When I successfully run `berks install`
125
- Then the cookbook store should have the git cookbooks:
166
+ Then the cookbook store should have the cookbooks installed by git:
126
167
  | berkshelf-cookbook-fixture | 0.2.0 | 70a527e17d91f01f031204562460ad1c17f972ee |
127
168
  And the output should contain:
128
169
  """
@@ -136,7 +177,7 @@ Feature: install cookbooks from a Berksfile
136
177
  cookbook "berkshelf-cookbook-fixture", github: "RiotGames/berkshelf-cookbook-fixture", tag: "v1.0.0", protocol: "<protocol>"
137
178
  """
138
179
  When I successfully run `berks install`
139
- Then the cookbook store should have the git cookbooks:
180
+ Then the cookbook store should have the cookbooks installed by git:
140
181
  | berkshelf-cookbook-fixture | 1.0.0 | b4f968c9001ad8de30f564a2107fab9cfa91f771 |
141
182
  And the output should contain:
142
183
  """
@@ -184,9 +225,24 @@ Feature: install cookbooks from a Berksfile
184
225
  """
185
226
  When I cd to "sparkle_motion"
186
227
  And I successfully run `berks install`
187
- Then the output should contain:
228
+ Then the output should contain exactly:
229
+ """
230
+ Using sparkle_motion (0.0.0) from metadata
231
+
232
+ """
233
+ And the exit status should be 0
234
+
235
+ Scenario: running install when current project is a cookbook and the 'metadata' is specified with a path
236
+ Given a cookbook named "fake"
237
+ And I write to "Berksfile" with:
238
+ """
239
+ metadata path: './fake'
188
240
  """
189
- Using sparkle_motion (0.0.0) at path:
241
+ When I successfully run `berks install`
242
+ Then the output should contain exactly:
243
+ """
244
+ Using fake (0.0.0) from metadata at './fake'
245
+
190
246
  """
191
247
  And the exit status should be 0
192
248
 
@@ -237,6 +293,39 @@ Feature: install cookbooks from a Berksfile
237
293
  """
238
294
  And the CLI should exit with the status code for error "DuplicateSourceDefined"
239
295
 
296
+ Scenario: When a version constraint in the metadata exists, but does not satisfy
297
+ Given a cookbook named "fake"
298
+ And I write to "Berksfile" with:
299
+ """
300
+ site :opscode
301
+ cookbook 'fake', path: './fake'
302
+ """
303
+ And the cookbook "fake" has the file "metadata.rb" with:
304
+ """
305
+ name 'fake'
306
+ version '1.0.0'
307
+
308
+ depends 'berkshelf-cookbook-fixture', '~> 0.2.0'
309
+ """
310
+ And the cookbook store has the cookbooks:
311
+ | berkshelf-cookbook-fixture | 0.2.0 |
312
+ And I successfully run `berks install`
313
+ And the cookbook "fake" has the file "metadata.rb" with:
314
+ """
315
+ name 'fake'
316
+ version '1.0.0'
317
+
318
+ depends 'berkshelf-cookbook-fixture', '~> 1.0.0'
319
+ """
320
+ When I successfully run `berks install`
321
+ Then the output should contain:
322
+ """
323
+ Installing berkshelf-cookbook-fixture (1.0.0)
324
+ """
325
+ And the cookbook store should have the cookbooks:
326
+ | berkshelf-cookbook-fixture | 1.0.0 |
327
+ And the exit status should be 0
328
+
240
329
  Scenario: installing when a git source defines a branch that does not satisfy the version constraint
241
330
  Given I write to "Berksfile" with:
242
331
  """
@@ -334,12 +423,9 @@ Feature: install cookbooks from a Berksfile
334
423
  When I run `berks install`
335
424
  Then the output should contain:
336
425
  """
337
- An error occurred during Git execution:
338
-
339
- fatal: remote error:
340
- Repository not found.
426
+ Failed to download 'doesntexist' from git:
341
427
  """
342
- And the CLI should exit with the status code for error "GitError"
428
+ And the CLI should exit with the status code for error "CookbookNotFound"
343
429
 
344
430
  Scenario: invalid site symbol
345
431
  Given I write to "Berksfile" with:
@@ -68,7 +68,7 @@ Feature: --format json
68
68
  {
69
69
  "name": "example_cookbook",
70
70
  "version": "0.5.0",
71
- "location": "path: '<%= File.expand_path(File.join(fixtures_path, 'cookbooks', 'example_cookbook-0.5.0')) %>'",
71
+ "location": "../../spec/fixtures/cookbooks/example_cookbook-0.5.0",
72
72
  "uploaded_to": "http://localhost:4000/"
73
73
  }
74
74
  ],
@@ -29,6 +29,7 @@ Feature: Creating and reading the Berkshelf lockfile
29
29
  | fake | 1.0.0 |
30
30
  And I write to "Berksfile" with:
31
31
  """
32
+ site :opscode
32
33
  cookbook 'fake', '1.0.0'
33
34
  """
34
35
  And I write to "Berksfile.lock" with:
@@ -40,11 +41,11 @@ Feature: Creating and reading the Berkshelf lockfile
40
41
  Then the file "Berksfile.lock" should contain JSON:
41
42
  """
42
43
  {
43
- "sha":"80396ed07db133e0192593adebb360c27eed88c2",
44
- "sources":{
45
- "fake":{
46
- "locked_version":"1.0.0",
47
- "constraint":"= 1.0.0"
44
+ "sha": "374a3d22920abae4a6d620a14a32b90d8babda8f",
45
+ "sources": {
46
+ "fake": {
47
+ "constraint": "= 1.0.0",
48
+ "locked_version": "1.0.0"
48
49
  }
49
50
  }
50
51
  }
@@ -65,10 +66,9 @@ Feature: Creating and reading the Berkshelf lockfile
65
66
  Then the file "Berksfile.lock" should contain JSON:
66
67
  """
67
68
  {
68
- "sha":"4b614de85168d72fda4b255fc31796b4c474c3fc",
69
+ "sha":"ebf27d476739b5aba7e7e8a61de23b3330e20a7d",
69
70
  "sources":{
70
71
  "fake":{
71
- "locked_version":"0.0.0",
72
72
  "constraint":"= 0.0.0",
73
73
  "path":"./fake"
74
74
  }
@@ -183,7 +183,7 @@ Feature: Creating and reading the Berkshelf lockfile
183
183
  And I write to "Berksfile.lock" with:
184
184
  """
185
185
  {
186
- "sha":"7d07c22eca03bf6da5aaf38ae81cb9a8a439c692",
186
+ "sha":"c6438d7590f4d695d8abae83ff22586ba6d3a52e",
187
187
  "sources":{
188
188
  "berkshelf-cookbook-fixture":{
189
189
  "constraint":"= 1.0.0",
@@ -331,41 +331,68 @@ Feature: Creating and reading the Berkshelf lockfile
331
331
  Then the file "Berksfile.lock" should contain JSON:
332
332
  """
333
333
  {
334
- "sha": "42a13f91f1ba19ce8c6776fe267e74510dee27ce",
334
+ "sha": "a148a5a75397588393801a2fd55df1325080868c",
335
335
  "sources":{
336
336
  "fake":{
337
- "path":"./fake",
338
- "locked_version":"0.0.0"
337
+ "path":"./fake"
339
338
  }
340
339
  }
341
340
  }
342
341
  """
343
342
 
344
- Scenario: Lockfile when `metadata` is specified
345
- Given I write to "metadata.rb" with:
343
+ Scenario: Installing a Berksfile with a metadata location
344
+ Given a cookbook named "fake"
345
+ And the cookbook "fake" has the file "Berksfile" with:
346
346
  """
347
- name 'fake'
348
- version '1.0.0'
347
+ site :opscode
348
+ metadata
349
349
  """
350
- And I write to "Berksfile" with:
350
+ When I cd to "fake"
351
+ And I successfully run `berks install`
352
+ Then the file "Berksfile.lock" should contain JSON:
353
+ """
354
+ {
355
+ "sha": "a7371143bae509b849bf94e5d65987581bf93133",
356
+ "sources": {
357
+ "fake": {
358
+ "path": "."
359
+ }
360
+ }
361
+ }
362
+ """
363
+
364
+ Scenario: Installing a Berksfile with a metadata location
365
+ Given a cookbook named "fake"
366
+ And the cookbook "fake" has the file "Berksfile" with:
351
367
  """
352
368
  site :opscode
353
369
  metadata
354
370
  """
355
- When I successfully run `berks install`
371
+ And the cookbook "fake" has the file "Berksfile.lock" with:
372
+ """
373
+ {
374
+ "sha": "a7371143bae509b849bf94e5d65987581bf93133",
375
+ "sources": {
376
+ "fake": {
377
+ "path": "."
378
+ }
379
+ }
380
+ }
381
+ """
382
+ When I cd to "fake"
383
+ And I successfully run `berks install`
356
384
  Then the file "Berksfile.lock" should contain JSON:
357
385
  """
358
386
  {
359
- "sha": "9e7f8da566fec49ac41c0d862cfdf728eee10568",
360
- "sources":{
361
- "fake":{
362
- "path":".",
363
- "locked_version":"1.0.0",
364
- "constraint":"= 1.0.0"
387
+ "sha": "a7371143bae509b849bf94e5d65987581bf93133",
388
+ "sources": {
389
+ "fake": {
390
+ "path": "."
365
391
  }
366
392
  }
367
393
  }
368
394
  """
395
+ And the exit status should be 0
369
396
 
370
397
  Scenario: Updating a Berksfile.lock with a different site location
371
398
  Given pending we have a reliable non-opscode site to test
@@ -56,6 +56,19 @@ Given /^the cookbook store has the cookbooks:$/ do |cookbooks|
56
56
  end
57
57
  end
58
58
 
59
+ Given /^the cookbook store has the cookbooks installed by git:$/ do |cookbooks|
60
+ cookbooks.raw.each do |name, version, sha|
61
+ folder = "#{name}-#{sha}"
62
+ metadata = File.join(folder, 'metadata.rb')
63
+
64
+ create_dir(folder)
65
+ write_file(metadata, [
66
+ "name '#{name}'",
67
+ "version '#{version}'"
68
+ ].join("\n"))
69
+ end
70
+ end
71
+
59
72
  Given /^the cookbook store contains a cookbook "(.*?)" "(.*?)" with dependencies:$/ do |name, version, dependencies|
60
73
  generate_cookbook(cookbook_store, name, version, dependencies: dependencies.raw)
61
74
  end
@@ -72,7 +85,7 @@ Then /^the cookbook store should have the cookbooks:$/ do |cookbooks|
72
85
  end
73
86
  end
74
87
 
75
- Then /^the cookbook store should have the git cookbooks:$/ do |cookbooks|
88
+ Then /^the cookbook store should have the cookbooks installed by git:$/ do |cookbooks|
76
89
  cookbooks.raw.each do |name, version, sha1|
77
90
  expect(cookbook_store).to have_structure {
78
91
  directory "#{name}-#{sha1}" do