berkshelf 3.0.0.beta7 → 3.0.0.beta8

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.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +4 -1
  4. data/CONTRIBUTING.md +1 -1
  5. data/Gemfile +0 -1
  6. data/Guardfile +0 -8
  7. data/README.md +33 -13
  8. data/berkshelf.gemspec +3 -3
  9. data/features/commands/install.feature +16 -88
  10. data/features/commands/search.feature +15 -0
  11. data/features/commands/shelf/show.feature +2 -2
  12. data/features/commands/shelf/uninstall.feature +1 -1
  13. data/features/commands/show.feature +3 -3
  14. data/features/commands/update.feature +29 -1
  15. data/features/commands/upload.feature +172 -7
  16. data/features/commands/vendor.feature +32 -0
  17. data/features/json_formatter.feature +26 -24
  18. data/features/lifecycle.feature +285 -0
  19. data/features/lockfile.feature +9 -7
  20. data/features/step_definitions/chef_server_steps.rb +1 -0
  21. data/features/step_definitions/cli_steps.rb +2 -2
  22. data/features/step_definitions/filesystem_steps.rb +2 -4
  23. data/gem_graph.png +0 -0
  24. data/generator_files/chefignore +0 -2
  25. data/lib/berkshelf.rb +39 -14
  26. data/lib/berkshelf/berksfile.rb +161 -113
  27. data/lib/berkshelf/cached_cookbook.rb +2 -2
  28. data/lib/berkshelf/cli.rb +15 -3
  29. data/lib/berkshelf/commands/shelf.rb +3 -7
  30. data/lib/berkshelf/community_rest.rb +9 -9
  31. data/lib/berkshelf/config.rb +3 -3
  32. data/lib/berkshelf/cookbook_generator.rb +0 -8
  33. data/lib/berkshelf/cookbook_store.rb +1 -2
  34. data/lib/berkshelf/dependency.rb +25 -138
  35. data/lib/berkshelf/downloader.rb +41 -7
  36. data/lib/berkshelf/errors.rb +113 -214
  37. data/lib/berkshelf/formatters/base.rb +42 -0
  38. data/lib/berkshelf/formatters/human.rb +145 -0
  39. data/lib/berkshelf/formatters/json.rb +149 -133
  40. data/lib/berkshelf/formatters/null.rb +8 -18
  41. data/lib/berkshelf/init_generator.rb +1 -1
  42. data/lib/berkshelf/installer.rb +115 -104
  43. data/lib/berkshelf/location.rb +22 -121
  44. data/lib/berkshelf/locations/base.rb +75 -0
  45. data/lib/berkshelf/locations/git.rb +196 -0
  46. data/lib/berkshelf/locations/github.rb +8 -0
  47. data/lib/berkshelf/locations/path.rb +78 -0
  48. data/lib/berkshelf/lockfile.rb +452 -290
  49. data/lib/berkshelf/logger.rb +9 -3
  50. data/lib/berkshelf/mixin/logging.rb +4 -9
  51. data/lib/berkshelf/resolver.rb +12 -12
  52. data/lib/berkshelf/source.rb +13 -1
  53. data/lib/berkshelf/version.rb +1 -1
  54. data/spec/fixtures/cookbooks/example_cookbook-0.5.0/metadata.rb +3 -7
  55. data/spec/fixtures/cookbooks/example_cookbook/metadata.rb +3 -6
  56. data/spec/spec_helper.rb +5 -6
  57. data/spec/support/matchers/file_system_matchers.rb +4 -0
  58. data/spec/support/shared_examples/formatter.rb +11 -0
  59. data/spec/unit/berkshelf/berksfile_spec.rb +25 -28
  60. data/spec/unit/berkshelf/cli_spec.rb +19 -11
  61. data/spec/unit/berkshelf/dependency_spec.rb +4 -164
  62. data/spec/unit/berkshelf/formatters/base_spec.rb +35 -0
  63. data/spec/unit/berkshelf/formatters/human_spec.rb +7 -0
  64. data/spec/unit/berkshelf/formatters/json_spec.rb +7 -0
  65. data/spec/unit/berkshelf/formatters/null_spec.rb +7 -11
  66. data/spec/unit/berkshelf/location_spec.rb +16 -144
  67. data/spec/unit/berkshelf/locations/base_spec.rb +80 -0
  68. data/spec/unit/berkshelf/locations/git_spec.rb +249 -0
  69. data/spec/unit/berkshelf/locations/path_spec.rb +107 -0
  70. data/spec/unit/berkshelf/lockfile_parser_spec.rb +3 -3
  71. data/spec/unit/berkshelf/lockfile_spec.rb +55 -11
  72. data/spec/unit/berkshelf/logger_spec.rb +2 -2
  73. data/spec/unit/berkshelf/mixin/logging_spec.rb +5 -9
  74. data/spec/unit/berkshelf/source_spec.rb +32 -13
  75. data/spec/unit/berkshelf_spec.rb +6 -9
  76. metadata +33 -33
  77. data/.ruby-version +0 -1
  78. data/berkshelf-complete.sh +0 -75
  79. data/lib/berkshelf/formatters.rb +0 -110
  80. data/lib/berkshelf/formatters/human_readable.rb +0 -142
  81. data/lib/berkshelf/git.rb +0 -204
  82. data/lib/berkshelf/locations/git_location.rb +0 -135
  83. data/lib/berkshelf/locations/github_location.rb +0 -55
  84. data/lib/berkshelf/locations/mercurial_location.rb +0 -114
  85. data/lib/berkshelf/locations/path_location.rb +0 -88
  86. data/lib/berkshelf/mercurial.rb +0 -146
  87. data/lib/berkshelf/mixin.rb +0 -7
  88. data/spec/support/mercurial.rb +0 -123
  89. data/spec/unit/berkshelf/formatters_spec.rb +0 -114
  90. data/spec/unit/berkshelf/git_spec.rb +0 -312
  91. data/spec/unit/berkshelf/locations/git_location_spec.rb +0 -126
  92. data/spec/unit/berkshelf/locations/mercurial_location_spec.rb +0 -131
  93. data/spec/unit/berkshelf/locations/path_location_spec.rb +0 -25
  94. data/spec/unit/berkshelf/mercurial_spec.rb +0 -172
