chef 11.14.0.alpha.2-x86-mingw32 → 11.14.0.alpha.3-x86-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/bin/chef-service-manager +1 -1
  3. data/lib/chef/application.rb +8 -2
  4. data/lib/chef/chef_fs/command_line.rb +4 -4
  5. data/lib/chef/chef_fs/file_system.rb +3 -3
  6. data/lib/chef/chef_fs/parallelizer.rb +66 -90
  7. data/lib/chef/chef_fs/parallelizer/flatten_enumerable.rb +35 -0
  8. data/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb +279 -0
  9. data/lib/chef/config.rb +36 -2
  10. data/lib/chef/cookbook/cookbook_version_loader.rb +0 -1
  11. data/lib/chef/cookbook/synchronizer.rb +64 -42
  12. data/lib/chef/cookbook_uploader.rb +4 -25
  13. data/lib/chef/cookbook_version.rb +12 -11
  14. data/lib/chef/formatters/error_inspectors/api_error_formatting.rb +18 -1
  15. data/lib/chef/formatters/error_inspectors/cookbook_sync_error_inspector.rb +1 -3
  16. data/lib/chef/knife/bootstrap.rb +23 -1
  17. data/lib/chef/knife/bootstrap/chef-aix.erb +58 -0
  18. data/lib/chef/knife/bootstrap/chef-full.erb +16 -13
  19. data/lib/chef/knife/core/bootstrap_context.rb +25 -1
  20. data/lib/chef/knife/list.rb +9 -8
  21. data/lib/chef/knife/serve.rb +44 -0
  22. data/lib/chef/knife/show.rb +2 -3
  23. data/lib/chef/knife/ssh.rb +1 -0
  24. data/lib/chef/mixin/create_path.rb +20 -4
  25. data/lib/chef/node.rb +19 -3
  26. data/lib/chef/platform/provider_mapping.rb +0 -1
  27. data/lib/chef/platform/query_helpers.rb +4 -3
  28. data/lib/chef/provider/env/windows.rb +10 -3
  29. data/lib/chef/provider/file.rb +1 -1
  30. data/lib/chef/provider/mount.rb +84 -42
  31. data/lib/chef/provider/package/freebsd/base.rb +92 -0
  32. data/lib/chef/provider/package/freebsd/pkg.rb +113 -0
  33. data/lib/chef/provider/package/freebsd/pkgng.rb +80 -0
  34. data/lib/chef/provider/package/freebsd/port.rb +70 -0
  35. data/lib/chef/providers.rb +3 -1
  36. data/lib/chef/resource/chef_gem.rb +2 -1
  37. data/lib/chef/resource/freebsd_package.rb +39 -3
  38. data/lib/chef/resource/lwrp_base.rb +2 -2
  39. data/lib/chef/resource/mount.rb +9 -9
  40. data/lib/chef/util/threaded_job_queue.rb +61 -0
  41. data/lib/chef/version.rb +1 -1
  42. data/lib/chef/version/platform.rb +2 -0
  43. data/lib/chef/whitelist.rb +82 -0
  44. data/lib/chef/win32/registry.rb +0 -1
  45. data/lib/chef/win32/version.rb +4 -3
  46. data/spec/functional/win32/versions_spec.rb +4 -4
  47. data/spec/integration/client/ipv6_spec.rb +1 -1
  48. data/spec/integration/knife/chef_fs_data_store_spec.rb +1 -1
  49. data/spec/integration/knife/chef_repo_path_spec.rb +4 -1
  50. data/spec/integration/knife/common_options_spec.rb +9 -9
  51. data/spec/integration/knife/cookbook_api_ipv6_spec.rb +2 -2
  52. data/spec/integration/knife/deps_spec.rb +3 -0
  53. data/spec/integration/knife/list_spec.rb +3 -0
  54. data/spec/integration/knife/raw_spec.rb +5 -2
  55. data/spec/integration/knife/redirection_spec.rb +4 -1
  56. data/spec/integration/knife/serve_spec.rb +57 -0
  57. data/spec/integration/knife/show_spec.rb +3 -0
  58. data/spec/support/pedant/run_pedant.rb +1 -0
  59. data/spec/support/platform_helpers.rb +7 -5
  60. data/spec/support/shared/context/config.rb +21 -0
  61. data/spec/support/shared/functional/file_resource.rb +52 -0
  62. data/spec/unit/chef_fs/parallelizer.rb +482 -0
  63. data/spec/unit/client_spec.rb +4 -2
  64. data/spec/unit/config_spec.rb +66 -12
  65. data/spec/unit/knife/bootstrap_spec.rb +6 -0
  66. data/spec/unit/knife/core/bootstrap_context_spec.rb +31 -1
  67. data/spec/unit/node_spec.rb +73 -3
  68. data/spec/unit/provider/mount_spec.rb +102 -79
  69. data/spec/unit/provider/package/{freebsd_spec.rb → freebsd/pkg_spec.rb} +19 -32
  70. data/spec/unit/provider/package/freebsd/pkgng_spec.rb +155 -0
  71. data/spec/unit/provider/package/freebsd/port_spec.rb +160 -0
  72. data/spec/unit/resource/chef_gem_spec.rb +5 -0
  73. data/spec/unit/resource/freebsd_package_spec.rb +63 -11
  74. data/spec/unit/resource/mount_spec.rb +11 -0
  75. data/spec/unit/role_spec.rb +5 -1
  76. data/spec/unit/run_lock_spec.rb +2 -0
  77. data/spec/unit/util/threaded_job_queue_spec.rb +51 -0
  78. data/spec/unit/version/platform_spec.rb +1 -1
  79. metadata +176 -161
  80. data/lib/chef/provider/package/freebsd.rb +0 -149
