knife-essentials 0.9.8 → 1.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -8,20 +8,30 @@ describe 'knife list' do
|
|
8
8
|
when_the_chef_server "is empty" do
|
9
9
|
it "knife list / returns all top level directories" do
|
10
10
|
knife('list /').should_succeed <<EOM
|
11
|
+
/clients
|
11
12
|
/cookbooks
|
12
13
|
/data_bags
|
13
14
|
/environments
|
15
|
+
/nodes
|
14
16
|
/roles
|
17
|
+
/users
|
15
18
|
EOM
|
16
19
|
end
|
17
20
|
|
18
21
|
it "knife list -R / returns everything" do
|
19
22
|
knife('list -R /').should_succeed <<EOM
|
20
23
|
/:
|
24
|
+
clients
|
21
25
|
cookbooks
|
22
26
|
data_bags
|
23
27
|
environments
|
28
|
+
nodes
|
24
29
|
roles
|
30
|
+
users
|
31
|
+
|
32
|
+
/clients:
|
33
|
+
chef-validator.json
|
34
|
+
chef-webui.json
|
25
35
|
|
26
36
|
/cookbooks:
|
27
37
|
|
@@ -30,7 +40,12 @@ roles
|
|
30
40
|
/environments:
|
31
41
|
_default.json
|
32
42
|
|
43
|
+
/nodes:
|
44
|
+
|
33
45
|
/roles:
|
46
|
+
|
47
|
+
/users:
|
48
|
+
admin.json
|
34
49
|
EOM
|
35
50
|
end
|
36
51
|
end
|
@@ -53,20 +68,32 @@ EOM
|
|
53
68
|
|
54
69
|
it "knife list / returns all top level directories" do
|
55
70
|
knife('list /').should_succeed <<EOM
|
71
|
+
/clients
|
56
72
|
/cookbooks
|
57
73
|
/data_bags
|
58
74
|
/environments
|
75
|
+
/nodes
|
59
76
|
/roles
|
77
|
+
/users
|
60
78
|
EOM
|
61
79
|
end
|
62
80
|
|
63
81
|
it "knife list -R / returns everything" do
|
64
82
|
knife('list -R /').should_succeed <<EOM
|
65
83
|
/:
|
84
|
+
clients
|
66
85
|
cookbooks
|
67
86
|
data_bags
|
68
87
|
environments
|
88
|
+
nodes
|
69
89
|
roles
|
90
|
+
users
|
91
|
+
|
92
|
+
/clients:
|
93
|
+
chef-validator.json
|
94
|
+
chef-webui.json
|
95
|
+
client1.json
|
96
|
+
client2.json
|
70
97
|
|
71
98
|
/cookbooks:
|
72
99
|
cookbook1
|
@@ -99,14 +126,28 @@ _default.json
|
|
99
126
|
environment1.json
|
100
127
|
environment2.json
|
101
128
|
|
129
|
+
/nodes:
|
130
|
+
node1.json
|
131
|
+
node2.json
|
132
|
+
|
102
133
|
/roles:
|
103
134
|
role1.json
|
104
135
|
role2.json
|
136
|
+
|
137
|
+
/users:
|
138
|
+
admin.json
|
139
|
+
user1.json
|
140
|
+
user2.json
|
105
141
|
EOM
|
106
142
|
end
|
107
143
|
|
108
144
|
it "knife list -R --flat / returns everything" do
|
109
145
|
knife('list -R --flat /').should_succeed <<EOM
|
146
|
+
/clients
|
147
|
+
/clients/chef-validator.json
|
148
|
+
/clients/chef-webui.json
|
149
|
+
/clients/client1.json
|
150
|
+
/clients/client2.json
|
110
151
|
/cookbooks
|
111
152
|
/cookbooks/cookbook1
|
112
153
|
/cookbooks/cookbook1/metadata.rb
|
@@ -125,14 +166,26 @@ EOM
|
|
125
166
|
/environments/_default.json
|
126
167
|
/environments/environment1.json
|
127
168
|
/environments/environment2.json
|
169
|
+
/nodes
|
170
|
+
/nodes/node1.json
|
171
|
+
/nodes/node2.json
|
128
172
|
/roles
|
129
173
|
/roles/role1.json
|
130
174
|
/roles/role2.json
|
175
|
+
/users
|
176
|
+
/users/admin.json
|
177
|
+
/users/user1.json
|
178
|
+
/users/user2.json
|
131
179
|
EOM
|
132
180
|
end
|
133
181
|
|
134
182
|
it "knife list -Rfp / returns everything" do
|
135
183
|
knife('list -Rfp /').should_succeed <<EOM
|
184
|
+
/clients/
|
185
|
+
/clients/chef-validator.json
|
186
|
+
/clients/chef-webui.json
|
187
|
+
/clients/client1.json
|
188
|
+
/clients/client2.json
|
136
189
|
/cookbooks/
|
137
190
|
/cookbooks/cookbook1/
|
138
191
|
/cookbooks/cookbook1/metadata.rb
|
@@ -151,9 +204,16 @@ EOM
|
|
151
204
|
/environments/_default.json
|
152
205
|
/environments/environment1.json
|
153
206
|
/environments/environment2.json
|
207
|
+
/nodes/
|
208
|
+
/nodes/node1.json
|
209
|
+
/nodes/node2.json
|
154
210
|
/roles/
|
155
211
|
/roles/role1.json
|
156
212
|
/roles/role2.json
|
213
|
+
/users/
|
214
|
+
/users/admin.json
|
215
|
+
/users/user1.json
|
216
|
+
/users/user2.json
|
157
217
|
EOM
|
158
218
|
end
|
159
219
|
|
@@ -186,6 +246,10 @@ EOM
|
|
186
246
|
|
187
247
|
it "knife list /**.json returns all json files" do
|
188
248
|
knife('list /**.json').should_succeed <<EOM
|
249
|
+
/clients/chef-validator.json
|
250
|
+
/clients/chef-webui.json
|
251
|
+
/clients/client1.json
|
252
|
+
/clients/client2.json
|
189
253
|
/data_bags/bag1/item1.json
|
190
254
|
/data_bags/bag1/item2.json
|
191
255
|
/data_bags/bag2/item1.json
|
@@ -193,8 +257,13 @@ EOM
|
|
193
257
|
/environments/_default.json
|
194
258
|
/environments/environment1.json
|
195
259
|
/environments/environment2.json
|
260
|
+
/nodes/node1.json
|
261
|
+
/nodes/node2.json
|
196
262
|
/roles/role1.json
|
197
263
|
/roles/role2.json
|
264
|
+
/users/admin.json
|
265
|
+
/users/user1.json
|
266
|
+
/users/user2.json
|
198
267
|
EOM
|
199
268
|
end
|
200
269
|
|
@@ -232,6 +301,11 @@ EOM
|
|
232
301
|
|
233
302
|
it "knife list -Rfp returns everything" do
|
234
303
|
knife('list -Rfp').should_succeed <<EOM
|
304
|
+
clients/
|
305
|
+
clients/chef-validator.json
|
306
|
+
clients/chef-webui.json
|
307
|
+
clients/client1.json
|
308
|
+
clients/client2.json
|
235
309
|
cookbooks/
|
236
310
|
cookbooks/cookbook1/
|
237
311
|
cookbooks/cookbook1/metadata.rb
|
@@ -250,9 +324,16 @@ environments/
|
|
250
324
|
environments/_default.json
|
251
325
|
environments/environment1.json
|
252
326
|
environments/environment2.json
|
327
|
+
nodes/
|
328
|
+
nodes/node1.json
|
329
|
+
nodes/node2.json
|
253
330
|
roles/
|
254
331
|
roles/role1.json
|
255
332
|
roles/role2.json
|
333
|
+
users/
|
334
|
+
users/admin.json
|
335
|
+
users/user1.json
|
336
|
+
users/user2.json
|
256
337
|
EOM
|
257
338
|
end
|
258
339
|
end
|
@@ -265,6 +346,11 @@ EOM
|
|
265
346
|
|
266
347
|
it "knife list -Rfp / returns everything" do
|
267
348
|
knife('list -Rfp /').should_succeed <<EOM
|
349
|
+
/clients/
|
350
|
+
/clients/chef-validator.json
|
351
|
+
/clients/chef-webui.json
|
352
|
+
/clients/client1.json
|
353
|
+
/clients/client2.json
|
268
354
|
./
|
269
355
|
cookbook1/
|
270
356
|
cookbook1/metadata.rb
|
@@ -283,14 +369,26 @@ cookbook2/recipes/default.rb
|
|
283
369
|
/environments/_default.json
|
284
370
|
/environments/environment1.json
|
285
371
|
/environments/environment2.json
|
372
|
+
/nodes/
|
373
|
+
/nodes/node1.json
|
374
|
+
/nodes/node2.json
|
286
375
|
/roles/
|
287
376
|
/roles/role1.json
|
288
377
|
/roles/role2.json
|
378
|
+
/users/
|
379
|
+
/users/admin.json
|
380
|
+
/users/user1.json
|
381
|
+
/users/user2.json
|
289
382
|
EOM
|
290
383
|
end
|
291
384
|
|
292
385
|
it "knife list -Rfp .. returns everything" do
|
293
386
|
knife('list -Rfp ..').should_succeed <<EOM
|
387
|
+
/clients/
|
388
|
+
/clients/chef-validator.json
|
389
|
+
/clients/chef-webui.json
|
390
|
+
/clients/client1.json
|
391
|
+
/clients/client2.json
|
294
392
|
./
|
295
393
|
cookbook1/
|
296
394
|
cookbook1/metadata.rb
|
@@ -309,9 +407,16 @@ cookbook2/recipes/default.rb
|
|
309
407
|
/environments/_default.json
|
310
408
|
/environments/environment1.json
|
311
409
|
/environments/environment2.json
|
410
|
+
/nodes/
|
411
|
+
/nodes/node1.json
|
412
|
+
/nodes/node2.json
|
312
413
|
/roles/
|
313
414
|
/roles/role1.json
|
314
415
|
/roles/role2.json
|
416
|
+
/users/
|
417
|
+
/users/admin.json
|
418
|
+
/users/user1.json
|
419
|
+
/users/user2.json
|
315
420
|
EOM
|
316
421
|
end
|
317
422
|
|
@@ -461,6 +566,9 @@ EOM
|
|
461
566
|
|
462
567
|
it "knife list -Rfp / returns everything" do
|
463
568
|
knife('list -Rp --local --flat /').should_succeed <<EOM
|
569
|
+
/clients/
|
570
|
+
/clients/client1.json
|
571
|
+
/clients/client2.json
|
464
572
|
/cookbooks/
|
465
573
|
/cookbooks/cookbook1/
|
466
574
|
/cookbooks/cookbook1/metadata.rb
|
@@ -478,9 +586,15 @@ EOM
|
|
478
586
|
/environments/
|
479
587
|
/environments/environment1.json
|
480
588
|
/environments/environment2.json
|
589
|
+
/nodes/
|
590
|
+
/nodes/node1.json
|
591
|
+
/nodes/node2.json
|
481
592
|
/roles/
|
482
593
|
/roles/role1.json
|
483
594
|
/roles/role2.json
|
595
|
+
/users/
|
596
|
+
/users/user1.json
|
597
|
+
/users/user2.json
|
484
598
|
EOM
|
485
599
|
end
|
486
600
|
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'thin'
|
2
|
+
require 'support/integration_helper'
|
3
|
+
require 'chef/knife/list_essentials'
|
4
|
+
|
5
|
+
describe 'redirection' do
|
6
|
+
extend IntegrationSupport
|
7
|
+
include KnifeSupport
|
8
|
+
|
9
|
+
when_the_chef_server 'has a role' do
|
10
|
+
role 'x', {}
|
11
|
+
|
12
|
+
context 'and another server redirects to it with 302' do
|
13
|
+
before :each do
|
14
|
+
@real_chef_server_url = Chef::Config.chef_server_url
|
15
|
+
Chef::Config.chef_server_url = "http://127.0.0.1:9018"
|
16
|
+
app = lambda do |env|
|
17
|
+
[302, {'Content-Type' => 'text','Location' => "#{@real_chef_server_url}#{env['PATH_INFO']}" }, ['302 found'] ]
|
18
|
+
end
|
19
|
+
@redirector_server = Thin::Server.new('127.0.0.1', 9018, app, { :signals => false })
|
20
|
+
@redirector_thread = Thread.new do
|
21
|
+
begin
|
22
|
+
@redirector_server.start
|
23
|
+
rescue
|
24
|
+
@server_error = $!
|
25
|
+
Chef::Log.error("#{$!.message}\n#{$!.backtrace.join("\n")}")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
Timeout::timeout(5) do
|
29
|
+
until @redirector_server.running? || @server_error
|
30
|
+
sleep(0.01)
|
31
|
+
end
|
32
|
+
raise @server_error if @server_error
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
after :each do
|
37
|
+
Chef::Config.chef_server_url = @real_chef_server_url
|
38
|
+
@redirector_thread.kill
|
39
|
+
@redirector_thread.join(nil)
|
40
|
+
@redirector_thread = nil
|
41
|
+
@redirector_server = nil
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'knife list /roles returns the role' do
|
45
|
+
knife('list /roles').should_succeed "/roles/x.json\n"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -8,13 +8,13 @@ describe 'knife upload' 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'
|
@@ -28,20 +28,32 @@ describe 'knife upload' do
|
|
28
28
|
it 'knife upload does nothing' do
|
29
29
|
knife('upload /').should_succeed ''
|
30
30
|
knife('diff --name-status /').should_succeed <<EOM
|
31
|
+
D\t/clients/chef-validator.json
|
32
|
+
D\t/clients/chef-webui.json
|
33
|
+
D\t/clients/x.json
|
31
34
|
D\t/cookbooks/x
|
32
35
|
D\t/data_bags/x
|
33
36
|
D\t/environments/_default.json
|
34
37
|
D\t/environments/x.json
|
38
|
+
D\t/nodes/x.json
|
35
39
|
D\t/roles/x.json
|
40
|
+
D\t/users/admin.json
|
41
|
+
D\t/users/x.json
|
36
42
|
EOM
|
37
43
|
end
|
38
44
|
|
39
45
|
it 'knife upload --purge deletes everything' do
|
40
46
|
knife('upload --purge /').should_succeed(<<EOM, :stderr => "WARNING: /environments/_default.json cannot be deleted (default environment cannot be modified).\n")
|
47
|
+
Deleted extra entry /clients/chef-validator.json (purge is on)
|
48
|
+
Deleted extra entry /clients/chef-webui.json (purge is on)
|
49
|
+
Deleted extra entry /clients/x.json (purge is on)
|
41
50
|
Deleted extra entry /cookbooks/x (purge is on)
|
42
51
|
Deleted extra entry /data_bags/x (purge is on)
|
43
52
|
Deleted extra entry /environments/x.json (purge is on)
|
53
|
+
Deleted extra entry /nodes/x.json (purge is on)
|
44
54
|
Deleted extra entry /roles/x.json (purge is on)
|
55
|
+
Deleted extra entry /users/admin.json (purge is on)
|
56
|
+
Deleted extra entry /users/x.json (purge is on)
|
45
57
|
EOM
|
46
58
|
knife('diff --name-status /').should_succeed <<EOM
|
47
59
|
D\t/environments/_default.json
|
@@ -50,66 +62,17 @@ EOM
|
|
50
62
|
end
|
51
63
|
|
52
64
|
when_the_repository 'has an identical copy of each thing' do
|
53
|
-
file 'clients/
|
54
|
-
{}
|
55
|
-
|
65
|
+
file 'clients/chef-validator.json', { 'validator' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
66
|
+
file 'clients/chef-webui.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
67
|
+
file 'clients/x.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
56
68
|
file 'cookbooks/x/metadata.rb', 'version "1.0.0"'
|
57
|
-
file 'data_bags/x/y.json',
|
58
|
-
{
|
59
|
-
|
60
|
-
}
|
61
|
-
|
62
|
-
file '
|
63
|
-
{
|
64
|
-
"name": "_default",
|
65
|
-
"description": "The default Chef environment",
|
66
|
-
"cookbook_versions": {
|
67
|
-
},
|
68
|
-
"json_class": "Chef::Environment",
|
69
|
-
"chef_type": "environment",
|
70
|
-
"default_attributes": {
|
71
|
-
},
|
72
|
-
"override_attributes": {
|
73
|
-
}
|
74
|
-
}
|
75
|
-
EOM
|
76
|
-
file 'environments/x.json', <<EOM
|
77
|
-
{
|
78
|
-
"chef_type": "environment",
|
79
|
-
"cookbook_versions": {
|
80
|
-
},
|
81
|
-
"default_attributes": {
|
82
|
-
},
|
83
|
-
"description": "",
|
84
|
-
"json_class": "Chef::Environment",
|
85
|
-
"name": "x",
|
86
|
-
"override_attributes": {
|
87
|
-
}
|
88
|
-
}
|
89
|
-
EOM
|
90
|
-
file 'nodes/x.json', <<EOM
|
91
|
-
{}
|
92
|
-
EOM
|
93
|
-
file 'roles/x.json', <<EOM
|
94
|
-
{
|
95
|
-
"chef_type": "role",
|
96
|
-
"default_attributes": {
|
97
|
-
},
|
98
|
-
"description": "",
|
99
|
-
"env_run_lists": {
|
100
|
-
},
|
101
|
-
"json_class": "Chef::Role",
|
102
|
-
"name": "x",
|
103
|
-
"override_attributes": {
|
104
|
-
},
|
105
|
-
"run_list": [
|
106
|
-
|
107
|
-
]
|
108
|
-
}
|
109
|
-
EOM
|
110
|
-
file 'users/x.json', <<EOM
|
111
|
-
{}
|
112
|
-
EOM
|
69
|
+
file 'data_bags/x/y.json', {}
|
70
|
+
file 'environments/_default.json', { "description" => "The default Chef environment" }
|
71
|
+
file 'environments/x.json', {}
|
72
|
+
file 'nodes/x.json', {}
|
73
|
+
file 'roles/x.json', {}
|
74
|
+
file 'users/admin.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
75
|
+
file 'users/x.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
113
76
|
|
114
77
|
it 'knife upload makes no changes' do
|
115
78
|
knife('upload /cookbooks/x').should_succeed ''
|
@@ -122,23 +85,7 @@ EOM
|
|
122
85
|
end
|
123
86
|
|
124
87
|
context 'except the role file' do
|
125
|
-
file 'roles/x.json',
|
126
|
-
{
|
127
|
-
"chef_type": "role",
|
128
|
-
"default_attributes": {
|
129
|
-
},
|
130
|
-
"description": "blarghle",
|
131
|
-
"env_run_lists": {
|
132
|
-
},
|
133
|
-
"json_class": "Chef::Role",
|
134
|
-
"name": "x",
|
135
|
-
"override_attributes": {
|
136
|
-
},
|
137
|
-
"run_list": [
|
138
|
-
|
139
|
-
]
|
140
|
-
}
|
141
|
-
EOM
|
88
|
+
file 'roles/x.json', { 'description' => 'blarghle' }
|
142
89
|
it 'knife upload changes the role' do
|
143
90
|
knife('upload /').should_succeed "Updated /roles/x.json\n"
|
144
91
|
knife('diff --name-status /').should_succeed ''
|
@@ -149,7 +96,7 @@ EOM
|
|
149
96
|
file 'roles/x.json', <<EOM
|
150
97
|
{
|
151
98
|
"chef_type": "role",
|
152
|
-
"default_attributes":
|
99
|
+
"default_attributes": {
|
153
100
|
},
|
154
101
|
"env_run_lists": {
|
155
102
|
},
|
@@ -170,62 +117,28 @@ EOM
|
|
170
117
|
end
|
171
118
|
|
172
119
|
context 'as well as one extra copy of each thing' do
|
173
|
-
file 'clients/y.json', { '
|
120
|
+
file 'clients/y.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
174
121
|
file 'cookbooks/x/blah.rb', ''
|
175
122
|
file 'cookbooks/y/metadata.rb', 'version "1.0.0"'
|
176
|
-
file 'data_bags/x/z.json',
|
177
|
-
{
|
178
|
-
|
179
|
-
}
|
180
|
-
|
181
|
-
file '
|
182
|
-
{
|
183
|
-
"id": "zz"
|
184
|
-
}
|
185
|
-
EOM
|
186
|
-
file 'environments/y.json', <<EOM
|
187
|
-
{
|
188
|
-
"chef_type": "environment",
|
189
|
-
"cookbook_versions": {
|
190
|
-
},
|
191
|
-
"default_attributes": {
|
192
|
-
},
|
193
|
-
"description": "",
|
194
|
-
"json_class": "Chef::Environment",
|
195
|
-
"name": "y",
|
196
|
-
"override_attributes": {
|
197
|
-
}
|
198
|
-
}
|
199
|
-
EOM
|
200
|
-
file 'nodes/y.json', { 'name' => 'y' }
|
201
|
-
file 'roles/y.json', <<EOM
|
202
|
-
{
|
203
|
-
"chef_type": "role",
|
204
|
-
"default_attributes": {
|
205
|
-
},
|
206
|
-
"description": "",
|
207
|
-
"env_run_lists": {
|
208
|
-
},
|
209
|
-
"json_class": "Chef::Role",
|
210
|
-
"name": "y",
|
211
|
-
"override_attributes": {
|
212
|
-
},
|
213
|
-
"run_list": [
|
214
|
-
|
215
|
-
]
|
216
|
-
}
|
217
|
-
EOM
|
218
|
-
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 }
|
219
129
|
|
220
130
|
it 'knife upload adds the new files' do
|
221
131
|
knife('upload /').should_succeed <<EOM
|
132
|
+
Created /clients/y.json
|
222
133
|
Updated /cookbooks/x
|
223
134
|
Created /cookbooks/y
|
224
135
|
Created /data_bags/x/z.json
|
225
136
|
Created /data_bags/y
|
226
137
|
Created /data_bags/y/zz.json
|
227
138
|
Created /environments/y.json
|
139
|
+
Created /nodes/y.json
|
228
140
|
Created /roles/y.json
|
141
|
+
Created /users/y.json
|
229
142
|
EOM
|
230
143
|
knife('diff --name-status /').should_succeed ''
|
231
144
|
end
|
@@ -236,25 +149,34 @@ EOM
|
|
236
149
|
it 'knife upload does nothing' do
|
237
150
|
knife('upload /').should_succeed ''
|
238
151
|
knife('diff --name-status /').should_succeed <<EOM
|
152
|
+
D\t/clients
|
239
153
|
D\t/cookbooks
|
240
154
|
D\t/data_bags
|
241
155
|
D\t/environments
|
156
|
+
D\t/nodes
|
242
157
|
D\t/roles
|
158
|
+
D\t/users
|
243
159
|
EOM
|
244
160
|
end
|
245
161
|
|
246
162
|
it 'knife upload --purge deletes nothing' do
|
247
163
|
knife('upload --purge /').should_fail <<EOM
|
164
|
+
ERROR: /clients cannot be deleted.
|
248
165
|
ERROR: /cookbooks cannot be deleted.
|
249
166
|
ERROR: /data_bags cannot be deleted.
|
250
167
|
ERROR: /environments cannot be deleted.
|
168
|
+
ERROR: /nodes cannot be deleted.
|
251
169
|
ERROR: /roles cannot be deleted.
|
170
|
+
ERROR: /users cannot be deleted.
|
252
171
|
EOM
|
253
172
|
knife('diff --name-status /').should_succeed <<EOM
|
173
|
+
D\t/clients
|
254
174
|
D\t/cookbooks
|
255
175
|
D\t/data_bags
|
256
176
|
D\t/environments
|
177
|
+
D\t/nodes
|
257
178
|
D\t/roles
|
179
|
+
D\t/users
|
258
180
|
EOM
|
259
181
|
end
|
260
182
|
|
@@ -270,16 +192,8 @@ EOM
|
|
270
192
|
# Test upload of an item when the other end doesn't even have the container
|
271
193
|
when_the_chef_server 'is empty' do
|
272
194
|
when_the_repository 'has two data bag items' do
|
273
|
-
file 'data_bags/x/y.json',
|
274
|
-
{
|
275
|
-
"id": "y"
|
276
|
-
}
|
277
|
-
EOM
|
278
|
-
file 'data_bags/x/z.json', <<EOM
|
279
|
-
{
|
280
|
-
"id": "z"
|
281
|
-
}
|
282
|
-
EOM
|
195
|
+
file 'data_bags/x/y.json', {}
|
196
|
+
file 'data_bags/x/z.json', {}
|
283
197
|
it 'knife upload of one data bag item itself succeeds' do
|
284
198
|
knife('upload /data_bags/x/y.json').should_succeed <<EOM
|
285
199
|
Created /data_bags/x
|
@@ -294,23 +208,12 @@ EOM
|
|
294
208
|
|
295
209
|
when_the_chef_server 'has three data bag items' do
|
296
210
|
data_bag 'x', { 'deleted' => {}, 'modified' => {}, 'unmodified' => {} }
|
211
|
+
|
297
212
|
when_the_repository 'has a modified, unmodified, added and deleted data bag item' do
|
298
|
-
file 'data_bags/x/added.json',
|
299
|
-
{
|
300
|
-
|
301
|
-
|
302
|
-
EOM
|
303
|
-
file 'data_bags/x/modified.json', <<EOM
|
304
|
-
{
|
305
|
-
"id": "modified",
|
306
|
-
"foo": "bar"
|
307
|
-
}
|
308
|
-
EOM
|
309
|
-
file 'data_bags/x/unmodified.json', <<EOM
|
310
|
-
{
|
311
|
-
"id": "unmodified"
|
312
|
-
}
|
313
|
-
EOM
|
213
|
+
file 'data_bags/x/added.json', {}
|
214
|
+
file 'data_bags/x/modified.json', { 'foo' => 'bar' }
|
215
|
+
file 'data_bags/x/unmodified.json', {}
|
216
|
+
|
314
217
|
it 'knife upload of the modified file succeeds' do
|
315
218
|
knife('upload /data_bags/x/modified.json').should_succeed <<EOM
|
316
219
|
Updated /data_bags/x/modified.json
|
@@ -579,13 +482,13 @@ EOM
|
|
579
482
|
|
580
483
|
with_versioned_cookbooks do
|
581
484
|
when_the_chef_server "has one of each thing" do
|
582
|
-
client 'x',
|
485
|
+
client 'x', {}
|
583
486
|
cookbook 'x', '1.0.0', { 'metadata.rb' => 'version "1.0.0"' }
|
584
|
-
data_bag 'x', { 'y' =>
|
585
|
-
environment 'x',
|
586
|
-
node 'x',
|
587
|
-
role 'x',
|
588
|
-
user 'x',
|
487
|
+
data_bag 'x', { 'y' => {} }
|
488
|
+
environment 'x', {}
|
489
|
+
node 'x', {}
|
490
|
+
role 'x', {}
|
491
|
+
user 'x', {}
|
589
492
|
|
590
493
|
when_the_repository 'has only top-level directories' do
|
591
494
|
directory 'clients'
|
@@ -599,20 +502,32 @@ EOM
|
|
599
502
|
it 'knife upload does nothing' do
|
600
503
|
knife('upload /').should_succeed ''
|
601
504
|
knife('diff --name-status /').should_succeed <<EOM
|
505
|
+
D\t/clients/chef-validator.json
|
506
|
+
D\t/clients/chef-webui.json
|
507
|
+
D\t/clients/x.json
|
602
508
|
D\t/cookbooks/x-1.0.0
|
603
509
|
D\t/data_bags/x
|
604
510
|
D\t/environments/_default.json
|
605
511
|
D\t/environments/x.json
|
512
|
+
D\t/nodes/x.json
|
606
513
|
D\t/roles/x.json
|
514
|
+
D\t/users/admin.json
|
515
|
+
D\t/users/x.json
|
607
516
|
EOM
|
608
517
|
end
|
609
518
|
|
610
519
|
it 'knife upload --purge deletes everything' do
|
611
520
|
knife('upload --purge /').should_succeed(<<EOM, :stderr => "WARNING: /environments/_default.json cannot be deleted (default environment cannot be modified).\n")
|
521
|
+
Deleted extra entry /clients/chef-validator.json (purge is on)
|
522
|
+
Deleted extra entry /clients/chef-webui.json (purge is on)
|
523
|
+
Deleted extra entry /clients/x.json (purge is on)
|
612
524
|
Deleted extra entry /cookbooks/x-1.0.0 (purge is on)
|
613
525
|
Deleted extra entry /data_bags/x (purge is on)
|
614
526
|
Deleted extra entry /environments/x.json (purge is on)
|
527
|
+
Deleted extra entry /nodes/x.json (purge is on)
|
615
528
|
Deleted extra entry /roles/x.json (purge is on)
|
529
|
+
Deleted extra entry /users/admin.json (purge is on)
|
530
|
+
Deleted extra entry /users/x.json (purge is on)
|
616
531
|
EOM
|
617
532
|
knife('diff --name-status /').should_succeed <<EOM
|
618
533
|
D\t/environments/_default.json
|
@@ -621,66 +536,17 @@ EOM
|
|
621
536
|
end
|
622
537
|
|
623
538
|
when_the_repository 'has an identical copy of each thing' do
|
624
|
-
file 'clients/
|
625
|
-
{}
|
626
|
-
|
539
|
+
file 'clients/chef-validator.json', { 'validator' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
540
|
+
file 'clients/chef-webui.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
541
|
+
file 'clients/x.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
627
542
|
file 'cookbooks/x-1.0.0/metadata.rb', 'version "1.0.0"'
|
628
|
-
file 'data_bags/x/y.json',
|
629
|
-
{
|
630
|
-
|
631
|
-
}
|
632
|
-
|
633
|
-
file '
|
634
|
-
{
|
635
|
-
"name": "_default",
|
636
|
-
"description": "The default Chef environment",
|
637
|
-
"cookbook_versions": {
|
638
|
-
},
|
639
|
-
"json_class": "Chef::Environment",
|
640
|
-
"chef_type": "environment",
|
641
|
-
"default_attributes": {
|
642
|
-
},
|
643
|
-
"override_attributes": {
|
644
|
-
}
|
645
|
-
}
|
646
|
-
EOM
|
647
|
-
file 'environments/x.json', <<EOM
|
648
|
-
{
|
649
|
-
"chef_type": "environment",
|
650
|
-
"cookbook_versions": {
|
651
|
-
},
|
652
|
-
"default_attributes": {
|
653
|
-
},
|
654
|
-
"description": "",
|
655
|
-
"json_class": "Chef::Environment",
|
656
|
-
"name": "x",
|
657
|
-
"override_attributes": {
|
658
|
-
}
|
659
|
-
}
|
660
|
-
EOM
|
661
|
-
file 'nodes/x.json', <<EOM
|
662
|
-
{}
|
663
|
-
EOM
|
664
|
-
file 'roles/x.json', <<EOM
|
665
|
-
{
|
666
|
-
"chef_type": "role",
|
667
|
-
"default_attributes": {
|
668
|
-
},
|
669
|
-
"description": "",
|
670
|
-
"env_run_lists": {
|
671
|
-
},
|
672
|
-
"json_class": "Chef::Role",
|
673
|
-
"name": "x",
|
674
|
-
"override_attributes": {
|
675
|
-
},
|
676
|
-
"run_list": [
|
677
|
-
|
678
|
-
]
|
679
|
-
}
|
680
|
-
EOM
|
681
|
-
file 'users/x.json', <<EOM
|
682
|
-
{}
|
683
|
-
EOM
|
543
|
+
file 'data_bags/x/y.json', {}
|
544
|
+
file 'environments/_default.json', { 'description' => 'The default Chef environment' }
|
545
|
+
file 'environments/x.json', {}
|
546
|
+
file 'nodes/x.json', {}
|
547
|
+
file 'roles/x.json', {}
|
548
|
+
file 'users/admin.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY }
|
549
|
+
file 'users/x.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
684
550
|
|
685
551
|
it 'knife upload makes no changes' do
|
686
552
|
knife('upload /cookbooks/x-1.0.0').should_succeed ''
|
@@ -693,23 +559,8 @@ EOM
|
|
693
559
|
end
|
694
560
|
|
695
561
|
context 'except the role file' do
|
696
|
-
file 'roles/x.json',
|
697
|
-
{
|
698
|
-
"chef_type": "role",
|
699
|
-
"default_attributes": {
|
700
|
-
},
|
701
|
-
"description": "blarghle",
|
702
|
-
"env_run_lists": {
|
703
|
-
},
|
704
|
-
"json_class": "Chef::Role",
|
705
|
-
"name": "x",
|
706
|
-
"override_attributes": {
|
707
|
-
},
|
708
|
-
"run_list": [
|
562
|
+
file 'roles/x.json', { 'description' => 'blarghle' }
|
709
563
|
|
710
|
-
]
|
711
|
-
}
|
712
|
-
EOM
|
713
564
|
it 'knife upload changes the role' do
|
714
565
|
knife('upload /').should_succeed "Updated /roles/x.json\n"
|
715
566
|
knife('diff --name-status /').should_succeed ''
|
@@ -720,7 +571,7 @@ EOM
|
|
720
571
|
file 'roles/x.json', <<EOM
|
721
572
|
{
|
722
573
|
"chef_type": "role",
|
723
|
-
"default_attributes":
|
574
|
+
"default_attributes": {
|
724
575
|
},
|
725
576
|
"env_run_lists": {
|
726
577
|
},
|
@@ -741,56 +592,20 @@ EOM
|
|
741
592
|
end
|
742
593
|
|
743
594
|
context 'as well as one extra copy of each thing' do
|
744
|
-
file 'clients/y.json', { '
|
595
|
+
file 'clients/y.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
745
596
|
file 'cookbooks/x-1.0.0/blah.rb', ''
|
746
597
|
file 'cookbooks/x-2.0.0/metadata.rb', 'version "2.0.0"'
|
747
598
|
file 'cookbooks/y-1.0.0/metadata.rb', 'version "1.0.0"'
|
748
|
-
file 'data_bags/x/z.json',
|
749
|
-
{
|
750
|
-
|
751
|
-
}
|
752
|
-
|
753
|
-
file '
|
754
|
-
{
|
755
|
-
"id": "zz"
|
756
|
-
}
|
757
|
-
EOM
|
758
|
-
file 'environments/y.json', <<EOM
|
759
|
-
{
|
760
|
-
"chef_type": "environment",
|
761
|
-
"cookbook_versions": {
|
762
|
-
},
|
763
|
-
"default_attributes": {
|
764
|
-
},
|
765
|
-
"description": "",
|
766
|
-
"json_class": "Chef::Environment",
|
767
|
-
"name": "y",
|
768
|
-
"override_attributes": {
|
769
|
-
}
|
770
|
-
}
|
771
|
-
EOM
|
772
|
-
file 'nodes/y.json', { 'name' => 'y' }
|
773
|
-
file 'roles/y.json', <<EOM
|
774
|
-
{
|
775
|
-
"chef_type": "role",
|
776
|
-
"default_attributes": {
|
777
|
-
},
|
778
|
-
"description": "",
|
779
|
-
"env_run_lists": {
|
780
|
-
},
|
781
|
-
"json_class": "Chef::Role",
|
782
|
-
"name": "y",
|
783
|
-
"override_attributes": {
|
784
|
-
},
|
785
|
-
"run_list": [
|
786
|
-
|
787
|
-
]
|
788
|
-
}
|
789
|
-
EOM
|
790
|
-
file 'users/y.json', { 'name' => 'y' }
|
599
|
+
file 'data_bags/x/z.json', {}
|
600
|
+
file 'data_bags/y/zz.json', {}
|
601
|
+
file 'environments/y.json', {}
|
602
|
+
file 'nodes/y.json', {}
|
603
|
+
file 'roles/y.json', {}
|
604
|
+
file 'users/y.json', { 'public_key' => ChefZero::PUBLIC_KEY }
|
791
605
|
|
792
606
|
it 'knife upload adds the new files' do
|
793
607
|
knife('upload /').should_succeed <<EOM
|
608
|
+
Created /clients/y.json
|
794
609
|
Updated /cookbooks/x-1.0.0
|
795
610
|
Created /cookbooks/x-2.0.0
|
796
611
|
Created /cookbooks/y-1.0.0
|
@@ -798,7 +613,9 @@ Created /data_bags/x/z.json
|
|
798
613
|
Created /data_bags/y
|
799
614
|
Created /data_bags/y/zz.json
|
800
615
|
Created /environments/y.json
|
616
|
+
Created /nodes/y.json
|
801
617
|
Created /roles/y.json
|
618
|
+
Created /users/y.json
|
802
619
|
EOM
|
803
620
|
knife('diff --name-status /').should_succeed ''
|
804
621
|
end
|
@@ -809,25 +626,34 @@ EOM
|
|
809
626
|
it 'knife upload does nothing' do
|
810
627
|
knife('upload /').should_succeed ''
|
811
628
|
knife('diff --name-status /').should_succeed <<EOM
|
629
|
+
D\t/clients
|
812
630
|
D\t/cookbooks
|
813
631
|
D\t/data_bags
|
814
632
|
D\t/environments
|
633
|
+
D\t/nodes
|
815
634
|
D\t/roles
|
635
|
+
D\t/users
|
816
636
|
EOM
|
817
637
|
end
|
818
638
|
|
819
639
|
it 'knife upload --purge deletes nothing' do
|
820
640
|
knife('upload --purge /').should_fail <<EOM
|
641
|
+
ERROR: /clients cannot be deleted.
|
821
642
|
ERROR: /cookbooks cannot be deleted.
|
822
643
|
ERROR: /data_bags cannot be deleted.
|
823
644
|
ERROR: /environments cannot be deleted.
|
645
|
+
ERROR: /nodes cannot be deleted.
|
824
646
|
ERROR: /roles cannot be deleted.
|
647
|
+
ERROR: /users cannot be deleted.
|
825
648
|
EOM
|
826
649
|
knife('diff --name-status /').should_succeed <<EOM
|
650
|
+
D\t/clients
|
827
651
|
D\t/cookbooks
|
828
652
|
D\t/data_bags
|
829
653
|
D\t/environments
|
654
|
+
D\t/nodes
|
830
655
|
D\t/roles
|
656
|
+
D\t/users
|
831
657
|
EOM
|
832
658
|
end
|
833
659
|
|
@@ -843,16 +669,9 @@ EOM
|
|
843
669
|
# Test upload of an item when the other end doesn't even have the container
|
844
670
|
when_the_chef_server 'is empty' do
|
845
671
|
when_the_repository 'has two data bag items' do
|
846
|
-
file 'data_bags/x/y.json',
|
847
|
-
{
|
848
|
-
|
849
|
-
}
|
850
|
-
EOM
|
851
|
-
file 'data_bags/x/z.json', <<EOM
|
852
|
-
{
|
853
|
-
"id": "z"
|
854
|
-
}
|
855
|
-
EOM
|
672
|
+
file 'data_bags/x/y.json', {}
|
673
|
+
file 'data_bags/x/z.json', {}
|
674
|
+
|
856
675
|
it 'knife upload of one data bag item itself succeeds' do
|
857
676
|
knife('upload /data_bags/x/y.json').should_succeed <<EOM
|
858
677
|
Created /data_bags/x
|
@@ -868,22 +687,10 @@ EOM
|
|
868
687
|
when_the_chef_server 'has three data bag items' do
|
869
688
|
data_bag 'x', { 'deleted' => {}, 'modified' => {}, 'unmodified' => {} }
|
870
689
|
when_the_repository 'has a modified, unmodified, added and deleted data bag item' do
|
871
|
-
file 'data_bags/x/added.json',
|
872
|
-
{
|
873
|
-
|
874
|
-
|
875
|
-
EOM
|
876
|
-
file 'data_bags/x/modified.json', <<EOM
|
877
|
-
{
|
878
|
-
"id": "modified",
|
879
|
-
"foo": "bar"
|
880
|
-
}
|
881
|
-
EOM
|
882
|
-
file 'data_bags/x/unmodified.json', <<EOM
|
883
|
-
{
|
884
|
-
"id": "unmodified"
|
885
|
-
}
|
886
|
-
EOM
|
690
|
+
file 'data_bags/x/added.json', {}
|
691
|
+
file 'data_bags/x/modified.json', { 'foo' => 'bar' }
|
692
|
+
file 'data_bags/x/unmodified.json', {}
|
693
|
+
|
887
694
|
it 'knife upload of the modified file succeeds' do
|
888
695
|
knife('upload /data_bags/x/modified.json').should_succeed <<EOM
|
889
696
|
Updated /data_bags/x/modified.json
|
@@ -974,14 +781,17 @@ EOM
|
|
974
781
|
# case.
|
975
782
|
when_the_chef_server 'has a cookbook' do
|
976
783
|
cookbook 'x', '1.0.0', { 'metadata.rb' => 'version "1.0.0"', 'z.rb' => '' }
|
784
|
+
|
977
785
|
when_the_repository 'has a modified, extra and missing file for the cookbook' do
|
978
786
|
file 'cookbooks/x-1.0.0/metadata.rb', 'version "1.0.0"'
|
979
787
|
file 'cookbooks/x-1.0.0/y.rb', 'hi'
|
788
|
+
|
980
789
|
it 'knife upload of any individual file fails' do
|
981
790
|
knife('upload /cookbooks/x-1.0.0/metadata.rb').should_fail "ERROR: /cookbooks/x-1.0.0/metadata.rb cannot be updated.\n"
|
982
791
|
knife('upload /cookbooks/x-1.0.0/y.rb').should_fail "ERROR: /cookbooks/x-1.0.0 cannot have a child created under it.\n"
|
983
792
|
knife('upload --purge /cookbooks/x-1.0.0/z.rb').should_fail "ERROR: /cookbooks/x-1.0.0/z.rb cannot be deleted.\n"
|
984
793
|
end
|
794
|
+
|
985
795
|
# TODO this is a bit of an inconsistency: if we didn't specify --purge,
|
986
796
|
# technically we shouldn't have deleted missing files. But ... cookbooks
|
987
797
|
# are a special case.
|
@@ -991,6 +801,7 @@ Updated /cookbooks/x-1.0.0
|
|
991
801
|
EOM
|
992
802
|
knife('diff --name-status /cookbooks').should_succeed ''
|
993
803
|
end
|
804
|
+
|
994
805
|
it 'knife upload --purge of the cookbook itself succeeds' do
|
995
806
|
knife('upload /cookbooks/x-1.0.0').should_succeed <<EOM
|
996
807
|
Updated /cookbooks/x-1.0.0
|
@@ -998,8 +809,10 @@ EOM
|
|
998
809
|
knife('diff --name-status /cookbooks').should_succeed ''
|
999
810
|
end
|
1000
811
|
end
|
812
|
+
|
1001
813
|
when_the_repository 'has a missing file for the cookbook' do
|
1002
814
|
file 'cookbooks/x-1.0.0/metadata.rb', 'version "1.0.0"'
|
815
|
+
|
1003
816
|
it 'knife upload of the cookbook succeeds' do
|
1004
817
|
knife('upload /cookbooks/x-1.0.0').should_succeed <<EOM
|
1005
818
|
Updated /cookbooks/x-1.0.0
|
@@ -1007,10 +820,12 @@ EOM
|
|
1007
820
|
knife('diff --name-status /cookbooks').should_succeed ''
|
1008
821
|
end
|
1009
822
|
end
|
823
|
+
|
1010
824
|
when_the_repository 'has an extra file for the cookbook' do
|
1011
825
|
file 'cookbooks/x-1.0.0/metadata.rb', 'version "1.0.0"'
|
1012
826
|
file 'cookbooks/x-1.0.0/z.rb', ''
|
1013
827
|
file 'cookbooks/x-1.0.0/blah.rb', ''
|
828
|
+
|
1014
829
|
it 'knife upload of the cookbook succeeds' do
|
1015
830
|
knife('upload /cookbooks/x-1.0.0').should_succeed <<EOM
|
1016
831
|
Updated /cookbooks/x-1.0.0
|