compat_resource 12.10.6 → 12.10.7
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/Gemfile +1 -0
- data/Rakefile +2 -0
- data/files/lib/chef_compat/copied_from_chef/chef/dsl/core.rb +19 -10
- data/files/lib/chef_compat/copied_from_chef/chef/dsl/platform_introspection.rb +284 -0
- data/files/lib/chef_compat/copied_from_chef/chef/dsl/universal.rb +62 -0
- data/files/lib/chef_compat/copied_from_chef/chef/property.rb +6 -2
- data/files/lib/chef_compat/copied_from_chef/chef/resource.rb +4 -1
- data/files/lib/chef_compat/copied_from_chef/chef/resource_builder.rb +9 -4
- data/files/lib/compat_resource/version.rb +1 -1
- data/files/spec/data/Gemfile +2 -0
- metadata +5 -5
- data/files/spec/data/Gemfile.lock +0 -126
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f44c1502b64008be675f64d8c56c7a5bfa7b1f17
|
4
|
+
data.tar.gz: 36c46de73ae8075d47467868e07f882e91f3b974
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6869fc1630c3394d2a1a4f587542b160e8a9207b24811824cbc5ff015e522cdb84031498ffd19961a518de42f4ceffbab255c87562390e7a05150795550b18e6
|
7
|
+
data.tar.gz: e7e55d029ab8e05a1c8e9fe8cff3d56f4a0d4944b9955e9cd63fc5a5a9131c8c04db7d8bce2c143ac86e65b69f493ab5621a88486d4c9a3720ce5d89738b2534
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -18,7 +18,9 @@ CHEF_FILES = %w(
|
|
18
18
|
chef/delayed_evaluator
|
19
19
|
chef/dsl/core
|
20
20
|
chef/dsl/declare_resource
|
21
|
+
chef/dsl/platform_introspection
|
21
22
|
chef/dsl/recipe
|
23
|
+
chef/dsl/universal
|
22
24
|
chef/mixin/lazy_module_include
|
23
25
|
chef/mixin/notifying_block
|
24
26
|
chef/mixin/params_validate
|
@@ -26,28 +26,37 @@ module CopiedFromChef
|
|
26
26
|
#
|
27
27
|
|
28
28
|
require "chef_compat/copied_from_chef/chef/dsl/declare_resource"
|
29
|
+
require "chef_compat/copied_from_chef/chef/dsl/universal"
|
29
30
|
require "chef_compat/copied_from_chef/chef/mixin/notifying_block"
|
30
|
-
require "chef_compat/copied_from_chef/chef/mixin/
|
31
|
+
require "chef_compat/copied_from_chef/chef/mixin/lazy_module_include"
|
31
32
|
|
32
33
|
class Chef < (defined?(::Chef) ? ::Chef : Object)
|
33
34
|
module DSL
|
34
35
|
CopiedFromChef.extend_chef_module(::Chef::DSL, self) if defined?(::Chef::DSL)
|
35
|
-
#
|
36
|
-
# as user LWRPs. This module deliberately does not mixin the Resources or Defintions DSL bits
|
37
|
-
# so that cookbooks are not injeting random things into the namespace of core providers.
|
36
|
+
# Part of a family of DSL mixins.
|
38
37
|
#
|
39
|
-
#
|
40
|
-
#
|
38
|
+
# Chef::DSL::Recipe mixes into Recipes and LWRP Providers.
|
39
|
+
# - this does not target core chef resources and providers.
|
40
|
+
# - this is restricted to recipe/resource/provider context where a resource collection exists.
|
41
|
+
# - cookbook authors should typically include modules into here.
|
41
42
|
#
|
42
|
-
#
|
43
|
-
#
|
43
|
+
# Chef::DSL::Core mixes into Recipes, LWRP Providers and Core Providers
|
44
|
+
# - this adds cores providers on top of the Recipe DSL.
|
45
|
+
# - this is restricted to recipe/resource/provider context where a resource collection exists.
|
46
|
+
# - core chef authors should typically include modules into here.
|
47
|
+
#
|
48
|
+
# Chef::DSL::Universal mixes into Recipes, LWRP Resources+Providers, Core Resources+Providers, and Attributes files.
|
49
|
+
# - this adds resources and attributes files.
|
50
|
+
# - do not add helpers which manipulate the resource collection.
|
51
|
+
# - this is for general-purpose stuff that is useful nearly everywhere.
|
52
|
+
# - it also pollutes the namespace of nearly every context, watch out.
|
44
53
|
#
|
45
54
|
module Core
|
46
55
|
CopiedFromChef.extend_chef_module(::Chef::DSL::Core, self) if defined?(::Chef::DSL::Core)
|
56
|
+
include Chef::DSL::Universal
|
47
57
|
include Chef::DSL::DeclareResource
|
48
58
|
include Chef::Mixin::NotifyingBlock
|
49
|
-
|
50
|
-
include Chef::Mixin::ShellOut
|
59
|
+
extend Chef::Mixin::LazyModuleInclude
|
51
60
|
end
|
52
61
|
end
|
53
62
|
end
|
@@ -0,0 +1,284 @@
|
|
1
|
+
begin
|
2
|
+
require 'chef/dsl/platform_introspection'
|
3
|
+
rescue LoadError; end
|
4
|
+
|
5
|
+
require 'chef_compat/copied_from_chef'
|
6
|
+
class Chef
|
7
|
+
module ::ChefCompat
|
8
|
+
module CopiedFromChef
|
9
|
+
#
|
10
|
+
# Author:: Adam Jacob (<adam@chef.io>)
|
11
|
+
# Copyright:: Copyright 2008-2016, Chef Software Inc.
|
12
|
+
# License:: Apache License, Version 2.0
|
13
|
+
#
|
14
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
15
|
+
# you may not use this file except in compliance with the License.
|
16
|
+
# You may obtain a copy of the License at
|
17
|
+
#
|
18
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
19
|
+
#
|
20
|
+
# Unless required by applicable law or agreed to in writing, software
|
21
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
22
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
23
|
+
# See the License for the specific language governing permissions and
|
24
|
+
# limitations under the License.
|
25
|
+
#
|
26
|
+
|
27
|
+
class Chef < (defined?(::Chef) ? ::Chef : Object)
|
28
|
+
module DSL
|
29
|
+
CopiedFromChef.extend_chef_module(::Chef::DSL, self) if defined?(::Chef::DSL)
|
30
|
+
|
31
|
+
# == Chef::DSL::PlatformIntrospection
|
32
|
+
# Provides the DSL for platform-dependent switch logic, such as
|
33
|
+
# #value_for_platform.
|
34
|
+
module PlatformIntrospection
|
35
|
+
CopiedFromChef.extend_chef_module(::Chef::DSL::PlatformIntrospection, self) if defined?(::Chef::DSL::PlatformIntrospection)
|
36
|
+
|
37
|
+
# Implementation class for determining platform dependent values
|
38
|
+
class PlatformDependentValue < (defined?(::Chef::DSL::PlatformIntrospection::PlatformDependentValue) ? ::Chef::DSL::PlatformIntrospection::PlatformDependentValue : Object)
|
39
|
+
|
40
|
+
# Create a platform dependent value object.
|
41
|
+
# === Arguments
|
42
|
+
# platform_hash (Hash) a hash of the same structure as Chef::Platform,
|
43
|
+
# like this:
|
44
|
+
# {
|
45
|
+
# :debian => {:default => 'the value for all debian'}
|
46
|
+
# [:centos, :redhat, :fedora] => {:default => "value for all EL variants"}
|
47
|
+
# :ubuntu => { :default => "default for ubuntu", '10.04' => "value for 10.04 only"},
|
48
|
+
# :default => "the default when nothing else matches"
|
49
|
+
# }
|
50
|
+
# * platforms can be specified as Symbols or Strings
|
51
|
+
# * multiple platforms can be grouped by using an Array as the key
|
52
|
+
# * values for platforms need to be Hashes of the form:
|
53
|
+
# {platform_version => value_for_that_version}
|
54
|
+
# * the exception to the above is the default value, which is given as
|
55
|
+
# :default => default_value
|
56
|
+
def initialize(platform_hash)
|
57
|
+
super if defined?(::Chef::DSL::PlatformIntrospection::PlatformDependentValue)
|
58
|
+
@values = {}
|
59
|
+
platform_hash.each { |platforms, value| set(platforms, value) }
|
60
|
+
end
|
61
|
+
|
62
|
+
def value_for_node(node)
|
63
|
+
platform, version = node[:platform].to_s, node[:platform_version].to_s
|
64
|
+
# Check if we match a version constraint via Chef::VersionConstraint::Platform and Chef::Version::Platform
|
65
|
+
matched_value = match_versions(node)
|
66
|
+
if @values.key?(platform) && @values[platform].key?(version)
|
67
|
+
@values[platform][version]
|
68
|
+
elsif matched_value
|
69
|
+
matched_value
|
70
|
+
elsif @values.key?(platform) && @values[platform].key?("default")
|
71
|
+
@values[platform]["default"]
|
72
|
+
elsif @values.key?("default")
|
73
|
+
@values["default"]
|
74
|
+
else
|
75
|
+
nil
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
def match_versions(node)
|
82
|
+
begin
|
83
|
+
platform, version = node[:platform].to_s, node[:platform_version].to_s
|
84
|
+
return nil unless @values.key?(platform)
|
85
|
+
node_version = Chef::Version::Platform.new(version)
|
86
|
+
key_matches = []
|
87
|
+
keys = @values[platform].keys
|
88
|
+
keys.each do |k|
|
89
|
+
begin
|
90
|
+
if Chef::VersionConstraint::Platform.new(k).include?(node_version)
|
91
|
+
key_matches << k
|
92
|
+
end
|
93
|
+
rescue Chef::Exceptions::InvalidVersionConstraint => e
|
94
|
+
Chef::Log.debug "Caught InvalidVersionConstraint. This means that a key in value_for_platform cannot be interpreted as a Chef::VersionConstraint::Platform."
|
95
|
+
Chef::Log.debug(e)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
return @values[platform][version] if key_matches.include?(version)
|
99
|
+
case key_matches.length
|
100
|
+
when 0
|
101
|
+
return nil
|
102
|
+
when 1
|
103
|
+
return @values[platform][key_matches.first]
|
104
|
+
else
|
105
|
+
raise "Multiple matches detected for #{platform} with values #{@values}. The matches are: #{key_matches}"
|
106
|
+
end
|
107
|
+
rescue Chef::Exceptions::InvalidCookbookVersion => e
|
108
|
+
# Lets not break because someone passes a weird string like 'default' :)
|
109
|
+
Chef::Log.debug(e)
|
110
|
+
Chef::Log.debug "InvalidCookbookVersion exceptions are common and expected here: the generic constraint matcher attempted to match something which is not a constraint. Moving on to next version or constraint"
|
111
|
+
return nil
|
112
|
+
rescue Chef::Exceptions::InvalidPlatformVersion => e
|
113
|
+
Chef::Log.debug "Caught InvalidPlatformVersion, this means that Chef::Version::Platform does not know how to turn #{node_version} into an x.y.z format"
|
114
|
+
Chef::Log.debug(e)
|
115
|
+
return nil
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def set(platforms, value)
|
120
|
+
if platforms.to_s == "default"
|
121
|
+
@values["default"] = value
|
122
|
+
else
|
123
|
+
assert_valid_platform_values!(platforms, value)
|
124
|
+
Array(platforms).each { |platform| @values[platform.to_s] = normalize_keys(value) }
|
125
|
+
value
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def normalize_keys(hash)
|
130
|
+
hash.inject({}) do |h, key_value|
|
131
|
+
keys, value = *key_value
|
132
|
+
Array(keys).each do |key|
|
133
|
+
h[key.to_s] = value
|
134
|
+
end
|
135
|
+
h
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def assert_valid_platform_values!(platforms, value)
|
140
|
+
unless value.kind_of?(Hash)
|
141
|
+
msg = "platform dependent values must be specified in the format :platform => {:version => value} "
|
142
|
+
msg << "you gave a value #{value.inspect} for platform(s) #{platforms}"
|
143
|
+
raise ArgumentError, msg
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
# Given a hash similar to the one we use for Platforms, select a value from the hash. Supports
|
149
|
+
# per platform defaults, along with a single base default. Arrays may be passed as hash keys and
|
150
|
+
# will be expanded.
|
151
|
+
#
|
152
|
+
# === Parameters
|
153
|
+
# platform_hash:: A platform-style hash.
|
154
|
+
#
|
155
|
+
# === Returns
|
156
|
+
# value:: Whatever the most specific value of the hash is.
|
157
|
+
def value_for_platform(platform_hash)
|
158
|
+
PlatformDependentValue.new(platform_hash).value_for_node(node)
|
159
|
+
end
|
160
|
+
|
161
|
+
# Given a list of platforms, returns true if the current recipe is being run on a node with
|
162
|
+
# that platform, false otherwise.
|
163
|
+
#
|
164
|
+
# === Parameters
|
165
|
+
# args:: A list of platforms. Each platform can be in string or symbol format.
|
166
|
+
#
|
167
|
+
# === Returns
|
168
|
+
# true:: If the current platform is in the list
|
169
|
+
# false:: If the current platform is not in the list
|
170
|
+
def platform?(*args)
|
171
|
+
has_platform = false
|
172
|
+
|
173
|
+
args.flatten.each do |platform|
|
174
|
+
has_platform = true if platform.to_s == node[:platform]
|
175
|
+
end
|
176
|
+
|
177
|
+
has_platform
|
178
|
+
end
|
179
|
+
|
180
|
+
# Implementation class for determining platform family dependent values
|
181
|
+
class PlatformFamilyDependentValue < (defined?(::Chef::DSL::PlatformIntrospection::PlatformFamilyDependentValue) ? ::Chef::DSL::PlatformIntrospection::PlatformFamilyDependentValue : Object)
|
182
|
+
|
183
|
+
# Create a platform family dependent value object.
|
184
|
+
# === Arguments
|
185
|
+
# platform_family_hash (Hash) a map of platform families to values.
|
186
|
+
# like this:
|
187
|
+
# {
|
188
|
+
# :rhel => "value for all EL variants"
|
189
|
+
# :fedora => "value for fedora variants fedora and amazon" ,
|
190
|
+
# [:fedora, :rhel] => "value for all known redhat variants"
|
191
|
+
# :debian => "value for debian variants including debian, ubuntu, mint" ,
|
192
|
+
# :default => "the default when nothing else matches"
|
193
|
+
# }
|
194
|
+
# * platform families can be specified as Symbols or Strings
|
195
|
+
# * multiple platform families can be grouped by using an Array as the key
|
196
|
+
# * values for platform families can be any object, with no restrictions. Some examples:
|
197
|
+
# - [:stop, :start]
|
198
|
+
# - "mysql-devel"
|
199
|
+
# - { :key => "value" }
|
200
|
+
def initialize(platform_family_hash)
|
201
|
+
super if defined?(::Chef::DSL::PlatformIntrospection::PlatformFamilyDependentValue)
|
202
|
+
@values = {}
|
203
|
+
@values["default"] = nil
|
204
|
+
platform_family_hash.each { |platform_families, value| set(platform_families, value) }
|
205
|
+
end
|
206
|
+
|
207
|
+
def value_for_node(node)
|
208
|
+
if node.key?(:platform_family)
|
209
|
+
platform_family = node[:platform_family].to_s
|
210
|
+
if @values.key?(platform_family)
|
211
|
+
@values[platform_family]
|
212
|
+
else
|
213
|
+
@values["default"]
|
214
|
+
end
|
215
|
+
else
|
216
|
+
@values["default"]
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
private
|
221
|
+
|
222
|
+
def set(platform_family, value)
|
223
|
+
if platform_family.to_s == "default"
|
224
|
+
@values["default"] = value
|
225
|
+
else
|
226
|
+
Array(platform_family).each { |family| @values[family.to_s] = value }
|
227
|
+
value
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
# Given a hash mapping platform families to values, select a value from the hash. Supports a single
|
233
|
+
# base default if platform family is not in the map. Arrays may be passed as hash keys and will be
|
234
|
+
# expanded
|
235
|
+
#
|
236
|
+
# === Parameters
|
237
|
+
# platform_family_hash:: A hash in the form { platform_family_name => value }
|
238
|
+
#
|
239
|
+
# === Returns
|
240
|
+
# value:: Whatever the most specific value of the hash is.
|
241
|
+
def value_for_platform_family(platform_family_hash)
|
242
|
+
PlatformFamilyDependentValue.new(platform_family_hash).value_for_node(node)
|
243
|
+
end
|
244
|
+
|
245
|
+
# Given a list of platform families, returns true if the current recipe is being run on a
|
246
|
+
# node within that platform family, false otherwise.
|
247
|
+
#
|
248
|
+
# === Parameters
|
249
|
+
# args:: A list of platform families. Each platform family can be in string or symbol format.
|
250
|
+
#
|
251
|
+
# === Returns
|
252
|
+
# true:: if the current node platform family is in the list.
|
253
|
+
# false:: if the current node platform family is not in the list.
|
254
|
+
def platform_family?(*args)
|
255
|
+
args.flatten.any? do |platform_family|
|
256
|
+
platform_family.to_s == node[:platform_family]
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
# Shamelessly stolen from https://github.com/sethvargo/chef-sugar/blob/master/lib/chef/sugar/docker.rb
|
261
|
+
# Given a node object, returns whether the node is a docker container.
|
262
|
+
#
|
263
|
+
# === Parameters
|
264
|
+
# node:: [Chef::Node] The node to check.
|
265
|
+
#
|
266
|
+
# === Returns
|
267
|
+
# true:: if the current node is a docker container
|
268
|
+
# false:: if the current node is not a docker container
|
269
|
+
def docker?(node = run_context.nil? ? nil : run_context.node)
|
270
|
+
# Using "File.exist?('/.dockerinit') || File.exist?('/.dockerenv')" makes Travis sad,
|
271
|
+
# and that makes us sad too.
|
272
|
+
node && node[:virtualization] && node[:virtualization][:systems] &&
|
273
|
+
node[:virtualization][:systems][:docker] && node[:virtualization][:systems][:docker] == "guest"
|
274
|
+
end
|
275
|
+
|
276
|
+
end
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
# **DEPRECATED**
|
281
|
+
# This used to be part of chef/mixin/language. Load the file to activate the deprecation code.
|
282
|
+
end
|
283
|
+
end
|
284
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
begin
|
2
|
+
require 'chef/dsl/universal'
|
3
|
+
rescue LoadError; end
|
4
|
+
|
5
|
+
require 'chef_compat/copied_from_chef'
|
6
|
+
class Chef
|
7
|
+
module ::ChefCompat
|
8
|
+
module CopiedFromChef
|
9
|
+
#--
|
10
|
+
# Author:: Adam Jacob (<adam@chef.io>)
|
11
|
+
# Author:: Christopher Walters (<cw@chef.io>)
|
12
|
+
# Copyright:: Copyright 2008-2016, 2009-2015 Chef Software, Inc.
|
13
|
+
# License:: Apache License, Version 2.0
|
14
|
+
#
|
15
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
16
|
+
# you may not use this file except in compliance with the License.
|
17
|
+
# You may obtain a copy of the License at
|
18
|
+
#
|
19
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
20
|
+
#
|
21
|
+
# Unless required by applicable law or agreed to in writing, software
|
22
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
23
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
24
|
+
# See the License for the specific language governing permissions and
|
25
|
+
# limitations under the License.
|
26
|
+
#
|
27
|
+
|
28
|
+
require "chef_compat/copied_from_chef/chef/dsl/platform_introspection"
|
29
|
+
require "chef_compat/copied_from_chef/chef/mixin/powershell_out"
|
30
|
+
|
31
|
+
class Chef < (defined?(::Chef) ? ::Chef : Object)
|
32
|
+
module DSL
|
33
|
+
CopiedFromChef.extend_chef_module(::Chef::DSL, self) if defined?(::Chef::DSL)
|
34
|
+
# Part of a family of DSL mixins.
|
35
|
+
#
|
36
|
+
# Chef::DSL::Recipe mixes into Recipes and LWRP Providers.
|
37
|
+
# - this does not target core chef resources and providers.
|
38
|
+
# - this is restricted to recipe/resource/provider context where a resource collection exists.
|
39
|
+
# - cookbook authors should typically include modules into here.
|
40
|
+
#
|
41
|
+
# Chef::DSL::Core mixes into Recipes, LWRP Providers and Core Providers
|
42
|
+
# - this adds cores providers on top of the Recipe DSL.
|
43
|
+
# - this is restricted to recipe/resource/provider context where a resource collection exists.
|
44
|
+
# - core chef authors should typically include modules into here.
|
45
|
+
#
|
46
|
+
# Chef::DSL::Universal mixes into Recipes, LWRP Resources+Providers, Core Resources+Providers, and Attributes files.
|
47
|
+
# - this adds resources and attributes files.
|
48
|
+
# - do not add helpers which manipulate the resource collection.
|
49
|
+
# - this is for general-purpose stuff that is useful nearly everywhere.
|
50
|
+
# - it also pollutes the namespace of nearly every context, watch out.
|
51
|
+
#
|
52
|
+
module Universal
|
53
|
+
CopiedFromChef.extend_chef_module(::Chef::DSL::Universal, self) if defined?(::Chef::DSL::Universal)
|
54
|
+
include Chef::DSL::PlatformIntrospection
|
55
|
+
include Chef::Mixin::PowershellOut
|
56
|
+
include Chef::Mixin::ShellOut
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -537,8 +537,6 @@ super if defined?(::Chef::Property)
|
|
537
537
|
end
|
538
538
|
end
|
539
539
|
|
540
|
-
protected
|
541
|
-
|
542
540
|
#
|
543
541
|
# The options this Property will use for get/set behavior and validation.
|
544
542
|
#
|
@@ -589,6 +587,7 @@ super if defined?(::Chef::Property)
|
|
589
587
|
(options.has_key?(:is) && resource.send(:_pv_is, { name => nil }, name, options[:is], raise_error: false))
|
590
588
|
end
|
591
589
|
|
590
|
+
# @api private
|
592
591
|
def get_value(resource)
|
593
592
|
if instance_variable_name
|
594
593
|
resource.instance_variable_get(instance_variable_name)
|
@@ -597,6 +596,7 @@ super if defined?(::Chef::Property)
|
|
597
596
|
end
|
598
597
|
end
|
599
598
|
|
599
|
+
# @api private
|
600
600
|
def set_value(resource, value)
|
601
601
|
if instance_variable_name
|
602
602
|
resource.instance_variable_set(instance_variable_name, value)
|
@@ -605,6 +605,7 @@ super if defined?(::Chef::Property)
|
|
605
605
|
end
|
606
606
|
end
|
607
607
|
|
608
|
+
# @api private
|
608
609
|
def value_is_set?(resource)
|
609
610
|
if instance_variable_name
|
610
611
|
resource.instance_variable_defined?(instance_variable_name)
|
@@ -613,6 +614,7 @@ super if defined?(::Chef::Property)
|
|
613
614
|
end
|
614
615
|
end
|
615
616
|
|
617
|
+
# @api private
|
616
618
|
def reset_value(resource)
|
617
619
|
if instance_variable_name
|
618
620
|
if value_is_set?(resource)
|
@@ -623,6 +625,8 @@ super if defined?(::Chef::Property)
|
|
623
625
|
end
|
624
626
|
end
|
625
627
|
|
628
|
+
private
|
629
|
+
|
626
630
|
def exec_in_resource(resource, proc, *args)
|
627
631
|
if resource
|
628
632
|
if proc.arity > args.size
|
@@ -9,7 +9,7 @@ module CopiedFromChef
|
|
9
9
|
require "chef_compat/copied_from_chef/chef/resource/action_class"
|
10
10
|
require "chef_compat/copied_from_chef/chef/provider"
|
11
11
|
require "chef_compat/copied_from_chef/chef/mixin/properties"
|
12
|
-
require "chef_compat/copied_from_chef/chef/
|
12
|
+
require "chef_compat/copied_from_chef/chef/dsl/universal"
|
13
13
|
class Chef < (defined?(::Chef) ? ::Chef : Object)
|
14
14
|
class Resource < (defined?(::Chef::Resource) ? ::Chef::Resource : Object)
|
15
15
|
include Chef::Mixin::Properties
|
@@ -192,6 +192,9 @@ super if defined?(::Chef::Resource)
|
|
192
192
|
class << self
|
193
193
|
end
|
194
194
|
@@sorted_descendants = nil
|
195
|
+
module DeprecatedLWRPClass
|
196
|
+
CopiedFromChef.extend_chef_module(::Chef::Resource::DeprecatedLWRPClass, self) if defined?(::Chef::Resource::DeprecatedLWRPClass)
|
197
|
+
end
|
195
198
|
private
|
196
199
|
end
|
197
200
|
end
|
@@ -113,7 +113,11 @@ super if defined?(::Chef::ResourceBuilder)
|
|
113
113
|
end
|
114
114
|
|
115
115
|
def is_trivial_resource?(resource)
|
116
|
-
|
116
|
+
trivial_resource = resource_class.new(name, run_context)
|
117
|
+
# force un-lazy the name property on the created trivial resource
|
118
|
+
name_property = resource_class.properties.find { |sym, p| p.name_property? }
|
119
|
+
trivial_resource.send(name_property[0]) unless name_property.nil?
|
120
|
+
identicalish_resources?(trivial_resource, resource)
|
117
121
|
end
|
118
122
|
|
119
123
|
# this is an equality test specific to checking for 3694 cloning warnings
|
@@ -133,9 +137,10 @@ super if defined?(::Chef::ResourceBuilder)
|
|
133
137
|
end
|
134
138
|
|
135
139
|
def emit_cloned_resource_warning
|
136
|
-
|
137
|
-
|
138
|
-
|
140
|
+
message = "Cloning resource attributes for #{resource} from prior resource (CHEF-3694)"
|
141
|
+
message << "\nPrevious #{prior_resource}: #{prior_resource.source_line}" if prior_resource.source_line
|
142
|
+
message << "\nCurrent #{resource}: #{resource.source_line}" if resource.source_line
|
143
|
+
Chef.log_deprecation(message)
|
139
144
|
end
|
140
145
|
|
141
146
|
def emit_harmless_cloning_debug
|
data/files/spec/data/Gemfile
CHANGED
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.10.
|
4
|
+
version: 12.10.7
|
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-
|
11
|
+
date: 2016-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -82,7 +82,9 @@ files:
|
|
82
82
|
- files/lib/chef_compat/copied_from_chef/chef/delayed_evaluator.rb
|
83
83
|
- files/lib/chef_compat/copied_from_chef/chef/dsl/core.rb
|
84
84
|
- files/lib/chef_compat/copied_from_chef/chef/dsl/declare_resource.rb
|
85
|
+
- files/lib/chef_compat/copied_from_chef/chef/dsl/platform_introspection.rb
|
85
86
|
- files/lib/chef_compat/copied_from_chef/chef/dsl/recipe.rb
|
87
|
+
- files/lib/chef_compat/copied_from_chef/chef/dsl/universal.rb
|
86
88
|
- files/lib/chef_compat/copied_from_chef/chef/mixin/lazy_module_include.rb
|
87
89
|
- files/lib/chef_compat/copied_from_chef/chef/mixin/notifying_block.rb
|
88
90
|
- files/lib/chef_compat/copied_from_chef/chef/mixin/params_validate.rb
|
@@ -120,7 +122,6 @@ files:
|
|
120
122
|
- files/lib/compat_resource/version.rb
|
121
123
|
- files/spec/cookbook_spec.rb
|
122
124
|
- files/spec/data/Gemfile
|
123
|
-
- files/spec/data/Gemfile.lock
|
124
125
|
- files/spec/data/config.rb
|
125
126
|
- files/spec/data/cookbooks/cloning/metadata.rb
|
126
127
|
- files/spec/data/cookbooks/cloning/providers/resource.rb
|
@@ -169,9 +170,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
170
|
version: '0'
|
170
171
|
requirements: []
|
171
172
|
rubyforge_project:
|
172
|
-
rubygems_version: 2.6.
|
173
|
+
rubygems_version: 2.6.6
|
173
174
|
signing_key:
|
174
175
|
specification_version: 4
|
175
176
|
summary: Bring some new features of Chef 12.5 to previous 12.X releases
|
176
177
|
test_files: []
|
177
|
-
has_rdoc:
|
@@ -1,126 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: https://rubygems.org/
|
3
|
-
specs:
|
4
|
-
builder (3.2.2)
|
5
|
-
chef (12.3.0)
|
6
|
-
chef-zero (~> 4.1)
|
7
|
-
diff-lcs (~> 1.2, >= 1.2.4)
|
8
|
-
erubis (~> 2.7)
|
9
|
-
ffi-yajl (>= 1.2, < 3.0)
|
10
|
-
highline (~> 1.6, >= 1.6.9)
|
11
|
-
mixlib-authentication (~> 1.3)
|
12
|
-
mixlib-cli (~> 1.4)
|
13
|
-
mixlib-config (~> 2.0)
|
14
|
-
mixlib-log (~> 1.3)
|
15
|
-
mixlib-shellout (>= 2.0.0.rc.0, < 3.0)
|
16
|
-
net-ssh (~> 2.6)
|
17
|
-
net-ssh-multi (~> 1.1)
|
18
|
-
ohai (~> 8.0)
|
19
|
-
plist (~> 3.1.0)
|
20
|
-
pry (~> 0.9)
|
21
|
-
rspec-core (~> 3.2)
|
22
|
-
rspec-expectations (~> 3.2)
|
23
|
-
rspec-mocks (~> 3.2)
|
24
|
-
rspec_junit_formatter (~> 0.2.0)
|
25
|
-
serverspec (~> 2.7)
|
26
|
-
specinfra (~> 2.10)
|
27
|
-
chef-config (12.8.1)
|
28
|
-
mixlib-config (~> 2.0)
|
29
|
-
mixlib-shellout (~> 2.0)
|
30
|
-
chef-zero (4.5.0)
|
31
|
-
ffi-yajl (~> 2.2)
|
32
|
-
hashie (>= 2.0, < 4.0)
|
33
|
-
mixlib-log (~> 1.3)
|
34
|
-
rack
|
35
|
-
uuidtools (~> 2.1)
|
36
|
-
coderay (1.1.1)
|
37
|
-
diff-lcs (1.2.5)
|
38
|
-
erubis (2.7.0)
|
39
|
-
ffi (1.9.10)
|
40
|
-
ffi-yajl (2.2.3)
|
41
|
-
libyajl2 (~> 1.2)
|
42
|
-
hashie (3.4.3)
|
43
|
-
highline (1.7.8)
|
44
|
-
ipaddress (0.8.3)
|
45
|
-
libyajl2 (1.2.0)
|
46
|
-
method_source (0.8.2)
|
47
|
-
mixlib-authentication (1.4.0)
|
48
|
-
mixlib-log
|
49
|
-
rspec-core (~> 3.2)
|
50
|
-
rspec-expectations (~> 3.2)
|
51
|
-
rspec-mocks (~> 3.2)
|
52
|
-
mixlib-cli (1.5.0)
|
53
|
-
mixlib-config (2.2.1)
|
54
|
-
mixlib-log (1.6.0)
|
55
|
-
mixlib-shellout (2.2.6)
|
56
|
-
multi_json (1.11.2)
|
57
|
-
net-scp (1.2.1)
|
58
|
-
net-ssh (>= 2.6.5)
|
59
|
-
net-ssh (2.9.4)
|
60
|
-
net-ssh-gateway (1.2.0)
|
61
|
-
net-ssh (>= 2.6.5)
|
62
|
-
net-ssh-multi (1.2.1)
|
63
|
-
net-ssh (>= 2.6.5)
|
64
|
-
net-ssh-gateway (>= 1.2.0)
|
65
|
-
net-telnet (0.1.1)
|
66
|
-
ohai (8.12.1)
|
67
|
-
chef-config (>= 12.5.0.alpha.1, < 13)
|
68
|
-
ffi (~> 1.9)
|
69
|
-
ffi-yajl (~> 2.2)
|
70
|
-
ipaddress
|
71
|
-
mixlib-cli
|
72
|
-
mixlib-config (~> 2.0)
|
73
|
-
mixlib-log
|
74
|
-
mixlib-shellout (~> 2.0)
|
75
|
-
plist
|
76
|
-
systemu (~> 2.6.4)
|
77
|
-
wmi-lite (~> 1.0)
|
78
|
-
plist (3.1.0)
|
79
|
-
pry (0.10.3)
|
80
|
-
coderay (~> 1.1.0)
|
81
|
-
method_source (~> 0.8.1)
|
82
|
-
slop (~> 3.4)
|
83
|
-
rack (1.6.4)
|
84
|
-
rspec (3.4.0)
|
85
|
-
rspec-core (~> 3.4.0)
|
86
|
-
rspec-expectations (~> 3.4.0)
|
87
|
-
rspec-mocks (~> 3.4.0)
|
88
|
-
rspec-core (3.4.4)
|
89
|
-
rspec-support (~> 3.4.0)
|
90
|
-
rspec-expectations (3.4.0)
|
91
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
92
|
-
rspec-support (~> 3.4.0)
|
93
|
-
rspec-its (1.2.0)
|
94
|
-
rspec-core (>= 3.0.0)
|
95
|
-
rspec-expectations (>= 3.0.0)
|
96
|
-
rspec-mocks (3.4.1)
|
97
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
98
|
-
rspec-support (~> 3.4.0)
|
99
|
-
rspec-support (3.4.1)
|
100
|
-
rspec_junit_formatter (0.2.3)
|
101
|
-
builder (< 4)
|
102
|
-
rspec-core (>= 2, < 4, != 2.12.0)
|
103
|
-
serverspec (2.31.0)
|
104
|
-
multi_json
|
105
|
-
rspec (~> 3.0)
|
106
|
-
rspec-its
|
107
|
-
specinfra (~> 2.53)
|
108
|
-
sfl (2.2)
|
109
|
-
slop (3.6.0)
|
110
|
-
specinfra (2.54.1)
|
111
|
-
net-scp
|
112
|
-
net-ssh (>= 2.7, < 3.1)
|
113
|
-
net-telnet
|
114
|
-
sfl
|
115
|
-
systemu (2.6.5)
|
116
|
-
uuidtools (2.1.5)
|
117
|
-
wmi-lite (1.0.0)
|
118
|
-
|
119
|
-
PLATFORMS
|
120
|
-
ruby
|
121
|
-
|
122
|
-
DEPENDENCIES
|
123
|
-
chef (~> 12.3, < 12.4)
|
124
|
-
|
125
|
-
BUNDLED WITH
|
126
|
-
1.11.2
|