@@ -37,14 +37,14 @@ class Chef
37
37
  def self.build_from_file(cookbook_name, filename, run_context)
38
38
  rname = filename_to_qualified_string(cookbook_name, filename)
39
39
 
40
- # Add log entry if we override an existing light-weight resource.
40
+ # Add log entry if we override an existing lightweight resource.
41
41
  class_name = convert_to_class_name(rname)
42
42
  if Resource.strict_const_defined?(class_name)
43
43
  old_class = Resource.send(:remove_const, class_name)
44
44
  # CHEF-3432 -- Chef::Resource keeps a list of subclasses; need to
45
45
  # remove old ones from the list when replacing.
46
46
  resource_classes.delete(old_class)
47
- Chef::Log.info("#{class_name} light-weight resource already initialized -- overriding!")
47
+ Chef::Log.info("#{class_name} lightweight resource already initialized -- overriding!")
48
48
  end
49
49
 
50
50
  resource_class = Class.new(self)
@@ -81,16 +81,17 @@ class Chef
81
81
  end
82
82
 
83
83
  def options(arg=nil)
84
- if arg.is_a?(String)
85
- converted_arg = arg.gsub(/,/, ' ').split(/ /)
84
+ ret = set_or_return(
85
+ :options,
86
+ arg,
87
+ :kind_of => [ Array, String ]
88
+ )
89
+
90
+ if ret.is_a? String
91
+ ret.gsub(/,/, ' ').split(/ /)
86
92
  else
87
- converted_arg = arg
93
+ ret
88
94
  end
89
- set_or_return(
90
- :options,
91
- converted_arg,
92
- :kind_of => [ Array ]
93
- )
94
95
  end
95
96
 
96
97
  def dump(arg=nil)
@@ -162,4 +163,3 @@ class Chef
162
163
  end
163
164
  end
164
165
  end
