knife-essentials 0.8.3 → 0.8.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. data/lib/chef/knife/diff_essentials.rb +2 -2
  2. data/lib/chef/knife/download_essentials.rb +5 -1
  3. data/lib/chef/knife/list_essentials.rb +2 -1
  4. data/lib/chef/knife/upload_essentials.rb +5 -1
  5. data/lib/chef_fs/command_line.rb +94 -63
  6. data/lib/chef_fs/file_system.rb +113 -93
  7. data/lib/chef_fs/file_system/base_fs_object.rb +91 -37
  8. data/lib/chef_fs/file_system/chef_repository_file_system_cookbooks_dir.rb +14 -1
  9. data/lib/chef_fs/file_system/chef_server_root_dir.rb +2 -1
  10. data/lib/chef_fs/file_system/cookbook_file.rb +7 -1
  11. data/lib/chef_fs/file_system/cookbooks_dir.rb +13 -6
  12. data/lib/chef_fs/file_system/environments_dir.rb +59 -0
  13. data/lib/chef_fs/file_system/multiplexed_dir.rb +1 -1
  14. data/lib/chef_fs/file_system/nodes_dir.rb +1 -0
  15. data/lib/chef_fs/file_system/operation_not_allowed_error.rb +29 -0
  16. data/lib/chef_fs/file_system/operation_skipped_error.rb +29 -0
  17. data/lib/chef_fs/knife.rb +29 -21
  18. data/lib/chef_fs/version.rb +1 -1
  19. data/spec/chef_fs/diff_spec.rb +30 -30
  20. data/spec/chef_fs/file_system/cookbooks_dir_spec.rb +5 -1
  21. data/spec/integration/chef_repo_path_spec.rb +705 -0
  22. data/spec/integration/chef_repository_file_system_spec.rb +82 -713
  23. data/spec/integration/chefignore_spec.rb +258 -0
  24. data/spec/integration/diff_spec.rb +151 -0
  25. data/spec/integration/download_spec.rb +403 -0
  26. data/spec/integration/list_spec.rb +21 -21
  27. data/spec/integration/upload_spec.rb +407 -0
  28. data/spec/support/integration_helper.rb +9 -4
  29. data/spec/support/knife_support.rb +14 -2
  30. metadata +12 -3
@@ -1,7 +1,8 @@
1
1
  require 'support/integration_helper'
2
2
  require 'chef/knife/list_essentials'
3
+ require 'chef/knife/show_essentials'
3
4
 
4
- describe 'knife list' do
5
+ describe 'General chef_repo file system checks' do
5
6
  extend IntegrationSupport
6
7
  include KnifeSupport
7
8
 
@@ -11,21 +12,12 @@ describe 'knife list' do
11
12
  directory "environments"
12
13
  directory "data_bags/bag1"
13
14
 
14
- it "knife list --local -R / returns them" do
15
- knife('list --local -R /').should_succeed <<EOM
16
- /:
17
- data_bags
18
- environments
19
- roles
20
-
21
- /data_bags:
22
- bag1
23
-
24
- /data_bags/bag1:
25
-
26
- /environments:
27
-
28
- /roles:
15
+ it "knife list --local -Rfp / returns them" do
16
+ knife('list --local -Rfp /').should_succeed <<EOM
17
+ /data_bags/
18
+ /data_bags/bag1/
19
+ /environments/
20
+ /roles/
29
21
  EOM
30
22
  end
31
23
  end
@@ -41,12 +33,9 @@ EOM
41
33
  when_the_repository "has an empty cookbook directory" do
42
34
  directory 'cookbooks/cookbook1'
43
35
 
44
- it "knife list --local -R / does not return it" do
45
- knife('list --local -R /').should_succeed <<EOM
46
- /:
47
- cookbooks
48
-
49
- /cookbooks:
36
+ it "knife list --local -Rfp / does not return it" do
37
+ knife('list --local -Rfp /').should_succeed(<<EOM, :stderr => "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n")
38
+ /cookbooks/
50
39
  EOM
51
40
  end
52
41
  end
