compat_resource 12.7.1 → 12.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +5 -0
- data/files/lib/chef_compat/copied_from_chef/chef/constants.rb +5 -0
- data/files/lib/chef_compat/copied_from_chef/chef/delayed_evaluator.rb +4 -0
- data/files/lib/chef_compat/copied_from_chef/chef/dsl/declare_resource.rb +7 -3
- data/files/lib/chef_compat/copied_from_chef/chef/dsl/recipe.rb +4 -0
- data/files/lib/chef_compat/copied_from_chef/chef/mixin/params_validate.rb +7 -4
- data/files/lib/chef_compat/copied_from_chef/chef/mixin/properties.rb +9 -5
- data/files/lib/chef_compat/copied_from_chef/chef/property.rb +14 -11
- data/files/lib/chef_compat/copied_from_chef/chef/provider.rb +4 -0
- data/files/lib/chef_compat/copied_from_chef/chef/resource.rb +10 -6
- data/files/lib/chef_compat/copied_from_chef/chef/resource/action_class.rb +5 -1
- data/files/lib/chef_compat/copied_from_chef/chef/resource_builder.rb +4 -0
- data/files/lib/compat_resource/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed268da9671b0afd05e7febfabc797b8e259675d
|
4
|
+
data.tar.gz: e8eeaceb5f6707856a90c7b2c0d55549353afc5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0884d41c143edb61e2c4219f98983cbe379968d38d16a3606deba2180b9f4ee7d124d21eb2300864019b6fffb912704be6433dd813abb4be55ebad0827452fe3
|
7
|
+
data.tar.gz: 88a8398a2276ab2fcf7b4e2f69a8ddf174576a6be0171a4b3fff28d262a909d4a624af5aba361cb47f5f01061ea711bab660aa48fd48dfb3f676817646b83707
|
data/Rakefile
CHANGED
@@ -89,6 +89,11 @@ task :update do
|
|
89
89
|
chef_gem_path = Bundler.environment.specs['chef'].first.full_gem_path
|
90
90
|
CHEF_FILES.each do |file|
|
91
91
|
output = StringIO.new
|
92
|
+
# First lets try to load the original file if it exists
|
93
|
+
output.puts "begin"
|
94
|
+
output.puts " require '#{file}'"
|
95
|
+
output.puts "rescue LoadError; end"
|
96
|
+
output.puts ""
|
92
97
|
# Wrap the whole thing in a ChefCompat module
|
93
98
|
output.puts "require 'chef_compat/copied_from_chef'"
|
94
99
|
output.puts "class Chef"
|
@@ -1,3 +1,7 @@
|
|
1
|
+
begin
|
2
|
+
require 'chef/constants'
|
3
|
+
rescue LoadError; end
|
4
|
+
|
1
5
|
require 'chef_compat/copied_from_chef'
|
2
6
|
class Chef
|
3
7
|
module ::ChefCompat
|
@@ -24,6 +28,7 @@ class Chef < (defined?(::Chef) ? ::Chef : Object)
|
|
24
28
|
def NOT_PASSED.to_s
|
25
29
|
"NOT_PASSED"
|
26
30
|
end
|
31
|
+
|
27
32
|
def NOT_PASSED.inspect
|
28
33
|
to_s
|
29
34
|
end
|
@@ -1,3 +1,7 @@
|
|
1
|
+
begin
|
2
|
+
require 'chef/dsl/declare_resource'
|
3
|
+
rescue LoadError; end
|
4
|
+
|
1
5
|
require 'chef_compat/copied_from_chef'
|
2
6
|
class Chef
|
3
7
|
module ::ChefCompat
|
@@ -53,7 +57,7 @@ class Chef < (defined?(::Chef) ? ::Chef : Object)
|
|
53
57
|
# action :delete
|
54
58
|
# end
|
55
59
|
#
|
56
|
-
def declare_resource(type, name, created_at=nil, run_context: self.run_context, create_if_missing: false, &resource_attrs_block)
|
60
|
+
def declare_resource(type, name, created_at = nil, run_context: self.run_context, create_if_missing: false, &resource_attrs_block)
|
57
61
|
created_at ||= caller[0]
|
58
62
|
|
59
63
|
if create_if_missing
|
@@ -91,7 +95,7 @@ class Chef < (defined?(::Chef) ? ::Chef : Object)
|
|
91
95
|
# action :delete
|
92
96
|
# end
|
93
97
|
#
|
94
|
-
def build_resource(type, name, created_at=nil, run_context: self.run_context, &resource_attrs_block)
|
98
|
+
def build_resource(type, name, created_at = nil, run_context: self.run_context, &resource_attrs_block)
|
95
99
|
created_at ||= caller[0]
|
96
100
|
Thread.exclusive do
|
97
101
|
require "chef_compat/copied_from_chef/chef/resource_builder" unless defined?(Chef::ResourceBuilder)
|
@@ -105,7 +109,7 @@ class Chef < (defined?(::Chef) ? ::Chef : Object)
|
|
105
109
|
run_context: run_context,
|
106
110
|
cookbook_name: cookbook_name,
|
107
111
|
recipe_name: recipe_name,
|
108
|
-
enclosing_provider: self.is_a?(Chef::Provider) ? self :
|
112
|
+
enclosing_provider: self.is_a?(Chef::Provider) ? self : nil,
|
109
113
|
).build(&resource_attrs_block)
|
110
114
|
end
|
111
115
|
end
|
@@ -1,3 +1,7 @@
|
|
1
|
+
begin
|
2
|
+
require 'chef/mixin/params_validate'
|
3
|
+
rescue LoadError; end
|
4
|
+
|
1
5
|
require 'chef_compat/copied_from_chef'
|
2
6
|
class Chef
|
3
7
|
module ::ChefCompat
|
@@ -146,7 +150,7 @@ class Chef < (defined?(::Chef) ? ::Chef : Object)
|
|
146
150
|
end
|
147
151
|
|
148
152
|
# Raise an exception if the parameter is not found.
|
149
|
-
def _pv_required(opts, key, is_required=true, explicitly_allows_nil=false)
|
153
|
+
def _pv_required(opts, key, is_required = true, explicitly_allows_nil = false)
|
150
154
|
if is_required
|
151
155
|
return true if opts.has_key?(key.to_s) && (explicitly_allows_nil || !opts[key.to_s].nil?)
|
152
156
|
return true if opts.has_key?(key.to_sym) && (explicitly_allows_nil || !opts[key.to_sym].nil?)
|
@@ -335,7 +339,7 @@ class Chef < (defined?(::Chef) ? ::Chef : Object)
|
|
335
339
|
# property :x, name_property: true
|
336
340
|
# ```
|
337
341
|
#
|
338
|
-
def _pv_name_property(opts, key, is_name_property=true)
|
342
|
+
def _pv_name_property(opts, key, is_name_property = true)
|
339
343
|
if is_name_property
|
340
344
|
if opts[key].nil?
|
341
345
|
raise CannotValidateStaticallyError, "name_property cannot be evaluated without a resource." if self == Chef::Mixin::ParamsValidate
|
@@ -468,7 +472,6 @@ class Chef < (defined?(::Chef) ? ::Chef : Object)
|
|
468
472
|
# (which is the norm).
|
469
473
|
extend self
|
470
474
|
|
471
|
-
|
472
475
|
# Used by #set_or_return to avoid emitting a deprecation warning for
|
473
476
|
# "value nil" and to keep default stickiness working exactly the same
|
474
477
|
# @api private
|
@@ -482,7 +485,7 @@ class Chef < (defined?(::Chef) ? ::Chef : Object)
|
|
482
485
|
value
|
483
486
|
end
|
484
487
|
|
485
|
-
def call(resource, value=NOT_PASSED)
|
488
|
+
def call(resource, value = NOT_PASSED)
|
486
489
|
# setting to nil does a get
|
487
490
|
if value.nil? && !explicitly_accepts_nil?(resource)
|
488
491
|
get(resource)
|
@@ -1,3 +1,7 @@
|
|
1
|
+
begin
|
2
|
+
require 'chef/mixin/properties'
|
3
|
+
rescue LoadError; end
|
4
|
+
|
1
5
|
require 'chef_compat/copied_from_chef'
|
2
6
|
class Chef
|
3
7
|
module ::ChefCompat
|
@@ -24,7 +28,7 @@ class Chef < (defined?(::Chef) ? ::Chef : Object)
|
|
24
28
|
#
|
25
29
|
# @return [Hash<Symbol,Property>] The list of property names and types.
|
26
30
|
#
|
27
|
-
def properties(include_superclass=true)
|
31
|
+
def properties(include_superclass = true)
|
28
32
|
if include_superclass
|
29
33
|
result = {}
|
30
34
|
ancestors.reverse_each { |c| result.merge!(c.properties(false)) if c.respond_to?(:properties) }
|
@@ -99,10 +103,10 @@ class Chef < (defined?(::Chef) ? ::Chef : Object)
|
|
99
103
|
# @example With type and options
|
100
104
|
# property :x, String, default: 'hi'
|
101
105
|
#
|
102
|
-
def property(name, type=NOT_PASSED, **options)
|
106
|
+
def property(name, type = NOT_PASSED, **options)
|
103
107
|
name = name.to_sym
|
104
108
|
|
105
|
-
options.each { |k,v| options[k.to_sym] = v if k.is_a?(String) }
|
109
|
+
options.each { |k, v| options[k.to_sym] = v if k.is_a?(String) }
|
106
110
|
|
107
111
|
options[:instance_variable_name] = :"@#{name}" if !options.has_key?(:instance_variable_name)
|
108
112
|
options.merge!(name: name, declared_in: self)
|
@@ -207,7 +211,7 @@ class Chef < (defined?(::Chef) ? ::Chef : Object)
|
|
207
211
|
|
208
212
|
# If state_attrs *excludes* something which is currently desired state,
|
209
213
|
# mark it as desired_state: false.
|
210
|
-
local_properties.each do |name,property|
|
214
|
+
local_properties.each do |name, property|
|
211
215
|
if property.desired_state? && !names.include?(name)
|
212
216
|
self.property name, desired_state: false
|
213
217
|
end
|
@@ -255,7 +259,7 @@ class Chef < (defined?(::Chef) ? ::Chef : Object)
|
|
255
259
|
|
256
260
|
# If identity_properties *excludes* something which is currently part of
|
257
261
|
# the identity, mark it as identity: false.
|
258
|
-
properties.each do |name,property|
|
262
|
+
properties.each do |name, property|
|
259
263
|
if property.identity? && !names.include?(name)
|
260
264
|
|
261
265
|
self.property name, identity: false
|
@@ -1,3 +1,7 @@
|
|
1
|
+
begin
|
2
|
+
require 'chef/property'
|
3
|
+
rescue LoadError; end
|
4
|
+
|
1
5
|
require 'chef_compat/copied_from_chef'
|
2
6
|
class Chef
|
3
7
|
module ::ChefCompat
|
@@ -89,12 +93,11 @@ class Chef < (defined?(::Chef) ? ::Chef : Object)
|
|
89
93
|
#
|
90
94
|
def initialize(**options)
|
91
95
|
super if defined?(::Chef::Property)
|
92
|
-
options.each { |k,v| options[k.to_sym] = v; options.delete(k) if k.is_a?(String) }
|
96
|
+
options.each { |k, v| options[k.to_sym] = v; options.delete(k) if k.is_a?(String) }
|
93
97
|
@options = options
|
94
98
|
options[:name] = options[:name].to_sym if options[:name]
|
95
99
|
options[:instance_variable_name] = options[:instance_variable_name].to_sym if options[:instance_variable_name]
|
96
100
|
|
97
|
-
|
98
101
|
# Replace name_attribute with name_property
|
99
102
|
if options.has_key?(:name_attribute)
|
100
103
|
# If we have both name_attribute and name_property and they differ, raise an error
|
@@ -102,7 +105,7 @@ super if defined?(::Chef::Property)
|
|
102
105
|
raise ArgumentError, "Cannot specify both name_property and name_attribute together on property #{self}."
|
103
106
|
end
|
104
107
|
# replace name_property with name_attribute in place
|
105
|
-
options = Hash[options.map { |k,v| k == :name_attribute ? [ :name_property, v ] : [ k,v ] }]
|
108
|
+
options = Hash[options.map { |k, v| k == :name_attribute ? [ :name_property, v ] : [ k, v ] }]
|
106
109
|
@options = options
|
107
110
|
end
|
108
111
|
|
@@ -235,8 +238,8 @@ super if defined?(::Chef::Property)
|
|
235
238
|
# @return [Hash<Symbol,Object>]
|
236
239
|
#
|
237
240
|
def validation_options
|
238
|
-
@validation_options ||= options.reject { |k,v|
|
239
|
-
[:declared_in
|
241
|
+
@validation_options ||= options.reject { |k, v|
|
242
|
+
[:declared_in, :name, :instance_variable_name, :desired_state, :identity, :default, :name_property, :coerce, :required].include?(k)
|
240
243
|
}
|
241
244
|
end
|
242
245
|
|
@@ -260,7 +263,7 @@ super if defined?(::Chef::Property)
|
|
260
263
|
# will be returned without running, validating or coercing. If it is a
|
261
264
|
# `get`, the non-lazy, coerced, validated value will always be returned.
|
262
265
|
#
|
263
|
-
def call(resource, value=NOT_PASSED)
|
266
|
+
def call(resource, value = NOT_PASSED)
|
264
267
|
if value == NOT_PASSED
|
265
268
|
return get(resource)
|
266
269
|
end
|
@@ -344,7 +347,7 @@ super if defined?(::Chef::Property)
|
|
344
347
|
resource.enclosing_provider &&
|
345
348
|
resource.enclosing_provider.new_resource &&
|
346
349
|
resource.enclosing_provider.new_resource.respond_to?(name)
|
347
|
-
|
350
|
+
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}")
|
348
351
|
end
|
349
352
|
|
350
353
|
if has_default?
|
@@ -491,7 +494,7 @@ super if defined?(::Chef::Property)
|
|
491
494
|
if modified_options.has_key?(:name_property) ||
|
492
495
|
modified_options.has_key?(:name_attribute) ||
|
493
496
|
modified_options.has_key?(:default)
|
494
|
-
options = options.reject { |k,v| k == :name_attribute || k == :name_property || k == :default }
|
497
|
+
options = options.reject { |k, v| k == :name_attribute || k == :name_property || k == :default }
|
495
498
|
end
|
496
499
|
self.class.new(options.merge(modified_options))
|
497
500
|
end
|
@@ -508,7 +511,7 @@ super if defined?(::Chef::Property)
|
|
508
511
|
|
509
512
|
# We prefer this form because the property name won't show up in the
|
510
513
|
# stack trace if you use `define_method`.
|
511
|
-
declared_in.class_eval <<-EOM, __FILE__, __LINE__+1
|
514
|
+
declared_in.class_eval <<-EOM, __FILE__, __LINE__ + 1
|
512
515
|
def #{name}(value=NOT_PASSED)
|
513
516
|
raise "Property #{name} of \#{self} cannot be passed a block! If you meant to create a resource named #{name} instead, you'll need to first rename the property." if block_given?
|
514
517
|
self.class.properties[#{name.inspect}].call(self, value)
|
@@ -520,7 +523,7 @@ super if defined?(::Chef::Property)
|
|
520
523
|
EOM
|
521
524
|
rescue SyntaxError
|
522
525
|
# If the name is not a valid ruby name, we use define_method.
|
523
|
-
declared_in.define_method(name) do |value=NOT_PASSED, &block|
|
526
|
+
declared_in.define_method(name) do |value = NOT_PASSED, &block|
|
524
527
|
raise "Property #{name} of #{self} cannot be passed a block! If you meant to create a resource named #{name} instead, you'll need to first rename the property." if block
|
525
528
|
self.class.properties[name].call(self, value)
|
526
529
|
end
|
@@ -579,7 +582,7 @@ super if defined?(::Chef::Property)
|
|
579
582
|
# @api private
|
580
583
|
def explicitly_accepts_nil?(resource)
|
581
584
|
options.has_key?(:coerce) ||
|
582
|
-
|
585
|
+
(options.has_key?(:is) && resource.send(:_pv_is, { name => nil }, name, options[:is], raise_error: false))
|
583
586
|
end
|
584
587
|
|
585
588
|
def get_value(resource)
|
@@ -1,3 +1,7 @@
|
|
1
|
+
begin
|
2
|
+
require 'chef/resource'
|
3
|
+
rescue LoadError; end
|
4
|
+
|
1
5
|
require 'chef_compat/copied_from_chef'
|
2
6
|
class Chef
|
3
7
|
module ::ChefCompat
|
@@ -9,7 +13,7 @@ class Chef < (defined?(::Chef) ? ::Chef : Object)
|
|
9
13
|
class Resource < (defined?(::Chef::Resource) ? ::Chef::Resource : Object)
|
10
14
|
include Chef::Mixin::Properties
|
11
15
|
property :name, String, coerce: proc { |v| v.is_a?(Array) ? v.join(", ") : v.to_s }, desired_state: false
|
12
|
-
def initialize(name, run_context=nil)
|
16
|
+
def initialize(name, run_context = nil)
|
13
17
|
super if defined?(::Chef::Resource)
|
14
18
|
name(name) unless name.nil?
|
15
19
|
@run_context = run_context
|
@@ -38,7 +42,7 @@ super if defined?(::Chef::Resource)
|
|
38
42
|
@elapsed_time = 0
|
39
43
|
@sensitive = false
|
40
44
|
end
|
41
|
-
def action(arg=nil)
|
45
|
+
def action(arg = nil)
|
42
46
|
if arg
|
43
47
|
arg = Array(arg).map(&:to_sym)
|
44
48
|
arg.each do |action|
|
@@ -89,13 +93,13 @@ super if defined?(::Chef::Resource)
|
|
89
93
|
end
|
90
94
|
safe_ivars = instance_variables.map { |ivar| ivar.to_sym } - FORBIDDEN_IVARS
|
91
95
|
safe_ivars.each do |iv|
|
92
|
-
key = iv.to_s.sub(/^@/,"").to_sym
|
96
|
+
key = iv.to_s.sub(/^@/, "").to_sym
|
93
97
|
next if result.has_key?(key)
|
94
98
|
result[key] = instance_variable_get(iv)
|
95
99
|
end
|
96
100
|
result
|
97
101
|
end
|
98
|
-
def self.identity_property(name=nil)
|
102
|
+
def self.identity_property(name = nil)
|
99
103
|
result = identity_properties(*Array(name))
|
100
104
|
if result.size > 1
|
101
105
|
raise Chef::Exceptions::MultipleIdentityError, "identity_property cannot be called on an object with more than one identity property (#{result.map { |r| r.name }.join(", ")})."
|
@@ -103,7 +107,7 @@ super if defined?(::Chef::Resource)
|
|
103
107
|
result.first
|
104
108
|
end
|
105
109
|
attr_accessor :allowed_actions
|
106
|
-
def allowed_actions(value=NOT_PASSED)
|
110
|
+
def allowed_actions(value = NOT_PASSED)
|
107
111
|
if value != NOT_PASSED
|
108
112
|
self.allowed_actions = value
|
109
113
|
end
|
@@ -128,7 +132,7 @@ super if defined?(::Chef::Resource)
|
|
128
132
|
def self.allowed_actions=(value)
|
129
133
|
@allowed_actions = value.uniq
|
130
134
|
end
|
131
|
-
def self.default_action(action_name=NOT_PASSED)
|
135
|
+
def self.default_action(action_name = NOT_PASSED)
|
132
136
|
unless action_name.equal?(NOT_PASSED)
|
133
137
|
@default_action = Array(action_name).map(&:to_sym)
|
134
138
|
self.allowed_actions |= @default_action
|
@@ -1,3 +1,7 @@
|
|
1
|
+
begin
|
2
|
+
require 'chef/resource/action_class'
|
3
|
+
rescue LoadError; end
|
4
|
+
|
1
5
|
require 'chef_compat/copied_from_chef'
|
2
6
|
class Chef
|
3
7
|
module ::ChefCompat
|
@@ -40,7 +44,7 @@ class Chef < (defined?(::Chef) ? ::Chef : Object)
|
|
40
44
|
# We clear desired state in the copy, because it is supposed to be actual state.
|
41
45
|
# We keep identity properties and non-desired-state, which are assumed to be
|
42
46
|
# "control" values like `recurse: true`
|
43
|
-
current_resource.class.properties.each do |name,property|
|
47
|
+
current_resource.class.properties.each do |name, property|
|
44
48
|
if property.desired_state? && !property.identity? && !property.name_property?
|
45
49
|
property.reset(current_resource)
|
46
50
|
end
|
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.7.
|
4
|
+
version: 12.7.3
|
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: 2016-02-
|
11
|
+
date: 2016-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|