knife-solo 0.3.0.pre2 → 0.3.0.pre3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/CHANGELOG.md +70 -27
  2. data/README.rdoc +11 -6
  3. data/Rakefile +4 -2
  4. data/lib/chef/knife/bootstrap_solo.rb +40 -0
  5. data/lib/chef/knife/solo_bootstrap.rb +1 -1
  6. data/lib/chef/knife/solo_clean.rb +16 -4
  7. data/lib/chef/knife/solo_cook.rb +111 -36
  8. data/lib/chef/knife/solo_init.rb +14 -0
  9. data/lib/chef/knife/solo_prepare.rb +1 -1
  10. data/lib/knife-solo/bootstraps.rb +0 -18
  11. data/lib/knife-solo/bootstraps/darwin.rb +4 -16
  12. data/lib/knife-solo/bootstraps/linux.rb +36 -48
  13. data/lib/knife-solo/info.rb +1 -1
  14. data/lib/knife-solo/resources/knife.rb +4 -0
  15. data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/.travis.yml +7 -0
  16. data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/CHANGELOG +16 -0
  17. data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/LICENSE +202 -0
  18. data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/NOTICE +18 -0
  19. data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/README.md +141 -0
  20. data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/libraries/search.rb +72 -0
  21. data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/libraries/search/overrides.rb +99 -0
  22. data/lib/{chef/knife/patches → knife-solo/resources/patch_cookbooks/chef-solo-search/libraries/search}/parser.rb +1 -2
  23. data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/libraries/vendor/chef/solr_query/lucene.treetop +150 -0
  24. data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/libraries/vendor/chef/solr_query/lucene_nodes.rb +285 -0
  25. data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/libraries/vendor/chef/solr_query/query_transform.rb +65 -0
  26. data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/metadata.rb +11 -0
  27. data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/recipes/default.rb +2 -0
  28. data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/tests/Gemfile +8 -0
  29. data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/tests/data/data_bags/node/alpha.json +10 -0
  30. data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/tests/data/data_bags/node/beta.json +10 -0
  31. data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/tests/data/data_bags/node/without_json_class.json +7 -0
  32. data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/tests/data/data_bags/users/jerry.json +8 -0
  33. data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/tests/data/data_bags/users/lea.json +10 -0
  34. data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/tests/data/data_bags/users/mike.json +13 -0
  35. data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/tests/data/data_bags/users/tom.json +10 -0
  36. data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/tests/test_data_bags.rb +44 -0
  37. data/lib/knife-solo/resources/patch_cookbooks/chef-solo-search/tests/test_search.rb +241 -0
  38. data/lib/knife-solo/resources/solo.rb.erb +10 -0
  39. data/lib/knife-solo/ssh_command.rb +4 -3
  40. data/lib/knife-solo/tools.rb +22 -0
  41. data/test/bootstraps_test.rb +4 -11
  42. data/test/integration/cases/encrypted_data_bag.rb +3 -0
  43. data/test/integration/cases/knife_bootstrap.rb +14 -0
  44. data/test/integration/debian6_bootstrap_test.rb +1 -1
  45. data/test/integration/{debian7_bootstrap_test.rb → debian7_knife_bootstrap_test.rb} +3 -3
  46. data/test/knife_bootstrap_test.rb +61 -0
  47. data/test/solo_cook_test.rb +78 -3
  48. data/test/support/integration_test.rb +8 -3
  49. data/test/tools_test.rb +82 -0
  50. metadata +63 -21
  51. data/lib/chef/knife/patches/search.rb +0 -110
  52. data/lib/knife-solo/config.rb +0 -39
  53. data/lib/knife-solo/resources/solo.rb +0 -6
  54. data/test/knife-solo/config_test.rb +0 -38
@@ -29,6 +29,50 @@ class SoloCookTest < TestCase
29
29
  end
30
30
  end
31
31
 