@@ -54,12 +43,9 @@ EOM
54
43
  when_the_repository "has only empty cookbook subdirectories" do
55
44
  directory 'cookbooks/cookbook1/recipes'
56
45
 
57
- it "knife list --local -R / does not return it" do
58
- knife('list --local -R /').should_succeed <<EOM
59
- /:
60
- cookbooks
61
-
62
- /cookbooks:
46
+ it "knife list --local -Rfp / does not return it" do
47
+ knife('list --local -Rfp /').should_succeed(<<EOM, :stderr => "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n")
48
+ /cookbooks/
63
49
  EOM
64
50
  end
65
51
  end
@@ -68,22 +54,13 @@ EOM
68
54
  directory 'cookbooks/cookbook1/recipes'
69
55
  file 'cookbooks/cookbook1/templates/default/x.txt', ''
70
56
 
71
- it "knife list --local -R / does not return the empty ones" do
72
- knife('list --local -R /').should_succeed <<EOM
73
- /:
74
- cookbooks
75
-
76
- /cookbooks:
77
- cookbook1
78
-
79
- /cookbooks/cookbook1:
80
- templates
81
-
82
- /cookbooks/cookbook1/templates:
83
- default
84
-
85
- /cookbooks/cookbook1/templates/default:
86
- x.txt
57
+ it "knife list --local -Rfp / does not return the empty ones" do
58
+ knife('list --local -Rfp /').should_succeed <<EOM
59
+ /cookbooks/
60
+ /cookbooks/cookbook1/
61
+ /cookbooks/cookbook1/templates/
62
+ /cookbooks/cookbook1/templates/default/
63
+ /cookbooks/cookbook1/templates/default/x.txt
87
64
  EOM
88
65
  end
89
66
  end
@@ -91,12 +68,9 @@ EOM
91
68
  when_the_repository "has only empty cookbook sub-sub-directories" do
92
69
  directory 'cookbooks/cookbook1/templates/default'
93
70
 
94
- it "knife list --local -R / does not return it" do
95
- knife('list --local -R /').should_succeed <<EOM
96
- /:
97
- cookbooks
98
-
99
- /cookbooks:
71
+ it "knife list --local -Rfp / does not return it" do
72
+ knife('list --local -Rfp /').should_succeed(<<EOM, :stderr => "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n")
73
+ /cookbooks/
100
74
  EOM
101
75
  end
102
76
  end
@@ -106,22 +80,13 @@ EOM
106
80
  directory 'cookbooks/cookbook1/templates/rhel'
107
81
  directory 'cookbooks/cookbook1/files/default'
108
82
 
109
- it "knife list --local -R / does not return the empty ones" do
110
- knife('list --local -R /').should_succeed <<EOM
111
- /:
112
- cookbooks
113
-
114
- /cookbooks:
115
- cookbook1
116
-
117
- /cookbooks/cookbook1:
118
- templates
119
-
120
- /cookbooks/cookbook1/templates:
121
- default
122
-
123
- /cookbooks/cookbook1/templates/default:
124
- x.txt
83
+ it "knife list --local -Rfp / does not return the empty ones" do
84
+ knife('list --local -Rfp /').should_succeed <<EOM
85
+ /cookbooks/
86
+ /cookbooks/cookbook1/
87
+ /cookbooks/cookbook1/templates/
88
+ /cookbooks/cookbook1/templates/default/
89
+ /cookbooks/cookbook1/templates/default/x.txt
125
90
  EOM
126
91
  end
127
92
  end
@@ -131,8 +96,8 @@ EOM
131
96
  file "_default.json", {}
132
97
  end
133
98
 
134
- it "knife list --local -R / should NOT return it" do
135
- knife('list --local -R /').should_succeed ""
99
+ it "knife list --local -Rfp / should NOT return it" do
100
+ knife('list --local -Rfp /').should_succeed ""
136
101
  end
137
102
  end
138
103
 
@@ -153,31 +118,22 @@ EOM
153
118
  file "subdir/environment.json", {}
154
119
  end
155
120
 