165
-
@@ -0,0 +1,61 @@
1
+ # Copyright:: Copyright (c) 2014 Opscode, Inc.
2
+ # License:: Apache License, Version 2.0
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ require 'thread'
17
+
18
+ class Chef
19
+ class Util
20
+ # A simple threaded job queue
21
+ #
22
+ # Create a queue:
23
+ #
24
+ # queue = ThreadedJobQueue.new
25
+ #
26
+ # Add jobs:
27
+ #
28
+ # queue << lambda { |lock| foo.the_bar }
29
+ #
30
+ # A job is a callable that optionally takes a Mutex instance as its only
31
+ # parameter.
32
+ #
33
+ # Then start processing jobs with +n+ threads:
34
+ #
35
+ # queue.process(n)
36
+ #
37
+ class ThreadedJobQueue
38
+ def initialize
39
+ @queue = Queue.new
40
+ @lock = Mutex.new
41
+ end
42
+
43
+ def <<(job)
44
+ @queue << job
45
+ end
46
+
47
+ def process(concurrency = 10)
48
+ workers = (1..concurrency).map do
49
+ Thread.new do
50
+ loop do
51
+ fn = @queue.pop
52
+ fn.arity == 1 ? fn.call(@lock) : fn.call
53
+ end
54
+ end
55
+ end
56
+ workers.each { |worker| self << Thread.method(:exit) }
57
+ workers.each { |worker| worker.join }
58
+ end
59
+ end
60
+ end
61
+ end
data/lib/chef/version.rb CHANGED
@@ -17,7 +17,7 @@
17
17
 
18
18
  class Chef
19
19
  CHEF_ROOT = File.dirname(File.expand_path(File.dirname(__FILE__)))
20
- VERSION = '11.14.0.alpha.2'
20
+ VERSION = '11.14.0.alpha.3'
21
21
  end
22
22
 
23
23
  # NOTE: the Chef::Version class is defined in version_class.rb
@@ -31,6 +31,8 @@ class Chef
31
31
  [ $1.to_i, $2.to_i, 0 ]
32
32
  when /^(\d+)$/
33
33
  [ $1.to_i, 0, 0 ]
34
+ when /^(\d+).(\d+)-[a-z]+\d?(-p(\d+))?$/i # Match FreeBSD
35
+ [ $1.to_i, $2.to_i, ($4 ? $4.to_i : 0)]
34
36
  else
35
37
  msg = "'#{str.to_s}' does not match 'x.y.z', 'x.y' or 'x'"
36
38
  raise Chef::Exceptions::InvalidPlatformVersion.new( msg )
@@ -0,0 +1,82 @@
1
+
2
+ require 'chef/exceptions'
3
+
4
+ class Chef
5
+ class Whitelist
6
+
7
+ # filter takes two arguments - the data you want to filter, and a whitelisted array
8
+ # of keys you want included. You can capture a subtree of the data to filter by
9
+ # providing a "/"-delimited string of keys. If some key includes "/"-characters,
10
+ # you must provide an array of keys instead.
11
+ #
12
+ # Whitelist.filter(
13
+ # { "filesystem" => {
14
+ # "/dev/disk" => {
15
+ # "size" => "10mb"
16
+ # },
17
+ # "map - autohome" => {
18
+ # "size" => "10mb"
19
+ # }
20
+ # },
21
+ # "network" => {
22
+ # "interfaces" => {
23
+ # "eth0" => {...},
24
+ # "eth1" => {...}
25
+ # }
26
+ # }
27
+ # },
28
+ # ["network/interfaces/eth0", ["filesystem", "/dev/disk"]])
29
+ # will capture the eth0 and /dev/disk subtrees.
30
+ def self.filter(data, whitelist=nil)
31
+ return data if whitelist.nil?
32
+
33
+ new_data = {}
34
+ whitelist.each do |item|
35
+ self.add_data(data, new_data, item)
36
+ end
37
+ new_data
38
+ end
39
+
40
+ private
41
+
42
+ # Walk the data has according to the keys provided by the whitelisted item
43
+ # and add the data to the whitelisting result.
44
+ def self.add_data(data, new_data, item)
45
+ parts = self.to_array(item)
46
+
47
+ all_data = data
48
+ filtered_data = new_data
49
+ parts[0..-2].each do |part|
50
+ unless all_data[part]
51
+ Chef::Log.warn("Could not find whitelist attribute #{item}.")
52
+ return nil
53
+ end
54
+
55
+ filtered_data[part] ||= {}
56
+ filtered_data = filtered_data[part]
57
+ all_data = all_data[part]
58
+ end
59
+
60
+ unless all_data[parts[-1]]
61
+ Chef::Log.warn("Could not find whitelist attribute #{item}.")
62
+ return nil
63
+ end
64
+
65
+ filtered_data[parts[-1]] = all_data[parts[-1]]
66
+ new_data
67
+ end
68
+
69
+ # Accepts a String or an Array, and returns an Array of String keys that
70
+ # are used to traverse the data hash. Strings are split on "/", Arrays are
71
+ # assumed to contain exact keys (that is, Array elements will not be split
72
+ # by "/").
73
+ def self.to_array(item)
74
+ return item if item.kind_of? Array
75
+
76
+ parts = item.split("/")
77
+ parts.shift if !parts.empty? && parts[0].empty?
78
+ parts
79
+ end
80
+
81
+ end
82
+ end
@@ -20,7 +20,6 @@ require 'chef/reserved_names'
20
20
 
