knife-essentials 0.8.6 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/chef/knife/diff_essentials.rb +6 -1
- data/lib/chef_fs/command_line.rb +68 -75
- data/lib/chef_fs/data_handler/client_data_handler.rb +28 -0
- data/lib/chef_fs/data_handler/cookbook_data_handler.rb +36 -0
- data/lib/chef_fs/data_handler/data_bag_item_data_handler.rb +32 -0
- data/lib/chef_fs/data_handler/data_handler_base.rb +110 -0
- data/lib/chef_fs/data_handler/environment_data_handler.rb +38 -0
- data/lib/chef_fs/data_handler/node_data_handler.rb +34 -0
- data/lib/chef_fs/data_handler/role_data_handler.rb +38 -0
- data/lib/chef_fs/data_handler/user_data_handler.rb +20 -0
- data/lib/chef_fs/file_system.rb +4 -0
- data/lib/chef_fs/file_system/chef_repository_file_system_entry.rb +5 -7
- data/lib/chef_fs/file_system/chef_repository_file_system_root_dir.rb +14 -13
- data/lib/chef_fs/file_system/chef_server_root_dir.rb +6 -3
- data/lib/chef_fs/file_system/cookbook_file.rb +1 -5
- data/lib/chef_fs/file_system/data_bag_dir.rb +4 -9
- data/lib/chef_fs/file_system/data_bag_item.rb +6 -0
- data/lib/chef_fs/file_system/environments_dir.rb +2 -1
- data/lib/chef_fs/file_system/file_system_error.rb +3 -1
- data/lib/chef_fs/file_system/must_delete_recursively_error.rb +1 -4
- data/lib/chef_fs/file_system/nodes_dir.rb +2 -1
- data/lib/chef_fs/file_system/not_found_error.rb +1 -4
- data/lib/chef_fs/file_system/operation_failed_error.rb +32 -0
- data/lib/chef_fs/file_system/operation_not_allowed_error.rb +1 -2
- data/lib/chef_fs/file_system/rest_list_dir.rb +33 -6
- data/lib/chef_fs/file_system/rest_list_entry.rb +53 -15
- data/lib/chef_fs/version.rb +1 -1
- data/spec/chef_fs/file_system/chef_server_root_dir_spec.rb +1 -0
- data/spec/chef_fs/file_system/data_bags_dir_spec.rb +1 -0
- data/spec/integration/diff_spec.rb +75 -0
- data/spec/integration/download_spec.rb +27 -0
- data/spec/integration/raw_spec.rb +2 -24
- data/spec/integration/show_spec.rb +40 -23
- data/spec/integration/upload_spec.rb +61 -0
- metadata +11 -2
data/lib/chef_fs/version.rb
CHANGED
@@ -186,6 +186,13 @@ EOM
|
|
186
186
|
M\t/cookbooks/x/metadata.rb
|
187
187
|
D\t/cookbooks/x/onlyin1.0.1.rb
|
188
188
|
A\t/cookbooks/x/onlyin1.0.0.rb
|
189
|
+
EOM
|
190
|
+
end
|
191
|
+
|
192
|
+
it 'knife diff --diff-filter=MAT does not show deleted files' do
|
193
|
+
knife('diff --diff-filter=MAT --name-status /cookbooks/x').should_succeed <<EOM
|
194
|
+
M\t/cookbooks/x/metadata.rb
|
195
|
+
A\t/cookbooks/x/onlyin1.0.0.rb
|
189
196
|
EOM
|
190
197
|
end
|
191
198
|
end
|
@@ -222,4 +229,72 @@ EOM
|
|
222
229
|
end
|
223
230
|
end
|
224
231
|
end
|
232
|
+
|
233
|
+
context 'json diff tests' do
|
234
|
+
when_the_repository 'has an empty environment file' do
|
235
|
+
file 'environments/x.json', {}
|
236
|
+
when_the_chef_server 'has an empty environment' do
|
237
|
+
environment 'x', {}
|
238
|
+
it 'knife diff returns no differences' do
|
239
|
+
knife('diff /environments/x.json').should_succeed ''
|
240
|
+
end
|
241
|
+
end
|
242
|
+
when_the_chef_server 'has an environment with a different value' do
|
243
|
+
environment 'x', { 'description' => 'hi' }
|
244
|
+
it 'knife diff reports the difference', :pending => (RUBY_VERSION < "1.9") do
|
245
|
+
knife('diff /environments/x.json').should_succeed(/
|
246
|
+
{
|
247
|
+
- "name": "x",
|
248
|
+
- "description": "hi"
|
249
|
+
\+ "name": "x"
|
250
|
+
}
|
251
|
+
/)
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
when_the_repository 'has an environment file with a value in it' do
|
257
|
+
file 'environments/x.json', { 'description' => 'hi' }
|
258
|
+
when_the_chef_server 'has an environment with the same value' do
|
259
|
+
environment 'x', { 'description' => 'hi' }
|
260
|
+
it 'knife diff returns no differences' do
|
261
|
+
knife('diff /environments/x.json').should_succeed ''
|
262
|
+
end
|
263
|
+
end
|
264
|
+
when_the_chef_server 'has an environment with no value' do
|
265
|
+
environment 'x', {}
|
266
|
+
it 'knife diff reports the difference', :pending => (RUBY_VERSION < "1.9") do
|
267
|
+
knife('diff /environments/x.json').should_succeed(/
|
268
|
+
{
|
269
|
+
- "name": "x"
|
270
|
+
\+ "name": "x",
|
271
|
+
\+ "description": "hi"
|
272
|
+
}
|
273
|
+
/)
|
274
|
+
end
|
275
|
+
end
|
276
|
+
when_the_chef_server 'has an environment with a different value' do
|
277
|
+
environment 'x', { 'description' => 'lo' }
|
278
|
+
it 'knife diff reports the difference', :pending => (RUBY_VERSION < "1.9") do
|
279
|
+
knife('diff /environments/x.json').should_succeed(/
|
280
|
+
{
|
281
|
+
"name": "x",
|
282
|
+
- "description": "lo"
|
283
|
+
\+ "description": "hi"
|
284
|
+
}
|
285
|
+
/)
|
286
|
+
end
|
287
|
+
end
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
when_the_chef_server 'has an environment' do
|
292
|
+
environment 'x', {}
|
293
|
+
when_the_repository 'has an environment with bad JSON' do
|
294
|
+
file 'environments/x.json', '{'
|
295
|
+
it 'knife diff reports an error and does a textual diff' do
|
296
|
+
knife('diff /environments/x.json').should_succeed(/- "name": "x"/, :stderr => "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: A JSON text must at least contain two octets!\n")
|
297
|
+
end
|
298
|
+
end
|
299
|
+
end
|
225
300
|
end
|
@@ -497,4 +497,31 @@ EOM
|
|
497
497
|
end
|
498
498
|
end
|
499
499
|
end
|
500
|
+
|
501
|
+
when_the_chef_server 'has an environment' do
|
502
|
+
environment 'x', {}
|
503
|
+
when_the_repository 'has an environment with bad JSON' do
|
504
|
+
file 'environments/x.json', '{'
|
505
|
+
it 'knife download succeeds' do
|
506
|
+
knife('download /environments/x.json').should_succeed "Updated /environments/x.json\n", :stderr => "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: A JSON text must at least contain two octets!\n"
|
507
|
+
knife('diff --name-status /environments/x.json').should_succeed ''
|
508
|
+
end
|
509
|
+
end
|
510
|
+
|
511
|
+
when_the_repository 'has the same environment with the wrong name in the file' do
|
512
|
+
file 'environments/x.json', { 'name' => 'y' }
|
513
|
+
it 'knife download succeeds' do
|
514
|
+
knife('download /environments/x.json').should_succeed "Updated /environments/x.json\n"
|
515
|
+
knife('diff --name-status /environments/x.json').should_succeed ''
|
516
|
+
end
|
517
|
+
end
|
518
|
+
|
519
|
+
when_the_repository 'has the same environment with no name in the file' do
|
520
|
+
file 'environments/x.json', { 'description' => 'hi' }
|
521
|
+
it 'knife download succeeds' do
|
522
|
+
knife('download /environments/x.json').should_succeed "Updated /environments/x.json\n"
|
523
|
+
knife('diff --name-status /environments/x.json').should_succeed ''
|
524
|
+
end
|
525
|
+
end
|
526
|
+
end
|
500
527
|
end
|
@@ -104,18 +104,7 @@ EOM
|
|
104
104
|
/roles/x.json:
|
105
105
|
{
|
106
106
|
"name": "x",
|
107
|
-
"description": "eek"
|
108
|
-
"json_class": "Chef::Role",
|
109
|
-
"default_attributes": {
|
110
|
-
},
|
111
|
-
"override_attributes": {
|
112
|
-
},
|
113
|
-
"chef_type": "role",
|
114
|
-
"run_list": [
|
115
|
-
|
116
|
-
],
|
117
|
-
"env_run_lists": {
|
118
|
-
}
|
107
|
+
"description": "eek"
|
119
108
|
}
|
120
109
|
EOM
|
121
110
|
end
|
@@ -151,18 +140,7 @@ EOM
|
|
151
140
|
/roles/y.json:
|
152
141
|
{
|
153
142
|
"name": "y",
|
154
|
-
"description": "eek"
|
155
|
-
"json_class": "Chef::Role",
|
156
|
-
"default_attributes": {
|
157
|
-
},
|
158
|
-
"override_attributes": {
|
159
|
-
},
|
160
|
-
"chef_type": "role",
|
161
|
-
"run_list": [
|
162
|
-
|
163
|
-
],
|
164
|
-
"env_run_lists": {
|
165
|
-
}
|
143
|
+
"description": "eek"
|
166
144
|
}
|
167
145
|
EOM
|
168
146
|
end
|
@@ -56,16 +56,7 @@ EOM
|
|
56
56
|
knife('show /environments/x.json').should_succeed <<EOM
|
57
57
|
/environments/x.json:
|
58
58
|
{
|
59
|
-
"name": "x"
|
60
|
-
"description": "",
|
61
|
-
"cookbook_versions": {
|
62
|
-
},
|
63
|
-
"json_class": "Chef::Environment",
|
64
|
-
"chef_type": "environment",
|
65
|
-
"default_attributes": {
|
66
|
-
},
|
67
|
-
"override_attributes": {
|
68
|
-
}
|
59
|
+
"name": "x"
|
69
60
|
}
|
70
61
|
EOM
|
71
62
|
end
|
@@ -81,19 +72,7 @@ EOM
|
|
81
72
|
knife('show /roles/x.json').should_succeed <<EOM
|
82
73
|
/roles/x.json:
|
83
74
|
{
|
84
|
-
"name": "x"
|
85
|
-
"description": "",
|
86
|
-
"json_class": "Chef::Role",
|
87
|
-
"default_attributes": {
|
88
|
-
},
|
89
|
-
"override_attributes": {
|
90
|
-
},
|
91
|
-
"chef_type": "role",
|
92
|
-
"run_list": [
|
93
|
-
|
94
|
-
],
|
95
|
-
"env_run_lists": {
|
96
|
-
}
|
75
|
+
"name": "x"
|
97
76
|
}
|
98
77
|
EOM
|
99
78
|
end
|
@@ -121,4 +100,42 @@ EOM
|
|
121
100
|
end
|
122
101
|
end
|
123
102
|
end
|
103
|
+
|
104
|
+
when_the_chef_server 'has a hash with multiple keys' do
|
105
|
+
environment 'x', {
|
106
|
+
'default_attributes' => { 'foo' => 'bar' },
|
107
|
+
'cookbook_versions' => { 'blah' => '= 1.0.0'},
|
108
|
+
'override_attributes' => { 'x' => 'y' },
|
109
|
+
'description' => 'woo',
|
110
|
+
'name' => 'x'
|
111
|
+
}
|
112
|
+
it 'knife show shows the attributes in a predetermined order', :pending => (RUBY_VERSION < "1.8") do
|
113
|
+
knife('show /environments/x.json').should_succeed <<EOM
|
114
|
+
/environments/x.json:
|
115
|
+
{
|
116
|
+
"name": "x",
|
117
|
+
"description": "woo",
|
118
|
+
"cookbook_versions": {
|
119
|
+
"blah": "= 1.0.0"
|
120
|
+
},
|
121
|
+
"default_attributes": {
|
122
|
+
"foo": "bar"
|
123
|
+
},
|
124
|
+
"override_attributes": {
|
125
|
+
"x": "y"
|
126
|
+
}
|
127
|
+
}
|
128
|
+
EOM
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
when_the_repository 'has an environment with bad JSON' do
|
133
|
+
file 'environments/x.json', '{'
|
134
|
+
it 'knife show succeeds' do
|
135
|
+
knife('show --local /environments/x.json').should_succeed <<EOM
|
136
|
+
/environments/x.json:
|
137
|
+
{
|
138
|
+
EOM
|
139
|
+
end
|
140
|
+
end
|
124
141
|
end
|
@@ -513,4 +513,65 @@ EOM
|
|
513
513
|
end
|
514
514
|
end
|
515
515
|
end
|
516
|
+
|
517
|
+
when_the_chef_server 'has an environment' do
|
518
|
+
environment 'x', {}
|
519
|
+
when_the_repository 'has an environment with bad JSON' do
|
520
|
+
file 'environments/x.json', '{'
|
521
|
+
it 'knife upload tries and fails' do
|
522
|
+
knife('upload /environments/x.json').should_fail "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: A JSON text must at least contain two octets!\nERROR: /environments/x.json failed to write: Parse error reading JSON: A JSON text must at least contain two octets!\n"
|
523
|
+
knife('diff --name-status /environments/x.json').should_succeed "M\t/environments/x.json\n", :stderr => "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: A JSON text must at least contain two octets!\n"
|
524
|
+
end
|
525
|
+
end
|
526
|
+
|
527
|
+
when_the_repository 'has the same environment with the wrong name in the file' do
|
528
|
+
file 'environments/x.json', { 'name' => 'y' }
|
529
|
+
it 'knife upload fails' do
|
530
|
+
knife('upload /environments/x.json').should_fail "ERROR: /environments/x.json failed to write: Name in remote/environments/x.json/x.json must be 'x' (is 'y')\n"
|
531
|
+
knife('diff --name-status /environments/x.json').should_succeed "M\t/environments/x.json\n"
|
532
|
+
end
|
533
|
+
end
|
534
|
+
|
535
|
+
when_the_repository 'has the same environment with no name in the file' do
|
536
|
+
file 'environments/x.json', { 'description' => 'hi' }
|
537
|
+
it 'knife upload succeeds' do
|
538
|
+
knife('upload /environments/x.json').should_succeed "Updated /environments/x.json\n"
|
539
|
+
knife('diff --name-status /environments/x.json').should_succeed ''
|
540
|
+
end
|
541
|
+
end
|
542
|
+
end
|
543
|
+
|
544
|
+
when_the_chef_server 'is empty' do
|
545
|
+
when_the_repository 'has an environment with bad JSON' do
|
546
|
+
file 'environments/x.json', '{'
|
547
|
+
it 'knife upload tries and fails' do
|
548
|
+
knife('upload /environments/x.json').should_fail "ERROR: /environments failed to create_child: Parse error reading JSON creating child 'x.json': A JSON text must at least contain two octets!\n"
|
549
|
+
knife('diff --name-status /environments/x.json').should_succeed "A\t/environments/x.json\n"
|
550
|
+
end
|
551
|
+
end
|
552
|
+
|
553
|
+
when_the_repository 'has an environment with the wrong name in the file' do
|
554
|
+
file 'environments/x.json', { 'name' => 'y' }
|
555
|
+
it 'knife upload fails' do
|
556
|
+
knife('upload /environments/x.json').should_fail "ERROR: /environments failed to create_child: Name in remote/environments/x.json must be 'x' (is 'y')\n"
|
557
|
+
knife('diff --name-status /environments/x.json').should_succeed "A\t/environments/x.json\n"
|
558
|
+
end
|
559
|
+
end
|
560
|
+
|
561
|
+
when_the_repository 'has an environment with no name in the file' do
|
562
|
+
file 'environments/x.json', { 'description' => 'hi' }
|
563
|
+
it 'knife upload succeeds' do
|
564
|
+
knife('upload /environments/x.json').should_succeed "Created /environments/x.json\n"
|
565
|
+
knife('diff --name-status /environments/x.json').should_succeed ''
|
566
|
+
end
|
567
|
+
end
|
568
|
+
|
569
|
+
when_the_repository 'has a data bag with no id in the file' do
|
570
|
+
file 'data_bags/bag/x.json', { 'foo' => 'bar' }
|
571
|
+
it 'knife upload succeeds' do
|
572
|
+
knife('upload /data_bags/bag/x.json').should_succeed "Created /data_bags/bag\nCreated /data_bags/bag/x.json\n"
|
573
|
+
knife('diff --name-status /data_bags/bag/x.json').should_succeed ''
|
574
|
+
end
|
575
|
+
end
|
576
|
+
end
|
516
577
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-essentials
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: chef-zero
|
@@ -47,6 +47,14 @@ files:
|
|
47
47
|
- lib/chef/knife/show_essentials.rb
|
48
48
|
- lib/chef/knife/upload_essentials.rb
|
49
49
|
- lib/chef_fs/command_line.rb
|
50
|
+
- lib/chef_fs/data_handler/client_data_handler.rb
|
51
|
+
- lib/chef_fs/data_handler/cookbook_data_handler.rb
|
52
|
+
- lib/chef_fs/data_handler/data_bag_item_data_handler.rb
|
53
|
+
- lib/chef_fs/data_handler/data_handler_base.rb
|
54
|
+
- lib/chef_fs/data_handler/environment_data_handler.rb
|
55
|
+
- lib/chef_fs/data_handler/node_data_handler.rb
|
56
|
+
- lib/chef_fs/data_handler/role_data_handler.rb
|
57
|
+
- lib/chef_fs/data_handler/user_data_handler.rb
|
50
58
|
- lib/chef_fs/file_pattern.rb
|
51
59
|
- lib/chef_fs/file_system/base_fs_dir.rb
|
52
60
|
- lib/chef_fs/file_system/base_fs_object.rb
|
@@ -71,6 +79,7 @@ files:
|
|
71
79
|
- lib/chef_fs/file_system/nodes_dir.rb
|
72
80
|
- lib/chef_fs/file_system/nonexistent_fs_object.rb
|
73
81
|
- lib/chef_fs/file_system/not_found_error.rb
|
82
|
+
- lib/chef_fs/file_system/operation_failed_error.rb
|
74
83
|
- lib/chef_fs/file_system/operation_not_allowed_error.rb
|
75
84
|
- lib/chef_fs/file_system/rest_list_dir.rb
|
76
85
|
- lib/chef_fs/file_system/rest_list_entry.rb
|