156
- it "knife list --local -R / should NOT return them" do
121
+ it "knife list --local -Rfp / should NOT return them" do
157
122
  pending "Decide whether this is a good/bad idea" do
158
- knife('list --local -R /').should_succeed <<EOM
159
- /:
160
- data_bags
161
- environments
162
- roles
163
-
164
- /data_bags:
165
- bag1
166
-
167
- /data_bags/bag1:
168
- item1.json
169
-
170
- /environments:
171
- environment1.json
172
-
173
- /roles:
174
- role1.json
123
+ knife('list --local -Rfp /').should_succeed <<EOM
124
+ /data_bags/
125
+ /data_bags/bag1/
126
+ /data_bags/bag1/item1.json
127
+ /environments/
128
+ /environments/environment1.json
129
+ /roles/
130
+ /roles/role1.json
175
131
  EOM
176
132
  end
177
133
  end
178
134
  end
179
135
 
180
- when_the_repository "has extraneous subdirectories and files under cookbooks" do
136
+ when_the_repository "has extraneous subdirectories and files under a cookbook" do
181
137
  directory 'cookbooks/cookbook1' do
182
138
  file 'a.rb', ''
183
139
  file 'blarghle/blah.rb', ''
@@ -231,69 +187,40 @@ EOM
231
187
  end
232
188
  end
233
189
 
234
- it "knife list --local -R / should NOT return them" do
190
+ it "knife list --local -Rfp / should NOT return them" do
235
191
  pending "Decide whether this is a good idea" do
236
- knife('list --local -R /').should_succeed <<EOM
237
- /:
238
- cookbooks
239
-
240
- /cookbooks:
241
- cookbook1
242
-
243
- /cookbooks/cookbook1:
244
- a.rb
245
- attributes
246
- definitions
247
- files
248
- libraries
249
- providers
250
- recipes
251
- resources
252
- templates
253
-
254
- /cookbooks/cookbook1/attributes:
255
- a.rb
256
-
257
- /cookbooks/cookbook1/definitions:
258
- a.rb
259
-
260
- /cookbooks/cookbook1/files:
261
- a.rb
262
- b.json
263
- c
264
-
265
- /cookbooks/cookbook1/files/c:
266
- d.rb
267
- e.json
268
-
269
- /cookbooks/cookbook1/libraries:
270
- a.rb
271
-
272
- /cookbooks/cookbook1/providers:
273
- a.rb
274
- c
275
-
276
- /cookbooks/cookbook1/providers/c:
277
- d.rb
278
-
279
- /cookbooks/cookbook1/recipes:
280
- a.rb
281
-
282
- /cookbooks/cookbook1/resources:
283
- a.rb
284
- c
285
-
286
- /cookbooks/cookbook1/resources/c:
287
- d.rb
288
-
289
- /cookbooks/cookbook1/templates:
290
- a.rb
291
- b.json
292
- c
293
-
294
- /cookbooks/cookbook1/templates/c:
295
- d.rb
296
- e.json
192
+ knife('list --local -Rfp /').should_succeed <<EOM
193
+ /cookbooks/
194
+ /cookbooks/cookbook1/
195
+ /cookbooks/cookbook1/a.rb
196
+ /cookbooks/cookbook1/attributes/
197
+ /cookbooks/cookbook1/attributes/a.rb
198
+ /cookbooks/cookbook1/definitions/
199
+ /cookbooks/cookbook1/definitions/a.rb
200
+ /cookbooks/cookbook1/files/
201
+ /cookbooks/cookbook1/files/a.rb
202
+ /cookbooks/cookbook1/files/b.json
203
+ /cookbooks/cookbook1/files/c/
204
+ /cookbooks/cookbook1/files/c/d.rb
205
+ /cookbooks/cookbook1/files/c/e.json
206
+ /cookbooks/cookbook1/libraries/
207
+ /cookbooks/cookbook1/libraries/a.rb
208
+ /cookbooks/cookbook1/providers/
209
+ /cookbooks/cookbook1/providers/a.rb
210
+ /cookbooks/cookbook1/providers/c/
211
+ /cookbooks/cookbook1/providers/c/d.rb
212
+ /cookbooks/cookbook1/recipes/
213
+ /cookbooks/cookbook1/recipes/a.rb
214
+ /cookbooks/cookbook1/resources/
215
+ /cookbooks/cookbook1/resources/a.rb
216
+ /cookbooks/cookbook1/resources/c/
217
+ /cookbooks/cookbook1/resources/c/d.rb
218
+ /cookbooks/cookbook1/templates/
219
+ /cookbooks/cookbook1/templates/a.rb
220
+ /cookbooks/cookbook1/templates/b.json
221
+ /cookbooks/cookbook1/templates/c/
222
+ /cookbooks/cookbook1/templates/c/d.rb
223
+ /cookbooks/cookbook1/templates/c/e.json
297
224
  EOM