21
21
  if RUBY_PLATFORM =~ /mswin|mingw32|windows/
22
22
  require 'win32/registry'
23
- require 'ruby-wmi'
24
23
  require 'win32/api'
25
24
  end
26
25
 
@@ -18,6 +18,7 @@
18
18
 
19
19
  require 'chef/win32/api'
20
20
  require 'chef/win32/api/system'
21
+ require 'wmi-lite/wmi'
21
22
 
22
23
  class Chef
23
24
  module ReservedNames::Win32
@@ -114,7 +115,6 @@ class Chef
114
115
  # version numbers on Windows Server 2012 R2 and Windows 8.1 --
115
116
  # WMI always returns the truth. See article at
116
117
  # http://msdn.microsoft.com/en-us/library/windows/desktop/ms724439(v=vs.85).aspx
117
- require 'ruby-wmi'
118
118
 
119
119
  # CHEF-4888: Work around ruby #2618, expected to be fixed in Ruby 2.1.0
120
120
  # https://github.com/ruby/ruby/commit/588504b20f5cc880ad51827b93e571e32446e5db
@@ -122,8 +122,9 @@ class Chef
122
122
 
123
123
  WIN32OLE.ole_initialize
124
124
 
125
- os_info = WMI::Win32_OperatingSystem.find(:first)
126
- os_version = os_info.send('Version')
125
+ wmi = WmiLite::Wmi.new
126
+ os_info = wmi.first_of('Win32_OperatingSystem')
127
+ os_version = os_info['version']
127
128
 
128
129
  WIN32OLE.ole_uninitialize
129
130
 
@@ -19,13 +19,13 @@
19
19
  require 'spec_helper'
20
20
  if Chef::Platform.windows?
21
21
  require 'chef/win32/version'
22
- require 'ruby-wmi'
23
22
  end
24
23
 
25
24
  describe "Chef::ReservedNames::Win32::Version", :windows_only, :not_supported_on_win2k3 do
26
25
  before do
27
26
 
28
- host = WMI::Win32_OperatingSystem.find(:first)
27
+ wmi = WmiLite::Wmi.new
28
+ host = wmi.first_of('Win32_OperatingSystem')
29
29
 
30
30
  # Use WMI to determine current OS version.
31
31
  # On Win2k8R2 and later, we can dynamically obtain marketing
@@ -44,7 +44,7 @@ describe "Chef::ReservedNames::Win32::Version", :windows_only, :not_supported_on
44
44
  # The name from WMI is actually what we want in Win2k8R2+.
45
45
  # So this expectation sould continue to hold without modification
46
46
  # as new versions of Windows are released.
47
- @current_os_version = host.caption
47
+ @current_os_version = host['caption']
48
48
  end
49
49
 
50
50
  @version = Chef::ReservedNames::Win32::Version.new
@@ -98,7 +98,7 @@ describe "Chef::ReservedNames::Win32::Version", :windows_only, :not_supported_on
98
98
  def is_windows_server_2008?(wmi_host)
99
99
  is_win2k8 = false
100
100
 
101
- os_version = wmi_host.send('Version')
101
+ os_version = wmi_host['version']
102
102
 
103
103
  # The operating system version is a string in the following form
104
104
  # that can be split into components based on the '.' delimiter:
@@ -62,7 +62,7 @@ END_VALIDATION_PEM
62
62
 
63
63
  let(:basic_config_file) do
