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
@@ -188,29 +188,11 @@ class Chef
|
|
188
188
|
require 'chef/provider/service/upstart'
|
189
189
|
require 'chef/provider/service/debian'
|
190
190
|
require 'chef/provider/service/invokercd'
|
191
|
-
require 'chef/provider/service/freebsd'
|
192
|
-
require 'chef/provider/service/openbsd'
|
193
|
-
require 'chef/provider/service/solaris'
|
194
|
-
require 'chef/provider/service/macosx'
|
195
|
-
|
196
|
-
def self.os(os, *providers)
|
197
|
-
Chef.set_provider_priority_array(:service, providers, os: os)
|
198
|
-
end
|
199
|
-
def self.platform_family(platform_family, *providers)
|
200
|
-
Chef.set_provider_priority_array(:service, providers, platform_family: platform_family)
|
201
|
-
end
|
202
|
-
|
203
|
-
os %w(freebsd netbsd), Freebsd
|
204
|
-
os %w(openbsd), Openbsd
|
205
|
-
os %w(solaris2), Solaris
|
206
|
-
os %w(darwin), Macosx
|
207
|
-
os %w(linux), Systemd, Insserv, Redhat
|
208
|
-
|
209
|
-
platform_family %w(arch), Systemd, Arch
|
210
|
-
platform_family %w(gentoo), Systemd, Gentoo
|
211
|
-
platform_family %w(debian), Systemd, Upstart, Insserv, Debian, Invokercd
|
212
|
-
platform_family %w(rhel fedora suse), Systemd, Insserv, Redhat
|
213
191
|
|
192
|
+
Chef.set_provider_priority_array :service, [ Systemd, Arch ], platform_family: 'arch'
|
193
|
+
Chef.set_provider_priority_array :service, [ Systemd, Gentoo ], platform_family: 'gentoo'
|
194
|
+
Chef.set_provider_priority_array :service, [ Systemd, Upstart, Insserv, Debian, Invokercd ], platform_family: 'debian'
|
195
|
+
Chef.set_provider_priority_array :service, [ Systemd, Insserv, Redhat ], platform_family: %w(rhel fedora suse)
|
214
196
|
end
|
215
197
|
end
|
216
198
|
end
|
@@ -22,6 +22,8 @@ class Chef
|
|
22
22
|
class Provider
|
23
23
|
class Service
|
24
24
|
class Debian < Chef::Provider::Service::Init
|
25
|
+
provides :service, platform_family: 'debian'
|
26
|
+
|
25
27
|
UPDATE_RC_D_ENABLED_MATCHES = /\/rc[\dS].d\/S|not installed/i
|
26
28
|
UPDATE_RC_D_PRIORITIES = /\/rc([\dS]).d\/([SK])(\d\d)/i
|
27
29
|
|
@@ -24,6 +24,8 @@ class Chef
|
|
24
24
|
class Service
|
25
25
|
class Insserv < Chef::Provider::Service::Init
|
26
26
|
|
27
|
+
provides :service, platform_family: %w(debian rhel fedora suse)
|
28
|
+
|
27
29
|
def self.provides?(node, resource)
|
28
30
|
super && Chef::Platform::ServiceHelpers.service_resource_providers.include?(:insserv)
|
29
31
|
end
|
@@ -23,6 +23,8 @@ class Chef
|
|
23
23
|
class Service
|
24
24
|
class Invokercd < Chef::Provider::Service::Init
|
25
25
|
|
26
|
+
provides :service, platform_family: 'debian', override: true
|
27
|
+
|
26
28
|
def self.provides?(node, resource)
|
27
29
|
super && Chef::Platform::ServiceHelpers.service_resource_providers.include?(:invokercd)
|
28
30
|
end
|
@@ -25,6 +25,9 @@ class Chef
|
|
25
25
|
class Provider
|
26
26
|
class Service
|
27
27
|
class Upstart < Chef::Provider::Service::Simple
|
28
|
+
|
29
|
+
provides :service, platform_family: 'debian', override: true
|
30
|
+
|
28
31
|
UPSTART_STATE_FORMAT = /\w+ \(?(\w+)\)?[\/ ](\w+)/
|
29
32
|
|
30
33
|
def self.provides?(node, resource)
|
@@ -17,7 +17,7 @@
|
|
17
17
|
#
|
18
18
|
|
19
19
|
require 'chef/exceptions'
|
20
|
-
require 'chef/platform/
|
20
|
+
require 'chef/platform/priority_map'
|
21
21
|
|
22
22
|
class Chef
|
23
23
|
#
|
@@ -62,12 +62,47 @@ class Chef
|
|
62
62
|
maybe_chef_platform_lookup(resource)
|
63
63
|
end
|
64
64
|
|
65
|
+
# Does NOT call provides? on the resource (it is assumed this is being
|
66
|
+
# called *from* provides?).
|
65
67
|
def provided_by?(provider_class)
|
66
|
-
|
68
|
+
potential_handlers.include?(provider_class)
|
69
|
+
end
|
70
|
+
|
71
|
+
def enabled_handlers
|
72
|
+
@enabled_handlers ||= potential_handlers.select { |handler| !overrode_provides?(handler) || handler.provides?(node, resource) }
|
73
|
+
end
|
74
|
+
|
75
|
+
# TODO deprecate this and allow actions to be passed as a filter to
|
76
|
+
# `provides` so we don't have to have two separate things.
|
77
|
+
# @api private
|
78
|
+
def supported_handlers
|
79
|
+
enabled_handlers.select { |handler| handler.supports?(resource, action) }
|
67
80
|
end
|
68
81
|
|
69
82
|
private
|
70
83
|
|
84
|
+
def potential_handlers
|
85
|
+
handler_map.list(node, resource.resource_name).uniq
|
86
|
+
end
|
87
|
+
|
88
|
+
# The list of handlers, with any in the priority_map moved to the front
|
89
|
+
def prioritized_handlers
|
90
|
+
@prioritized_handlers ||= begin
|
91
|
+
supported_handlers = self.supported_handlers
|
92
|
+
if supported_handlers.empty?
|
93
|
+
# if none of the providers specifically support the resource, we still need to pick one of the providers that are
|
94
|
+
# enabled on the node to handle the why-run use case. FIXME we should only do this in why-run mode then.
|
95
|
+
Chef::Log.debug "No providers responded true to `supports?` for action #{action} on resource #{resource}, falling back to enabled handlers so we can return something anyway."
|
96
|
+
supported_handlers = enabled_handlers
|
97
|
+
end
|
98
|
+
|
99
|
+
prioritized = priority_map.list(node, resource.resource_name).flatten(1)
|
100
|
+
prioritized &= supported_handlers # Filter the priority map by the actual enabled handlers
|
101
|
+
prioritized |= supported_handlers # Bring back any handlers that aren't in the priority map, at the *end* (ordered set)
|
102
|
+
prioritized
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
71
106
|
# if resource.provider is set, just return one of those objects
|
72
107
|
def maybe_explicit_provider(resource)
|
73
108
|
return nil unless resource.provider
|
@@ -78,27 +113,7 @@ class Chef
|
|
78
113
|
def maybe_dynamic_provider_resolution(resource, action)
|
79
114
|
Chef::Log.debug "Providers for generic #{resource.resource_name} resource enabled on node include: #{enabled_handlers}"
|
80
115
|
|
81
|
-
|
82
|
-
handlers = prioritized_handlers
|
83
|
-
|
84
|
-
# Narrow it down to handlers that return `true` to `provides?`
|
85
|
-
# TODO deprecate this and don't bother calling--the fact that they said
|
86
|
-
# `provides` should be enough. But we need to do it right now because
|
87
|
-
# some classes implement additional handling.
|
88
|
-
enabled_handlers = prioritized_handlers.select { |handler| handler.provides?(node, resource) }
|
89
|
-
|
90
|
-
# Narrow it down to handlers that return `true` to `supports?`
|
91
|
-
# TODO deprecate this and allow actions to be passed as a filter to
|
92
|
-
# `provides` so we don't have to have two separate things.
|
93
|
-
supported_handlers = enabled_handlers.select { |handler| handler.supports?(resource, action) }
|
94
|
-
if supported_handlers.empty?
|
95
|
-
# if none of the providers specifically support the resource, we still need to pick one of the providers that are
|
96
|
-
# enabled on the node to handle the why-run use case. FIXME we should only do this in why-run mode then.
|
97
|
-
Chef::Log.debug "No providers responded true to `supports?` for action #{action} on resource #{resource}, falling back to enabled handlers so we can return something anyway."
|
98
|
-
handler = enabled_handlers.first
|
99
|
-
else
|
100
|
-
handler = supported_handlers.first
|
101
|
-
end
|
116
|
+
handler = prioritized_handlers.first
|
102
117
|
|
103
118
|
if handler
|
104
119
|
Chef::Log.debug "Provider for action #{action} on resource #{resource} is #{handler}"
|
@@ -114,13 +129,16 @@ class Chef
|
|
114
129
|
Chef::Platform.find_provider_for_node(node, resource)
|
115
130
|
end
|
116
131
|
|
117
|
-
def
|
118
|
-
Chef
|
132
|
+
def priority_map
|
133
|
+
Chef.provider_priority_map
|
119
134
|
end
|
120
135
|
|
121
|
-
def
|
122
|
-
|
123
|
-
|
136
|
+
def handler_map
|
137
|
+
Chef.provider_handler_map
|
138
|
+
end
|
139
|
+
|
140
|
+
def overrode_provides?(handler)
|
141
|
+
handler.method(:provides?).owner != Chef::Provider.method(:provides?).owner
|
124
142
|
end
|
125
143
|
|
126
144
|
module Deprecated
|
@@ -129,33 +147,21 @@ class Chef
|
|
129
147
|
@providers ||= Chef::Provider.descendants
|
130
148
|
end
|
131
149
|
|
132
|
-
# this cut looks at if the provider can handle the resource type on the node
|
133
150
|
def enabled_handlers
|
134
|
-
@enabled_handlers ||=
|
135
|
-
|
136
|
-
|
137
|
-
#
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
klass.supports?(resource, action)
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
# If there are no providers for a DSL, we search through the
|
151
|
-
def prioritized_handlers
|
152
|
-
@prioritized_handlers ||= super || begin
|
153
|
-
result = providers.select { |handler| handler.provides?(node, resource) }.sort_by(:name)
|
154
|
-
if !result.empty?
|
155
|
-
Chef::Log.deprecation("#{resource.resource_name.to_sym} is marked as providing DSL #{method_symbol}, but provides #{resource.resource_name.to_sym.inspect} was never called!")
|
156
|
-
Chef::Log.deprecation("In Chef 13, this will break: you must call provides to mark the names you provide, even if you also override provides? yourself.")
|
151
|
+
@enabled_handlers ||= begin
|
152
|
+
handlers = super
|
153
|
+
if handlers.empty?
|
154
|
+
# Look through all providers, and find ones that return true to provides.
|
155
|
+
# Don't bother with ones that don't override provides?, since they
|
156
|
+
# would have been in enabled_handlers already if that were so. (It's a
|
157
|
+
# perf concern otherwise.)
|
158
|
+
handlers = providers.select { |handler| overrode_provides?(handler) && handler.provides?(node, resource) }
|
159
|
+
handlers.each do |handler|
|
160
|
+
Chef::Log.deprecation("#{handler}.provides? returned true when asked if it provides DSL #{resource.resource_name}, but provides #{resource.resource_name.inspect} was never called!")
|
161
|
+
Chef::Log.deprecation("In Chef 13, this will break: you must call provides to mark the names you provide, even if you also override provides? yourself.")
|
162
|
+
end
|
157
163
|
end
|
158
|
-
|
164
|
+
handlers
|
159
165
|
end
|
160
166
|
end
|
161
167
|
end
|
data/lib/chef/resource.rb
CHANGED
@@ -171,27 +171,25 @@ class Chef
|
|
171
171
|
# @param arg [Array[Symbol], Symbol] A list of actions (e.g. `:create`)
|
172
172
|
# @return [Array[Symbol]] the list of actions.
|
173
173
|
#
|
174
|
-
attr_accessor :action
|
175
174
|
def action(arg=nil)
|
176
175
|
if arg
|
177
|
-
|
178
|
-
|
179
|
-
else
|
180
|
-
arg = arg.to_sym
|
181
|
-
end
|
182
|
-
Array(arg).each do |action|
|
176
|
+
arg = Array(arg).map(&:to_sym)
|
177
|
+
arg.each do |action|
|
183
178
|
validate(
|
184
179
|
{ action: action },
|
185
180
|
{ action: { kind_of: Symbol, equal_to: allowed_actions } }
|
186
181
|
)
|
187
182
|
end
|
188
|
-
|
183
|
+
@action = arg
|
189
184
|
else
|
190
185
|
# Pull the action from the class if it's not set
|
191
186
|
@action || self.class.default_action
|
192
187
|
end
|
193
188
|
end
|
194
189
|
|
190
|
+
# Alias for normal assigment syntax.
|
191
|
+
alias_method :action=, :action
|
192
|
+
|
195
193
|
#
|
196
194
|
# Sets up a notification that will run a particular action on another resource
|
197
195
|
# if and when *this* resource is updated by an action.
|
@@ -917,7 +915,7 @@ class Chef
|
|
917
915
|
if name
|
918
916
|
name = name.to_sym
|
919
917
|
# If our class is not already providing this name, provide it.
|
920
|
-
if !Chef::ResourceResolver.
|
918
|
+
if !Chef::ResourceResolver.includes_handler?(name, self)
|
921
919
|
provides name, canonical: true
|
922
920
|
end
|
923
921
|
@resource_name = name
|
@@ -981,22 +979,17 @@ class Chef
|
|
981
979
|
# Setting default_action will automatially add the action to
|
982
980
|
# allowed_actions, if it isn't already there.
|
983
981
|
#
|
984
|
-
# Defaults to :nothing.
|
982
|
+
# Defaults to [:nothing].
|
985
983
|
#
|
986
984
|
# @param action_name [Symbol,Array<Symbol>] The default action (or series
|
987
985
|
# of actions) to use.
|
988
986
|
#
|
989
|
-
# @return [
|
987
|
+
# @return [Array<Symbol>] The default actions for the resource.
|
990
988
|
#
|
991
989
|
def self.default_action(action_name=NULL_ARG)
|
992
990
|
unless action_name.equal?(NULL_ARG)
|
993
|
-
|
994
|
-
|
995
|
-
else
|
996
|
-
@default_action = action_name.to_sym
|
997
|
-
end
|
998
|
-
|
999
|
-
self.allowed_actions |= Array(@default_action)
|
991
|
+
@default_action = Array(action_name).map(&:to_sym)
|
992
|
+
self.allowed_actions |= @default_action
|
1000
993
|
end
|
1001
994
|
|
1002
995
|
if @default_action
|
@@ -1004,13 +997,14 @@ class Chef
|
|
1004
997
|
elsif superclass.respond_to?(:default_action)
|
1005
998
|
superclass.default_action
|
1006
999
|
else
|
1007
|
-
:nothing
|
1000
|
+
[:nothing]
|
1008
1001
|
end
|
1009
1002
|
end
|
1010
1003
|
def self.default_action=(action_name)
|
1011
1004
|
default_action(action_name)
|
1012
1005
|
end
|
1013
1006
|
|
1007
|
+
|
1014
1008
|
#
|
1015
1009
|
# Internal Resource Interface (for Chef)
|
1016
1010
|
#
|
@@ -1105,7 +1099,7 @@ class Chef
|
|
1105
1099
|
end
|
1106
1100
|
def self.inherited(child)
|
1107
1101
|
super
|
1108
|
-
|
1102
|
+
@@sorted_descendants = nil
|
1109
1103
|
# set resource_name automatically if it's not set
|
1110
1104
|
if child.name && !child.resource_name
|
1111
1105
|
if child.name =~ /^Chef::Resource::(\w+)$/
|
@@ -1143,13 +1137,13 @@ class Chef
|
|
1143
1137
|
remove_canonical_dsl
|
1144
1138
|
end
|
1145
1139
|
|
1146
|
-
result = Chef.
|
1140
|
+
result = Chef.resource_handler_map.set(name, self, options, &block)
|
1147
1141
|
Chef::DSL::Resources.add_resource_dsl(name)
|
1148
1142
|
result
|
1149
1143
|
end
|
1150
1144
|
|
1151
|
-
def self.provides?(node,
|
1152
|
-
Chef::ResourceResolver.
|
1145
|
+
def self.provides?(node, resource_name)
|
1146
|
+
Chef::ResourceResolver.new(node, resource_name).provided_by?(self)
|
1153
1147
|
end
|
1154
1148
|
|
1155
1149
|
# Helper for #notifies
|
@@ -1306,56 +1300,11 @@ class Chef
|
|
1306
1300
|
Chef::Resource.send(:remove_const, class_name)
|
1307
1301
|
end
|
1308
1302
|
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
# generated:
|
1313
|
-
#
|
1314
|
-
# - Chef::Resource::MyLwrp.new(...)
|
1315
|
-
# - resource.is_a?(Chef::Resource::MyLwrp)
|
1316
|
-
# - resource.kind_of?(Chef::Resource::MyLwrp)
|
1317
|
-
# - case resource
|
1318
|
-
# when Chef::Resource::MyLwrp
|
1319
|
-
# end
|
1320
|
-
#
|
1321
|
-
resource_subclass = Class.new(resource_class) do
|
1322
|
-
resource_name nil # we do not actually provide anything
|
1323
|
-
def initialize(*args, &block)
|
1324
|
-
Chef::Log.deprecation("Using an LWRP by its name (#{self.class.name}) directly is no longer supported in Chef 13 and will be removed. Use Chef::Resource.resource_for_node(node, name) instead.")
|
1325
|
-
super
|
1326
|
-
end
|
1327
|
-
def self.resource_name(*args)
|
1328
|
-
if args.empty?
|
1329
|
-
@resource_name ||= superclass.resource_name
|
1330
|
-
else
|
1331
|
-
super
|
1332
|
-
end
|
1333
|
-
end
|
1334
|
-
self
|
1335
|
-
end
|
1336
|
-
eval("Chef::Resource::#{class_name} = resource_subclass")
|
1337
|
-
# Make case, is_a and kind_of work with the new subclass, for backcompat.
|
1338
|
-
# Any subclass of Chef::Resource::ResourceClass is already a subclass of resource_class
|
1339
|
-
# Any subclass of resource_class is considered a subclass of Chef::Resource::ResourceClass
|
1340
|
-
resource_class.class_eval do
|
1341
|
-
define_method(:is_a?) do |other|
|
1342
|
-
other.is_a?(Module) && other === self
|
1343
|
-
end
|
1344
|
-
define_method(:kind_of?) do |other|
|
1345
|
-
other.is_a?(Module) && other === self
|
1346
|
-
end
|
1303
|
+
if !Chef::Config[:treat_deprecation_warnings_as_errors]
|
1304
|
+
Chef::Resource.const_set(class_name, resource_class)
|
1305
|
+
deprecated_constants[class_name.to_sym] = resource_class
|
1347
1306
|
end
|
1348
|
-
|
1349
|
-
define_singleton_method(:===) do |other|
|
1350
|
-
Chef::Log.deprecation("Using an LWRP by its name (#{class_name}) directly is no longer supported in Chef 13 and will be removed. Use Chef::Resource.resource_for_node(node, name) instead.")
|
1351
|
-
# resource_subclass is a superclass of all resource_class descendants.
|
1352
|
-
if self == resource_subclass && other.class <= resource_class
|
1353
|
-
return true
|
1354
|
-
end
|
1355
|
-
super(other)
|
1356
|
-
end
|
1357
|
-
end
|
1358
|
-
deprecated_constants[class_name.to_sym] = resource_subclass
|
1307
|
+
|
1359
1308
|
end
|
1360
1309
|
|
1361
1310
|
def self.deprecated_constants
|
@@ -1379,7 +1328,7 @@ class Chef
|
|
1379
1328
|
|
1380
1329
|
def self.remove_canonical_dsl
|
1381
1330
|
if @resource_name
|
1382
|
-
remaining = Chef.
|
1331
|
+
remaining = Chef.resource_handler_map.delete_canonical(@resource_name, self)
|
1383
1332
|
if !remaining
|
1384
1333
|
Chef::DSL::Resources.remove_resource_dsl(@resource_name)
|
1385
1334
|
end
|