@@ -48,6 +48,38 @@ Feature: Vendoring cookbooks to a directory
48
48
  And the directory "vendor/fake" should contain version "1.0.0" of the "fake" cookbook
49
49
  And the directory "vendor/ekaf" should contain version "2.0.0" of the "ekaf" cookbook
50
50
 
51
+ Scenario: vendoring a cookbook with transitive dependencies when a lockfile is present
52
+ Given a cookbook named "bacon"
53
+ And the cookbook "bacon" has the file "metadata.rb" with:
54
+ """
55
+ name 'bacon'
56
+ version '1.0.0'
57
+
58
+ depends 'fake'
59
+ depends 'ekaf'
60
+ """
61
+ And I have a Berksfile pointing at the local Berkshelf API with:
62
+ """
63
+ cookbook 'bacon', path: './bacon'
64
+ """
65
+ And I write to "Berksfile.lock" with:
66
+ """
67
+ DEPENDENCIES
68
+ bacon
69
+ path: ./bacon
70
+
71
+ GRAPH
72
+ bacon (1.0.0)
73
+ ekaf (>= 0.0.0)
74
+ fake (>= 0.0.0)
75
+ ekaf (2.0.0)
76
+ fake (1.0.0)
77
+ """
78
+ When I successfully run `berks vendor vendor`
79
+ Then the directory "vendor/bacon" should contain version "1.0.0" of the "bacon" cookbook
80
+ And the directory "vendor/fake" should contain version "1.0.0" of the "fake" cookbook
81
+ And the directory "vendor/ekaf" should contain version "2.0.0" of the "ekaf" cookbook
82
+
51
83
  Scenario: vendoring without an explicit path to vendor into
