chef 12.0.0.alpha.1 → 12.0.0.alpha.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. checksums.yaml +4 -4
  2. data/lib/chef/application.rb +8 -1
  3. data/lib/chef/application/apply.rb +4 -0
  4. data/lib/chef/application/client.rb +7 -7
  5. data/lib/chef/application/solo.rb +21 -13
  6. data/lib/chef/chef_fs/chef_fs_data_store.rb +60 -6
  7. data/lib/chef/chef_fs/config.rb +78 -4
  8. data/lib/chef/chef_fs/data_handler/acl_data_handler.rb +2 -2
  9. data/lib/chef/chef_fs/data_handler/client_data_handler.rb +1 -1
  10. data/lib/chef/chef_fs/data_handler/container_data_handler.rb +1 -1
  11. data/lib/chef/chef_fs/data_handler/cookbook_data_handler.rb +1 -1
  12. data/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +1 -1
  13. data/lib/chef/chef_fs/data_handler/data_handler_base.rb +76 -2
  14. data/lib/chef/chef_fs/data_handler/environment_data_handler.rb +1 -1
  15. data/lib/chef/chef_fs/data_handler/group_data_handler.rb +1 -1
  16. data/lib/chef/chef_fs/data_handler/node_data_handler.rb +1 -1
  17. data/lib/chef/chef_fs/data_handler/organization_data_handler.rb +30 -0
  18. data/lib/chef/chef_fs/data_handler/organization_invites_data_handler.rb +17 -0
  19. data/lib/chef/chef_fs/data_handler/organization_members_data_handler.rb +17 -0
  20. data/lib/chef/chef_fs/data_handler/role_data_handler.rb +1 -1
  21. data/lib/chef/chef_fs/data_handler/user_data_handler.rb +2 -1
  22. data/lib/chef/chef_fs/file_system.rb +0 -1
  23. data/lib/chef/chef_fs/file_system/acl_entry.rb +1 -1
  24. data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_dir.rb +1 -1
  25. data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +5 -1
  26. data/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb +73 -13
  27. data/lib/chef/chef_fs/file_system/chef_server_root_dir.rb +44 -5
  28. data/lib/chef/chef_fs/file_system/cookbook_dir.rb +1 -1
  29. data/lib/chef/chef_fs/file_system/cookbooks_dir.rb +3 -3
  30. data/lib/chef/chef_fs/file_system/org_entry.rb +34 -0
  31. data/lib/chef/chef_fs/file_system/organization_invites_entry.rb +58 -0
  32. data/lib/chef/chef_fs/file_system/organization_members_entry.rb +57 -0
  33. data/lib/chef/chef_fs/file_system/rest_list_entry.rb +13 -4
  34. data/lib/chef/chef_fs/knife.rb +1 -1
  35. data/lib/chef/client.rb +8 -2
  36. data/lib/chef/config.rb +75 -57
  37. data/lib/chef/config_fetcher.rb +6 -21
  38. data/lib/chef/dsl/data_query.rb +48 -3
  39. data/lib/chef/dsl/platform_introspection.rb +42 -0
  40. data/lib/chef/dsl/reboot_pending.rb +6 -3
  41. data/lib/chef/encrypted_data_bag_item.rb +1 -1
  42. data/lib/chef/encrypted_data_bag_item/encryptor.rb +12 -0
  43. data/lib/chef/exceptions.rb +2 -0
  44. data/lib/chef/http/basic_client.rb +14 -0
  45. data/lib/chef/http/json_output.rb +7 -2
  46. data/lib/chef/knife.rb +36 -121
  47. data/lib/chef/knife/bootstrap.rb +68 -54
  48. data/lib/chef/knife/bootstrap/archlinux-gems.erb +6 -1
  49. data/lib/chef/knife/bootstrap/chef-aix.erb +5 -0
  50. data/lib/chef/knife/bootstrap/chef-full.erb +5 -1
  51. data/lib/chef/knife/core/bootstrap_context.rb +70 -29
  52. data/lib/chef/knife/search.rb +56 -12
  53. data/lib/chef/knife/serve.rb +1 -1
  54. data/lib/chef/local_mode.rb +10 -4
  55. data/lib/chef/mixin/deep_merge.rb +6 -3
  56. data/lib/chef/mixin/shell_out.rb +33 -17
  57. data/lib/chef/null_logger.rb +72 -0
  58. data/lib/chef/platform.rb +2 -1
  59. data/lib/chef/platform/provider_mapping.rb +1 -1
  60. data/lib/chef/platform/rebooter.rb +54 -0
  61. data/lib/chef/provider/ifconfig.rb +15 -16
  62. data/lib/chef/provider/link.rb +1 -1
  63. data/lib/chef/provider/mount/mount.rb +1 -1
  64. data/lib/chef/provider/mount/solaris.rb +102 -64
  65. data/lib/chef/provider/package/aix.rb +4 -12
  66. data/lib/chef/provider/package/ips.rb +8 -12
  67. data/lib/chef/provider/package/macports.rb +4 -12
  68. data/lib/chef/provider/package/pacman.rb +2 -6
  69. data/lib/chef/provider/package/portage.rb +2 -6
  70. data/lib/chef/provider/package/rpm.rb +4 -12
  71. data/lib/chef/provider/package/solaris.rb +4 -12
  72. data/lib/chef/provider/reboot.rb +69 -0
  73. data/lib/chef/provider/service/debian.rb +10 -10
  74. data/lib/chef/provider/service/freebsd.rb +89 -73
  75. data/lib/chef/provider/service/gentoo.rb +2 -2
  76. data/lib/chef/provider/service/init.rb +6 -4
  77. data/lib/chef/provider/service/insserv.rb +3 -3
  78. data/lib/chef/provider/service/macosx.rb +2 -2
  79. data/lib/chef/provider/service/simple.rb +6 -4
  80. data/lib/chef/provider/service/solaris.rb +1 -1
  81. data/lib/chef/provider/service/systemd.rb +9 -9
  82. data/lib/chef/provider/service/upstart.rb +6 -6
  83. data/lib/chef/provider/subversion.rb +6 -6
  84. data/lib/chef/provider/user/dscl.rb +32 -28
  85. data/lib/chef/provider/user/windows.rb +6 -6
  86. data/lib/chef/provider/whyrun_safe_ruby_block.rb +1 -1
  87. data/lib/chef/providers.rb +1 -0
  88. data/lib/chef/recipe.rb +0 -1
  89. data/lib/chef/resource.rb +3 -5
  90. data/lib/chef/resource/mount.rb +9 -0
  91. data/lib/chef/resource/reboot.rb +48 -0
  92. data/lib/chef/resources.rb +1 -0
  93. data/lib/chef/run_context.rb +25 -0
  94. data/lib/chef/search/query.rb +122 -14
  95. data/lib/chef/util/path_helper.rb +54 -6
  96. data/lib/chef/util/windows/net_user.rb +4 -1
  97. data/lib/chef/version.rb +1 -1
  98. data/lib/chef/win32/api/file.rb +1 -5
  99. data/lib/chef/win32/api/net.rb +1 -0
  100. data/lib/chef/workstation_config_loader.rb +177 -0
  101. data/spec/functional/http/simple_spec.rb +57 -1
  102. data/spec/functional/mixin/shell_out_spec.rb +2 -2
  103. data/spec/functional/provider/whyrun_safe_ruby_block_spec.rb +51 -0
  104. data/spec/functional/rebooter_spec.rb +105 -0
  105. data/spec/functional/resource/deploy_revision_spec.rb +0 -4
  106. data/spec/functional/resource/file_spec.rb +26 -3
  107. data/spec/functional/resource/group_spec.rb +5 -3
  108. data/spec/functional/resource/link_spec.rb +16 -16
  109. data/spec/functional/resource/reboot_spec.rb +103 -0
  110. data/spec/integration/client/client_spec.rb +4 -8
  111. data/spec/integration/client/ipv6_spec.rb +1 -1
  112. data/spec/integration/knife/cookbook_api_ipv6_spec.rb +3 -2
  113. data/spec/integration/knife/delete_spec.rb +39 -0
  114. data/spec/integration/knife/deps_spec.rb +30 -20
  115. data/spec/integration/knife/download_spec.rb +77 -1
  116. data/spec/integration/knife/list_spec.rb +221 -0
  117. data/spec/integration/knife/raw_spec.rb +1 -1
  118. data/spec/integration/knife/show_spec.rb +2 -2
  119. data/spec/integration/knife/upload_spec.rb +154 -1
  120. data/spec/support/pedant/run_pedant.rb +0 -1
  121. data/spec/support/shared/functional/http.rb +8 -1
  122. data/spec/support/shared/integration/integration_helper.rb +11 -19
  123. data/spec/support/shared/unit/platform_introspector.rb +22 -0
  124. data/spec/unit/application/apply.rb +11 -1
  125. data/spec/unit/application/solo_spec.rb +19 -3
  126. data/spec/unit/chef_fs/config_spec.rb +58 -0
  127. data/spec/unit/config_fetcher_spec.rb +1 -3
  128. data/spec/unit/config_spec.rb +247 -220
  129. data/spec/unit/dsl/data_query_spec.rb +165 -23
  130. data/spec/unit/dsl/reboot_pending_spec.rb +1 -7
  131. data/spec/unit/encrypted_data_bag_item_spec.rb +1 -1
  132. data/spec/unit/knife/bootstrap_spec.rb +354 -182
  133. data/spec/unit/knife/core/bootstrap_context_spec.rb +67 -30
  134. data/spec/unit/knife_spec.rb +3 -30
  135. data/spec/unit/mixin/deep_merge_spec.rb +14 -0
  136. data/spec/unit/mixin/shell_out_spec.rb +134 -64
  137. data/spec/unit/provider/ifconfig/debian_spec.rb +19 -9
  138. data/spec/unit/provider/ifconfig/redhat_spec.rb +16 -14
  139. data/spec/unit/provider/ifconfig_spec.rb +3 -3
  140. data/spec/unit/provider/link_spec.rb +5 -5
  141. data/spec/unit/provider/mount/mount_spec.rb +10 -1
  142. data/spec/unit/provider/mount/solaris_spec.rb +185 -11
  143. data/spec/unit/provider/package/aix_spec.rb +5 -17
  144. data/spec/unit/provider/package/ips_spec.rb +8 -21
  145. data/spec/unit/provider/package/macports_spec.rb +12 -12
  146. data/spec/unit/provider/package/pacman_spec.rb +4 -12
  147. data/spec/unit/provider/package/portage_spec.rb +5 -15
  148. data/spec/unit/provider/package/rpm_spec.rb +7 -22
  149. data/spec/unit/provider/package/solaris_spec.rb +5 -16
  150. data/spec/unit/provider/service/arch_service_spec.rb +8 -14
  151. data/spec/unit/provider/service/debian_service_spec.rb +1 -1
  152. data/spec/unit/provider/service/freebsd_service_spec.rb +457 -225
  153. data/spec/unit/provider/service/gentoo_service_spec.rb +2 -2
  154. data/spec/unit/provider/service/init_service_spec.rb +10 -10
  155. data/spec/unit/provider/service/insserv_service_spec.rb +3 -4
  156. data/spec/unit/provider/service/invokercd_service_spec.rb +8 -9
  157. data/spec/unit/provider/service/macosx_spec.rb +5 -5
  158. data/spec/unit/provider/service/simple_service_spec.rb +4 -6
  159. data/spec/unit/provider/service/solaris_smf_service_spec.rb +1 -3
  160. data/spec/unit/provider/service/systemd_service_spec.rb +20 -20
  161. data/spec/unit/provider/service/upstart_service_spec.rb +15 -17
  162. data/spec/unit/provider/subversion_spec.rb +5 -6
  163. data/spec/unit/provider/user/dscl_spec.rb +2 -1
  164. data/spec/unit/provider/user/windows_spec.rb +7 -0
  165. data/spec/unit/provider/whyrun_safe_ruby_block_spec.rb +2 -2
  166. data/spec/unit/resource/mount_spec.rb +9 -0
  167. data/spec/unit/resource_spec.rb +0 -4
  168. data/spec/unit/rest_spec.rb +1 -1
  169. data/spec/unit/run_context_spec.rb +15 -0
  170. data/spec/unit/search/query_spec.rb +196 -40
  171. data/spec/unit/util/path_helper_spec.rb +111 -28
  172. data/spec/unit/workstation_config_loader_spec.rb +283 -0
  173. metadata +36 -20
  174. data/lib/chef/knife/bootstrap/centos5-gems.erb +0 -62
  175. data/lib/chef/knife/bootstrap/fedora13-gems.erb +0 -44
  176. data/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb +0 -53
  177. data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +0 -48
  178. data/lib/chef/knife/bootstrap/ubuntu12.04-gems.erb +0 -46
  179. data/spec/support/shared/integration/chef_zero_support.rb +0 -130
  180. data/spec/unit/knife/config_file_selection_spec.rb +0 -135
