chef 12.4.0-universal-mingw32 → 12.4.1-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chef/api_client.rb +31 -129
- data/lib/chef/api_client_v1.rb +325 -0
- data/lib/chef/chef_class.rb +15 -7
- data/lib/chef/chef_fs/file_system/chef_server_root_dir.rb +2 -2
- data/lib/chef/dsl/resources.rb +6 -4
- data/lib/chef/exceptions.rb +2 -2
- data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +2 -1
- data/lib/chef/knife/bootstrap/templates/chef-full.erb +4 -4
- data/lib/chef/knife/client_bulk_delete.rb +2 -2
- data/lib/chef/knife/client_create.rb +4 -4
- data/lib/chef/knife/client_delete.rb +3 -3
- data/lib/chef/knife/client_edit.rb +10 -2
- data/lib/chef/knife/client_list.rb +2 -2
- data/lib/chef/knife/client_reregister.rb +2 -2
- data/lib/chef/knife/client_show.rb +2 -2
- data/lib/chef/knife/osc_user_create.rb +3 -3
- data/lib/chef/knife/osc_user_delete.rb +2 -2
- data/lib/chef/knife/osc_user_edit.rb +3 -3
- data/lib/chef/knife/osc_user_list.rb +2 -2
- data/lib/chef/knife/osc_user_reregister.rb +2 -2
- data/lib/chef/knife/osc_user_show.rb +2 -2
- data/lib/chef/knife/user_create.rb +3 -3
- data/lib/chef/knife/user_delete.rb +4 -4
- data/lib/chef/knife/user_edit.rb +3 -3
- data/lib/chef/knife/user_list.rb +2 -2
- data/lib/chef/knife/user_reregister.rb +2 -2
- data/lib/chef/knife/user_show.rb +2 -2
- data/lib/chef/node_map.rb +14 -18
- data/lib/chef/platform/handler_map.rb +45 -0
- data/lib/chef/platform/priority_map.rb +19 -32
- data/lib/chef/platform/provider_handler_map.rb +29 -0
- data/lib/chef/platform/provider_mapping.rb +3 -2
- data/lib/chef/platform/resource_handler_map.rb +29 -0
- data/lib/chef/platform/resource_priority_map.rb +0 -6
- data/lib/chef/provider.rb +1 -1
- data/lib/chef/provider/dsc_resource.rb +2 -2
- data/lib/chef/provider/dsc_script.rb +1 -1
- data/lib/chef/provider/mount/aix.rb +1 -1
- data/lib/chef/provider/package.rb +0 -31
- data/lib/chef/provider/package/aix.rb +1 -0
- data/lib/chef/provider/package/apt.rb +1 -0
- data/lib/chef/provider/package/homebrew.rb +1 -0
- data/lib/chef/provider/package/ips.rb +1 -0
- data/lib/chef/provider/package/macports.rb +1 -0
- data/lib/chef/provider/package/openbsd.rb +1 -0
- data/lib/chef/provider/package/pacman.rb +1 -0
- data/lib/chef/provider/package/paludis.rb +1 -0
- data/lib/chef/provider/package/portage.rb +2 -0
- data/lib/chef/provider/package/smartos.rb +1 -0
- data/lib/chef/provider/package/solaris.rb +2 -0
- data/lib/chef/provider/package/yum.rb +1 -0
- data/lib/chef/provider/package/zypper.rb +1 -0
- data/lib/chef/provider/service.rb +4 -22
- data/lib/chef/provider/service/debian.rb +2 -0
- data/lib/chef/provider/service/insserv.rb +2 -0
- data/lib/chef/provider/service/invokercd.rb +2 -0
- data/lib/chef/provider/service/openbsd.rb +1 -1
- data/lib/chef/provider/service/redhat.rb +2 -0
- data/lib/chef/provider/service/upstart.rb +3 -0
- data/lib/chef/provider_resolver.rb +59 -53
- data/lib/chef/resource.rb +22 -73
- data/lib/chef/resource/dsc_script.rb +1 -1
- data/lib/chef/resource/ips_package.rb +1 -0
- data/lib/chef/resource/mount.rb +8 -0
- data/lib/chef/resource/openbsd_package.rb +0 -11
- data/lib/chef/resource/solaris_package.rb +1 -4
- data/lib/chef/resource_resolver.rb +54 -26
- data/lib/chef/run_list/versioned_recipe_list.rb +6 -5
- data/lib/chef/user.rb +52 -188
- data/lib/chef/user_v1.rb +335 -0
- data/lib/chef/version.rb +1 -1
- data/spec/data/trusted_certs/opscode.pem +53 -56
- data/spec/functional/provider/whyrun_safe_ruby_block_spec.rb +1 -1
- data/spec/functional/resource/package_spec.rb +0 -2
- data/spec/integration/recipes/recipe_dsl_spec.rb +661 -126
- data/spec/spec_helper.rb +19 -13
- data/spec/support/shared/unit/api_versioning.rb +2 -2
- data/spec/unit/api_client_spec.rb +22 -201
- data/spec/unit/api_client_v1_spec.rb +457 -0
- data/spec/unit/knife/client_bulk_delete_spec.rb +4 -4
- data/spec/unit/knife/client_create_spec.rb +1 -1
- data/spec/unit/knife/client_delete_spec.rb +3 -3
- data/spec/unit/knife/client_edit_spec.rb +14 -1
- data/spec/unit/knife/client_list_spec.rb +1 -1
- data/spec/unit/knife/client_reregister_spec.rb +2 -2
- data/spec/unit/knife/client_show_spec.rb +2 -2
- data/spec/unit/knife/osc_user_create_spec.rb +5 -5
- data/spec/unit/knife/osc_user_delete_spec.rb +1 -1
- data/spec/unit/knife/osc_user_edit_spec.rb +1 -1
- data/spec/unit/knife/osc_user_list_spec.rb +1 -1
- data/spec/unit/knife/osc_user_reregister_spec.rb +1 -1
- data/spec/unit/knife/osc_user_show_spec.rb +1 -1
- data/spec/unit/knife/user_create_spec.rb +1 -1
- data/spec/unit/knife/user_delete_spec.rb +2 -2
- data/spec/unit/knife/user_edit_spec.rb +2 -2
- data/spec/unit/knife/user_list_spec.rb +1 -1
- data/spec/unit/knife/user_reregister_spec.rb +1 -1
- data/spec/unit/knife/user_show_spec.rb +2 -2
- data/spec/unit/lwrp_spec.rb +146 -134
- data/spec/unit/node_map_spec.rb +12 -0
- data/spec/unit/platform_spec.rb +1 -1
- data/spec/unit/provider/deploy_spec.rb +1 -1
- data/spec/unit/provider/dsc_resource_spec.rb +3 -3
- data/spec/unit/provider/dsc_script_spec.rb +2 -2
- data/spec/unit/provider_resolver_spec.rb +170 -135
- data/spec/unit/recipe_spec.rb +3 -3
- data/spec/unit/resource/breakpoint_spec.rb +1 -1
- data/spec/unit/resource/cron_spec.rb +1 -1
- data/spec/unit/resource/directory_spec.rb +1 -1
- data/spec/unit/resource/dsc_resource_spec.rb +1 -1
- data/spec/unit/resource/dsc_script_spec.rb +2 -2
- data/spec/unit/resource/env_spec.rb +1 -1
- data/spec/unit/resource/erl_call_spec.rb +1 -1
- data/spec/unit/resource/file_spec.rb +1 -1
- data/spec/unit/resource/group_spec.rb +1 -1
- data/spec/unit/resource/link_spec.rb +1 -1
- data/spec/unit/resource/mdadm_spec.rb +1 -1
- data/spec/unit/resource/mount_spec.rb +1 -1
- data/spec/unit/resource/ohai_spec.rb +1 -1
- data/spec/unit/resource/registry_key_spec.rb +1 -1
- data/spec/unit/resource/route_spec.rb +1 -1
- data/spec/unit/resource/ruby_block_spec.rb +3 -3
- data/spec/unit/resource/user_spec.rb +1 -1
- data/spec/unit/resource/windows_service_spec.rb +1 -1
- data/spec/unit/resource_resolver_spec.rb +8 -4
- data/spec/unit/resource_spec.rb +89 -3
- data/spec/unit/run_list/versioned_recipe_list_spec.rb +115 -48
- data/spec/unit/user_spec.rb +97 -405
- data/spec/unit/user_v1_spec.rb +584 -0
- metadata +11 -6
- data/lib/chef/osc_user.rb +0 -194
- data/spec/unit/osc_user_spec.rb +0 -276
data/lib/chef/knife/user_edit.rb
CHANGED
@@ -23,7 +23,7 @@ class Chef
|
|
23
23
|
class UserEdit < Knife
|
24
24
|
|
25
25
|
deps do
|
26
|
-
require 'chef/
|
26
|
+
require 'chef/user_v1'
|
27
27
|
require 'chef/json_compat'
|
28
28
|
end
|
29
29
|
|
@@ -56,7 +56,7 @@ EOF
|
|
56
56
|
exit 1
|
57
57
|
end
|
58
58
|
|
59
|
-
original_user = Chef::
|
59
|
+
original_user = Chef::UserV1.load(@user_name).to_hash
|
60
60
|
|
61
61
|
# DEPRECATION NOTE
|
62
62
|
# Remove this if statement and corrosponding code post OSC 11 support.
|
@@ -69,7 +69,7 @@ EOF
|
|
69
69
|
else # EC / CS 12 user create
|
70
70
|
edited_user = edit_data(original_user)
|
71
71
|
if original_user != edited_user
|
72
|
-
user = Chef::
|
72
|
+
user = Chef::UserV1.from_hash(edited_user)
|
73
73
|
user.update
|
74
74
|
ui.msg("Saved #{user}.")
|
75
75
|
else
|
data/lib/chef/knife/user_list.rb
CHANGED
@@ -25,7 +25,7 @@ class Chef
|
|
25
25
|
class UserList < Knife
|
26
26
|
|
27
27
|
deps do
|
28
|
-
require 'chef/
|
28
|
+
require 'chef/user_v1'
|
29
29
|
require 'chef/json_compat'
|
30
30
|
end
|
31
31
|
|
@@ -37,7 +37,7 @@ class Chef
|
|
37
37
|
:description => "Show corresponding URIs"
|
38
38
|
|
39
39
|
def run
|
40
|
-
output(format_list_for_display(Chef::
|
40
|
+
output(format_list_for_display(Chef::UserV1.list))
|
41
41
|
end
|
42
42
|
|
43
43
|
end
|
@@ -23,7 +23,7 @@ class Chef
|
|
23
23
|
class UserReregister < Knife
|
24
24
|
|
25
25
|
deps do
|
26
|
-
require 'chef/
|
26
|
+
require 'chef/user_v1'
|
27
27
|
require 'chef/json_compat'
|
28
28
|
end
|
29
29
|
|
@@ -61,7 +61,7 @@ EOF
|
|
61
61
|
exit 1
|
62
62
|
end
|
63
63
|
|
64
|
-
user = Chef::
|
64
|
+
user = Chef::UserV1.load(@user_name)
|
65
65
|
|
66
66
|
# DEPRECATION NOTE
|
67
67
|
# Remove this if statement and corrosponding code post OSC 11 support.
|
data/lib/chef/knife/user_show.rb
CHANGED
@@ -25,7 +25,7 @@ class Chef
|
|
25
25
|
include Knife::Core::MultiAttributeReturnOption
|
26
26
|
|
27
27
|
deps do
|
28
|
-
require 'chef/
|
28
|
+
require 'chef/user_v1'
|
29
29
|
require 'chef/json_compat'
|
30
30
|
end
|
31
31
|
|
@@ -58,7 +58,7 @@ EOF
|
|
58
58
|
exit 1
|
59
59
|
end
|
60
60
|
|
61
|
-
user = Chef::
|
61
|
+
user = Chef::UserV1.load(@user_name)
|
62
62
|
|
63
63
|
# DEPRECATION NOTE
|
64
64
|
# Remove this if statement and corrosponding code post OSC 11 support.
|
data/lib/chef/node_map.rb
CHANGED
@@ -19,13 +19,6 @@
|
|
19
19
|
class Chef
|
20
20
|
class NodeMap
|
21
21
|
|
22
|
-
#
|
23
|
-
# Create a new NodeMap
|
24
|
-
#
|
25
|
-
def initialize
|
26
|
-
@map = {}
|
27
|
-
end
|
28
|
-
|
29
22
|
#
|
30
23
|
# Set a key/value pair on the map with a filter. The filter must be true
|
31
24
|
# when applied to the node in order to retrieve the value.
|
@@ -55,18 +48,17 @@ class Chef
|
|
55
48
|
# The map is sorted in order of preference already; we just need to find
|
56
49
|
# our place in it (just before the first value with the same preference level).
|
57
50
|
insert_at = nil
|
58
|
-
|
59
|
-
|
51
|
+
map[key] ||= []
|
52
|
+
map[key].each_with_index do |matcher,index|
|
60
53
|
cmp = compare_matchers(key, new_matcher, matcher)
|
61
54
|
insert_at ||= index if cmp && cmp <= 0
|
62
55
|
end
|
63
56
|
if insert_at
|
64
|
-
|
57
|
+
map[key].insert(insert_at, new_matcher)
|
65
58
|
else
|
66
|
-
|
59
|
+
map[key] << new_matcher
|
67
60
|
end
|
68
|
-
|
69
|
-
@map
|
61
|
+
map
|
70
62
|
end
|
71
63
|
|
72
64
|
#
|
@@ -100,8 +92,8 @@ class Chef
|
|
100
92
|
#
|
101
93
|
def list(node, key, canonical: nil)
|
102
94
|
raise ArgumentError, "first argument must be a Chef::Node" unless node.is_a?(Chef::Node) || node.nil?
|
103
|
-
return [] unless
|
104
|
-
|
95
|
+
return [] unless map.has_key?(key)
|
96
|
+
map[key].select do |matcher|
|
105
97
|
node_matches?(node, matcher) && canonical_matches?(canonical, matcher)
|
106
98
|
end.map { |matcher| matcher[:value] }
|
107
99
|
end
|
@@ -110,11 +102,11 @@ class Chef
|
|
110
102
|
# @return remaining
|
111
103
|
# @api private
|
112
104
|
def delete_canonical(key, value)
|
113
|
-
remaining =
|
105
|
+
remaining = map[key]
|
114
106
|
if remaining
|
115
107
|
remaining.delete_if { |matcher| matcher[:canonical] && Array(matcher[:value]) == Array(value) }
|
116
108
|
if remaining.empty?
|
117
|
-
|
109
|
+
map.delete(key)
|
118
110
|
remaining = nil
|
119
111
|
end
|
120
112
|
end
|
@@ -181,7 +173,7 @@ class Chef
|
|
181
173
|
end
|
182
174
|
|
183
175
|
def compare_matchers(key, new_matcher, matcher)
|
184
|
-
cmp = compare_matcher_properties(new_matcher, matcher) { |m| m[:
|
176
|
+
cmp = compare_matcher_properties(new_matcher, matcher) { |m| m[:block] }
|
185
177
|
return cmp if cmp != 0
|
186
178
|
cmp = compare_matcher_properties(new_matcher, matcher) { |m| m[:filters][:platform_version] }
|
187
179
|
return cmp if cmp != 0
|
@@ -222,5 +214,9 @@ class Chef
|
|
222
214
|
end
|
223
215
|
cmp
|
224
216
|
end
|
217
|
+
|
218
|
+
def map
|
219
|
+
@map ||= {}
|
220
|
+
end
|
225
221
|
end
|
226
222
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
#
|
2
|
+
# Author:: John Keiser (<jkeiser@chef.io>)
|
3
|
+
# Copyright:: Copyright (c) 2015 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 'chef/node_map'
|
20
|
+
|
21
|
+
class Chef
|
22
|
+
class Platform
|
23
|
+
class HandlerMap < Chef::NodeMap
|
24
|
+
#
|
25
|
+
# "provides" lines with identical filters sort by class name (ascending).
|
26
|
+
#
|
27
|
+
def compare_matchers(key, new_matcher, matcher)
|
28
|
+
cmp = super
|
29
|
+
if cmp == 0
|
30
|
+
# Sort by class name (ascending) as well, if all other properties
|
31
|
+
# are exactly equal
|
32
|
+
if new_matcher[:value].is_a?(Class) && !new_matcher[:override]
|
33
|
+
cmp = compare_matcher_properties(new_matcher, matcher) { |m| m[:value].name }
|
34
|
+
if cmp < 0
|
35
|
+
Chef::Log.warn "You are overriding #{key} on #{new_matcher[:filters].inspect} with #{new_matcher[:value].inspect}: used to be #{matcher[:value].inspect}. Use override: true if this is what you intended."
|
36
|
+
elsif cmp > 0
|
37
|
+
Chef::Log.warn "You declared a new resource #{new_matcher[:value].inspect} for resource #{key}, but it comes alphabetically after #{matcher[:value].inspect} and has the same filters (#{new_matcher[:filters].inspect}), so it will not be used. Use override: true if you want to use it for #{key}."
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
cmp
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -1,3 +1,21 @@
|
|
1
|
+
#
|
2
|
+
# Author:: John Keiser (<jkeiser@chef.io>)
|
3
|
+
# Copyright:: Copyright (c) 2015 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
|
+
|
1
19
|
require 'chef/node_map'
|
2
20
|
|
3
21
|
class Chef
|
@@ -6,7 +24,7 @@ class Chef
|
|
6
24
|
def priority(resource_name, priority_array, *filter)
|
7
25
|
set_priority_array(resource_name.to_sym, priority_array, *filter)
|
8
26
|
end
|
9
|
-
|
27
|
+
|
10
28
|
# @api private
|
11
29
|
def get_priority_array(node, key)
|
12
30
|
get(node, key)
|
@@ -18,37 +36,6 @@ class Chef
|
|
18
36
|
set(key, priority_array, *filter, &block)
|
19
37
|
priority_array
|
20
38
|
end
|
21
|
-
|
22
|
-
# @api private
|
23
|
-
def list_handlers(node, key, **filters)
|
24
|
-
list(node, key, **filters).flatten(1).uniq
|
25
|
-
end
|
26
|
-
|
27
|
-
#
|
28
|
-
# Priority maps have one extra precedence: priority arrays override "provides,"
|
29
|
-
# and "provides" lines with identical filters sort by class name (ascending).
|
30
|
-
#
|
31
|
-
def compare_matchers(key, new_matcher, matcher)
|
32
|
-
# Priority arrays come before "provides"
|
33
|
-
if new_matcher[:value].is_a?(Array) != matcher[:value].is_a?(Array)
|
34
|
-
return new_matcher[:value].is_a?(Array) ? -1 : 1
|
35
|
-
end
|
36
|
-
|
37
|
-
cmp = super
|
38
|
-
if cmp == 0
|
39
|
-
# Sort by class name (ascending) as well, if all other properties
|
40
|
-
# are exactly equal
|
41
|
-
if new_matcher[:value].is_a?(Class) && !new_matcher[:override]
|
42
|
-
cmp = compare_matcher_properties(new_matcher, matcher) { |m| m[:value].name }
|
43
|
-
if cmp < 0
|
44
|
-
Chef::Log.warn "You are overriding #{key} on #{new_matcher[:filters].inspect} with #{new_matcher[:value].inspect}: used to be #{matcher[:value].inspect}. Use override: true if this is what you intended."
|
45
|
-
elsif cmp > 0
|
46
|
-
Chef::Log.warn "You declared a new resource #{new_matcher[:value].inspect} for resource #{key}, but it comes alphabetically after #{matcher[:value].inspect} and has the same filters (#{new_matcher[:filters].inspect}), so it will not be used. Use override: true if you want to use it for #{key}."
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
cmp
|
51
|
-
end
|
52
39
|
end
|
53
40
|
end
|
54
41
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#
|
2
|
+
# Author:: John Keiser (<jkeiser@chef.io>)
|
3
|
+
# Copyright:: Copyright (c) 2015 Chef Software, 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 'singleton'
|
20
|
+
require 'chef/platform/handler_map'
|
21
|
+
|
22
|
+
class Chef
|
23
|
+
class Platform
|
24
|
+
# @api private
|
25
|
+
class ProviderHandlerMap < Chef::Platform::HandlerMap
|
26
|
+
include Singleton
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -176,7 +176,7 @@ class Chef
|
|
176
176
|
platform_provider(platform, version, resource_type) ||
|
177
177
|
resource_matching_provider(platform, version, resource_type)
|
178
178
|
|
179
|
-
raise
|
179
|
+
raise Chef::Exceptions::ProviderNotFound, "Cannot find a provider for #{resource_type} on #{platform} version #{version}" if provider_klass.nil?
|
180
180
|
|
181
181
|
provider_klass
|
182
182
|
end
|
@@ -197,7 +197,8 @@ class Chef
|
|
197
197
|
|
198
198
|
def resource_matching_provider(platform, version, resource_type)
|
199
199
|
if resource_type.kind_of?(Chef::Resource)
|
200
|
-
class_name = resource_type.class.
|
200
|
+
class_name = resource_type.class.name ? resource_type.class.name.split('::').last :
|
201
|
+
convert_to_class_name(resource_type.resource_name.to_s)
|
201
202
|
|
202
203
|
begin
|
203
204
|
result = Chef::Provider.const_get(class_name)
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#
|
2
|
+
# Author:: John Keiser (<jkeiser@chef.io>)
|
3
|
+
# Copyright:: Copyright (c) 2015 Chef Software, 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 'singleton'
|
20
|
+
require 'chef/platform/handler_map'
|
21
|
+
|
22
|
+
class Chef
|
23
|
+
class Platform
|
24
|
+
# @api private
|
25
|
+
class ResourceHandlerMap < Chef::Platform::HandlerMap
|
26
|
+
include Singleton
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -6,12 +6,6 @@ class Chef
|
|
6
6
|
# @api private
|
7
7
|
class ResourcePriorityMap < Chef::Platform::PriorityMap
|
8
8
|
include Singleton
|
9
|
-
|
10
|
-
# @api private
|
11
|
-
def get_priority_array(node, resource_name, canonical: nil)
|
12
|
-
super(node, resource_name.to_sym, canonical: canonical)
|
13
|
-
end
|
14
|
-
|
15
9
|
end
|
16
10
|
end
|
17
11
|
end
|
data/lib/chef/provider.rb
CHANGED
@@ -176,7 +176,7 @@ class Chef
|
|
176
176
|
end
|
177
177
|
|
178
178
|
def self.provides(short_name, opts={}, &block)
|
179
|
-
Chef.
|
179
|
+
Chef.provider_handler_map.set(short_name, self, opts, &block)
|
180
180
|
end
|
181
181
|
|
182
182
|
def self.provides?(node, resource)
|
@@ -53,7 +53,7 @@ class Chef
|
|
53
53
|
requirements.assert(:run) do |a|
|
54
54
|
a.assertion { supports_dsc_invoke_resource? }
|
55
55
|
err = ["You must have Powershell version >= 5.0.10018.0 to use dsc_resource."]
|
56
|
-
a.failure_message Chef::Exceptions::
|
56
|
+
a.failure_message Chef::Exceptions::ProviderNotFound,
|
57
57
|
err
|
58
58
|
a.whyrun err + ["Assuming a previous resource installs Powershell 5.0.10018.0 or higher."]
|
59
59
|
a.block_action!
|
@@ -63,7 +63,7 @@ class Chef
|
|
63
63
|
meta_configuration['RefreshMode'] == 'Disabled'
|
64
64
|
}
|
65
65
|
err = ["The LCM must have its RefreshMode set to Disabled. "]
|
66
|
-
a.failure_message Chef::Exceptions::
|
66
|
+
a.failure_message Chef::Exceptions::ProviderNotFound, err.join(' ')
|
67
67
|
a.whyrun err + ["Assuming a previous resource sets the RefreshMode."]
|
68
68
|
a.block_action!
|
69
69
|
end
|
@@ -70,7 +70,7 @@ class Chef
|
|
70
70
|
"Powershell 4.0 or higher was not detected on your system and is required to use the dsc_script resource.",
|
71
71
|
]
|
72
72
|
a.assertion { supports_dsc? }
|
73
|
-
a.failure_message Chef::Exceptions::
|
73
|
+
a.failure_message Chef::Exceptions::ProviderNotFound, err.join(' ')
|
74
74
|
a.whyrun err + ["Assuming a previous resource installs Powershell 4.0 or higher."]
|
75
75
|
a.block_action!
|
76
76
|
end
|
@@ -491,37 +491,6 @@ class Chef
|
|
491
491
|
end
|
492
492
|
end
|
493
493
|
|
494
|
-
# Set provider priority
|
495
|
-
require 'chef/chef_class'
|
496
|
-
require 'chef/provider/package/dpkg'
|
497
|
-
require 'chef/provider/package/homebrew'
|
498
|
-
require 'chef/provider/package/macports'
|
499
|
-
require 'chef/provider/package/apt'
|
500
|
-
require 'chef/provider/package/yum'
|
501
|
-
require 'chef/provider/package/zypper'
|
502
|
-
require 'chef/provider/package/portage'
|
503
|
-
require 'chef/provider/package/pacman'
|
504
|
-
require 'chef/provider/package/ips'
|
505
|
-
require 'chef/provider/package/solaris'
|
506
|
-
require 'chef/provider/package/smartos'
|
507
|
-
require 'chef/provider/package/aix'
|
508
|
-
require 'chef/provider/package/paludis'
|
509
|
-
|
510
|
-
Chef.set_provider_priority_array :package, [ Homebrew, Macports ], os: "darwin"
|
511
|
-
|
512
|
-
Chef.set_provider_priority_array :package, Apt, platform_family: "debian"
|
513
|
-
Chef.set_provider_priority_array :package, Yum, platform_family: %w(rhel fedora)
|
514
|
-
Chef.set_provider_priority_array :package, Zypper, platform_family: "suse"
|
515
|
-
Chef.set_provider_priority_array :package, Portage, platform: "gentoo"
|
516
|
-
Chef.set_provider_priority_array :package, Pacman, platform: "arch"
|
517
|
-
Chef.set_provider_priority_array :package, Ips, platform: %w(openindiana opensolaris omnios solaris2)
|
518
|
-
Chef.set_provider_priority_array :package, Solaris, platform: "nexentacore"
|
519
|
-
Chef.set_provider_priority_array :package, Solaris, platform: "solaris2", platform_version: '< 5.11'
|
520
|
-
|
521
|
-
Chef.set_provider_priority_array :package, SmartOS, platform: "smartos"
|
522
|
-
Chef.set_provider_priority_array :package, Aix, platform: "aix"
|
523
|
-
Chef.set_provider_priority_array :package, Paludis, platform: "exherbo"
|
524
|
-
|
525
494
|
private
|
526
495
|
|
527
496
|
def shell_out_with_timeout(*command_args)
|