compat_resource 12.5.26 → 12.7.0
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.
- checksums.yaml +4 -4
- data/files/lib/chef_compat/copied_from_chef/chef/dsl/declare_resource.rb +2 -2
- data/files/lib/chef_compat/copied_from_chef/chef/dsl/recipe.rb +2 -2
- data/files/lib/chef_compat/copied_from_chef/chef/mixin/params_validate.rb +14 -4
- data/files/lib/chef_compat/copied_from_chef/chef/mixin/properties.rb +3 -3
- data/files/lib/chef_compat/copied_from_chef/chef/property.rb +98 -36
- data/files/lib/chef_compat/copied_from_chef/chef/provider.rb +19 -19
- data/files/lib/chef_compat/copied_from_chef/chef/resource.rb +17 -17
- data/files/lib/chef_compat/copied_from_chef/chef/resource_builder.rb +1 -1
- data/files/lib/chef_compat/monkeypatches/chef/exceptions.rb +4 -1
- data/files/lib/chef_compat/monkeypatches/chef/log.rb +0 -1
- data/files/lib/compat_resource/version.rb +1 -1
- data/files/spec/data/Gemfile.lock +19 -21
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 154eebdbd187ddd7eee14842727a39f1b447dd21
|
4
|
+
data.tar.gz: 6ad6654c932db5ae4ad4b2de9801d8d67e81f74e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04a32ccdc4f1ce060bed2a4e99ea39c394157be4b6a4be0ce25be9f23a91de2132c3f0e0afb13e7734d64469cbb939df8a5ae014c550e01c3cdeaf409b10884f
|
7
|
+
data.tar.gz: 7bddb0214270ce21dce221755f8dfe2edf7215961fb2ef2725ece9977dc236210b9143d5ce76d8a8cfb17c05c68935ab26fc3bd5c8e94eacf7eec08bd2059326
|
@@ -94,7 +94,7 @@ class Chef < (defined?(::Chef) ? ::Chef : Object)
|
|
94
94
|
def build_resource(type, name, created_at=nil, run_context: self.run_context, &resource_attrs_block)
|
95
95
|
created_at ||= caller[0]
|
96
96
|
Thread.exclusive do
|
97
|
-
require
|
97
|
+
require "chef_compat/copied_from_chef/chef/resource_builder" unless defined?(Chef::ResourceBuilder)
|
98
98
|
end
|
99
99
|
|
100
100
|
Chef::ResourceBuilder.new(
|
@@ -105,7 +105,7 @@ class Chef < (defined?(::Chef) ? ::Chef : Object)
|
|
105
105
|
run_context: run_context,
|
106
106
|
cookbook_name: cookbook_name,
|
107
107
|
recipe_name: recipe_name,
|
108
|
-
enclosing_provider: self.is_a?(Chef::Provider) ? self : nil
|
108
|
+
enclosing_provider: self.is_a?(Chef::Provider) ? self : nil,
|
109
109
|
).build(&resource_attrs_block)
|
110
110
|
end
|
111
111
|
end
|
@@ -2,7 +2,7 @@ require 'chef_compat/copied_from_chef'
|
|
2
2
|
class Chef
|
3
3
|
module ::ChefCompat
|
4
4
|
module CopiedFromChef
|
5
|
-
require
|
5
|
+
require "chef_compat/copied_from_chef/chef/dsl/declare_resource"
|
6
6
|
class Chef < (defined?(::Chef) ? ::Chef : Object)
|
7
7
|
module DSL
|
8
8
|
CopiedFromChef.extend_chef_module(::Chef::DSL, self) if defined?(::Chef::DSL)
|
@@ -16,7 +16,7 @@ class Chef < (defined?(::Chef) ? ::Chef : Object)
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
19
|
-
require
|
19
|
+
require "chef_compat/copied_from_chef/chef/resource"
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -19,16 +19,15 @@ module CopiedFromChef
|
|
19
19
|
# See the License for the specific language governing permissions and
|
20
20
|
# limitations under the License.
|
21
21
|
|
22
|
-
require
|
23
|
-
require
|
24
|
-
require
|
22
|
+
require "chef_compat/copied_from_chef/chef/constants"
|
23
|
+
require "chef_compat/copied_from_chef/chef/property"
|
24
|
+
require "chef_compat/copied_from_chef/chef/delayed_evaluator"
|
25
25
|
|
26
26
|
class Chef < (defined?(::Chef) ? ::Chef : Object)
|
27
27
|
module Mixin
|
28
28
|
CopiedFromChef.extend_chef_module(::Chef::Mixin, self) if defined?(::Chef::Mixin)
|
29
29
|
module ParamsValidate
|
30
30
|
CopiedFromChef.extend_chef_module(::Chef::Mixin::ParamsValidate, self) if defined?(::Chef::Mixin::ParamsValidate)
|
31
|
-
|
32
31
|
# Takes a hash of options, along with a map to validate them. Returns the original
|
33
32
|
# options hash, plus any changes that might have been made (through things like setting
|
34
33
|
# default values in the validation map)
|
@@ -339,6 +338,7 @@ class Chef < (defined?(::Chef) ? ::Chef : Object)
|
|
339
338
|
def _pv_name_property(opts, key, is_name_property=true)
|
340
339
|
if is_name_property
|
341
340
|
if opts[key].nil?
|
341
|
+
raise CannotValidateStaticallyError, "name_property cannot be evaluated without a resource." if self == Chef::Mixin::ParamsValidate
|
342
342
|
opts[key] = self.instance_variable_get(:"@name")
|
343
343
|
end
|
344
344
|
end
|
@@ -409,6 +409,7 @@ class Chef < (defined?(::Chef) ? ::Chef : Object)
|
|
409
409
|
to_be.each do |tb|
|
410
410
|
case tb
|
411
411
|
when Proc
|
412
|
+
raise CannotValidateStaticallyError, "is: proc { } must be evaluated once for each resource" if self == Chef::Mixin::ParamsValidate
|
412
413
|
return true if instance_exec(value, &tb)
|
413
414
|
when Property
|
414
415
|
validate(opts, { key => tb.validation_options })
|
@@ -442,12 +443,21 @@ class Chef < (defined?(::Chef) ? ::Chef : Object)
|
|
442
443
|
#
|
443
444
|
def _pv_coerce(opts, key, coercer)
|
444
445
|
if opts.has_key?(key.to_s)
|
446
|
+
raise CannotValidateStaticallyError, "coerce must be evaluated for each resource." if self == Chef::Mixin::ParamsValidate
|
445
447
|
opts[key.to_s] = instance_exec(opts[key], &coercer)
|
446
448
|
elsif opts.has_key?(key.to_sym)
|
449
|
+
raise CannotValidateStaticallyError, "coerce must be evaluated for each resource." if self == Chef::Mixin::ParamsValidate
|
447
450
|
opts[key.to_sym] = instance_exec(opts[key], &coercer)
|
448
451
|
end
|
449
452
|
end
|
450
453
|
|
454
|
+
# We allow Chef::Mixin::ParamsValidate.validate(), but we will raise an
|
455
|
+
# error if you try to do anything requiring there to be an actual resource.
|
456
|
+
# This way, you can statically validate things if you have constant validation
|
457
|
+
# (which is the norm).
|
458
|
+
extend self
|
459
|
+
|
460
|
+
|
451
461
|
# Used by #set_or_return to avoid emitting a deprecation warning for
|
452
462
|
# "value nil" and to keep default stickiness working exactly the same
|
453
463
|
# @api private
|
@@ -2,9 +2,9 @@ require 'chef_compat/copied_from_chef'
|
|
2
2
|
class Chef
|
3
3
|
module ::ChefCompat
|
4
4
|
module CopiedFromChef
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
5
|
+
require "chef_compat/copied_from_chef/chef/delayed_evaluator"
|
6
|
+
require "chef_compat/copied_from_chef/chef/mixin/params_validate"
|
7
|
+
require "chef_compat/copied_from_chef/chef/property"
|
8
8
|
|
9
9
|
class Chef < (defined?(::Chef) ? ::Chef : Object)
|
10
10
|
module Mixin
|
@@ -20,7 +20,7 @@ module CopiedFromChef
|
|
20
20
|
# limitations under the License.
|
21
21
|
#
|
22
22
|
|
23
|
-
require
|
23
|
+
require "chef_compat/copied_from_chef/chef/delayed_evaluator"
|
24
24
|
|
25
25
|
class Chef < (defined?(::Chef) ? ::Chef : Object)
|
26
26
|
#
|
@@ -89,16 +89,21 @@ class Chef < (defined?(::Chef) ? ::Chef : Object)
|
|
89
89
|
#
|
90
90
|
def initialize(**options)
|
91
91
|
super if defined?(::Chef::Property)
|
92
|
-
options.each { |k,v| options[k.to_sym] = v if k.is_a?(String) }
|
92
|
+
options.each { |k,v| options[k.to_sym] = v; options.delete(k) if k.is_a?(String) }
|
93
|
+
@options = options
|
94
|
+
options[:name] = options[:name].to_sym if options[:name]
|
95
|
+
options[:instance_variable_name] = options[:instance_variable_name].to_sym if options[:instance_variable_name]
|
96
|
+
|
93
97
|
|
94
98
|
# Replace name_attribute with name_property
|
95
99
|
if options.has_key?(:name_attribute)
|
96
100
|
# If we have both name_attribute and name_property and they differ, raise an error
|
97
101
|
if options.has_key?(:name_property)
|
98
|
-
raise ArgumentError, "Cannot specify both name_property and name_attribute together on property #{
|
102
|
+
raise ArgumentError, "Cannot specify both name_property and name_attribute together on property #{self}."
|
99
103
|
end
|
100
104
|
# replace name_property with name_attribute in place
|
101
105
|
options = Hash[options.map { |k,v| k == :name_attribute ? [ :name_property, v ] : [ k,v ] }]
|
106
|
+
@options = options
|
102
107
|
end
|
103
108
|
|
104
109
|
# Only pick the first of :default, :name_property and :name_attribute if
|
@@ -111,17 +116,22 @@ super if defined?(::Chef::Property)
|
|
111
116
|
options.delete(:name_property)
|
112
117
|
preferred_default = :default
|
113
118
|
end
|
114
|
-
Chef.log_deprecation("Cannot specify both default and name_property together on property #{
|
119
|
+
Chef.log_deprecation("Cannot specify both default and name_property together on property #{self}. Only one (#{preferred_default}) will be obeyed. In Chef 13, this will become an error. Please remove one or the other from the property.")
|
115
120
|
end
|
116
121
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
122
|
+
# Validate the default early, so the user gets a good error message, and
|
123
|
+
# cache it so we don't do it again if so
|
124
|
+
begin
|
125
|
+
# If we can validate it all the way to output, do it.
|
126
|
+
@stored_default = input_to_stored_value(nil, default, is_default: true)
|
127
|
+
rescue Chef::Exceptions::CannotValidateStaticallyError
|
128
|
+
# If the validation is not static (i.e. has procs), we will have to
|
129
|
+
# coerce and validate the default each time we run
|
130
|
+
end
|
121
131
|
end
|
122
132
|
|
123
133
|
def to_s
|
124
|
-
name
|
134
|
+
"#{name}#{declared_in ? " of resource #{declared_in.resource_name}" : ""}"
|
125
135
|
end
|
126
136
|
|
127
137
|
#
|
@@ -255,14 +265,26 @@ super if defined?(::Chef::Property)
|
|
255
265
|
return get(resource)
|
256
266
|
end
|
257
267
|
|
258
|
-
if value.nil?
|
268
|
+
if value.nil?
|
259
269
|
# In Chef 12, value(nil) does a *get* instead of a set, so we
|
260
270
|
# warn if the value would have been changed. In Chef 13, it will be
|
261
271
|
# equivalent to value = nil.
|
262
272
|
result = get(resource)
|
263
|
-
|
264
|
-
|
273
|
+
|
274
|
+
# Warn about this becoming a set in Chef 13.
|
275
|
+
begin
|
276
|
+
input_to_stored_value(resource, value)
|
277
|
+
# If nil is valid, and it would change the value, warn that this will change to a set.
|
278
|
+
if !result.nil?
|
279
|
+
Chef.log_deprecation("An attempt was made to change #{name} from #{result.inspect} to nil by calling #{name}(nil). In Chef 12, this does a get rather than a set. In Chef 13, this will change to set the value to nil.")
|
280
|
+
end
|
281
|
+
rescue Chef::Exceptions::DeprecatedFeatureError
|
282
|
+
raise
|
283
|
+
rescue
|
284
|
+
# If nil is invalid, warn that this will become an error.
|
285
|
+
Chef.log_deprecation("nil is an invalid value for #{self}. In Chef 13, this warning will change to an error. Error: #{$!}")
|
265
286
|
end
|
287
|
+
|
266
288
|
result
|
267
289
|
else
|
268
290
|
# Anything else, such as myprop(value) is a set
|
@@ -293,16 +315,14 @@ super if defined?(::Chef::Property)
|
|
293
315
|
# this property, or if the value is required and not set.
|
294
316
|
#
|
295
317
|
def get(resource)
|
318
|
+
# If it's set, return it (and evaluate any lazy values)
|
296
319
|
if is_set?(resource)
|
297
320
|
value = get_value(resource)
|
298
|
-
|
299
|
-
value = exec_in_resource(resource, value)
|
300
|
-
value = coerce(resource, value)
|
301
|
-
validate(resource, value)
|
302
|
-
end
|
303
|
-
value
|
321
|
+
value = stored_value_to_output(resource, value)
|
304
322
|
|
305
323
|
else
|
324
|
+
# We are getting the default value.
|
325
|
+
|
306
326
|
# If the user does something like this:
|
307
327
|
#
|
308
328
|
# ```
|
@@ -322,19 +342,20 @@ super if defined?(::Chef::Property)
|
|
322
342
|
resource.resource_initializing &&
|
323
343
|
resource.respond_to?(:enclosing_provider) &&
|
324
344
|
resource.enclosing_provider &&
|
325
|
-
resource.enclosing_provider.
|
345
|
+
resource.enclosing_provider.new_resource &&
|
346
|
+
resource.enclosing_provider.new_resource.respond_to?(name)
|
326
347
|
Chef::Log.warn("#{Chef::Log.caller_location}: property #{name} is declared in both #{resource} and #{resource.enclosing_provider}. Use new_resource.#{name} instead. At #{Chef::Log.caller_location}")
|
327
348
|
end
|
328
349
|
|
329
350
|
if has_default?
|
330
|
-
|
331
|
-
if
|
332
|
-
value =
|
351
|
+
# If we were able to cache the stored_default, grab it.
|
352
|
+
if defined?(@stored_default)
|
353
|
+
value = @stored_default
|
354
|
+
else
|
355
|
+
# Otherwise, we have to validate it now.
|
356
|
+
value = input_to_stored_value(resource, default, is_default: true)
|
333
357
|
end
|
334
|
-
|
335
|
-
value = coerce(resource, value)
|
336
|
-
|
337
|
-
# We don't validate defaults
|
358
|
+
value = stored_value_to_output(resource, value, is_default: true)
|
338
359
|
|
339
360
|
# If the value is mutable (non-frozen), we set it on the instance
|
340
361
|
# so that people can mutate it. (All constant default values are
|
@@ -367,11 +388,7 @@ super if defined?(::Chef::Property)
|
|
367
388
|
# this property.
|
368
389
|
#
|
369
390
|
def set(resource, value)
|
370
|
-
|
371
|
-
value = coerce(resource, value)
|
372
|
-
validate(resource, value)
|
373
|
-
end
|
374
|
-
set_value(resource, value)
|
391
|
+
set_value(resource, input_to_stored_value(resource, value))
|
375
392
|
end
|
376
393
|
|
377
394
|
#
|
@@ -424,7 +441,10 @@ super if defined?(::Chef::Property)
|
|
424
441
|
#
|
425
442
|
def coerce(resource, value)
|
426
443
|
if options.has_key?(:coerce)
|
427
|
-
|
444
|
+
# If we have no default value, `nil` is never coerced or validated
|
445
|
+
unless !has_default? && value.nil?
|
446
|
+
value = exec_in_resource(resource, options[:coerce], value)
|
447
|
+
end
|
428
448
|
end
|
429
449
|
value
|
430
450
|
end
|
@@ -443,7 +463,10 @@ super if defined?(::Chef::Property)
|
|
443
463
|
# this property.
|
444
464
|
#
|
445
465
|
def validate(resource, value)
|
446
|
-
|
466
|
+
# If we have no default value, `nil` is never coerced or validated
|
467
|
+
unless value.nil? && !has_default?
|
468
|
+
(resource || Chef::Mixin::ParamsValidate).validate({ name => value }, { name => validation_options })
|
469
|
+
end
|
447
470
|
end
|
448
471
|
|
449
472
|
#
|
@@ -596,15 +619,54 @@ super if defined?(::Chef::Property)
|
|
596
619
|
value = resource.instance_exec(*args, &proc)
|
597
620
|
end
|
598
621
|
else
|
599
|
-
|
622
|
+
# If we don't have a resource yet, we can't exec in resource!
|
623
|
+
raise Chef::Exceptions::CannotValidateStaticallyError, "Cannot validate or coerce without a resource"
|
624
|
+
end
|
625
|
+
end
|
626
|
+
|
627
|
+
def input_to_stored_value(resource, value, is_default: false)
|
628
|
+
unless value.is_a?(DelayedEvaluator)
|
629
|
+
value = coerce_and_validate(resource, value, is_default: is_default)
|
600
630
|
end
|
631
|
+
value
|
632
|
+
end
|
601
633
|
|
634
|
+
def stored_value_to_output(resource, value, is_default: false)
|
635
|
+
# Crack open lazy values before giving the result to the user
|
602
636
|
if value.is_a?(DelayedEvaluator)
|
603
|
-
value =
|
604
|
-
|
637
|
+
value = exec_in_resource(resource, value)
|
638
|
+
value = coerce_and_validate(resource, value, is_default: is_default)
|
605
639
|
end
|
606
640
|
value
|
607
641
|
end
|
642
|
+
|
643
|
+
# Coerces and validates the value. If the value is a default, it will warn
|
644
|
+
# the user that invalid defaults are bad mmkay, and return it as if it were
|
645
|
+
# valid.
|
646
|
+
def coerce_and_validate(resource, value, is_default: false)
|
647
|
+
result = coerce(resource, value)
|
648
|
+
begin
|
649
|
+
# If the input is from a default, we need to emit an invalid default warning on validate.
|
650
|
+
validate(resource, result)
|
651
|
+
rescue Chef::Exceptions::CannotValidateStaticallyError
|
652
|
+
# This one gets re-raised
|
653
|
+
raise
|
654
|
+
rescue
|
655
|
+
# Anything else is just an invalid default: in those cases, we just
|
656
|
+
# warn and return the (possibly coerced) value to the user.
|
657
|
+
if is_default
|
658
|
+
if value.nil?
|
659
|
+
Chef.log_deprecation("Default value nil is invalid for property #{self}. Possible fixes: 1. Remove 'default: nil' if nil means 'undefined'. 2. Set a valid default value if there is a reasonable one. 3. Allow nil as a valid value of your property (for example, 'property #{name.inspect}, [ String, nil ], default: nil'). Error: #{$!}")
|
660
|
+
else
|
661
|
+
Chef.log_deprecation("Default value #{value.inspect} is invalid for property #{self}. In Chef 13 this will become an error: #{$!}.")
|
662
|
+
end
|
663
|
+
else
|
664
|
+
raise
|
665
|
+
end
|
666
|
+
end
|
667
|
+
|
668
|
+
result
|
669
|
+
end
|
608
670
|
end
|
609
671
|
end
|
610
672
|
end
|
@@ -30,11 +30,11 @@ super if defined?(::Chef::Provider)
|
|
30
30
|
modified = specified_properties.select { |p| new_resource.send(p) != current_resource.send(p) }
|
31
31
|
if modified.empty?
|
32
32
|
properties_str = if sensitive
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
Chef::Log.debug("Skipping update of #{new_resource
|
33
|
+
specified_properties.join(", ")
|
34
|
+
else
|
35
|
+
specified_properties.map { |p| "#{p}=#{new_resource.send(p).inspect}" }.join(", ")
|
36
|
+
end
|
37
|
+
Chef::Log.debug("Skipping update of #{new_resource}: has not changed any of the specified properties #{properties_str}.")
|
38
38
|
return false
|
39
39
|
end
|
40
40
|
|
@@ -42,10 +42,10 @@ super if defined?(::Chef::Provider)
|
|
42
42
|
property_size = modified.map { |p| p.size }.max
|
43
43
|
modified.map! do |p|
|
44
44
|
properties_str = if sensitive
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
"(suppressed sensitive property)"
|
46
|
+
else
|
47
|
+
"#{new_resource.send(p).inspect} (was #{current_resource.send(p).inspect})"
|
48
|
+
end
|
49
49
|
" set #{p.to_s.ljust(property_size)} to #{properties_str}"
|
50
50
|
end
|
51
51
|
converge_by([ "update #{current_resource.identity}" ] + modified, &converge_block)
|
@@ -55,12 +55,12 @@ super if defined?(::Chef::Provider)
|
|
55
55
|
# write down any properties we are setting.
|
56
56
|
property_size = properties.map { |p| p.size }.max
|
57
57
|
created = properties.map do |property|
|
58
|
-
default =
|
58
|
+
default = " (default value)" unless new_resource.property_is_set?(property)
|
59
59
|
properties_str = if sensitive
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
60
|
+
"(suppressed sensitive property)"
|
61
|
+
else
|
62
|
+
new_resource.send(property).inspect
|
63
|
+
end
|
64
64
|
" set #{property.to_s.ljust(property_size)} to #{properties_str}#{default}"
|
65
65
|
end
|
66
66
|
|
@@ -97,10 +97,10 @@ super if defined?(::Chef::Provider)
|
|
97
97
|
EOM
|
98
98
|
end
|
99
99
|
dsl_methods =
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
100
|
+
resource.class.public_instance_methods +
|
101
|
+
resource.class.protected_instance_methods -
|
102
|
+
provider_class.instance_methods -
|
103
|
+
resource.class.properties.keys
|
104
104
|
def_delegators(:new_resource, *dsl_methods)
|
105
105
|
end
|
106
106
|
include @included_resource_dsl_module
|
@@ -141,7 +141,7 @@ super if defined?(::Chef::Provider)
|
|
141
141
|
end
|
142
142
|
end
|
143
143
|
end
|
144
|
-
require
|
144
|
+
require "chef_compat/copied_from_chef/chef/dsl/recipe"
|
145
145
|
include Chef::DSL::Recipe::FullDSL
|
146
146
|
end
|
147
147
|
protected
|
@@ -2,13 +2,13 @@ require 'chef_compat/copied_from_chef'
|
|
2
2
|
class Chef
|
3
3
|
module ::ChefCompat
|
4
4
|
module CopiedFromChef
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
5
|
+
require "chef_compat/copied_from_chef/chef/resource/action_class"
|
6
|
+
require "chef_compat/copied_from_chef/chef/provider"
|
7
|
+
require "chef_compat/copied_from_chef/chef/mixin/properties"
|
8
8
|
class Chef < (defined?(::Chef) ? ::Chef : Object)
|
9
9
|
class Resource < (defined?(::Chef::Resource) ? ::Chef::Resource : Object)
|
10
10
|
include Chef::Mixin::Properties
|
11
|
-
property :name, String, coerce: proc { |v| v.is_a?(Array) ? v.join(
|
11
|
+
property :name, String, coerce: proc { |v| v.is_a?(Array) ? v.join(", ") : v.to_s }, desired_state: false
|
12
12
|
def initialize(name, run_context=nil)
|
13
13
|
super if defined?(::Chef::Resource)
|
14
14
|
name(name) unless name.nil?
|
@@ -44,7 +44,7 @@ super if defined?(::Chef::Resource)
|
|
44
44
|
arg.each do |action|
|
45
45
|
validate(
|
46
46
|
{ action: action },
|
47
|
-
{ action: { kind_of: Symbol, equal_to: allowed_actions } }
|
47
|
+
{ action: { kind_of: Symbol, equal_to: allowed_actions } },
|
48
48
|
)
|
49
49
|
end
|
50
50
|
@action = arg
|
@@ -89,7 +89,7 @@ super if defined?(::Chef::Resource)
|
|
89
89
|
end
|
90
90
|
safe_ivars = instance_variables.map { |ivar| ivar.to_sym } - FORBIDDEN_IVARS
|
91
91
|
safe_ivars.each do |iv|
|
92
|
-
key = iv.to_s.sub(/^@/,
|
92
|
+
key = iv.to_s.sub(/^@/,"").to_sym
|
93
93
|
next if result.has_key?(key)
|
94
94
|
result[key] = instance_variable_get(iv)
|
95
95
|
end
|
@@ -113,7 +113,7 @@ super if defined?(::Chef::Resource)
|
|
113
113
|
@resource_name || self.class.resource_name
|
114
114
|
end
|
115
115
|
def self.use_automatic_resource_name
|
116
|
-
automatic_name = convert_to_snake_case(self.name.split(
|
116
|
+
automatic_name = convert_to_snake_case(self.name.split("::")[-1])
|
117
117
|
resource_name automatic_name
|
118
118
|
end
|
119
119
|
def self.allowed_actions(*actions)
|
@@ -168,17 +168,17 @@ super if defined?(::Chef::Resource)
|
|
168
168
|
end
|
169
169
|
def self.declare_action_class(&block)
|
170
170
|
@action_class ||= begin
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
171
|
+
if superclass.respond_to?(:action_class)
|
172
|
+
base_provider = superclass.action_class
|
173
|
+
end
|
174
|
+
base_provider ||= Chef::Provider
|
175
175
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
176
|
+
resource_class = self
|
177
|
+
Class.new(base_provider) do
|
178
|
+
include ActionClass
|
179
|
+
self.resource_class = resource_class
|
180
|
+
end
|
181
|
+
end
|
182
182
|
@action_class.class_eval(&block) if block
|
183
183
|
@action_class
|
184
184
|
end
|
@@ -1,7 +1,10 @@
|
|
1
|
+
require 'chef/exceptions'
|
2
|
+
|
1
3
|
class Chef
|
2
4
|
class Exceptions
|
3
5
|
# Used in Resource::ActionClass#load_current_resource to denote that
|
4
6
|
# the resource doesn't actually exist (for example, the file does not exist)
|
5
|
-
class CurrentValueDoesNotExist < RuntimeError; end
|
7
|
+
class CurrentValueDoesNotExist < RuntimeError; end unless defined?(CurrentValueDoesNotExist)
|
8
|
+
class CannotValidateStaticallyError < RuntimeError; end unless defined?(CannotValidateStaticallyError)
|
6
9
|
end
|
7
10
|
end
|
@@ -9,7 +9,6 @@ module ChefCompat
|
|
9
9
|
@compat_resource_filter_paths ||=
|
10
10
|
Gem.loaded_specs['chef'].require_paths.map { |p| File.join(Gem.loaded_specs['chef'].full_gem_path, p) } +
|
11
11
|
Gem.loaded_specs['compat_resource'].require_paths.map { |p| File.join(Gem.loaded_specs['compat_resource'].full_gem_path, p) }
|
12
|
-
puts caller.select { |c| !@compat_resource_filter_paths.any? { |path| c.start_with?(path) } }
|
13
12
|
|
14
13
|
caller.select { |c| !@compat_resource_filter_paths.any? { |path| c.start_with?(path) } }.first
|
15
14
|
end
|
@@ -1,10 +1,9 @@
|
|
1
|
-
|
2
|
-
remote: git://github.com/chef/chef.git
|
3
|
-
revision: 5f51f93f71cdee3ed598b38cecd8f5fa1a585f49
|
1
|
+
GEM
|
4
2
|
specs:
|
3
|
+
builder (3.2.2)
|
5
4
|
chef (12.6.0)
|
6
5
|
chef-config (= 12.6.0)
|
7
|
-
chef-zero (~> 4.
|
6
|
+
chef-zero (~> 4.2, >= 4.2.2)
|
8
7
|
diff-lcs (~> 1.2, >= 1.2.4)
|
9
8
|
erubis (~> 2.7)
|
10
9
|
ffi-yajl (~> 2.2)
|
@@ -29,11 +28,7 @@ GIT
|
|
29
28
|
chef-config (12.6.0)
|
30
29
|
mixlib-config (~> 2.0)
|
31
30
|
mixlib-shellout (~> 2.0)
|
32
|
-
|
33
|
-
GEM
|
34
|
-
specs:
|
35
|
-
builder (3.2.2)
|
36
|
-
chef-zero (4.4.0)
|
31
|
+
chef-zero (4.4.2)
|
37
32
|
ffi-yajl (~> 2.2)
|
38
33
|
hashie (>= 2.0, < 4.0)
|
39
34
|
mixlib-log (~> 1.3)
|
@@ -43,15 +38,18 @@ GEM
|
|
43
38
|
diff-lcs (1.2.5)
|
44
39
|
erubis (2.7.0)
|
45
40
|
ffi (1.9.10)
|
46
|
-
ffi-yajl (2.2.
|
41
|
+
ffi-yajl (2.2.3)
|
47
42
|
libyajl2 (~> 1.2)
|
48
43
|
hashie (3.4.3)
|
49
44
|
highline (1.7.8)
|
50
|
-
ipaddress (0.8.
|
45
|
+
ipaddress (0.8.2)
|
51
46
|
libyajl2 (1.2.0)
|
52
47
|
method_source (0.8.2)
|
53
|
-
mixlib-authentication (1.
|
48
|
+
mixlib-authentication (1.4.0)
|
54
49
|
mixlib-log
|
50
|
+
rspec-core (~> 3.2)
|
51
|
+
rspec-expectations (~> 3.2)
|
52
|
+
rspec-mocks (~> 3.2)
|
55
53
|
mixlib-cli (1.5.0)
|
56
54
|
mixlib-config (2.2.1)
|
57
55
|
mixlib-log (1.6.0)
|
@@ -66,7 +64,7 @@ GEM
|
|
66
64
|
net-ssh (>= 2.6.5)
|
67
65
|
net-ssh-gateway (>= 1.2.0)
|
68
66
|
net-telnet (0.1.1)
|
69
|
-
ohai (8.
|
67
|
+
ohai (8.9.0)
|
70
68
|
chef-config (>= 12.5.0.alpha.1, < 13)
|
71
69
|
ffi (~> 1.9)
|
72
70
|
ffi-yajl (~> 2.2)
|
@@ -85,12 +83,12 @@ GEM
|
|
85
83
|
method_source (~> 0.8.1)
|
86
84
|
slop (~> 3.4)
|
87
85
|
rack (1.6.4)
|
88
|
-
rake (10.
|
86
|
+
rake (10.5.0)
|
89
87
|
rspec (3.4.0)
|
90
88
|
rspec-core (~> 3.4.0)
|
91
89
|
rspec-expectations (~> 3.4.0)
|
92
90
|
rspec-mocks (~> 3.4.0)
|
93
|
-
rspec-core (3.4.
|
91
|
+
rspec-core (3.4.2)
|
94
92
|
rspec-support (~> 3.4.0)
|
95
93
|
rspec-expectations (3.4.0)
|
96
94
|
diff-lcs (>= 1.2.0, < 2.0)
|
@@ -98,21 +96,21 @@ GEM
|
|
98
96
|
rspec-its (1.2.0)
|
99
97
|
rspec-core (>= 3.0.0)
|
100
98
|
rspec-expectations (>= 3.0.0)
|
101
|
-
rspec-mocks (3.4.
|
99
|
+
rspec-mocks (3.4.1)
|
102
100
|
diff-lcs (>= 1.2.0, < 2.0)
|
103
101
|
rspec-support (~> 3.4.0)
|
104
102
|
rspec-support (3.4.1)
|
105
103
|
rspec_junit_formatter (0.2.3)
|
106
104
|
builder (< 4)
|
107
105
|
rspec-core (>= 2, < 4, != 2.12.0)
|
108
|
-
serverspec (2.
|
106
|
+
serverspec (2.29.1)
|
109
107
|
multi_json
|
110
108
|
rspec (~> 3.0)
|
111
109
|
rspec-its
|
112
|
-
specinfra (~> 2.
|
110
|
+
specinfra (~> 2.48)
|
113
111
|
sfl (2.2)
|
114
112
|
slop (3.6.0)
|
115
|
-
specinfra (2.
|
113
|
+
specinfra (2.50.3)
|
116
114
|
net-scp
|
117
115
|
net-ssh (>= 2.7, < 3.1)
|
118
116
|
net-telnet
|
@@ -126,7 +124,7 @@ PLATFORMS
|
|
126
124
|
ruby
|
127
125
|
|
128
126
|
DEPENDENCIES
|
129
|
-
chef
|
127
|
+
chef
|
130
128
|
|
131
129
|
BUNDLED WITH
|
132
|
-
1.
|
130
|
+
1.11.2
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: compat_resource
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 12.
|
4
|
+
version: 12.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Keiser
|
8
8
|
autorequire:
|
9
9
|
bindir: files/bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
164
|
version: '0'
|
165
165
|
requirements: []
|
166
166
|
rubyforge_project:
|
167
|
-
rubygems_version: 2.5.
|
167
|
+
rubygems_version: 2.4.5.1
|
168
168
|
signing_key:
|
169
169
|
specification_version: 4
|
170
170
|
summary: Bring some new features of Chef 12.5 to previous 12.X releases
|