32
+ def test_expanded_config_paths_returns_empty_array_for_nil
33
+ Chef::Config[:foo] = nil
34
+ assert_equal [], command.expanded_config_paths(:foo)
35
+ end
36
+
37
+ def test_expanded_config_paths_returns_pathnames
38
+ Chef::Config[:foo] = ["foo"]
39
+ assert_instance_of Pathname, command.expanded_config_paths(:foo).first
40
+ end
41
+
42
+ def test_expanded_config_paths_expands_paths
43
+ Chef::Config[:foo] = ["foo", "/absolute/path"]
44
+ paths = command.expanded_config_paths(:foo)
45
+ assert_equal File.join(Dir.pwd, "foo"), paths[0].to_s
46
+ assert_equal "/absolute/path", paths[1].to_s
47
+ end
48
+
49
+ def test_patch_cookbooks_paths_exists
50
+ path = command.patch_cookbooks_path
51
+ refute_nil path, "patch_cookbooks_path should not be nil"
52
+ assert Dir.exist?(path), "patch_cookbooks_path is not a directory"
53
+ end
54
+
55
+ def test_cookbook_paths_includes_patch_cookbooks
56
+ cmd = command
57
+ assert_equal cmd.patch_cookbooks_path, cmd.cookbook_paths.last, "patch_cookbooks is not included"
58
+ end
59
+
60
+ def test_cookbook_paths_expands_paths
61
+ cmd = command
62
+ Chef::Config.cookbook_path = ["mycookbooks", "/some/other/path"]
63
+ assert_equal File.join(Dir.pwd, "mycookbooks"), cmd.cookbook_paths[0].to_s
64
+ assert_equal "/some/other/path", cmd.cookbook_paths[1].to_s
65
+ end
66
+
67
+ def test_add_cookbook_path_prepends_the_path
68
+ cmd = command
69
+ Chef::Config.cookbook_path = ["mycookbooks", "/some/other/path"]
70
+ cmd.add_cookbook_path "/new/path"
71
+ assert_equal "/new/path", cmd.cookbook_paths[0].to_s
72
+ assert_equal File.join(Dir.pwd, "mycookbooks"), cmd.cookbook_paths[1].to_s
73
+ assert_equal "/some/other/path", cmd.cookbook_paths[2].to_s
74
+ end
75
+
32
76
  def test_does_not_run_librarian_if_no_cheffile
33
77
  in_kitchen do
34
78
  Librarian::Action::Install.any_instance.expects(:run).never
@@ -38,7 +82,7 @@ class SoloCookTest < TestCase
38
82
 
39
83
  def test_runs_librarian_if_cheffile_found
40
84
  in_kitchen do
41
- File.open("Cheffile", 'w') {}
85
+ FileUtils.touch "Cheffile"
42
86
  Librarian::Action::Install.any_instance.expects(:run)
43
87
  command("somehost").run
44
88
  end
@@ -46,12 +90,43 @@ class SoloCookTest < TestCase
46
90
 
47
91
  def test_does_not_run_librarian_if_denied_by_option
48
92
  in_kitchen do
49
- File.open("Cheffile", 'w') {}
93
+ FileUtils.touch "Cheffile"
50
94
  Librarian::Action::Install.any_instance.expects(:run).never
51
95
  command("somehost", "--no-librarian").run
52
96
  end
53
97
  end
54
98
 
