knife-essentials 0.9.8 → 1.0.0.beta1
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.
- data/lib/chef/knife/delete_essentials.rb +3 -3
- data/lib/chef/knife/deps_essentials.rb +1 -1
- data/lib/chef/knife/edit_essentials.rb +1 -1
- data/lib/chef/knife/list_essentials.rb +23 -17
- data/lib/chef/knife/show_essentials.rb +14 -7
- data/lib/chef/knife/xargs_essentials.rb +1 -1
- data/lib/chef_fs/command_line.rb +100 -84
- data/lib/chef_fs/file_system.rb +77 -35
- data/lib/chef_fs/file_system/chef_server_root_dir.rb +7 -7
- data/lib/chef_fs/file_system/cookbook_dir.rb +1 -1
- data/lib/chef_fs/file_system/rest_list_entry.rb +2 -0
- data/lib/chef_fs/knife.rb +24 -4
- data/lib/chef_fs/parallelizer.rb +127 -0
- data/lib/chef_fs/raw_request.rb +8 -4
- data/lib/chef_fs/version.rb +1 -1
- data/spec/integration/chef_repo_path_spec.rb +76 -1
- data/spec/integration/delete_spec.rb +256 -13
- data/spec/integration/deps_spec.rb +20 -20
- data/spec/integration/diff_spec.rb +47 -120
- data/spec/integration/download_spec.rb +92 -237
- data/spec/integration/list_spec.rb +114 -0
- data/spec/integration/redirection_spec.rb +49 -0
- data/spec/integration/upload_spec.rb +120 -305
- data/spec/support/file_system_support.rb +1 -1
- data/spec/support/knife_support.rb +4 -0
- metadata +7 -5
@@ -50,14 +50,14 @@ EOM
|
|
50
50
|
when_the_repository 'has a node with no environment or run_list' do
|
51
51
|
file 'nodes/mort.json', {}
|
52
52
|
it 'knife deps reports just the node' do
|
53
|
-
knife('deps
|
53
|
+
knife('deps /nodes/mort.json').should_succeed "/nodes/mort.json\n"
|
54
54
|
end
|
55
55
|
end
|
56
56
|
when_the_repository 'has a node with an environment' do
|
57
57
|
file 'environments/desert.json', {}
|
58
58
|
file 'nodes/mort.json', { 'chef_environment' => 'desert' }
|
59
59
|
it 'knife deps reports just the node' do
|
60
|
-
knife('deps
|
60
|
+
knife('deps /nodes/mort.json').should_succeed "/environments/desert.json\n/nodes/mort.json\n"
|
61
61
|
end
|
62
62
|
end
|
63
63
|
when_the_repository 'has a node with roles and recipes in its run_list' do
|
@@ -68,7 +68,7 @@ EOM
|
|
68
68
|
file 'cookbooks/soup/recipes/chicken.rb', ''
|
69
69
|
file 'nodes/mort.json', { 'run_list' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) }
|
70
70
|
it 'knife deps reports just the node' do
|
71
|
-
knife('deps
|
71
|
+
knife('deps /nodes/mort.json').should_succeed <<EOM
|
72
72
|
/roles/minor.json
|
73
73
|
/cookbooks/quiche
|
74
74
|
/cookbooks/soup
|
@@ -115,7 +115,7 @@ EOM
|
|
115
115
|
file 'nodes/bart.json', { 'run_list' => [ 'role[minor]' ] }
|
116
116
|
|
117
117
|
it 'knife deps reports all dependencies' do
|
118
|
-
knife('deps
|
118
|
+
knife('deps /nodes/mort.json').should_succeed <<EOM
|
119
119
|
/environments/desert.json
|
120
120
|
/roles/minor.json
|
121
121
|
/cookbooks/quiche
|
@@ -125,7 +125,7 @@ EOM
|
|
125
125
|
EOM
|
126
126
|
end
|
127
127
|
it 'knife deps * reports all dependencies of all things' do
|
128
|
-
knife('deps
|
128
|
+
knife('deps /nodes/*').should_succeed <<EOM
|
129
129
|
/roles/minor.json
|
130
130
|
/nodes/bart.json
|
131
131
|
/environments/desert.json
|
@@ -136,7 +136,7 @@ EOM
|
|
136
136
|
EOM
|
137
137
|
end
|
138
138
|
it 'knife deps a b reports all dependencies of a and b' do
|
139
|
-
knife('deps
|
139
|
+
knife('deps /nodes/bart.json /nodes/mort.json').should_succeed <<EOM
|
140
140
|
/roles/minor.json
|
141
141
|
/nodes/bart.json
|
142
142
|
/environments/desert.json
|
@@ -147,7 +147,7 @@ EOM
|
|
147
147
|
EOM
|
148
148
|
end
|
149
149
|
it 'knife deps --tree /* shows dependencies in a tree' do
|
150
|
-
knife('deps --tree
|
150
|
+
knife('deps --tree /nodes/*').should_succeed <<EOM
|
151
151
|
/nodes/bart.json
|
152
152
|
/roles/minor.json
|
153
153
|
/nodes/mort.json
|
@@ -159,7 +159,7 @@ EOM
|
|
159
159
|
EOM
|
160
160
|
end
|
161
161
|
it 'knife deps --tree --no-recurse shows only the first level of dependencies' do
|
162
|
-
knife('deps --tree --no-recurse
|
162
|
+
knife('deps --tree --no-recurse /nodes/*').should_succeed <<EOM
|
163
163
|
/nodes/bart.json
|
164
164
|
/roles/minor.json
|
165
165
|
/nodes/mort.json
|
@@ -233,7 +233,7 @@ EOM
|
|
233
233
|
)
|
234
234
|
end
|
235
235
|
it 'knife deps /nodes/x.json reports an error' do
|
236
|
-
knife('deps
|
236
|
+
knife('deps /nodes/x.json').should_fail(
|
237
237
|
:exit_code => 2,
|
238
238
|
:stdout => "/nodes/x.json\n",
|
239
239
|
:stderr => "ERROR: /nodes/x.json: No such file or directory\n"
|
@@ -274,7 +274,7 @@ EOM
|
|
274
274
|
when_the_repository 'is missing a dependent environment' do
|
275
275
|
file 'nodes/mort.json', { 'chef_environment' => 'desert' }
|
276
276
|
it 'knife deps reports the environment, along with an error' do
|
277
|
-
knife('deps
|
277
|
+
knife('deps /nodes/mort.json').should_fail(
|
278
278
|
:exit_code => 2,
|
279
279
|
:stdout => "/environments/desert.json\n/nodes/mort.json\n",
|
280
280
|
:stderr => "ERROR: /environments/desert.json: No such file or directory\n"
|
@@ -363,14 +363,14 @@ EOM
|
|
363
363
|
when_the_chef_server 'has a node with no environment or run_list' do
|
364
364
|
node 'mort', {}
|
365
365
|
it 'knife deps reports just the node' do
|
366
|
-
knife('deps --remote
|
366
|
+
knife('deps --remote /nodes/mort.json').should_succeed "/nodes/mort.json\n"
|
367
367
|
end
|
368
368
|
end
|
369
369
|
when_the_chef_server 'has a node with an environment' do
|
370
370
|
environment 'desert', {}
|
371
371
|
node 'mort', { 'chef_environment' => 'desert' }
|
372
372
|
it 'knife deps reports just the node' do
|
373
|
-
knife('deps --remote
|
373
|
+
knife('deps --remote /nodes/mort.json').should_succeed "/environments/desert.json\n/nodes/mort.json\n"
|
374
374
|
end
|
375
375
|
end
|
376
376
|
when_the_chef_server 'has a node with roles and recipes in its run_list' do
|
@@ -379,7 +379,7 @@ EOM
|
|
379
379
|
cookbook 'soup', '1.0.0', { 'metadata.rb' => "name 'soup'\nversion '1.0.0'\n", 'recipes' => { 'chicken.rb' => '' } }
|
380
380
|
node 'mort', { 'run_list' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) }
|
381
381
|
it 'knife deps reports just the node' do
|
382
|
-
knife('deps --remote
|
382
|
+
knife('deps --remote /nodes/mort.json').should_succeed <<EOM
|
383
383
|
/roles/minor.json
|
384
384
|
/cookbooks/quiche
|
385
385
|
/cookbooks/soup
|
@@ -422,7 +422,7 @@ EOM
|
|
422
422
|
node 'bart', { 'run_list' => [ 'role[minor]' ] }
|
423
423
|
|
424
424
|
it 'knife deps reports all dependencies' do
|
425
|
-
knife('deps --remote
|
425
|
+
knife('deps --remote /nodes/mort.json').should_succeed <<EOM
|
426
426
|
/environments/desert.json
|
427
427
|
/roles/minor.json
|
428
428
|
/cookbooks/quiche
|
@@ -432,7 +432,7 @@ EOM
|
|
432
432
|
EOM
|
433
433
|
end
|
434
434
|
it 'knife deps * reports all dependencies of all things' do
|
435
|
-
knife('deps --remote
|
435
|
+
knife('deps --remote /nodes/*').should_succeed <<EOM
|
436
436
|
/roles/minor.json
|
437
437
|
/nodes/bart.json
|
438
438
|
/environments/desert.json
|
@@ -443,7 +443,7 @@ EOM
|
|
443
443
|
EOM
|
444
444
|
end
|
445
445
|
it 'knife deps a b reports all dependencies of a and b' do
|
446
|
-
knife('deps --remote
|
446
|
+
knife('deps --remote /nodes/bart.json /nodes/mort.json').should_succeed <<EOM
|
447
447
|
/roles/minor.json
|
448
448
|
/nodes/bart.json
|
449
449
|
/environments/desert.json
|
@@ -454,7 +454,7 @@ EOM
|
|
454
454
|
EOM
|
455
455
|
end
|
456
456
|
it 'knife deps --tree /* shows dependencies in a tree' do
|
457
|
-
knife('deps --remote --tree
|
457
|
+
knife('deps --remote --tree /nodes/*').should_succeed <<EOM
|
458
458
|
/nodes/bart.json
|
459
459
|
/roles/minor.json
|
460
460
|
/nodes/mort.json
|
@@ -466,7 +466,7 @@ EOM
|
|
466
466
|
EOM
|
467
467
|
end
|
468
468
|
it 'knife deps --tree --no-recurse shows only the first level of dependencies' do
|
469
|
-
knife('deps --remote --tree --no-recurse
|
469
|
+
knife('deps --remote --tree --no-recurse /nodes/*').should_succeed <<EOM
|
470
470
|
/nodes/bart.json
|
471
471
|
/roles/minor.json
|
472
472
|
/nodes/mort.json
|
@@ -540,7 +540,7 @@ EOM
|
|
540
540
|
)
|
541
541
|
end
|
542
542
|
it 'knife deps /nodes/x.json reports an error' do
|
543
|
-
knife('deps --remote
|
543
|
+
knife('deps --remote /nodes/x.json').should_fail(
|
544
544
|
:exit_code => 2,
|
545
545
|
:stdout => "/nodes/x.json\n",
|
546
546
|
:stderr => "ERROR: /nodes/x.json: No such file or directory\n"
|
@@ -581,7 +581,7 @@ EOM
|
|
581
581
|
when_the_chef_server 'is missing a dependent environment' do
|
582
582
|
node 'mort', { 'chef_environment' => 'desert' }
|
583
583
|
it 'knife deps reports the environment, along with an error' do
|
584
|
-
knife('deps --remote
|
584
|
+
knife('deps --remote /nodes/mort.json').should_fail(
|
585
585
|
:exit_code => 2,
|
586
586
|
:stdout => "/environments/desert.json\n/nodes/mort.json\n",
|
587
587
|
:stderr => "ERROR: /environments/desert.json: No such file or directory\n"
|
@@ -26,76 +26,34 @@ describe 'knife diff' do
|
|
26
26
|
|
27
27
|
it 'knife diff reports everything as deleted' do
|
28
28
|
knife('diff --name-status /').should_succeed <<EOM
|
29
|
+
D\t/clients/chef-validator.json
|
30
|
+
D\t/clients/chef-webui.json
|
31
|
+
D\t/clients/x.json
|
29
32
|
D\t/cookbooks/x
|
30
33
|
D\t/data_bags/x
|
31
34
|
D\t/environments/_default.json
|
32
35
|
D\t/environments/x.json
|
36
|
+
D\t/nodes/x.json
|
33
37
|
D\t/roles/x.json
|
38
|
+
D\t/users/admin.json
|
39
|
+
D\t/users/x.json
|
34
40
|
EOM
|
35
41
|
end
|
36
42
|
end
|
37
43
|
|
38
44
|
when_the_repository 'has an identical copy of each thing' do
|
39
|
-
|
40
|
-
{}
|
41
|
-
|
45
|
+
|
46
|
+
file 'clients/chef-validator.json', { 'validator' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
47
|
+
file 'clients/chef-webui.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
48
|
+
file 'clients/x.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
42
49
|
file 'cookbooks/x/metadata.rb', 'version "1.0.0"'
|
43
|
-
file 'data_bags/x/y.json',
|
44
|
-
{
|
45
|
-
|
46
|
-
}
|
47
|
-
|
48
|
-
file '
|
49
|
-
{
|
50
|
-
"name": "_default",
|
51
|
-
"description": "The default Chef environment",
|
52
|
-
"cookbook_versions": {
|
53
|
-
},
|
54
|
-
"json_class": "Chef::Environment",
|
55
|
-
"chef_type": "environment",
|
56
|
-
"default_attributes": {
|
57
|
-
},
|
58
|
-
"override_attributes": {
|
59
|
-
}
|
60
|
-
}
|
61
|
-
EOM
|
62
|
-
file 'environments/x.json', <<EOM
|
63
|
-
{
|
64
|
-
"chef_type": "environment",
|
65
|
-
"cookbook_versions": {
|
66
|
-
},
|
67
|
-
"default_attributes": {
|
68
|
-
},
|
69
|
-
"description": "",
|
70
|
-
"json_class": "Chef::Environment",
|
71
|
-
"name": "x",
|
72
|
-
"override_attributes": {
|
73
|
-
}
|
74
|
-
}
|
75
|
-
EOM
|
76
|
-
file 'nodes/x.json', <<EOM
|
77
|
-
{}
|
78
|
-
EOM
|
79
|
-
file 'roles/x.json', <<EOM
|
80
|
-
{
|
81
|
-
"chef_type": "role",
|
82
|
-
"default_attributes": {
|
83
|
-
},
|
84
|
-
"description": "",
|
85
|
-
"env_run_lists": {
|
86
|
-
},
|
87
|
-
"json_class": "Chef::Role",
|
88
|
-
"name": "x",
|
89
|
-
"override_attributes": {
|
90
|
-
},
|
91
|
-
"run_list": [
|
92
|
-
|
93
|
-
]
|
94
|
-
}
|
95
|
-
EOM
|
96
|
-
file 'users/x.json', <<EOM
|
97
|
-
{}
|
98
|
-
EOM
|
50
|
+
file 'data_bags/x/y.json', {}
|
51
|
+
file 'environments/_default.json', { "description" => "The default Chef environment" }
|
52
|
+
file 'environments/x.json', {}
|
53
|
+
file 'nodes/x.json', {}
|
54
|
+
file 'roles/x.json', {}
|
55
|
+
file 'users/admin.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
56
|
+
file 'users/x.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
99
57
|
|
100
58
|
it 'knife diff reports no differences' do
|
101
59
|
knife('diff /').should_succeed ''
|
@@ -123,7 +81,7 @@ EOM
|
|
123
81
|
end
|
124
82
|
|
125
83
|
context 'as well as one extra copy of each thing' do
|
126
|
-
file 'clients/y.json', {}
|
84
|
+
file 'clients/y.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
127
85
|
file 'cookbooks/x/blah.rb', ''
|
128
86
|
file 'cookbooks/y/metadata.rb', 'version "1.0.0"'
|
129
87
|
file 'data_bags/x/z.json', {}
|
@@ -131,16 +89,19 @@ EOM
|
|
131
89
|
file 'environments/y.json', {}
|
132
90
|
file 'nodes/y.json', {}
|
133
91
|
file 'roles/y.json', {}
|
134
|
-
file 'users/y.json', {}
|
92
|
+
file 'users/y.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
135
93
|
|
136
94
|
it 'knife diff reports the new files as added' do
|
137
95
|
knife('diff --name-status /').should_succeed <<EOM
|
96
|
+
A\t/clients/y.json
|
138
97
|
A\t/cookbooks/x/blah.rb
|
139
98
|
A\t/cookbooks/y
|
140
99
|
A\t/data_bags/x/z.json
|
141
100
|
A\t/data_bags/y
|
142
101
|
A\t/environments/y.json
|
102
|
+
A\t/nodes/y.json
|
143
103
|
A\t/roles/y.json
|
104
|
+
A\t/users/y.json
|
144
105
|
EOM
|
145
106
|
end
|
146
107
|
|
@@ -165,10 +126,13 @@ EOM
|
|
165
126
|
when_the_repository 'is empty' do
|
166
127
|
it 'knife diff reports everything as deleted' do
|
167
128
|
knife('diff --name-status /').should_succeed <<EOM
|
129
|
+
D\t/clients
|
168
130
|
D\t/cookbooks
|
169
131
|
D\t/data_bags
|
170
132
|
D\t/environments
|
133
|
+
D\t/nodes
|
171
134
|
D\t/roles
|
135
|
+
D\t/users
|
172
136
|
EOM
|
173
137
|
end
|
174
138
|
end
|
@@ -321,76 +285,33 @@ EOM
|
|
321
285
|
|
322
286
|
it 'knife diff reports everything as deleted' do
|
323
287
|
knife('diff --name-status /').should_succeed <<EOM
|
288
|
+
D\t/clients/chef-validator.json
|
289
|
+
D\t/clients/chef-webui.json
|
290
|
+
D\t/clients/x.json
|
324
291
|
D\t/cookbooks/x-1.0.0
|
325
292
|
D\t/data_bags/x
|
326
293
|
D\t/environments/_default.json
|
327
294
|
D\t/environments/x.json
|
295
|
+
D\t/nodes/x.json
|
328
296
|
D\t/roles/x.json
|
297
|
+
D\t/users/admin.json
|
298
|
+
D\t/users/x.json
|
329
299
|
EOM
|
330
300
|
end
|
331
301
|
end
|
332
302
|
|
333
303
|
when_the_repository 'has an identical copy of each thing' do
|
334
|
-
file 'clients/
|
335
|
-
{}
|
336
|
-
|
304
|
+
file 'clients/chef-validator.json', { 'validator' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
305
|
+
file 'clients/chef-webui.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
306
|
+
file 'clients/x.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
337
307
|
file 'cookbooks/x-1.0.0/metadata.rb', 'version "1.0.0"'
|
338
|
-
file 'data_bags/x/y.json',
|
339
|
-
{
|
340
|
-
|
341
|
-
}
|
342
|
-
|
343
|
-
file '
|
344
|
-
{
|
345
|
-
"name": "_default",
|
346
|
-
"description": "The default Chef environment",
|
347
|
-
"cookbook_versions": {
|
348
|
-
},
|
349
|
-
"json_class": "Chef::Environment",
|
350
|
-
"chef_type": "environment",
|
351
|
-
"default_attributes": {
|
352
|
-
},
|
353
|
-
"override_attributes": {
|
354
|
-
}
|
355
|
-
}
|
356
|
-
EOM
|
357
|
-
file 'environments/x.json', <<EOM
|
358
|
-
{
|
359
|
-
"chef_type": "environment",
|
360
|
-
"cookbook_versions": {
|
361
|
-
},
|
362
|
-
"default_attributes": {
|
363
|
-
},
|
364
|
-
"description": "",
|
365
|
-
"json_class": "Chef::Environment",
|
366
|
-
"name": "x",
|
367
|
-
"override_attributes": {
|
368
|
-
}
|
369
|
-
}
|
370
|
-
EOM
|
371
|
-
file 'nodes/x.json', <<EOM
|
372
|
-
{}
|
373
|
-
EOM
|
374
|
-
file 'roles/x.json', <<EOM
|
375
|
-
{
|
376
|
-
"chef_type": "role",
|
377
|
-
"default_attributes": {
|
378
|
-
},
|
379
|
-
"description": "",
|
380
|
-
"env_run_lists": {
|
381
|
-
},
|
382
|
-
"json_class": "Chef::Role",
|
383
|
-
"name": "x",
|
384
|
-
"override_attributes": {
|
385
|
-
},
|
386
|
-
"run_list": [
|
387
|
-
|
388
|
-
]
|
389
|
-
}
|
390
|
-
EOM
|
391
|
-
file 'users/x.json', <<EOM
|
392
|
-
{}
|
393
|
-
EOM
|
308
|
+
file 'data_bags/x/y.json', {}
|
309
|
+
file 'environments/_default.json', { "description" => "The default Chef environment" }
|
310
|
+
file 'environments/x.json', {}
|
311
|
+
file 'nodes/x.json', {}
|
312
|
+
file 'roles/x.json', {}
|
313
|
+
file 'users/admin.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
314
|
+
file 'users/x.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
394
315
|
|
395
316
|
it 'knife diff reports no differences' do
|
396
317
|
knife('diff /').should_succeed ''
|
@@ -431,13 +352,16 @@ EOM
|
|
431
352
|
|
432
353
|
it 'knife diff reports the new files as added' do
|
433
354
|
knife('diff --name-status /').should_succeed <<EOM
|
355
|
+
A\t/clients/y.json
|
434
356
|
A\t/cookbooks/x-1.0.0/blah.rb
|
435
357
|
A\t/cookbooks/x-2.0.0
|
436
358
|
A\t/cookbooks/y-1.0.0
|
437
359
|
A\t/data_bags/x/z.json
|
438
360
|
A\t/data_bags/y
|
439
361
|
A\t/environments/y.json
|
362
|
+
A\t/nodes/y.json
|
440
363
|
A\t/roles/y.json
|
364
|
+
A\t/users/y.json
|
441
365
|
EOM
|
442
366
|
end
|
443
367
|
|
@@ -462,10 +386,13 @@ EOM
|
|
462
386
|
when_the_repository 'is empty' do
|
463
387
|
it 'knife diff reports everything as deleted' do
|
464
388
|
knife('diff --name-status /').should_succeed <<EOM
|
389
|
+
D\t/clients
|
465
390
|
D\t/cookbooks
|
466
391
|
D\t/data_bags
|
467
392
|
D\t/environments
|
393
|
+
D\t/nodes
|
468
394
|
D\t/roles
|
395
|
+
D\t/users
|
469
396
|
EOM
|
470
397
|
end
|
471
398
|
end
|
@@ -8,13 +8,13 @@ describe 'knife download' do
|
|
8
8
|
|
9
9
|
context 'without versioned cookbooks' do
|
10
10
|
when_the_chef_server "has one of each thing" do
|
11
|
-
client 'x',
|
11
|
+
client 'x', {}
|
12
12
|
cookbook 'x', '1.0.0', { 'metadata.rb' => 'version "1.0.0"' }
|
13
|
-
data_bag 'x', { 'y' =>
|
14
|
-
environment 'x',
|
15
|
-
node 'x',
|
16
|
-
role 'x',
|
17
|
-
user 'x',
|
13
|
+
data_bag 'x', { 'y' => {} }
|
14
|
+
environment 'x', {}
|
15
|
+
node 'x', {}
|
16
|
+
role 'x', {}
|
17
|
+
user 'x', {}
|
18
18
|
|
19
19
|
when_the_repository 'has only top-level directories' do
|
20
20
|
directory 'clients'
|
@@ -27,79 +27,36 @@ describe 'knife download' do
|
|
27
27
|
|
28
28
|
it 'knife download downloads everything' do
|
29
29
|
knife('download /').should_succeed <<EOM
|
30
|
+
Created /clients/chef-validator.json
|
31
|
+
Created /clients/chef-webui.json
|
32
|
+
Created /clients/x.json
|
30
33
|
Created /cookbooks/x
|
31
34
|
Created /cookbooks/x/metadata.rb
|
32
35
|
Created /data_bags/x
|
33
36
|
Created /data_bags/x/y.json
|
34
37
|
Created /environments/_default.json
|
35
38
|
Created /environments/x.json
|
39
|
+
Created /nodes/x.json
|
36
40
|
Created /roles/x.json
|
41
|
+
Created /users/admin.json
|
42
|
+
Created /users/x.json
|
37
43
|
EOM
|
38
44
|
knife('diff --name-status /').should_succeed ''
|
39
45
|
end
|
40
46
|
end
|
41
47
|
|
42
48
|
when_the_repository 'has an identical copy of each thing' do
|
43
|
-
file 'clients/
|
44
|
-
{}
|
45
|
-
|
49
|
+
file 'clients/chef-validator.json', { 'validator' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
50
|
+
file 'clients/chef-webui.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
51
|
+
file 'clients/x.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
46
52
|
file 'cookbooks/x/metadata.rb', 'version "1.0.0"'
|
47
|
-
file 'data_bags/x/y.json',
|
48
|
-
{
|
49
|
-
|
50
|
-
}
|
51
|
-
|
52
|
-
file '
|
53
|
-
{
|
54
|
-
"name": "_default",
|
55
|
-
"description": "The default Chef environment",
|
56
|
-
"cookbook_versions": {
|
57
|
-
},
|
58
|
-
"json_class": "Chef::Environment",
|
59
|
-
"chef_type": "environment",
|
60
|
-
"default_attributes": {
|
61
|
-
},
|
62
|
-
"override_attributes": {
|
63
|
-
}
|
64
|
-
}
|
65
|
-
EOM
|
66
|
-
file 'environments/x.json', <<EOM
|
67
|
-
{
|
68
|
-
"chef_type": "environment",
|
69
|
-
"cookbook_versions": {
|
70
|
-
},
|
71
|
-
"default_attributes": {
|
72
|
-
},
|
73
|
-
"description": "",
|
74
|
-
"json_class": "Chef::Environment",
|
75
|
-
"name": "x",
|
76
|
-
"override_attributes": {
|
77
|
-
}
|
78
|
-
}
|
79
|
-
EOM
|
80
|
-
file 'nodes/x.json', <<EOM
|
81
|
-
{}
|
82
|
-
EOM
|
83
|
-
file 'roles/x.json', <<EOM
|
84
|
-
{
|
85
|
-
"chef_type": "role",
|
86
|
-
"default_attributes": {
|
87
|
-
},
|
88
|
-
"description": "",
|
89
|
-
"env_run_lists": {
|
90
|
-
},
|
91
|
-
"json_class": "Chef::Role",
|
92
|
-
"name": "x",
|
93
|
-
"override_attributes": {
|
94
|
-
},
|
95
|
-
"run_list": [
|
96
|
-
|
97
|
-
]
|
98
|
-
}
|
99
|
-
EOM
|
100
|
-
file 'users/x.json', <<EOM
|
101
|
-
{}
|
102
|
-
EOM
|
53
|
+
file 'data_bags/x/y.json', {}
|
54
|
+
file 'environments/_default.json', { "description" => "The default Chef environment" }
|
55
|
+
file 'environments/x.json', {}
|
56
|
+
file 'nodes/x.json', {}
|
57
|
+
file 'roles/x.json', {}
|
58
|
+
file 'users/admin.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
59
|
+
file 'users/x.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
103
60
|
|
104
61
|
it 'knife download makes no changes' do
|
105
62
|
knife('download /').should_succeed ''
|
@@ -160,73 +117,42 @@ EOM
|
|
160
117
|
end
|
161
118
|
|
162
119
|
context 'as well as one extra copy of each thing' do
|
163
|
-
file 'clients/y.json', { '
|
120
|
+
file 'clients/y.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
164
121
|
file 'cookbooks/x/blah.rb', ''
|
165
122
|
file 'cookbooks/y/metadata.rb', 'version "1.0.0"'
|
166
|
-
file 'data_bags/x/z.json',
|
167
|
-
{
|
168
|
-
|
169
|
-
}
|
170
|
-
|
171
|
-
file '
|
172
|
-
{
|
173
|
-
"id": "zz"
|
174
|
-
}
|
175
|
-
EOM
|
176
|
-
file 'environments/y.json', <<EOM
|
177
|
-
{
|
178
|
-
"chef_type": "environment",
|
179
|
-
"cookbook_versions": {
|
180
|
-
},
|
181
|
-
"default_attributes": {
|
182
|
-
},
|
183
|
-
"description": "",
|
184
|
-
"json_class": "Chef::Environment",
|
185
|
-
"name": "y",
|
186
|
-
"override_attributes": {
|
187
|
-
}
|
188
|
-
}
|
189
|
-
EOM
|
190
|
-
file 'nodes/y.json', { 'name' => 'y' }
|
191
|
-
file 'roles/y.json', <<EOM
|
192
|
-
{
|
193
|
-
"chef_type": "role",
|
194
|
-
"default_attributes": {
|
195
|
-
},
|
196
|
-
"description": "",
|
197
|
-
"env_run_lists": {
|
198
|
-
},
|
199
|
-
"json_class": "Chef::Role",
|
200
|
-
"name": "y",
|
201
|
-
"override_attributes": {
|
202
|
-
},
|
203
|
-
"run_list": [
|
204
|
-
|
205
|
-
]
|
206
|
-
}
|
207
|
-
EOM
|
208
|
-
file 'users/y.json', { 'name' => 'y' }
|
123
|
+
file 'data_bags/x/z.json', {}
|
124
|
+
file 'data_bags/y/zz.json', {}
|
125
|
+
file 'environments/y.json', {}
|
126
|
+
file 'nodes/y.json', {}
|
127
|
+
file 'roles/y.json', {}
|
128
|
+
file 'users/y.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
209
129
|
|
210
130
|
it 'knife download does nothing' do
|
211
131
|
knife('download /').should_succeed ''
|
212
132
|
knife('diff --name-status /').should_succeed <<EOM
|
133
|
+
A\t/clients/y.json
|
213
134
|
A\t/cookbooks/x/blah.rb
|
214
135
|
A\t/cookbooks/y
|
215
136
|
A\t/data_bags/x/z.json
|
216
137
|
A\t/data_bags/y
|
217
138
|
A\t/environments/y.json
|
139
|
+
A\t/nodes/y.json
|
218
140
|
A\t/roles/y.json
|
141
|
+
A\t/users/y.json
|
219
142
|
EOM
|
220
143
|
end
|
221
144
|
|
222
145
|
it 'knife download --purge deletes the extra files' do
|
223
146
|
knife('download --purge /').should_succeed <<EOM
|
147
|
+
Deleted extra entry /clients/y.json (purge is on)
|
224
148
|
Deleted extra entry /cookbooks/x/blah.rb (purge is on)
|
225
149
|
Deleted extra entry /cookbooks/y (purge is on)
|
226
150
|
Deleted extra entry /data_bags/x/z.json (purge is on)
|
227
151
|
Deleted extra entry /data_bags/y (purge is on)
|
228
152
|
Deleted extra entry /environments/y.json (purge is on)
|
153
|
+
Deleted extra entry /nodes/y.json (purge is on)
|
229
154
|
Deleted extra entry /roles/y.json (purge is on)
|
155
|
+
Deleted extra entry /users/y.json (purge is on)
|
230
156
|
EOM
|
231
157
|
knife('diff --name-status /').should_succeed ''
|
232
158
|
end
|
@@ -236,6 +162,10 @@ EOM
|
|
236
162
|
when_the_repository 'is empty' do
|
237
163
|
it 'knife download creates the extra files' do
|
238
164
|
knife('download /').should_succeed <<EOM
|
165
|
+
Created /clients
|
166
|
+
Created /clients/chef-validator.json
|
167
|
+
Created /clients/chef-webui.json
|
168
|
+
Created /clients/x.json
|
239
169
|
Created /cookbooks
|
240
170
|
Created /cookbooks/x
|
241
171
|
Created /cookbooks/x/metadata.rb
|
@@ -245,8 +175,13 @@ Created /data_bags/x/y.json
|
|
245
175
|
Created /environments
|
246
176
|
Created /environments/_default.json
|
247
177
|
Created /environments/x.json
|
178
|
+
Created /nodes
|
179
|
+
Created /nodes/x.json
|
248
180
|
Created /roles
|
249
181
|
Created /roles/x.json
|
182
|
+
Created /users
|
183
|
+
Created /users/admin.json
|
184
|
+
Created /users/x.json
|
250
185
|
EOM
|
251
186
|
knife('diff --name-status /').should_succeed ''
|
252
187
|
end
|
@@ -529,13 +464,13 @@ EOM
|
|
529
464
|
|
530
465
|
with_versioned_cookbooks do
|
531
466
|
when_the_chef_server "has one of each thing" do
|
532
|
-
client 'x',
|
467
|
+
client 'x', {}
|
533
468
|
cookbook 'x', '1.0.0', { 'metadata.rb' => 'version "1.0.0"' }
|
534
|
-
data_bag 'x', { 'y' =>
|
535
|
-
environment 'x',
|
536
|
-
node 'x',
|
537
|
-
role 'x',
|
538
|
-
user 'x',
|
469
|
+
data_bag 'x', { 'y' => {} }
|
470
|
+
environment 'x', {}
|
471
|
+
node 'x', {}
|
472
|
+
role 'x', {}
|
473
|
+
user 'x', {}
|
539
474
|
|
540
475
|
when_the_repository 'has only top-level directories' do
|
541
476
|
directory 'clients'
|
@@ -548,79 +483,36 @@ EOM
|
|
548
483
|
|
549
484
|
it 'knife download downloads everything' do
|
550
485
|
knife('download /').should_succeed <<EOM
|
486
|
+
Created /clients/chef-validator.json
|
487
|
+
Created /clients/chef-webui.json
|
488
|
+
Created /clients/x.json
|
551
489
|
Created /cookbooks/x-1.0.0
|
552
490
|
Created /cookbooks/x-1.0.0/metadata.rb
|
553
491
|
Created /data_bags/x
|
554
492
|
Created /data_bags/x/y.json
|
555
493
|
Created /environments/_default.json
|
556
494
|
Created /environments/x.json
|
495
|
+
Created /nodes/x.json
|
557
496
|
Created /roles/x.json
|
497
|
+
Created /users/admin.json
|
498
|
+
Created /users/x.json
|
558
499
|
EOM
|
559
500
|
knife('diff --name-status /').should_succeed ''
|
560
501
|
end
|
561
502
|
end
|
562
503
|
|
563
504
|
when_the_repository 'has an identical copy of each thing' do
|
564
|
-
file 'clients/
|
565
|
-
{}
|
566
|
-
|
505
|
+
file 'clients/chef-validator.json', { 'validator' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
506
|
+
file 'clients/chef-webui.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
507
|
+
file 'clients/x.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
567
508
|
file 'cookbooks/x-1.0.0/metadata.rb', 'version "1.0.0"'
|
568
|
-
file 'data_bags/x/y.json',
|
569
|
-
{
|
570
|
-
|
571
|
-
}
|
572
|
-
|
573
|
-
file '
|
574
|
-
{
|
575
|
-
"name": "_default",
|
576
|
-
"description": "The default Chef environment",
|
577
|
-
"cookbook_versions": {
|
578
|
-
},
|
579
|
-
"json_class": "Chef::Environment",
|
580
|
-
"chef_type": "environment",
|
581
|
-
"default_attributes": {
|
582
|
-
},
|
583
|
-
"override_attributes": {
|
584
|
-
}
|
585
|
-
}
|
586
|
-
EOM
|
587
|
-
file 'environments/x.json', <<EOM
|
588
|
-
{
|
589
|
-
"chef_type": "environment",
|
590
|
-
"cookbook_versions": {
|
591
|
-
},
|
592
|
-
"default_attributes": {
|
593
|
-
},
|
594
|
-
"description": "",
|
595
|
-
"json_class": "Chef::Environment",
|
596
|
-
"name": "x",
|
597
|
-
"override_attributes": {
|
598
|
-
}
|
599
|
-
}
|
600
|
-
EOM
|
601
|
-
file 'nodes/x.json', <<EOM
|
602
|
-
{}
|
603
|
-
EOM
|
604
|
-
file 'roles/x.json', <<EOM
|
605
|
-
{
|
606
|
-
"chef_type": "role",
|
607
|
-
"default_attributes": {
|
608
|
-
},
|
609
|
-
"description": "",
|
610
|
-
"env_run_lists": {
|
611
|
-
},
|
612
|
-
"json_class": "Chef::Role",
|
613
|
-
"name": "x",
|
614
|
-
"override_attributes": {
|
615
|
-
},
|
616
|
-
"run_list": [
|
617
|
-
|
618
|
-
]
|
619
|
-
}
|
620
|
-
EOM
|
621
|
-
file 'users/x.json', <<EOM
|
622
|
-
{}
|
623
|
-
EOM
|
509
|
+
file 'data_bags/x/y.json', {}
|
510
|
+
file 'environments/_default.json', { "description" => "The default Chef environment" }
|
511
|
+
file 'environments/x.json', {}
|
512
|
+
file 'nodes/x.json', {}
|
513
|
+
file 'roles/x.json', {}
|
514
|
+
file 'users/admin.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
515
|
+
file 'users/x.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
624
516
|
|
625
517
|
it 'knife download makes no changes' do
|
626
518
|
knife('download /').should_succeed ''
|
@@ -633,23 +525,8 @@ EOM
|
|
633
525
|
end
|
634
526
|
|
635
527
|
context 'except the role file' do
|
636
|
-
file 'roles/x.json',
|
637
|
-
{
|
638
|
-
"chef_type": "role",
|
639
|
-
"default_attributes": {
|
640
|
-
},
|
641
|
-
"description": "blarghle",
|
642
|
-
"env_run_lists": {
|
643
|
-
},
|
644
|
-
"json_class": "Chef::Role",
|
645
|
-
"name": "x",
|
646
|
-
"override_attributes": {
|
647
|
-
},
|
648
|
-
"run_list": [
|
528
|
+
file 'roles/x.json', { "description" => "blarghle" }
|
649
529
|
|
650
|
-
]
|
651
|
-
}
|
652
|
-
EOM
|
653
530
|
it 'knife download changes the role' do
|
654
531
|
knife('download /').should_succeed "Updated /roles/x.json\n"
|
655
532
|
knife('diff --name-status /').should_succeed ''
|
@@ -658,8 +535,8 @@ EOM
|
|
658
535
|
|
659
536
|
context 'except the role file is textually different, but not ACTUALLY different' do
|
660
537
|
file 'roles/x.json', <<EOM
|
661
|
-
{
|
662
|
-
"chef_type": "role",
|
538
|
+
{
|
539
|
+
"chef_type": "role" ,
|
663
540
|
"default_attributes": {
|
664
541
|
},
|
665
542
|
"env_run_lists": {
|
@@ -670,7 +547,7 @@ EOM
|
|
670
547
|
"override_attributes": {
|
671
548
|
},
|
672
549
|
"run_list": [
|
673
|
-
|
550
|
+
|
674
551
|
]
|
675
552
|
}
|
676
553
|
EOM
|
@@ -681,76 +558,45 @@ EOM
|
|
681
558
|
end
|
682
559
|
|
683
560
|
context 'as well as one extra copy of each thing' do
|
684
|
-
file 'clients/y.json', { '
|
561
|
+
file 'clients/y.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
685
562
|
file 'cookbooks/x-1.0.0/blah.rb', ''
|
686
563
|
file 'cookbooks/x-2.0.0/metadata.rb', 'version "2.0.0"'
|
687
564
|
file 'cookbooks/y-1.0.0/metadata.rb', 'version "1.0.0"'
|
688
|
-
file 'data_bags/x/z.json',
|
689
|
-
{
|
690
|
-
|
691
|
-
}
|
692
|
-
|
693
|
-
file '
|
694
|
-
{
|
695
|
-
"id": "zz"
|
696
|
-
}
|
697
|
-
EOM
|
698
|
-
file 'environments/y.json', <<EOM
|
699
|
-
{
|
700
|
-
"chef_type": "environment",
|
701
|
-
"cookbook_versions": {
|
702
|
-
},
|
703
|
-
"default_attributes": {
|
704
|
-
},
|
705
|
-
"description": "",
|
706
|
-
"json_class": "Chef::Environment",
|
707
|
-
"name": "y",
|
708
|
-
"override_attributes": {
|
709
|
-
}
|
710
|
-
}
|
711
|
-
EOM
|
712
|
-
file 'nodes/y.json', { 'name' => 'y' }
|
713
|
-
file 'roles/y.json', <<EOM
|
714
|
-
{
|
715
|
-
"chef_type": "role",
|
716
|
-
"default_attributes": {
|
717
|
-
},
|
718
|
-
"description": "",
|
719
|
-
"env_run_lists": {
|
720
|
-
},
|
721
|
-
"json_class": "Chef::Role",
|
722
|
-
"name": "y",
|
723
|
-
"override_attributes": {
|
724
|
-
},
|
725
|
-
"run_list": [
|
726
|
-
|
727
|
-
]
|
728
|
-
}
|
729
|
-
EOM
|
730
|
-
file 'users/y.json', { 'name' => 'y' }
|
565
|
+
file 'data_bags/x/z.json', {}
|
566
|
+
file 'data_bags/y/zz.json', {}
|
567
|
+
file 'environments/y.json', {}
|
568
|
+
file 'nodes/y.json', {}
|
569
|
+
file 'roles/y.json', {}
|
570
|
+
file 'users/y.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
731
571
|
|
732
572
|
it 'knife download does nothing' do
|
733
573
|
knife('download /').should_succeed ''
|
734
574
|
knife('diff --name-status /').should_succeed <<EOM
|
575
|
+
A\t/clients/y.json
|
735
576
|
A\t/cookbooks/x-1.0.0/blah.rb
|
736
577
|
A\t/cookbooks/x-2.0.0
|
737
578
|
A\t/cookbooks/y-1.0.0
|
738
579
|
A\t/data_bags/x/z.json
|
739
580
|
A\t/data_bags/y
|
740
581
|
A\t/environments/y.json
|
582
|
+
A\t/nodes/y.json
|
741
583
|
A\t/roles/y.json
|
584
|
+
A\t/users/y.json
|
742
585
|
EOM
|
743
586
|
end
|
744
587
|
|
745
588
|
it 'knife download --purge deletes the extra files' do
|
746
589
|
knife('download --purge /').should_succeed <<EOM
|
590
|
+
Deleted extra entry /clients/y.json (purge is on)
|
747
591
|
Deleted extra entry /cookbooks/x-1.0.0/blah.rb (purge is on)
|
748
592
|
Deleted extra entry /cookbooks/x-2.0.0 (purge is on)
|
749
593
|
Deleted extra entry /cookbooks/y-1.0.0 (purge is on)
|
750
594
|
Deleted extra entry /data_bags/x/z.json (purge is on)
|
751
595
|
Deleted extra entry /data_bags/y (purge is on)
|
752
596
|
Deleted extra entry /environments/y.json (purge is on)
|
597
|
+
Deleted extra entry /nodes/y.json (purge is on)
|
753
598
|
Deleted extra entry /roles/y.json (purge is on)
|
599
|
+
Deleted extra entry /users/y.json (purge is on)
|
754
600
|
EOM
|
755
601
|
knife('diff --name-status /').should_succeed ''
|
756
602
|
end
|
@@ -760,6 +606,10 @@ EOM
|
|
760
606
|
when_the_repository 'is empty' do
|
761
607
|
it 'knife download creates the extra files' do
|
762
608
|
knife('download /').should_succeed <<EOM
|
609
|
+
Created /clients
|
610
|
+
Created /clients/chef-validator.json
|
611
|
+
Created /clients/chef-webui.json
|
612
|
+
Created /clients/x.json
|
763
613
|
Created /cookbooks
|
764
614
|
Created /cookbooks/x-1.0.0
|
765
615
|
Created /cookbooks/x-1.0.0/metadata.rb
|
@@ -769,8 +619,13 @@ Created /data_bags/x/y.json
|
|
769
619
|
Created /environments
|
770
620
|
Created /environments/_default.json
|
771
621
|
Created /environments/x.json
|
622
|
+
Created /nodes
|
623
|
+
Created /nodes/x.json
|
772
624
|
Created /roles
|
773
625
|
Created /roles/x.json
|
626
|
+
Created /users
|
627
|
+
Created /users/admin.json
|
628
|
+
Created /users/x.json
|
774
629
|
EOM
|
775
630
|
knife('diff --name-status /').should_succeed ''
|
776
631
|
end
|