298
225
  end
299
226
  end
@@ -301,580 +228,22 @@ EOM
301
228
 
302
229
  when_the_repository "has a file in cookbooks/" do
303
230
  file 'cookbooks/file', ''
304
- it 'does not show up in list -R' do
305
- pending "don't show files when only directories are allowed" do
306
- knife('list --local -R /').should_succeed <<EOM
307
- /:
308
- cookbooks
309
-
310
- /cookbooks:
231
+ it 'does not show up in list -Rfp' do
232
+ knife('list --local -Rfp /').should_succeed <<EOM
233
+ /cookbooks/
311
234
  EOM
312
- end
313
235
  end
314
236
  end
315
237
 
316
238
  when_the_repository "has a file in data_bags/" do
317
239
  file 'data_bags/file', ''
318
- it 'does not show up in list -R' do
240
+ it 'does not show up in list -Rfp' do
319
241
  pending "don't show files when only directories are allowed" do
320
- knife('list --local -R /').should_succeed <<EOM
321
- /:
322
- data_bags
323
-
324
- /data_bags:
242
+ knife('list --local -Rfp /').should_succeed <<EOM
243
+ /data_bags/
325
244
  EOM
326
245
  end
327
246
  end
328
247
  end
329
248
  end
330
-
331
- context 'chefignore tests' do
332
- when_the_repository "has lots of stuff in it" do
333
- file 'roles/x.json', {}
334
- file 'environments/x.json', {}
335
- file 'data_bags/bag1/x.json', {}
336
- file 'cookbooks/cookbook1/x.json', {}
337
-
338
- context "and has a chefignore everywhere except cookbooks" do
339
- chefignore = "x.json\nroles/x.json\nenvironments/x.json\ndata_bags/bag1/x.json\nbag1/x.json\ncookbooks/cookbook1/x.json\ncookbook1/x.json\n"
340
- file 'chefignore', chefignore
341
- file 'roles/chefignore', chefignore
342
- file 'environments/chefignore', chefignore
343
- file 'data_bags/chefignore', chefignore
344
- file 'data_bags/bag1/chefignore', chefignore
345
- file 'cookbooks/cookbook1/chefignore', chefignore
346
-
347
- it 'nothing is ignored' do
348
- # NOTE: many of the "chefignore" files should probably not show up
349
- # themselves, but we have other tests that talk about that
350
- knife('list --local -R /').should_succeed <<EOM
351
- /:
352
- cookbooks
353
- data_bags
354
- environments
355
- roles
356
-
357
- /cookbooks:
358
- cookbook1
359
-
360
- /cookbooks/cookbook1:
361
- chefignore
362
- x.json
363
-
364
- /data_bags:
365
- bag1
366
- chefignore
367
-
368
- /data_bags/bag1:
369
- chefignore
370
- x.json
371
-
372
- /environments:
373
- chefignore
374
- x.json
375
-
376
- /roles:
377
- chefignore
378
- x.json
379
- EOM
380
- end
381
- end
382
- end
383
-
384
- when_the_repository 'has a cookbook with only chefignored files' do
385
- file 'cookbooks/cookbook1/templates/default/x.rb', ''
386
- file 'cookbooks/cookbook1/libraries/x.rb', ''
387
- file 'cookbooks/chefignore', "libraries/x.rb\ntemplates/default/x.rb\n"
388
-
389
- it 'the cookbook is not listed' do
390
- knife('list --local -R /').should_succeed <<EOM
391
- /:
392
- cookbooks
393
-
394
- /cookbooks:
395
- chefignore
396
- EOM
397
- end
398
- end
399
-
400
- when_the_repository "has multiple cookbooks" do
401
- file 'cookbooks/cookbook1/x.json', {}
402
- file 'cookbooks/cookbook1/y.json', {}
403
- file 'cookbooks/cookbook2/x.json', {}
404
- file 'cookbooks/cookbook2/y.json', {}
405
-
406
- context 'and has a chefignore with filenames' do
407
- file 'cookbooks/chefignore', "x.json\n"
408
-
409
- it 'matching files and directories get ignored in all cookbooks' do
410
- knife('list --local -R /').should_succeed <<EOM
411
- /:
412
- cookbooks
413
-
414
- /cookbooks:
415
- chefignore
416
- cookbook1
417
- cookbook2
418
-
419
- /cookbooks/cookbook1:
420
- y.json
421
-
422
- /cookbooks/cookbook2:
423
- y.json
424
- EOM
425
- end
426
- end
427
-
428
- context "and has a chefignore with wildcards" do
429
- file 'cookbooks/chefignore', "x.*\n"
430
- file 'cookbooks/cookbook1/x.rb', ''
431
-
432
- it 'matching files and directories get ignored in all cookbooks' do
433
- knife('list --local -R /').should_succeed <<EOM
434
- /:
435
- cookbooks
436
-
437
- /cookbooks:
438
- chefignore
439
- cookbook1
440
- cookbook2
441
-
442
- /cookbooks/cookbook1:
443
- y.json
444
-
445
- /cookbooks/cookbook2:
446
- y.json
447
- EOM
448
- end
449
- end
450
-
451
- context "and has a chefignore with relative paths" do
452
- file 'cookbooks/cookbook1/recipes/x.rb', ''
453
- file 'cookbooks/cookbook2/recipes/y.rb', ''
454
- file 'cookbooks/chefignore', "recipes/x.rb\n"
455
-
456
- it 'matching directories get ignored' do
457
- knife('list --local -R /').should_succeed <<EOM
458
- /:
459
- cookbooks
460
-
461
- /cookbooks:
462
- chefignore
463
- cookbook1
464
- cookbook2
465
-
466
- /cookbooks/cookbook1:
467
- x.json
468
- y.json
469
-
470
- /cookbooks/cookbook2:
471
- recipes
472
- x.json
473
- y.json
474
-
475
- /cookbooks/cookbook2/recipes:
476
- y.rb
477
- EOM
478
- end
479
- end
480
-
481
- context "and has a chefignore with subdirectories" do
482
- file 'cookbooks/cookbook1/recipes/y.rb', ''
483
- file 'cookbooks/chefignore', "recipes\n"
484
-
485
- it 'matching directories do NOT get ignored' do
486
- knife('list --local -R /').should_succeed <<EOM
487
- /:
488
- cookbooks
489
-
490
- /cookbooks:
491
- chefignore
492
- cookbook1
493
- cookbook2
494
-
495
- /cookbooks/cookbook1:
496
- recipes
497
- x.json
498
- y.json
499
-
500
- /cookbooks/cookbook1/recipes:
501
- y.rb
502
-
503
- /cookbooks/cookbook2:
504
- x.json
505
- y.json
506
- EOM
507
- end
508
- end
509
-
510
- context "and has a chefignore that ignores all files in a subdirectory" do
511
- file 'cookbooks/cookbook1/templates/default/x.rb', ''
512
- file 'cookbooks/cookbook1/libraries/x.rb', ''
513
- file 'cookbooks/chefignore', "libraries/x.rb\ntemplates/default/x.rb\n"
514
-
515
- it 'ignores the subdirectory entirely' do
516
- knife('list --local -R /').should_succeed <<EOM
517
- /:
518
- cookbooks
519
-
520
- /cookbooks:
521
- chefignore
522
- cookbook1
523
- cookbook2
524
-
525
- /cookbooks/cookbook1:
526
- x.json
527
- y.json
528
-
529
- /cookbooks/cookbook2:
530
- x.json
531
- y.json
532
- EOM
533
- end
534
- end
535
-
536
- context "and has an empty chefignore" do
537
- file 'cookbooks/chefignore', "\n"
538
-
539
- it 'nothing is ignored' do
540
- knife('list --local -R /').should_succeed <<EOM
541
- /:
542
- cookbooks
543
-
544
- /cookbooks:
545
- chefignore
546
- cookbook1
547
- cookbook2
548
-
549
- /cookbooks/cookbook1:
550
- x.json
551
- y.json
552
-
553
- /cookbooks/cookbook2:
554
- x.json
555
- y.json
556
- EOM
557
- end
558
- end
559
-
560
- context "and has a chefignore with comments and empty lines" do
561
- file 'cookbooks/chefignore', "\n\n # blah\n#\nx.json\n\n"
562
-
563
- it 'matching files and directories get ignored in all cookbooks' do
564
- knife('list --local -R /').should_succeed <<EOM
565
- /:
566
- cookbooks
567
-
568
- /cookbooks:
569
- chefignore
570
- cookbook1
571
- cookbook2
572
-
573
- /cookbooks/cookbook1:
574
- y.json
575
-
576
- /cookbooks/cookbook2:
577
- y.json
578
- EOM
579
- end
580
- end
581
- end
582
-
583
- when_the_repository "has multiple cookbook paths" do
584
- before :each do
585
- Chef::Config.cookbook_path = [
586
- File.join(Chef::Config.chef_repo_path, 'cookbooks1'),
587
- File.join(Chef::Config.chef_repo_path, 'cookbooks2')
588
- ]
589
- end
590
-
591
- file 'cookbooks1/mycookbook/metadata.rb', ''
592
- file 'cookbooks1/mycookbook/x.json', {}
593
- file 'cookbooks2/yourcookbook/metadata.rb', ''
594
- file 'cookbooks2/yourcookbook/x.json', ''
595
-
596
- context "and multiple chefignores" do
597
- file 'cookbooks1/chefignore', "metadata.rb\n"
598
- file 'cookbooks2/chefignore', "x.json\n"
599
- it "chefignores apply only to the directories they are in" do
600
- knife('list --local -R /').should_succeed(<<EOM, :stderr => "WARN: Child with name 'chefignore' found in multiple directories: #{Chef::Config.chef_repo_path}/cookbooks2/chefignore and #{Chef::Config.chef_repo_path}/cookbooks1/chefignore\n")
601
- /:
602
- cookbooks
603
-
604
- /cookbooks:
605
- chefignore
606
- mycookbook
607
- yourcookbook
608
-
609
- /cookbooks/mycookbook:
610
- x.json
611
-
612
- /cookbooks/yourcookbook:
613
- metadata.rb
614
- EOM
615
- end
616
-
617
- context "and conflicting cookbooks" do
618
- file 'cookbooks1/yourcookbook/metadata.rb', ''
619
- file 'cookbooks1/yourcookbook/x.json', ''
620
- file 'cookbooks1/yourcookbook/onlyincookbooks1.rb', ''
621
- file 'cookbooks2/yourcookbook/onlyincookbooks2.rb', ''
622
-
623
- it "chefignores apply only to the winning cookbook" do
624
- knife('list --local -R /').should_succeed(<<EOM, :stderr => "WARN: Child with name 'chefignore' found in multiple directories: #{Chef::Config.chef_repo_path}/cookbooks2/chefignore and #{Chef::Config.chef_repo_path}/cookbooks1/chefignore\nWARN: Child with name 'yourcookbook' found in multiple directories: #{Chef::Config.chef_repo_path}/cookbooks2/yourcookbook and #{Chef::Config.chef_repo_path}/cookbooks1/yourcookbook\n")
625
- /:
626
- cookbooks
627
-
628
- /cookbooks:
629
- chefignore
630
- mycookbook
631
- yourcookbook
632
-
633
- /cookbooks/mycookbook:
634
- x.json
635
-
636
- /cookbooks/yourcookbook:
637
- onlyincookbooks1.rb
638
- x.json
639
- EOM
640
- end
641
- end
642
- end
643
- end
644
- end
645
-
646
- # TODO alternate repo_path / *_path
647
- context 'alternate *_path' do
648
- when_the_repository 'has clients and clients2, cookbooks and cookbooks2, etc.' do
649
- file 'clients/client1.json', {}
650
- file 'cookbooks/cookbook1/metadata.rb', ''
651
- file 'data_bags/bag/item.json', {}
652
- file 'environments/env1.json', {}
653
- file 'nodes/node1.json', {}
654
- file 'roles/role1.json', {}
655
- file 'users/user1.json', {}
656
-
657
- file 'clients2/client1.json', {}
658
- file 'cookbooks2/cookbook2/metadata.rb', ''
659
- file 'data_bags2/bag2/item2.json', {}
660
- file 'environments2/env2.json', {}
661
- file 'nodes2/node2.json', {}
662
- file 'roles2/role2.json', {}
663
- file 'users2/user2.json', {}
664
-
665
- directory 'chef_repo2' do
666
- file 'clients/client3.json', {}
667
- file 'cookbooks/cookbook3/metadata.rb', ''
668
- file 'data_bags/bag3/item3.json', {}
669
- file 'environments/env3.json', {}
670
- file 'nodes/node3.json', {}
671
- file 'roles/role3.json', {}
672
- file 'users/user3.json', {}
673
- end
674
-
675
- context 'when all _paths are set to alternates' do
676
- before :each do
677
- %w(client cookbook data_bag environment node role user).each do |object_name|
678
- Chef::Config["#{object_name}_path".to_sym] = File.join(Chef::Config.chef_repo_path, "#{object_name}s2")
679
- end
680
- Chef::Config.chef_repo_path = File.join(Chef::Config.chef_repo_path, 'chef_repo2')
681
- end
682
-
683
- context 'when cwd is at the top level' do
684
- cwd '.'
685
- it 'knife list --local -R fails' do
686
- knife('list --local -R').should_fail("ERROR: Attempt to use relative path '' when current directory is outside the repository path\n")
687
- end
688
- end
689
-
690
- context 'when cwd is inside the data_bags directory' do
691
- cwd 'data_bags'
692
- it 'knife list --local -R fails' do
693
- knife('list --local -R').should_fail("ERROR: Attempt to use relative path '' when current directory is outside the repository path\n")
694
- end
695
- end
696
-
697
- context 'when cwd is inside chef_repo2' do
698
- cwd 'chef_repo2'
699
- it 'knife list --local -R lists everything' do
700
- knife('list --local -R').should_succeed <<EOM
701
- .:
702
- cookbooks
703
- data_bags
704
- environments
705
- roles
706
-
707
- cookbooks:
708
- cookbook2
709
-
710
- cookbooks/cookbook2:
711
- metadata.rb
712
-
713
- data_bags:
714
- bag2
715
-
716
- data_bags/bag2:
717
- item2.json
718
-
719
- environments:
720
- env2.json
721
-
722
- roles:
723
- role2.json
724
- EOM
725
- end
726
- end
727
-
728
- context 'when cwd is inside data_bags2' do
729
- cwd 'data_bags2'
730
- it 'knife list --local -R lists data bags' do
731
- knife('list --local -R').should_succeed <<EOM
732
- .:
733
- bag2
734
-
735
- bag2:
736
- item2.json
737
- EOM
738
- end
739
- it 'knife list --local -R ../roles lists roles' do
740
- knife('list --local -R ../roles').should_succeed "/roles/role2.json\n"
741
- end
742
- end
743
- end
744
-
745
- context 'when all _paths except chef_repo_path are set to alternates' do
746
- before :each do
747
- %w(client cookbook data_bag environment node role user).each do |object_name|
748
- Chef::Config["#{object_name}_path".to_sym] = File.join(Chef::Config.chef_repo_path, "#{object_name}s2")
749
- end
750
- end
751
-
752
- context 'when cwd is at the top level' do
753
- cwd '.'
754
- it 'knife list --local -R lists everything' do
755
- knife('list --local -R').should_succeed <<EOM
756
- .:
757
- cookbooks
758
- data_bags
759
- environments
760
- roles
761
-
762
- cookbooks:
763
- cookbook2
764
-
765
- cookbooks/cookbook2:
766
- metadata.rb
767
-
768
- data_bags:
769
- bag2
770
-
771
- data_bags/bag2:
772
- item2.json
773
-
774
- environments:
775
- env2.json
776
-
777
- roles:
778
- role2.json
779
- EOM
780
- end
781
- end
782
-
783
- context 'when cwd is inside the data_bags directory' do
784
- cwd 'data_bags'
785
- it 'knife list --local -R fails' do
786
- knife('list --local -R').should_fail("ERROR: Attempt to use relative path '' when current directory is outside the repository path\n")
787
- end
788
- end
789
-
790
- context 'when cwd is inside chef_repo2' do
791
- cwd 'chef_repo2'
792
- it 'knife list -R fails' do
793
- knife('list --local -R').should_fail("ERROR: Attempt to use relative path '' when current directory is outside the repository path\n")
794
- end
795
- end
796
-
797
- context 'when cwd is inside data_bags2' do
798
- cwd 'data_bags2'
799
- it 'knife list --local -R lists data bags' do
800
- knife('list --local -R').should_succeed <<EOM
801
- .:
802
- bag2
803
-
804
- bag2:
805
- item2.json
806
- EOM
807
- end
808
- end
809
- end
810
-
811
- context 'when only chef_repo_path is set to its alternate' do
812
- before :each do
813
- %w(client cookbook data_bag environment node role user).each do |object_name|
814
- Chef::Config["#{object_name}_path".to_sym] = nil
815
- end
816
- Chef::Config.chef_repo_path = File.join(Chef::Config.chef_repo_path, 'chef_repo2')
817
- end
818
-
819
- context 'when cwd is at the top level' do
820
- cwd '.'
821
- it 'knife list --local -R fails' do
822
- knife('list --local -R').should_fail("ERROR: Attempt to use relative path '' when current directory is outside the repository path\n")
823
- end
824
- end
825
-
826
- context 'when cwd is inside the data_bags directory' do
827
- cwd 'data_bags'
828
- it 'knife list --local -R fails' do
829
- knife('list --local -R').should_fail("ERROR: Attempt to use relative path '' when current directory is outside the repository path\n")
830
- end
831
- end
832
-
833
- context 'when cwd is inside chef_repo2' do
834
- cwd 'chef_repo2'
835
- it 'knife list --local -R lists everything' do
836
- knife('list --local -R').should_succeed <<EOM
837
- .:
838
- cookbooks
839
- data_bags
840
- environments
841
- roles
842
-
843
- cookbooks:
844
- cookbook3
845
-
846
- cookbooks/cookbook3:
847
- metadata.rb
848
-
849
- data_bags:
850
- bag3
851
-
852
- data_bags/bag3:
853
- item3.json
854
-
855
- environments:
856
- env3.json
857
-
858
- roles:
859
- role3.json
860
- EOM
861
- end
862
- end
863
- end
864
-
865
- context 'when paths are set to point to both versions of each' do
866
- before :each do
867
- %w(client cookbooks data_bag environment node role user).each do |object_name|
868
- Chef::Config["#{object_name}_path".to_sym] = [
869
- File.join(Chef::Config.chef_repo_path, "#{object_name}s"),
870
- File.join(Chef::Config.chef_repo_path, "#{object_name}s2")
871
- ]
872
- end
873
- Chef::Config.chef_repo_path = File.join(Chef::Config.chef_repo_path, 'chef_repo_top')
874
- end
875
- end
876
- end
877
- end
878
-
879
- # TODO nonexistent repo_path / *_path
880
249
  end