99
+ def test_complains_if_librarian_gem_missing
100
+ in_kitchen do
101
+ FileUtils.touch "Cheffile"
102
+ cmd = command("somehost")
103
+ cmd.expects(:load_librarian).returns(false)
104
+ cmd.ui.expects(:err).with(regexp_matches(/librarian-chef gem/))
105
+ Librarian::Action::Install.any_instance.expects(:run).never
106
+ cmd.run
107
+ end
108
+ end
109
+
110
+ def test_wont_complain_if_librarian_gem_missing_but_no_cheffile
111
+ in_kitchen do
112
+ cmd = command("somehost")
113
+ cmd.expects(:load_librarian).never
114
+ cmd.ui.expects(:err).never
115
+ Librarian::Action::Install.any_instance.expects(:run).never
116
+ cmd.run
117
+ end
118
+ end
119
+
120
+ def test_adds_librarian_path_to_cookbooks
121
+ ENV['LIBRARIAN_CHEF_PATH'] = "librarian/path"
122
+ in_kitchen do
123
+ FileUtils.touch "Cheffile"
124
+ cmd = command("somehost")
125
+ cmd.run
126
+ assert_equal File.join(Dir.pwd, "librarian/path"), cmd.cookbook_paths[0].to_s
127
+ end
128
+ end
129
+
55
130
  def test_validates_chef_version
56
131
  in_kitchen do
57
132
  cmd = command("somehost")
@@ -144,7 +219,7 @@ class SoloCookTest < TestCase
144
219
  def command(*args)
145
220
  cmd = knife_command(Chef::Knife::SoloCook, *args)
146
221
  cmd.stubs(:check_chef_version)
147
- cmd.stubs(:add_patches)
222
+ cmd.stubs(:run_portable_mkdir_p)
148
223
  cmd.stubs(:rsync)
149
224
  cmd.stubs(:stream_command).returns(SuccessfulResult.new)
150
225
  cmd
@@ -85,10 +85,15 @@ class IntegrationTest < TestCase
85
85
  "-i #{key_file} #{user}@#{server.public_ip_address}"
86
86
  end
87
87
 
88
- # Asserts that a prepare or cook command is successful
89
- def assert_subcommand(subcommand)
90
- system "knife solo #{subcommand} #{connection_string} -VV >> #{log_file}"
88
+ # Asserts that a knife command is successful
89
+ def assert_knife_command(subcommand)
90
+ system "knife #{subcommand} #{connection_string} -VV >> #{log_file}"
91
91
  assert $?.success?
92
92
  end
93
+
94
+ # Asserts that a knife solo subcommand is successful
95
+ def assert_subcommand(subcommand)
96
+ assert_knife_command "solo #{subcommand}"
97
+ end
93
98
  end
94
99
 