52
84
  Given I have a Berksfile pointing at the local Berkshelf API with:
53
85
  """
@@ -24,12 +24,12 @@ Feature: --format json
24
24
  "name": "berkshelf"
25
25
  }
26
26
  ],
27
- "errors": [
28
-
29
- ],
27
+ "errors": [],
30
28
  "messages": [
29
+ "Resolving cookbook dependencies...",
31
30
  "Fetching cookbook index from http://0.0.0.0:26210..."
32
- ]
31
+ ],
32
+ "warnings": []
33
33
  }
34
34
  """
35
35
 
@@ -50,12 +50,12 @@ Feature: --format json
50
50
  "version": "1.0.0"
51
51
  }
52
52
  ],
53
- "errors": [
54
-
55
- ],
53
+ "errors": [],
56
54
  "messages": [
55
+ "Resolving cookbook dependencies...",
57
56
  "Fetching cookbook index from http://0.0.0.0:26210..."
58
- ]
57
+ ],
58
+ "warnings": []
59
59
  }
60
60
  """
61
61
 
@@ -88,11 +88,9 @@ Feature: --format json
88
88
  "license": "none"
89
89
  }
90
90
  ],
91
- "errors": [
92
-
93
- ],
94
- "messages": [
95
- ]
91
+ "errors": [],
92
+ "messages": [],
93
+ "warnings": []
96
94
  }
97
95
  """
98
96
 
@@ -101,6 +99,15 @@ Feature: --format json
101
99
  """
102
100
  cookbook 'example_cookbook', path: '../../fixtures/cookbooks/example_cookbook-0.5.0'
103
101
  """
102
+ And I write to "Berksfile.lock" with:
103
+ """
104
+ DEPENDENCIES
105
+ example_cookbook
106
+ path: ../../fixtures/cookbooks/example_cookbook-0.5.0
107
+
108
+ GRAPH
109
+ example_cookbook (0.5.0)
110
+ """
104
111
  When I successfully run `berks upload --format json`
105
112
  Then the output should contain JSON:
106
113
  """
@@ -109,16 +116,12 @@ Feature: --format json
109
116
  {
110
117
  "name": "example_cookbook",
111
118
  "version": "0.5.0",
112
- "location": "../../fixtures/cookbooks/example_cookbook-0.5.0",
113
119
  "uploaded_to": "http://localhost:26310/"
114
120
  }
115
121
  ],
116
- "errors": [
117
-
118
- ],
119
- "messages": [
120
- "Fetching cookbook index from http://0.0.0.0:26210..."
121
- ]
122
+ "errors": [],
123
+ "messages": [],
124
+ "warnings": []
122
125
  }
123
126
  """
124
127
 
@@ -158,11 +161,10 @@ Feature: --format json
158
161
  "name": "seth"
159
162
  }
160
163
  ],
161
- "errors": [
162
-
163
- ],
164
+ "errors": [],
164
165
  "messages": [
165
166
  "The following cookbooks have newer versions:"
166
- ]
167
+ ],
168
+ "warnings": []
167
169
  }