64
64
  <<-END_CLIENT_RB
65
- chef_server_url "http://[::1]:8889"
65
+ chef_server_url "http://[::1]:8900"
66
66
  validation_key '#{path_to('config/validator.pem')}'
67
67
  cache_path '#{cache_path}'
68
68
  client_key '#{cache_path}/client.pem'
@@ -22,7 +22,7 @@ require 'chef/knife/show'
22
22
  require 'chef/knife/raw'
23
23
  require 'chef/knife/cookbook_upload'
24
24
 
25
- describe 'knife raw -z' do
25
+ describe 'ChefFSDataStore tests' do
26
26
  extend IntegrationSupport
27
27
  include KnifeSupport
28
28
 
@@ -16,6 +16,7 @@
16
16
  # limitations under the License.
17
17
 
18
18
  require 'support/shared/integration/integration_helper'
19
+ require 'support/shared/context/config'
19
20
  require 'chef/knife/list'
20
21
  require 'chef/knife/show'
21
22
 
@@ -101,7 +102,7 @@ EOM
101
102
  /users/
102
103
  /users/user3.json
103
104
  EOM
104
- end
105
+ end
105
106
 
106
107
  context 'when cwd is at the top level' do
107
108
  cwd '.'
@@ -801,6 +802,8 @@ EOM
801
802
  end
802
803
 
803
804
  context 'when data_bag_path is set and nothing else' do
805
+ include_context "default config options"
806
+
804
807
  before :each do
805
808
  %w(client cookbook environment node role user).each do |object_name|
806
809
  Chef::Config.delete("#{object_name}_path".to_sym)
@@ -37,16 +37,16 @@ describe 'knife common options' do
37
37
  Chef::Config.chef_zero.enabled = true
38
38
  end
39
39
 
40
- it 'knife raw /nodes/x should retrieve the role' do
40
+ it 'knife raw /nodes/x should retrieve the node' do
41
41
  knife('raw /nodes/x').should_succeed /"name": "x"/
42
42
  end
43
43
 
44
44
  context 'And chef_zero.port is 9999' do
45
45
  before(:each) { Chef::Config.chef_zero.port = 9999 }
46
-
47
- it 'knife raw /nodes/x should retrieve the role' do
46
+
47
+ it 'knife raw /nodes/x should retrieve the node' do
48
48
  knife('raw /nodes/x').should_succeed /"name": "x"/
49
- Chef::Config.chef_server_url.should == 'http://127.0.0.1:9999'
49
+ Chef::Config.chef_server_url.should == 'http://localhost:9999'
50
50
  end
51
51
  end
52
52
 
@@ -81,23 +81,23 @@ syHLXYFNy0OxMtH/bBAXBGNHd9gf5uOnqh0pYcbe/uRAxumC7Rl0cL509eURiA2T
81
81
  -----END RSA PRIVATE KEY-----
82
82
  EOM
83
83
 
84
- it 'knife raw /nodes/x should retrieve the role' do
84
+ it 'knife raw /nodes/x should retrieve the node' do
85
85
  knife('raw /nodes/x').should_succeed /"name": "x"/
86
86
  end
87
87
  end
88
88
  end
89
89
 
90
- it 'knife raw -z /nodes/x retrieves the role' do
90
+ it 'knife raw -z /nodes/x retrieves the node' do
91
91
  knife('raw -z /nodes/x').should_succeed /"name": "x"/
92
92
  end
93
93
 
94
- it 'knife raw --local-mode /nodes/x retrieves the role' do
94
+ it 'knife raw --local-mode /nodes/x retrieves the node' do
95
95
  knife('raw --local-mode /nodes/x').should_succeed /"name": "x"/
96
96
  end
97
97
 
98
- it 'knife raw -z --chef-zero-port=9999 /nodes/x retrieves the role' do
98
+ it 'knife raw -z --chef-zero-port=9999 /nodes/x retrieves the node' do
99
99
  knife('raw -z --chef-zero-port=9999 /nodes/x').should_succeed /"name": "x"/
100
- Chef::Config.chef_server_url.should == 'http://127.0.0.1:9999'
100
+ Chef::Config.chef_server_url.should == 'http://localhost:9999'
101
101
  end