@@ -1,130 +0,0 @@
1
- require 'tempfile'
2
- require 'chef_zero/server'
3
- require 'chef_zero/rest_request'
4
-
5
- # This is a copy of chef_zero/rspec, modified to implement contextual
6
- # helpers as instance_methods rather than class methods. This makes it
7
- # possible to use them with let bindings and other RSpec code reuse
8
- # mechanisms.
9
- #
10
- # Unfortunately, at the time of this writing, chef-zero master doesn't
11
- # work for our rspec tests, so in the interests of making forward
12
- # progress, we're using a modified version of the chef_zero/rspec code
13
- # here.
14
- #
15
- # This file should be entirely replaced by chef_zero/rspec once these
16
- # issues are fixed.
17
- module ChefZeroSupport
18
- module Server
19
-
20
- def self.server
21
- @server
22
- end
23
- def self.server=(value)
24
- @server = value
25
- end
26
- def self.client_key
27
- @client_key
28
- end
29
- def self.client_key=(value)
30
- @client_key = value
31
- end
32
- def self.request_log
33
- @request_log ||= []
34
- end
35
- def self.clear_request_log
36
- @request_log = []
37
- end
38
-
39
- end
40
-
41
- def client(name, client)
42
- ChefZeroSupport::Server.server.load_data({ 'clients' => { name => client }})
43
- end
44
-
45
- def cookbook(name, version, cookbook = {}, options = {})
46
-
47
- auto_metadata = "name '#{name}'; version '#{version}'"
48
-
49
- cookbook["metadata.rb"] ||= auto_metadata
50
-
51
- ChefZeroSupport::Server.server.load_data({ 'cookbooks' => { "#{name}-#{version}" => cookbook.merge(options) }})
52
- end
53
-
54
- def data_bag(name, data_bag)
55
- ChefZeroSupport::Server.server.load_data({ 'data' => { name => data_bag }})
56
- end
57
-
58
- def environment(name, environment)
59
- ChefZeroSupport::Server.server.load_data({ 'environments' => { name => environment }})
60
- end
61
-
62
- def node(name, node)
63
- ChefZeroSupport::Server.server.load_data({ 'nodes' => { name => node }})
64
- end
65
-
66
- def role(name, role)
67
- ChefZeroSupport::Server.server.load_data({ 'roles' => { name => role }})
68
- end
69
-
70
- def user(name, user)
71
- ChefZeroSupport::Server.server.load_data({ 'users' => { name => user }})
72
- end
73
-
74
- RSpec.shared_context "With chef-zero running" do
75
- before :each do
76
-
77
- default_opts = {:port => 8900, :signals => false, :log_requests => true}
78
- server_opts = if self.respond_to?(:chef_zero_opts)
79
- default_opts.merge(chef_zero_opts)
80
- else
81
- default_opts
82
- end
83
-
84
- if ChefZeroSupport::Server.server && server_opts.any? { |opt, value| ChefZeroSupport::Server.server.options[opt] != value }
85
- ChefZeroSupport::Server.server.stop
86
- ChefZeroSupport::Server.server = nil
87
- end
88
-
89
- unless ChefZeroSupport::Server.server
90
- # TODO: can this be logged easily?
91
- # pp :zero_opts => server_opts
92
-
93
- # Set up configuration so that clients will point to the server
94
- ChefZeroSupport::Server.server = ChefZero::Server.new(server_opts)
95
- ChefZeroSupport::Server.client_key = Tempfile.new(['chef_zero_client_key', '.pem'])
96
- ChefZeroSupport::Server.client_key.write(ChefZero::PRIVATE_KEY)
97
- ChefZeroSupport::Server.client_key.close
98
- # Start the server
99
- ChefZeroSupport::Server.server.start_background
100
- ChefZeroSupport::Server.server.on_response do |request, response|
101
- ChefZeroSupport::Server.request_log << [ request, response ]
102
- end
103
- else
104
- ChefZeroSupport::Server.server.clear_data
105
- end
106
- ChefZeroSupport::Server.clear_request_log
107
-
108
- if defined?(Chef::Config)
109
- @old_chef_server_url = Chef::Config.chef_server_url
110
- @old_node_name = Chef::Config.node_name
111
- @old_client_key = Chef::Config.client_key
112
- Chef::Config.chef_server_url = ChefZeroSupport::Server.server.url
113
- Chef::Config.node_name = 'admin'
114
- Chef::Config.client_key = ChefZeroSupport::Server.client_key.path
115
- Chef::Config.http_retry_count = 0
116
- end
117
- end
118
-
119
- if defined?(Chef::Config)
120
- after :each do
121
- Chef::Config.chef_server_url = @old_chef_server_url
122
- Chef::Config.node_name = @old_node_name
123
- Chef::Config.client_key = @old_client_key
124
- end
125
- end
126
-
127
- end
128
-
129
- end
130
-
@@ -1,135 +0,0 @@
1
- #
2
- # Author:: Nicolas Vinot (<aeris@imirhil.fr>)
3
- # Copyright:: Copyright (c) 2010 Opscode, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
20
- require 'tmpdir'
21
-
22
- describe Chef::Knife do
23
-
24
- let(:missing_config_fetcher) do
25
- double(Chef::ConfigFetcher, :config_missing? => true)
26
- end
27
-
28
- let(:available_config_fetcher) do
29
- double(Chef::ConfigFetcher, :config_missing? => false,
30
- :read_config => "")
31
- end
32
-
33
- def have_config_file(path)
34
- Chef::ConfigFetcher.should_receive(:new).at_least(1).times.with(path, nil).and_return(available_config_fetcher)
35
- end
36
-
37
- before do
38
- # Make sure tests can run when HOME is not set...
39
- @original_home = ENV["HOME"]
40
- ENV["HOME"] = Dir.tmpdir
41
- end
42
-
43
- after do
44
- ENV["HOME"] = @original_home
45
- end
46
-
47
- before :each do
48
- Chef::Config.stub(:from_file).and_return(true)
49
- Chef::ConfigFetcher.stub(:new).and_return(missing_config_fetcher)
50
- end
51
-
52
- it "configure knife from KNIFE_HOME env variable" do
53
- env_config = File.expand_path(File.join(Dir.tmpdir, 'knife.rb'))
54
- have_config_file(env_config)
55
-
56
- ENV['KNIFE_HOME'] = Dir.tmpdir
57
- @knife = Chef::Knife.new
58
- @knife.configure_chef
59
- @knife.config[:config_file].should == env_config
60
- end
61
-
62
- it "configure knife from PWD" do
63
- pwd_config = "#{Dir.pwd}/knife.rb"
64
- have_config_file(pwd_config)
65
-
66
- @knife = Chef::Knife.new
67
- @knife.configure_chef
68
- @knife.config[:config_file].should == pwd_config
69
- end
70
-
71
- it "configure knife from UPWARD" do
72
- upward_dir = File.expand_path "#{Dir.pwd}/.chef"
73
- upward_config = File.expand_path "#{upward_dir}/knife.rb"
74
- have_config_file(upward_config)
75
- Chef::Knife.stub(:chef_config_dir).and_return(upward_dir)
76
-
77
- @knife = Chef::Knife.new
78
- @knife.configure_chef
79
- @knife.config[:config_file].should == upward_config
80
- end
81
-
82
- it "configure knife from HOME" do
83
- home_config = File.expand_path(File.join("#{ENV['HOME']}", "/.chef/knife.rb"))
84
- have_config_file(home_config)
85
-
86
- @knife = Chef::Knife.new
87
- @knife.configure_chef
88
- @knife.config[:config_file].should == home_config
89
- end
90
-
91
- it "configure knife from nothing" do
92
- ::File.stub(:exist?).and_return(false)
93
- @knife = Chef::Knife.new
94
- @knife.ui.should_receive(:warn).with("No knife configuration file found")
95
- @knife.configure_chef
96
- @knife.config[:config_file].should be_nil
97
- end
98
-
99
- it "configure knife precedence" do
100
- env_config = File.join(Dir.tmpdir, 'knife.rb')
101
- pwd_config = "#{Dir.pwd}/knife.rb"
102
- upward_dir = File.expand_path "#{Dir.pwd}/.chef"
103
- upward_config = File.expand_path "#{upward_dir}/knife.rb"
104
- home_config = File.expand_path(File.join("#{ENV['HOME']}", "/.chef/knife.rb"))
105
- configs = [ env_config, pwd_config, upward_config, home_config ]
106
-
107
- Chef::Knife.stub(:chef_config_dir).and_return(upward_dir)
108
- ENV['KNIFE_HOME'] = Dir.tmpdir
109
-
110
- @knife = Chef::Knife.new
111
-
112
- @knife.configure_chef
113
- @knife.config[:config_file].should be_nil
114
-
115
- have_config_file(home_config)
116
- @knife = Chef::Knife.new
117
- @knife.configure_chef
118
- @knife.config[:config_file].should == home_config
119
-
120
- have_config_file(upward_config)
121
- @knife = Chef::Knife.new
122
- @knife.configure_chef
123
- @knife.config[:config_file].should == upward_config
124
-
125
- have_config_file(pwd_config)
126
- @knife = Chef::Knife.new
127
- @knife.configure_chef
128
- @knife.config[:config_file].should == pwd_config
129
-
130
- have_config_file(env_config)
131
- @knife = Chef::Knife.new
132
- @knife.configure_chef
133
- @knife.config[:config_file].should == env_config
134
- end
135
- end