168
170
  """
@@ -0,0 +1,285 @@
1
+ #
2
+ # The lifecycle feature contains a series of "long-running" lifecycle commands.
3
+ # These tests do not fit into a single command as they are cross-cutting and
4
+ # require more setup than a typical test.
5
+ #
6
+ # These tests are designed to mirror the real-world use cases for Berkshelf in
7
+ # day-to-day work. It also contains a collection of previously known bugs to
8
+ # prevent regressions.
9
+ #
10
+ Feature: Lifecycle commands
11
+ Background:
12
+ * the cookbook store has the cookbooks:
13
+ | ekaf | 1.0.0 |
14
+ | fake | 1.0.0 |
15
+
16
+ Scenario: A trusted lockfile does not fetch the dependency index
17
+ * I have a Berksfile pointing at the local Berkshelf API with:
18
+ """
19
+ cookbook 'fake', '1.0.0'
20
+ """
21
+ * I write to "Berksfile.lock" with:
22
+ """
23
+ DEPENDENCIES
24
+ fake (= 1.0.0)
25
+
26
+ GRAPH
27
+ fake (1.0.0)
28
+ """
29
+ * I successfully run `berks install`
30
+ * the output should not contain "Fetching cookbook index"
31
+ * the output should contain "Using fake (1.0.0)"
32
+
33
+ Scenario: An untrusted lockfile fetches the dependency index
34
+ * I have a Berksfile pointing at the local Berkshelf API with:
35
+ """
36
+ cookbook 'fake', '1.0.0'
37
+ """
38
+ * I successfully run `berks install`
39
+ * the output should contain "Fetching cookbook index"
40
+ * the file "Berksfile.lock" should contain:
41
+ """
42
+ DEPENDENCIES
43
+ fake (= 1.0.0)
44
+
45
+ GRAPH
46
+ fake (1.0.0)
47
+ """
48
+ * I append to "Berksfile" with:
49
+ """
50
+
51
+ cookbook 'ekaf', '1.0.0'
52
+ """
53
+ * I successfully run `berks install`
54
+ * the file "Berksfile.lock" should contain:
55
+ """
56
+ DEPENDENCIES
57
+ ekaf (= 1.0.0)
58
+ fake (= 1.0.0)
59
+
60
+ GRAPH
61
+ ekaf (1.0.0)
62
+ fake (1.0.0)
63
+ """
64
+ * the output should contain "Using ekaf (1.0.0)"
65
+ * the output should contain "Using fake (1.0.0)"
66
+
67
+ Scenario: Removing a direct dependency
68
+ * I have a Berksfile pointing at the local Berkshelf API with:
69
+ """
70
+ cookbook 'fake', '1.0.0'
71
+ """
72
+ * I write to "Berksfile.lock" with:
73
+ """
74
+ DEPENDENCIES
75
+ ekaf (= 1.0.0)
76
+ fake (= 1.0.0)
77
+
78
+ GRAPH
79
+ ekaf (1.0.0)
80
+ fake (1.0.0)
81
+ """
82
+ * I successfully run `berks install`
83
+ * the file "Berksfile.lock" should contain:
84
+ """
85
+ DEPENDENCIES
86
+ fake (= 1.0.0)
87
+
88
+ GRAPH
89
+ fake (1.0.0)
90
+ """
91
+ * the output should not contain "Using ekaf (1.0.0)"
92
+ * the output should contain "Using fake (1.0.0)"
93
+
94
+ Scenario: A trusted lockfile with transitive dependencies does not fetch the dependency index
95
+ * I have a Berksfile pointing at the local Berkshelf API with:
96
+ """
97
+ metadata
98
+ """
99
+ * I write to "metadata.rb" with:
100
+ """
101
+ name 'transitive'
102
+ version '1.2.3'
103
+ depends 'fake', '1.0.0'
104
+ """
105
+ * I write to "Berksfile.lock" with:
106
+ """
107
+ DEPENDENCIES
108
+ transitive
109
+ path: .
110
+ metadata: true
111
+
112
+ GRAPH
113
+ fake (1.0.0)
114
+ transitive (1.2.3)
115
+ fake (= 1.0.0)
116
+ """
117
+ * I successfully run `berks install`
118
+ * the output should not contain "Fetching cookbook index"
119
+ * the output should contain "Using fake (1.0.0)"
120
+ * the output should contain "Using transitive (1.2.3)"
121
+
122
+ Scenario: An utrusted lockfile because of transitive dependencies fetches the dependency index
123
+ * I have a Berksfile pointing at the local Berkshelf API with:
124
+ """
125
+ metadata
126
+ """
127
+ * I write to "metadata.rb" with:
128
+ """
129
+ name 'transitive'
130
+ version '1.2.3'
131
+ depends 'fake', '1.0.0'
132
+ """
133
+ * I successfully run `berks install`
134
+ * the output should contain "Fetching cookbook index"
135
+ * the file "Berksfile.lock" should contain:
136
+ """
137
+ DEPENDENCIES
138
+ transitive
139
+ path: .
140
+ metadata: true
141
+
142
+ GRAPH
143
+ fake (1.0.0)
144
+ transitive (1.2.3)
145
+ fake (= 1.0.0)
146
+ """
147
+ * I append to "metadata.rb" with:
148
+ """
149
+
150
+ depends 'ekaf', '1.0.0'
151
+ """
152
+ * I successfully run `berks install`
153
+ * the file "Berksfile.lock" should contain:
154
+ """
155
+ DEPENDENCIES
156
+ transitive
157
+ path: .
158
+ metadata: true
159
+
160
+ GRAPH
161
+ ekaf (1.0.0)
162
+ fake (1.0.0)
163
+ transitive (1.2.3)
164
+ ekaf (= 1.0.0)
165
+ fake (= 1.0.0)
166
+ """
167
+ * the output should contain "Using ekaf (1.0.0)"
168
+ * the output should contain "Using fake (1.0.0)"
169
+ * the output should contain "Using transitive (1.2.3)"
170
+
171
+ Scenario: Removing a transitive dependency
172
+ * I have a Berksfile pointing at the local Berkshelf API with:
173
+ """
174
+ metadata
175
+ """
176
+ * I write to "metadata.rb" with:
177
+ """
178
+ name 'transitive'
179
+ version '1.2.3'
180
+ depends 'fake', '1.0.0'
181
+ """
182
+ * I write to "Berksfile.lock" with:
183
+ """
184
+ DEPENDENCIES
185
+ transitive
186
+ path: .
187
+ metadata: true
188
+
189
+ GRAPH
190
+ ekaf (1.0.0)
191
+ fake (1.0.0)
192
+ transitive (1.2.3)
193
+ ekaf (= 1.0.0)
194
+ fake (= 1.0.0)
195
+ """
196
+ * I successfully run `berks install`
197
+ * the file "Berksfile.lock" should contain:
198
+ """
199
+ DEPENDENCIES
200
+ transitive
201
+ path: .
202
+ metadata: true
203
+
204
+ GRAPH
205
+ fake (1.0.0)
206
+ transitive (1.2.3)
207
+ fake (= 1.0.0)
208
+ """
209
+ * the output should not contain "Using ekaf (1.0.0)"
210
+ * the output should contain "Using fake (1.0.0)"
211
+
212
+ Scenario: Bumping the version of a local cookbook
213
+ * I have a Berksfile pointing at the local Berkshelf API with:
214
+ """
215
+ metadata
216
+ """
217
+ * I write to "metadata.rb" with:
218
+ """
219
+ name 'fake'
220
+ version '1.0.0'
221
+ """
222
+ * I successfully run `berks install`
223
+ * the file "Berksfile.lock" should contain:
224
+ """
225
+ DEPENDENCIES
226
+ fake
227
+ path: .
228
+ metadata: true
229
+
230
+ GRAPH
231
+ fake (1.0.0)
232
+ """
233
+ * I write to "metadata.rb" with:
234
+ """
235
+ name 'fake'
236
+ version '1.0.1'
237
+ """
238
+ * I successfully run `berks install`
239
+ * the file "Berksfile.lock" should contain:
240
+ """
241
+ DEPENDENCIES
242
+ fake
243
+ path: .
244
+ metadata: true
245
+
246
+ GRAPH
247
+ fake (1.0.1)
248
+ """
249
+ * the output should contain "Using fake (1.0.1)"
250
+
251
+ Scenario: Switching a dependency to a new location
252
+ * I have a Berksfile pointing at the local Berkshelf API with:
253
+ """
254
+ cookbook 'fake'
255
+ """
256
+ * I write to "Berksfile.lock" with:
257
+ """
258
+ DEPENDENCIES
259
+ fake
260
+
261
+ GRAPH
262
+ fake (1.0.0)
263
+ """
264
+ * I have a Berksfile pointing at the local Berkshelf API with:
265
+ """
266
+ cookbook 'fake', path: './fake'
267
+ """
268
+ * I write to "fake/metadata.rb" with:
269
+
270
+ """
271
+ name 'fake'
272
+ version '2.0.0'
273
+ """
274
+ * I successfully run `berks install`
275
+ * the file "Berksfile.lock" should contain:
276
+ """
277
+ DEPENDENCIES
278
+ fake
279
+ path: ./fake
280
+
281
+ GRAPH
282
+ fake (2.0.0)
283
+ """
284
+ * the output should not contain "Using fake (1.0.0)"
285
+ * the output should contain "Using fake (2.0.0)"
@@ -177,7 +177,8 @@ Feature: Creating and reading the Berkshelf lockfile
177
177
  DEPENDENCIES
178
178
  berkshelf-cookbook-fixture
179
179
  git: git://github.com/RiotGames/berkshelf-cookbook-fixture.git
180
- ref: 919afa0c402089df23ebdf36637f12271b8a96b4
180
+ revision: 919afa0c402089df23ebdf36637f12271b8a96b4
181
+ ref: 919afa0
181
182
 
182
183
  GRAPH
183
184
  berkshelf-cookbook-fixture (1.0.0)
@@ -194,14 +195,14 @@ Feature: Creating and reading the Berkshelf lockfile
194
195
  DEPENDENCIES
195
196
  berkshelf-cookbook-fixture
196
197
  git: git://github.com/RiotGames/berkshelf-cookbook-fixture.git
198
+ revision: a97b9447cbd41a5fe58eee2026e48ccb503bd3bc
197
199
  branch: master
198
- ref: a97b9447cbd41a5fe58eee2026e48ccb503bd3bc
199
200
 
200
201
  GRAPH
201
202
  berkshelf-cookbook-fixture (1.0.0)
202
203
  """