@@ -0,0 +1,82 @@
1
+ require 'test_helper'
2
+ require 'support/kitchen_helper'
3
+
4
+ require 'chef/config'
5
+ require 'knife-solo/tools'
6
+
7
+ class DummyToolsCommand < Chef::Knife
8
+ include KnifeSolo::Tools
9
+
10
+ option :foo,
11
+ :long => '--foo FOO'
12
+
13
+ option :boo,
14
+ :long => '--[no-]boo'
15
+ end
16
+
17
+ class ToolsTest < TestCase
18
+ include KitchenHelper
19
+
20
+ def setup
21
+ Chef::Config[:knife][:foo] = nil
22
+ Chef::Config[:knife][:boo] = nil
23
+ end
24
+
25
+ def test_config_value_defaults_to_nil
26
+ assert_nil command.config_value(:foo)
27
+ assert_nil command.config_value(:boo)
28
+ end
29
+
30
+ def test_config_value_returns_the_default
31
+ assert_equal 'bar', command.config_value(:foo, 'bar')
32
+
33
+ assert_equal true, command.config_value(:boo, true)
34
+ assert_equal false, command.config_value(:boo, false)
35
+ end
36
+
37
+ def test_config_value_uses_cli_option
38
+ assert_equal 'bar', command('--foo=bar').config_value(:foo)
39
+ assert_equal 'bar', command('--foo=bar').config_value(:foo, 'baz')
40
+
41
+ assert_equal true, command('--boo').config_value(:boo)
42
+ assert_equal true, command('--boo').config_value(:boo, false)
43
+ assert_equal false, command('--no-boo').config_value(:boo)
44
+ assert_equal false, command('--no-boo').config_value(:boo, true)
45
+ end
46
+
47
+ def test_config_value_uses_configuration
48
+ Chef::Config[:knife][:foo] = 'bar'
49
+ assert_equal 'bar', command.config_value(:foo)
50
+ assert_equal 'bar', command.config_value(:foo, 'baz')
51
+
52
+ Chef::Config[:knife][:boo] = true
53
+ assert_equal true, command.config_value(:boo)
54
+ assert_equal true, command.config_value(:boo, false)
55
+
56
+ Chef::Config[:knife][:boo] = false
57
+ assert_equal false, command.config_value(:boo)
58
+ assert_equal false, command.config_value(:boo, true)
59
+ end
60
+
61
+ def test_config_value_prefers_cli_option
62
+ Chef::Config[:knife][:foo] = 'foo'
63
+ assert_equal 'bar', command('--foo=bar').config_value(:foo)
64
+ assert_equal 'bar', command('--foo=bar').config_value(:foo, 'baz')
65
+
66
+ Chef::Config[:knife][:boo] = true
67
+ assert_equal true, command('--boo').config_value(:boo)
68
+ assert_equal true, command('--boo').config_value(:boo, false)
69
+ assert_equal false, command('--no-boo').config_value(:boo)
70
+ assert_equal false, command('--no-boo').config_value(:boo, true)
71
+
72
+ Chef::Config[:knife][:boo] = false
73
+ assert_equal true, command('--boo').config_value(:boo)
74
+ assert_equal true, command('--boo').config_value(:boo, false)
75
+ assert_equal false, command('--no-boo').config_value(:boo)
76
+ assert_equal false, command('--no-boo').config_value(:boo, true)
77
+ end
78
+
79
+ def command(*args)
80
+ knife_command(DummyToolsCommand, *args)
81
+ end
82
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-solo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.pre2
4
+ version: 0.3.0.pre3
5
5
  prerelease: 6
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-02-20 00:00:00.000000000 Z
12
+ date: 2013-04-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -28,7 +28,7 @@ dependencies:
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
30
  - !ruby/object:Gem::Dependency
31
- name: rake
31
+ name: fog
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
@@ -44,7 +44,7 @@ dependencies:
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
46
  - !ruby/object:Gem::Dependency
47
- name: mocha
47
+ name: librarian-chef
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
@@ -60,7 +60,7 @@ dependencies:
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  - !ruby/object:Gem::Dependency
63
- name: rdoc
63
+ name: minitest
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  none: false
66
66
  requirements:
@@ -76,7 +76,7 @@ dependencies:
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
78
  - !ruby/object:Gem::Dependency
79
- name: fog
79
+ name: mocha
80
80
  requirement: !ruby/object:Gem::Requirement
81
81
  none: false
82
82
  requirements:
@@ -92,7 +92,7 @@ dependencies:
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
94
  - !ruby/object:Gem::Dependency
95
- name: minitest
95
+ name: parallel
96
96
  requirement: !ruby/object:Gem::Requirement
97
97
  none: false
98
98
  requirements:
@@ -108,7 +108,23 @@ dependencies:
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
110
  - !ruby/object:Gem::Dependency
111
- name: parallel
111
+ name: rake
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: rdoc
112
128
  requirement: !ruby/object:Gem::Requirement
113
129
  none: false
114
130
  requirements:
@@ -162,13 +178,13 @@ dependencies:
162
178
  - !ruby/object:Gem::Version
163
179
  version: '3.0'
164
180
  - !ruby/object:Gem::Dependency
165
- name: librarian
181
+ name: erubis
166
182
  requirement: !ruby/object:Gem::Requirement
167
183
  none: false
168
184
  requirements:
169
185
  - - ~>
170
186
  - !ruby/object:Gem::Version
171
- version: 0.0.20
187
+ version: 2.7.0
172
188
  type: :runtime