102
102
  end
103
103
  end
@@ -74,7 +74,7 @@ END_VALIDATION_PEM
74
74
 
75
75
  let(:knife_rb_content) do
76
76
  <<-END_CLIENT_RB
77
- chef_server_url "http://[::1]:8889"
77
+ chef_server_url "http://[::1]:8900"
78
78
  syntax_check_cache_path '#{cache_path}'
79
79
  client_key '#{path_to('config/knifeuser.pem')}'
80
80
  node_name 'whoisthisis'
@@ -89,7 +89,7 @@ END_CLIENT_RB
89
89
 
90
90
  it "successfully uploads a cookbook" do
91
91
  shell_out!("knife cookbook upload apache2 #{knife_config_flag}", :cwd => chef_dir)
92
- versions_list_json = Chef::HTTP::Simple.new("http://[::1]:8889").get("/cookbooks/apache2", "accept" => "application/json")
92
+ versions_list_json = Chef::HTTP::Simple.new("http://[::1]:8900").get("/cookbooks/apache2", "accept" => "application/json")
93
93
  versions_list = Chef::JSONCompat.from_json(versions_list_json)
94
94
  versions_list["apache2"]["versions"].should_not be_empty
95
95
  end
@@ -16,6 +16,7 @@
16
16
  # limitations under the License.
17
17
 
18
18
  require 'support/shared/integration/integration_helper'
19
+ require 'support/shared/context/config'
19
20
  require 'chef/knife/deps'
20
21
 
21
22
  describe 'knife deps' do
@@ -340,6 +341,8 @@ EOM
340
341
  end
341
342
 
342
343
  context 'remote' do
344
+ include_context "default config options"
345
+
343
346
  when_the_chef_server 'has a role with no run_list' do
344
347
  role 'starring', {}
345
348
  it 'knife deps reports no dependencies' do
@@ -16,12 +16,15 @@
16
16
  # limitations under the License.
17
17
 
18
18
  require 'support/shared/integration/integration_helper'
19
+ require 'support/shared/context/config'
19
20
  require 'chef/knife/list'
20
21
 
21
22
  describe 'knife list' do
22
23
  extend IntegrationSupport
23
24
  include KnifeSupport
24
25
 
26
+ include_context "default config options"
27
+
25
28
  when_the_chef_server "is empty" do
26
29
  it "knife list / returns all top level directories" do
27
30
  knife('list /').should_succeed <<EOM
@@ -16,6 +16,7 @@
16
16
  # limitations under the License.
17
17
 
18
18
  require 'support/shared/integration/integration_helper'
19
+ require 'support/shared/context/config'
19
20
  require 'chef/knife/raw'
20
21
  require 'chef/knife/show'
21
22
 
@@ -24,6 +25,8 @@ describe 'knife raw' do
24
25
  include KnifeSupport
25
26
  include AppServerSupport
26
27
 
28
+ include_context "default config options"
29
+
27
30
  when_the_chef_server "has one of each thing" do
28
31
  client 'x', '{}'
29
32
  cookbook 'x', '1.0.0', { 'metadata.rb' => 'version "1.0.0"' }
@@ -166,7 +169,7 @@ EOM
166
169
 
167
170
  context 'When a server returns raw json' do
168
171
  before :each do
169
- Chef::Config.chef_server_url = "http://127.0.0.1:9018"
172
+ Chef::Config.chef_server_url = "http://localhost:9018"
170
173
  app = lambda do |env|
171
174
  [200, {'Content-Type' => 'application/json' }, ['{ "x": "y", "a": "b" }'] ]
172
175
  end
@@ -196,7 +199,7 @@ EOM
196
199
 
197
200
  context 'When a server returns text' do
198
201
  before :each do
199
- Chef::Config.chef_server_url = "http://127.0.0.1:9018"
202
+ Chef::Config.chef_server_url = "http://localhost:9018"
200
203
  app = lambda do |env|
201
204
  [200, {'Content-Type' => 'text' }, ['{ "x": "y", "a": "b" }'] ]
202
205
  end