203
204
 
204
- Scenario: Updating a Berksfile.lock with a git location and a branch
205
+ Scenario: Updating a Berksfile.lock with a git location and a tag
205
206
  Given I have a Berksfile pointing at the local Berkshelf API with:
206
207
  """
207
208
  cookbook 'berkshelf-cookbook-fixture', git: 'git://github.com/RiotGames/berkshelf-cookbook-fixture.git', tag: 'v0.2.0'
@@ -212,8 +213,8 @@ Feature: Creating and reading the Berkshelf lockfile
212
213
  DEPENDENCIES
213
214
  berkshelf-cookbook-fixture
214
215
  git: git://github.com/RiotGames/berkshelf-cookbook-fixture.git
215
- branch: v0.2.0
216
- ref: 70a527e17d91f01f031204562460ad1c17f972ee
216
+ revision: 70a527e17d91f01f031204562460ad1c17f972ee
217
+ tag: v0.2.0
217
218
 
218
219
  GRAPH
219
220
  berkshelf-cookbook-fixture (0.2.0)
@@ -230,7 +231,8 @@ Feature: Creating and reading the Berkshelf lockfile
230
231
  DEPENDENCIES
231
232
  berkshelf-cookbook-fixture
232
233
  git: git://github.com/RiotGames/berkshelf-cookbook-fixture.git
233
- ref: 919afa0c402089df23ebdf36637f12271b8a96b4
234
+ revision: 919afa0c402089df23ebdf36637f12271b8a96b4
235
+ ref: 919afa0
234
236
 
235
237
  GRAPH
236
238
  berkshelf-cookbook-fixture (1.0.0)
@@ -247,8 +249,8 @@ Feature: Creating and reading the Berkshelf lockfile
247
249
  DEPENDENCIES
248
250
  berkshelf-cookbook-fixture
249
251
  git: git://github.com/RiotGames/berkshelf-cookbook-fixture.git
252
+ revision: 93f5768b7d14df45e10d16c8bf6fe98ba3ff809a
250
253
  branch: rel
251
- ref: 93f5768b7d14df45e10d16c8bf6fe98ba3ff809a
252
254
  rel: cookbooks/berkshelf-cookbook-fixture
253
255
 
254
256
  GRAPH