173
189
  prerelease: false
174
190
  version_requirements: !ruby/object:Gem::Requirement
@@ -176,7 +192,7 @@ dependencies:
176
192
  requirements:
177
193
  - - ~>
178
194
  - !ruby/object:Gem::Version
179
- version: 0.0.20
195
+ version: 2.7.0
180
196
  description: Handles bootstrapping, running chef solo, rsyncing cookbooks etc
181
197
  email: mat@schaffer.me
182
198
  executables: []
@@ -187,10 +203,9 @@ files:
187
203
  - LICENSE
188
204
  - README.rdoc
189
205
  - Rakefile
206
+ - lib/chef/knife/bootstrap_solo.rb
190
207
  - lib/chef/knife/cook.rb
191
208
  - lib/chef/knife/kitchen.rb
192
- - lib/chef/knife/patches/parser.rb
193
- - lib/chef/knife/patches/search.rb
194
209
  - lib/chef/knife/prepare.rb
195
210
  - lib/chef/knife/solo_bootstrap.rb
196
211
  - lib/chef/knife/solo_clean.rb
@@ -204,12 +219,12 @@ files:
204
219
  - lib/knife-solo/bootstraps/freebsd.rb
205
220
  - lib/knife-solo/bootstraps/linux.rb
206
221
  - lib/knife-solo/bootstraps/sun_os.rb
207
- - lib/knife-solo/config.rb
208
222
  - lib/knife-solo/deprecated_command.rb
209
223
  - lib/knife-solo/gitignore.rb
210
224
  - lib/knife-solo/info.rb
211
225
  - lib/knife-solo/node_config_command.rb
212
- - lib/knife-solo/resources/solo.rb
226
+ - lib/knife-solo/resources/knife.rb
227
+ - lib/knife-solo/resources/solo.rb.erb
213
228
  - lib/knife-solo/ssh_command.rb
214
229
  - lib/knife-solo/tools.rb
215
230
  - test/bootstraps_test.rb
@@ -221,9 +236,10 @@ files:
221
236
  - test/integration/cases/cache_path_usage.rb
222
237
  - test/integration/cases/empty_cook.rb
223
238
  - test/integration/cases/encrypted_data_bag.rb
239
+ - test/integration/cases/knife_bootstrap.rb
224
240
  - test/integration/centos5_6_test.rb
225
241
  - test/integration/debian6_bootstrap_test.rb
226
- - test/integration/debian7_bootstrap_test.rb
242
+ - test/integration/debian7_knife_bootstrap_test.rb
227
243
  - test/integration/gentoo2011_test.rb
228
244
  - test/integration/omnios_r151004_test.rb
229
245
  - test/integration/scientific_linux_63_test.rb
@@ -232,7 +248,7 @@ files:
232
248
  - test/integration/ubuntu12_04_bootstrap_test.rb
233
249
  - test/integration/ubuntu12_04_test.rb
234
250
  - test/integration_helper.rb
235
- - test/knife-solo/config_test.rb
251
+ - test/knife_bootstrap_test.rb
236
252
  - test/minitest/parallel.rb
237
253
  - test/node_config_command_test.rb
238
254
  - test/solo_bootstrap_test.rb
@@ -258,7 +274,31 @@ files:
258
274
  - test/support/test_case.rb
259
275
  - test/support/validation_helper.rb
260
276
  - test/test_helper.rb
261
- homepage: http://matschaffer.github.com/knife-solo/
277
+ - test/tools_test.rb
278
+ - lib/knife-solo/resources/patch_cookbooks/chef-solo-search/.travis.yml
279
+ - lib/knife-solo/resources/patch_cookbooks/chef-solo-search/CHANGELOG
280
+ - lib/knife-solo/resources/patch_cookbooks/chef-solo-search/LICENSE
281
+ - lib/knife-solo/resources/patch_cookbooks/chef-solo-search/NOTICE
282
+ - lib/knife-solo/resources/patch_cookbooks/chef-solo-search/README.md
283
+ - lib/knife-solo/resources/patch_cookbooks/chef-solo-search/libraries/search.rb
284
+ - lib/knife-solo/resources/patch_cookbooks/chef-solo-search/libraries/search/overrides.rb
285
+ - lib/knife-solo/resources/patch_cookbooks/chef-solo-search/libraries/search/parser.rb
286
+ - lib/knife-solo/resources/patch_cookbooks/chef-solo-search/libraries/vendor/chef/solr_query/lucene.treetop
287
+ - lib/knife-solo/resources/patch_cookbooks/chef-solo-search/libraries/vendor/chef/solr_query/lucene_nodes.rb
288
+ - lib/knife-solo/resources/patch_cookbooks/chef-solo-search/libraries/vendor/chef/solr_query/query_transform.rb
289
+ - lib/knife-solo/resources/patch_cookbooks/chef-solo-search/metadata.rb
290
+ - lib/knife-solo/resources/patch_cookbooks/chef-solo-search/recipes/default.rb
291
+ - lib/knife-solo/resources/patch_cookbooks/chef-solo-search/tests/Gemfile
292
+ - lib/knife-solo/resources/patch_cookbooks/chef-solo-search/tests/data/data_bags/node/alpha.json
293
+ - lib/knife-solo/resources/patch_cookbooks/chef-solo-search/tests/data/data_bags/node/beta.json
294
+ - lib/knife-solo/resources/patch_cookbooks/chef-solo-search/tests/data/data_bags/node/without_json_class.json
295
+ - lib/knife-solo/resources/patch_cookbooks/chef-solo-search/tests/data/data_bags/users/jerry.json
296
+ - lib/knife-solo/resources/patch_cookbooks/chef-solo-search/tests/data/data_bags/users/lea.json
297
+ - lib/knife-solo/resources/patch_cookbooks/chef-solo-search/tests/data/data_bags/users/mike.json
298
+ - lib/knife-solo/resources/patch_cookbooks/chef-solo-search/tests/data/data_bags/users/tom.json
299
+ - lib/knife-solo/resources/patch_cookbooks/chef-solo-search/tests/test_data_bags.rb
300
+ - lib/knife-solo/resources/patch_cookbooks/chef-solo-search/tests/test_search.rb
301
+ homepage: http://matschaffer.github.io/knife-solo/
262
302
  licenses: []
263
303
  post_install_message: ! "Thanks for installing knife-solo!\n\nIf you run into any
264
304
  issues please let us know at:\n https://github.com/matschaffer/knife-solo/issues\n\nIf
@@ -276,7 +316,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
276
316
  version: '0'
277
317
  segments:
278
318
  - 0
279
- hash: -3096439346196899405
319
+ hash: 281010758936316492
280
320
  required_rubygems_version: !ruby/object:Gem::Requirement
281
321
  none: false
282
322
  requirements:
@@ -299,9 +339,10 @@ test_files:
299
339
  - test/integration/cases/cache_path_usage.rb
300
340
  - test/integration/cases/empty_cook.rb
301
341
  - test/integration/cases/encrypted_data_bag.rb
342
+ - test/integration/cases/knife_bootstrap.rb
302
343
  - test/integration/centos5_6_test.rb
303
344
  - test/integration/debian6_bootstrap_test.rb
304
- - test/integration/debian7_bootstrap_test.rb
345
+ - test/integration/debian7_knife_bootstrap_test.rb
305
346
  - test/integration/gentoo2011_test.rb
306
347
  - test/integration/omnios_r151004_test.rb
307
348
  - test/integration/scientific_linux_63_test.rb
@@ -310,7 +351,7 @@ test_files:
310
351
  - test/integration/ubuntu12_04_bootstrap_test.rb
311
352
  - test/integration/ubuntu12_04_test.rb
312
353
  - test/integration_helper.rb
313
- - test/knife-solo/config_test.rb
354
+ - test/knife_bootstrap_test.rb
314
355
  - test/minitest/parallel.rb
315
356
  - test/node_config_command_test.rb
316
357
  - test/solo_bootstrap_test.rb
@@ -336,3 +377,4 @@ test_files:
336
377
  - test/support/test_case.rb
337
378
  - test/support/validation_helper.rb
338
379
  - test/test_helper.rb
380
+ - test/tools_test.rb
@@ -1,110 +0,0 @@
1
- #
2
- # Copyright 2011, edelight GmbH
3
- #
4
- # Authors:
5
- # Markus Korn <markus.korn@edelight.de>
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
- #
19
-
20
- if Chef::Config[:solo]
21
-
22
- if (defined? require_relative).nil?
23
- # defenition of 'require_relative' for ruby < 1.9, found on stackoverflow.com
24
- def require_relative(relative_feature)
25
- c = caller.first
26
- fail "Can't parse #{c}" unless c.rindex(/:\d+(:in `.*')?$/)
27
- file = $`
28
- if /\A\((.*)\)/ =~ file # eval, etc.
29
- raise LoadError, "require_relative is called in #{$1}"
30
- end
31
- absolute = File.expand_path(relative_feature, File.dirname(file))
32
- require absolute
33
- end
34
- end
35
-
36
- require_relative 'parser.rb'
37
-
38
- class Chef
39
- module Mixin
40
- module Language
41
-
42
- # Overwrite the search method of recipes to operate locally by using
43
- # data found in data_bags.
44
- # Only very basic lucene syntax is supported and also sorting the result
45
- # is not implemented, if this search method does not support a given query
46
- # an exception is raised.
47
- # This search() method returns a block iterator or an Array, depending
48
- # on how this method is called.
49
- def search(obj, query=nil, sort=nil, start=0, rows=1000, &block)
50
- if !sort.nil?
51
- raise "Sorting search results is not supported"
52
- end
53
- @_query = Query.parse(query)
54
- if @_query.nil?
55
- raise "Query #{query} is not supported"
56
- end
57
- @_result = []
58
-
59
- case obj
60
- when :node
61
- search_nodes(start, rows, &block)
62
- when :role
63
- search_roles(start, rows, &block)
64
- else
65
- search_data_bag(obj, start, rows, &block)
66
- end
67
-
68
-
69
- if block_given?
70
- pos = 0
71
- while (pos >= start and pos < (start + rows) and pos < @_result.size)
72
- yield @_result[pos]
73
- pos += 1
74
- end
75
- else
76
- return @_result.slice(start, rows)
77
- end
78
- end
79
-
80
- def search_nodes(start, rows, &block)
81
- Dir.glob(File.join(Chef::Config[:data_bag_path], "node", "*.json")).map do |f|
82
- # parse and hashify the node
83
- node = JSON.parse(IO.read(f))
84
- if @_query.match(node.to_hash)
85
- @_result << node
86
- end
87
- end
88
- end
89
-
90
- def search_roles(start, rows, &block)
91
- raise "Role searching not implemented"
92
- end
93
-
94
- def search_data_bag(bag_name, start, rows, &block)
95
- secret_path = Chef::Config[:encrypted_data_bag_secret]
96
- data_bag(bag_name.to_s).each do |bag_item_id|
97
- if secret_path && secret = Chef::EncryptedDataBagItem.load_secret(secret_path)
98
- bag_item = Chef::EncryptedDataBagItem.load(bag_name, bag_item_id, secret)
99
- else
100
- bag_item = data_bag_item(bag_name.to_s, bag_item_id)
101
- end
102
- if @_query.match(bag_item)
103
- @_result << bag_item
104
- end
105
- end
106
- end
107
- end
108
- end
109
- end
110
- end