chef 12.11.18-universal-mingw32 → 12.12.13-universal-mingw32
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 +4 -4
- data/Rakefile +3 -2
- data/VERSION +1 -1
- data/acceptance/Gemfile.lock +22 -23
- data/acceptance/data-collector/test/integration/default/serverspec/default_spec.rb +2 -41
- data/lib/chef/application/solo.rb +7 -0
- data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +1 -1
- data/lib/chef/data_collector.rb +79 -43
- data/lib/chef/data_collector/messages.rb +4 -33
- data/lib/chef/data_collector/messages/helpers.rb +2 -2
- data/lib/chef/data_collector/resource_report.rb +21 -11
- data/lib/chef/decorator/unchain.rb +43 -0
- data/lib/chef/exceptions.rb +5 -0
- data/lib/chef/http.rb +5 -5
- data/lib/chef/knife/cookbook_create.rb +4 -0
- data/lib/chef/knife/cookbook_site_download.rb +8 -1
- data/lib/chef/knife/cookbook_site_install.rb +8 -0
- data/lib/chef/knife/cookbook_site_list.rb +8 -1
- data/lib/chef/knife/cookbook_site_search.rb +8 -1
- data/lib/chef/knife/cookbook_site_share.rb +8 -1
- data/lib/chef/knife/cookbook_site_show.rb +14 -3
- data/lib/chef/knife/cookbook_site_unshare.rb +8 -1
- data/lib/chef/knife/core/bootstrap_context.rb +1 -1
- data/lib/chef/knife/supermarket_download.rb +33 -0
- data/lib/chef/knife/supermarket_install.rb +33 -0
- data/lib/chef/knife/supermarket_list.rb +33 -0
- data/lib/chef/knife/supermarket_search.rb +33 -0
- data/lib/chef/knife/supermarket_share.rb +33 -0
- data/lib/chef/knife/supermarket_show.rb +33 -0
- data/lib/chef/knife/supermarket_unshare.rb +33 -0
- data/lib/chef/node.rb +13 -32
- data/lib/chef/node/attribute.rb +123 -70
- data/lib/chef/node/attribute_collections.rb +9 -130
- data/lib/chef/node/common_api.rb +124 -0
- data/lib/chef/node/immutable_collections.rb +27 -2
- data/lib/chef/property.rb +6 -2
- data/lib/chef/provider.rb +4 -5
- data/lib/chef/provider/batch.rb +1 -1
- data/lib/chef/provider/directory.rb +3 -1
- data/lib/chef/provider/package/openbsd.rb +1 -1
- data/lib/chef/provider/package/rubygems.rb +9 -3
- data/lib/chef/provider/package/windows/exe.rb +2 -5
- data/lib/chef/provider/powershell_script.rb +1 -1
- data/lib/chef/provider/remote_directory.rb +2 -0
- data/lib/chef/resource.rb +22 -17
- data/lib/chef/resource_builder.rb +9 -4
- data/lib/chef/shell.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/spec/data/run_context/cookbooks/circular-dep1/attributes/default.rb +2 -4
- data/spec/data/run_context/cookbooks/circular-dep2/attributes/default.rb +2 -3
- data/spec/data/run_context/cookbooks/dependency1/attributes/aa_first.rb +2 -2
- data/spec/data/run_context/cookbooks/dependency1/attributes/default.rb +2 -2
- data/spec/data/run_context/cookbooks/dependency1/attributes/zz_last.rb +2 -3
- data/spec/data/run_context/cookbooks/dependency2/attributes/default.rb +2 -3
- data/spec/data/run_context/cookbooks/no-default-attr/attributes/server.rb +2 -3
- data/spec/data/run_context/cookbooks/test-with-circular-deps/attributes/default.rb +2 -3
- data/spec/data/run_context/cookbooks/test-with-deps/attributes/default.rb +2 -3
- data/spec/functional/assets/chocolatey_feed/test-A.1.0.nupkg +0 -0
- data/spec/functional/assets/chocolatey_feed/test-A.1.5.nupkg +0 -0
- data/spec/functional/assets/chocolatey_feed/test-A.2.0.nupkg +0 -0
- data/spec/functional/assets/chocolatey_feed/test-B.1.0.nupkg +0 -0
- data/spec/functional/resource/dsc_script_spec.rb +1 -0
- data/spec/functional/resource/package_spec.rb +1 -1
- data/spec/functional/resource/template_spec.rb +3 -3
- data/spec/functional/shell_spec.rb +1 -1
- data/spec/integration/knife/client_bulk_delete_spec.rb +130 -0
- data/spec/integration/knife/client_create_spec.rb +69 -0
- data/spec/integration/knife/client_delete_spec.rb +63 -0
- data/spec/integration/knife/client_key_create_spec.rb +65 -0
- data/spec/integration/knife/client_key_delete_spec.rb +42 -0
- data/spec/integration/knife/client_key_list_spec.rb +60 -0
- data/spec/integration/knife/client_key_show_spec.rb +44 -0
- data/spec/integration/knife/client_list_spec.rb +48 -0
- data/spec/integration/knife/client_show_spec.rb +36 -0
- data/spec/integration/knife/cookbook_bulk_delete_spec.rb +64 -0
- data/spec/integration/knife/cookbook_download_spec.rb +95 -0
- data/spec/integration/knife/cookbook_list_spec.rb +54 -0
- data/spec/integration/knife/cookbook_show_spec.rb +159 -0
- data/spec/integration/knife/cookbook_upload_spec.rb +90 -0
- data/spec/integration/knife/data_bag_create_spec.rb +58 -0
- data/spec/integration/knife/data_bag_delete_spec.rb +58 -0
- data/spec/integration/knife/data_bag_from_file_spec.rb +115 -0
- data/spec/integration/knife/data_bag_list_spec.rb +43 -0
- data/spec/integration/knife/data_bag_show_spec.rb +53 -0
- data/spec/integration/knife/environment_compare_spec.rb +74 -0
- data/spec/integration/knife/environment_create_spec.rb +40 -0
- data/spec/integration/knife/environment_delete_spec.rb +36 -0
- data/spec/integration/knife/environment_from_file_spec.rb +115 -0
- data/spec/integration/knife/environment_list_spec.rb +41 -0
- data/spec/integration/knife/environment_show_spec.rb +56 -0
- data/spec/integration/knife/node_bulk_delete_spec.rb +51 -0
- data/spec/integration/knife/node_create_spec.rb +46 -0
- data/spec/integration/knife/node_delete_spec.rb +47 -0
- data/spec/integration/knife/node_environment_set_spec.rb +42 -0
- data/spec/integration/knife/node_from_file_spec.rb +58 -0
- data/spec/integration/knife/node_list_spec.rb +44 -0
- data/spec/integration/knife/node_run_list_add_spec.rb +53 -0
- data/spec/integration/knife/node_run_list_remove_spec.rb +35 -0
- data/spec/integration/knife/node_run_list_set_spec.rb +40 -0
- data/spec/integration/knife/node_show_spec.rb +35 -0
- data/spec/integration/knife/role_bulk_delete_spec.rb +51 -0
- data/spec/integration/knife/role_create_spec.rb +40 -0
- data/spec/integration/knife/role_delete_spec.rb +47 -0
- data/spec/integration/knife/role_from_file_spec.rb +95 -0
- data/spec/integration/knife/role_list_spec.rb +44 -0
- data/spec/integration/knife/role_show_spec.rb +50 -0
- data/spec/support/shared/integration/knife_support.rb +10 -3
- data/spec/unit/application/solo_spec.rb +7 -0
- data/spec/unit/cookbook_version_spec.rb +4 -4
- data/spec/unit/data_collector/messages/helpers_spec.rb +3 -7
- data/spec/unit/data_collector/messages_spec.rb +28 -45
- data/spec/unit/data_collector_spec.rb +40 -47
- data/spec/unit/knife/cookbook_create_spec.rb +1 -0
- data/spec/unit/knife/cookbook_site_download_spec.rb +1 -0
- data/spec/unit/knife/node_environment_set_spec.rb +0 -24
- data/spec/unit/knife/node_run_list_set_spec.rb +0 -25
- data/spec/unit/node/attribute_spec.rb +7 -9
- data/spec/unit/node/immutable_collections_spec.rb +4 -0
- data/spec/unit/node/vivid_mash_spec.rb +344 -0
- data/spec/unit/node_spec.rb +115 -26
- data/spec/unit/provider/directory_spec.rb +11 -1
- data/spec/unit/provider/package/windows/exe_spec.rb +14 -9
- data/spec/unit/provider/powershell_script_spec.rb +4 -4
- data/spec/unit/provider/remote_directory_spec.rb +15 -0
- data/spec/unit/recipe_spec.rb +31 -6
- data/spec/unit/run_context_spec.rb +2 -2
- data/spec/unit/shell/shell_session_spec.rb +1 -1
- data/tasks/dependencies.rb +0 -2
- metadata +55 -786
- data/acceptance/.bundle/config +0 -2
- data/acceptance/basics/.kitchen/logs/chef-current-install-ubuntu-1404.log +0 -2
- data/acceptance/basics/.kitchen/logs/kitchen.log +0 -3
- data/acceptance/fips/.kitchen/logs/fips-integration-centos-6.log +0 -3
- data/acceptance/fips/.kitchen/logs/fips-integration-windows-2012r2.log +0 -3
- data/acceptance/fips/.kitchen/logs/fips-unit-functional-centos-6.log +0 -3
- data/acceptance/fips/.kitchen/logs/fips-unit-functional-windows-2012r2.log +0 -3
- data/acceptance/fips/.kitchen/logs/kitchen.log +0 -6
- data/acceptance/trivial/.kitchen/logs/chef-current-install-windows-2012r2.log +0 -2
- data/acceptance/trivial/.kitchen/logs/kitchen.log +0 -3
- data/acceptance/windows-service/.kitchen/logs/chef-windows-service-windows-2012r2.log +0 -2
- data/acceptance/windows-service/.kitchen/logs/kitchen.log +0 -3
@@ -16,15 +16,15 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
+
require "chef/node/common_api"
|
20
|
+
|
19
21
|
class Chef
|
20
22
|
class Node
|
21
|
-
|
22
23
|
# == AttrArray
|
23
24
|
# AttrArray is identical to Array, except that it keeps a reference to the
|
24
25
|
# "root" (Chef::Node::Attribute) object, and will trigger a cache
|
25
26
|
# invalidation on that object when mutated.
|
26
27
|
class AttrArray < Array
|
27
|
-
|
28
28
|
MUTATOR_METHODS = [
|
29
29
|
:<<,
|
30
30
|
:[]=,
|
@@ -62,8 +62,9 @@ class Chef
|
|
62
62
|
# Node::Attribute object.
|
63
63
|
MUTATOR_METHODS.each do |mutator|
|
64
64
|
define_method(mutator) do |*args, &block|
|
65
|
+
ret = super(*args, &block)
|
65
66
|
root.reset_cache(root.top_level_breadcrumb)
|
66
|
-
|
67
|
+
ret
|
67
68
|
end
|
68
69
|
end
|
69
70
|
|
@@ -96,14 +97,12 @@ class Chef
|
|
96
97
|
# in the creation of a new VividMash for that key. (This only works when
|
97
98
|
# using the element reference method, `[]` -- other methods, such as
|
98
99
|
# #fetch, work as normal).
|
99
|
-
# * It supports a set_unless flag (via the root Attribute object) which
|
100
|
-
# allows `||=` style behavior (`||=` does not work with
|
101
|
-
# auto-vivification). This is only implemented for #[]=; methods such as
|
102
|
-
# #store work as normal.
|
103
100
|
# * attr_accessor style element set and get are supported via method_missing
|
104
101
|
class VividMash < Mash
|
105
102
|
attr_reader :root
|
106
103
|
|
104
|
+
include CommonAPI
|
105
|
+
|
107
106
|
# Methods that mutate a VividMash. Each of them is overridden so that it
|
108
107
|
# also invalidates the cached merged_attributes on the root Attribute
|
109
108
|
# object.
|
@@ -148,12 +147,9 @@ class Chef
|
|
148
147
|
|
149
148
|
def []=(key, value)
|
150
149
|
root.top_level_breadcrumb ||= key
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
root.reset_cache(root.top_level_breadcrumb)
|
155
|
-
super
|
156
|
-
end
|
150
|
+
ret = super
|
151
|
+
root.reset_cache(root.top_level_breadcrumb)
|
152
|
+
ret
|
157
153
|
end
|
158
154
|
|
159
155
|
alias :attribute? :has_key?
|
@@ -176,10 +172,6 @@ class Chef
|
|
176
172
|
end
|
177
173
|
end
|
178
174
|
|
179
|
-
def set_unless?
|
180
|
-
@root.set_unless?
|
181
|
-
end
|
182
|
-
|
183
175
|
def convert_key(key)
|
184
176
|
super
|
185
177
|
end
|
@@ -206,118 +198,5 @@ class Chef
|
|
206
198
|
end
|
207
199
|
|
208
200
|
end
|
209
|
-
|
210
|
-
# == MultiMash
|
211
|
-
# This is a Hash-like object that contains multiple VividMashes in it. Its
|
212
|
-
# purpose is so that the user can descend into the mash and delete a subtree
|
213
|
-
# from all of the Mash objects (used to delete all values in a subtree from
|
214
|
-
# default, force_default, role_default and env_default at the same time). The
|
215
|
-
# assignment operator strictly does assignment (does no merging) and works
|
216
|
-
# by deleting the subtree and then assigning to the last mash which passed in
|
217
|
-
# the initializer.
|
218
|
-
#
|
219
|
-
# A lot of the complexity of this class comes from the fact that at any key
|
220
|
-
# value some or all of the mashes may walk off their ends and become nil or
|
221
|
-
# true or something. The schema may change so that one precidence leve may
|
222
|
-
# be 'true' object and another may be a VividMash. It is also possible that
|
223
|
-
# one or many of them may transition from VividMashes to Hashes or Arrays.
|
224
|
-
#
|
225
|
-
# It also supports the case where you may be deleting a key using node.rm
|
226
|
-
# in which case if intermediate keys all walk off into nil then you don't want
|
227
|
-
# to be autovivifying keys as you go. On the other hand you may be using
|
228
|
-
# node.force_default! in which case you'll wind up with a []= operator at the
|
229
|
-
# end and you want autovivification, so we conditionally have to support either
|
230
|
-
# operation.
|
231
|
-
#
|
232
|
-
# @todo: can we have an autovivify class that decorates a class that doesn't
|
233
|
-
# autovivify or something so that the code is less awful?
|
234
|
-
#
|
235
|
-
class MultiMash
|
236
|
-
attr_reader :root
|
237
|
-
attr_reader :mashes
|
238
|
-
attr_reader :opts
|
239
|
-
attr_reader :primary_mash
|
240
|
-
|
241
|
-
# Initialize with an array of mashes. For the delete return value to work
|
242
|
-
# properly the mashes must come from the same attribute level (i.e. all
|
243
|
-
# override or all default, but not a mix of both).
|
244
|
-
def initialize(root, primary_mash, mashes, opts = {})
|
245
|
-
@root = root
|
246
|
-
@primary_mash = primary_mash
|
247
|
-
@mashes = mashes
|
248
|
-
@opts = opts
|
249
|
-
@opts[:autovivify] = true if @opts[:autovivify].nil?
|
250
|
-
end
|
251
|
-
|
252
|
-
def [](key)
|
253
|
-
# handle the secondary mashes
|
254
|
-
new_mashes = []
|
255
|
-
mashes.each do |mash|
|
256
|
-
new_mash = safe_evalute_key(mash, key)
|
257
|
-
# secondary mashes never autovivify so once they fall into nil, we just stop tracking them
|
258
|
-
new_mashes.push(new_mash) unless new_mash.nil?
|
259
|
-
end
|
260
|
-
|
261
|
-
new_primary_mash = safe_evalute_key(primary_mash, key)
|
262
|
-
|
263
|
-
if new_primary_mash.nil? && @opts[:autovivify]
|
264
|
-
primary_mash[key] = VividMash.new(root)
|
265
|
-
new_primary_mash = primary_mash[key]
|
266
|
-
end
|
267
|
-
|
268
|
-
MultiMash.new(root, new_primary_mash, new_mashes, opts)
|
269
|
-
end
|
270
|
-
|
271
|
-
def []=(key, value)
|
272
|
-
if primary_mash.nil?
|
273
|
-
# This theoretically should never happen since node#force_default! setter methods will autovivify and
|
274
|
-
# node#rm methods do not end in #[]= operators.
|
275
|
-
raise TypeError, "No autovivification was specified initially on a method chain ending in assignment"
|
276
|
-
end
|
277
|
-
ret = delete(key)
|
278
|
-
primary_mash[key] = value
|
279
|
-
ret
|
280
|
-
end
|
281
|
-
|
282
|
-
# mash.element('foo', 'bar') is the same as mash['foo']['bar']
|
283
|
-
def element(key = nil, *subkeys)
|
284
|
-
return self if key.nil?
|
285
|
-
submash = self[key]
|
286
|
-
subkeys.empty? ? submash : submash.element(*subkeys)
|
287
|
-
end
|
288
|
-
|
289
|
-
def delete(key)
|
290
|
-
# the return value is a deep merge which is correct semantics when
|
291
|
-
# merging between attributes on the same level (this would be incorrect
|
292
|
-
# if passed both override and default attributes which would need hash_only
|
293
|
-
# merging).
|
294
|
-
ret = mashes.inject(Mash.new) do |merged, mash|
|
295
|
-
Chef::Mixin::DeepMerge.merge(merged, mash)
|
296
|
-
end
|
297
|
-
ret = Chef::Mixin::DeepMerge.merge(ret, primary_mash)
|
298
|
-
mashes.each do |mash|
|
299
|
-
mash.delete(key) if mash.respond_to?(:delete)
|
300
|
-
end
|
301
|
-
primary_mash.delete(key) if primary_mash.respond_to?(:delete)
|
302
|
-
ret[key]
|
303
|
-
end
|
304
|
-
|
305
|
-
private
|
306
|
-
|
307
|
-
def safe_evalute_key(mash, key)
|
308
|
-
if mash.respond_to?(:[])
|
309
|
-
if mash.respond_to?(:has_key?)
|
310
|
-
if mash.has_key?(key)
|
311
|
-
return mash[key] if mash[key].respond_to?(:[])
|
312
|
-
end
|
313
|
-
elsif !mash[key].nil?
|
314
|
-
return mash[key] if mash[key].respond_to?(:[])
|
315
|
-
end
|
316
|
-
end
|
317
|
-
return nil
|
318
|
-
end
|
319
|
-
|
320
|
-
end
|
321
|
-
|
322
201
|
end
|
323
202
|
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright:: Copyright 2016, Chef Software, Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
|
18
|
+
class Chef
|
19
|
+
class Node
|
20
|
+
# shared API between VividMash and ImmutableMash, writer code can be
|
21
|
+
# 'shared' to keep it logically in this file by adding them to the
|
22
|
+
# block list in ImmutableMash.
|
23
|
+
module CommonAPI
|
24
|
+
# method-style access to attributes
|
25
|
+
|
26
|
+
def valid_container?(obj, key)
|
27
|
+
return obj.is_a?(Hash) || (obj.is_a?(Array) && key.is_a?(Fixnum))
|
28
|
+
end
|
29
|
+
|
30
|
+
private :valid_container?
|
31
|
+
|
32
|
+
# - autovivifying / autoreplacing writer
|
33
|
+
# - non-container-ey intermediate objects are replaced with hashes
|
34
|
+
def write(*args, &block)
|
35
|
+
value = block_given? ? yield : args.pop
|
36
|
+
last = args.pop
|
37
|
+
prev_memo = prev_key = nil
|
38
|
+
chain = args.inject(self) do |memo, key|
|
39
|
+
if !valid_container?(memo, key)
|
40
|
+
prev_memo[prev_key] = {}
|
41
|
+
memo = prev_memo[prev_key]
|
42
|
+
end
|
43
|
+
prev_memo = memo
|
44
|
+
prev_key = key
|
45
|
+
memo[key]
|
46
|
+
end
|
47
|
+
if !valid_container?(chain, last)
|
48
|
+
prev_memo[prev_key] = {}
|
49
|
+
chain = prev_memo[prev_key]
|
50
|
+
end
|
51
|
+
chain[last] = value
|
52
|
+
end
|
53
|
+
|
54
|
+
# this autovivifies, but can throw NoSuchAttribute when trying to access #[] on
|
55
|
+
# something that is not a container ("schema violation" issues).
|
56
|
+
#
|
57
|
+
def write!(*args, &block)
|
58
|
+
value = block_given? ? yield : args.pop
|
59
|
+
last = args.pop
|
60
|
+
obj = args.inject(self) do |memo, key|
|
61
|
+
raise Chef::Exceptions::AttributeTypeMismatch unless valid_container?(memo, key)
|
62
|
+
memo[key]
|
63
|
+
end
|
64
|
+
raise Chef::Exceptions::AttributeTypeMismatch unless valid_container?(obj, last)
|
65
|
+
obj[last] = value
|
66
|
+
end
|
67
|
+
|
68
|
+
# FIXME:(?) does anyone need a non-autovivifying writer for attributes that throws exceptions?
|
69
|
+
|
70
|
+
# return true or false based on if the attribute exists
|
71
|
+
def exist?(*path)
|
72
|
+
path.inject(self) do |memo, key|
|
73
|
+
return false unless valid_container?(memo, key)
|
74
|
+
if memo.is_a?(Hash)
|
75
|
+
if memo.key?(key)
|
76
|
+
memo[key]
|
77
|
+
else
|
78
|
+
return false
|
79
|
+
end
|
80
|
+
elsif memo.is_a?(Array)
|
81
|
+
if memo.length > key
|
82
|
+
memo[key]
|
83
|
+
else
|
84
|
+
return false
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
return true
|
89
|
+
end
|
90
|
+
|
91
|
+
# this is a safe non-autovivifying reader that returns nil if the attribute does not exist
|
92
|
+
def read(*path)
|
93
|
+
begin
|
94
|
+
read!(*path)
|
95
|
+
rescue Chef::Exceptions::NoSuchAttribute
|
96
|
+
nil
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# non-autovivifying reader that throws an exception if the attribute does not exist
|
101
|
+
def read!(*path)
|
102
|
+
raise Chef::Exceptions::NoSuchAttribute unless exist?(*path)
|
103
|
+
path.inject(self) do |memo, key|
|
104
|
+
memo[key]
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# FIXME:(?) does anyone really like the autovivifying reader that we have and wants the same behavior? readers that write? ugh...
|
109
|
+
|
110
|
+
def unlink(*path, last)
|
111
|
+
hash = path.empty? ? self : read(*path)
|
112
|
+
return nil unless hash.is_a?(Hash) || hash.is_a?(Array)
|
113
|
+
root.top_level_breadcrumb ||= last
|
114
|
+
hash.delete(last)
|
115
|
+
end
|
116
|
+
|
117
|
+
def unlink!(*path)
|
118
|
+
raise Chef::Exceptions::NoSuchAttribute unless exist?(*path)
|
119
|
+
unlink(*path)
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
@@ -1,3 +1,21 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright:: Copyright 2012-2016, Chef Software, Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
|
18
|
+
require "chef/node/common_api"
|
1
19
|
|
2
20
|
class Chef
|
3
21
|
class Node
|
@@ -124,6 +142,7 @@ class Chef
|
|
124
142
|
class ImmutableMash < Mash
|
125
143
|
|
126
144
|
include Immutablize
|
145
|
+
include CommonAPI
|
127
146
|
|
128
147
|
alias :internal_set :[]=
|
129
148
|
private :internal_set
|
@@ -144,6 +163,10 @@ class Chef
|
|
144
163
|
:replace,
|
145
164
|
:select!,
|
146
165
|
:shift,
|
166
|
+
:write,
|
167
|
+
:write!,
|
168
|
+
:unlink,
|
169
|
+
:unlink!,
|
147
170
|
]
|
148
171
|
|
149
172
|
def initialize(mash_data)
|
@@ -167,13 +190,15 @@ class Chef
|
|
167
190
|
end
|
168
191
|
|
169
192
|
def method_missing(symbol, *args)
|
170
|
-
if
|
193
|
+
if symbol == :to_ary
|
194
|
+
super
|
195
|
+
elsif args.empty?
|
171
196
|
if key?(symbol)
|
172
197
|
self[symbol]
|
173
198
|
else
|
174
199
|
raise NoMethodError, "Undefined method or attribute `#{symbol}' on `node'"
|
175
200
|
end
|
176
|
-
|
201
|
+
# This will raise a ImmutableAttributeModification error:
|
177
202
|
elsif symbol.to_s =~ /=$/
|
178
203
|
key_to_set = symbol.to_s[/^(.+)=$/, 1]
|
179
204
|
self[key_to_set] = (args.length == 1 ? args[0] : args)
|
data/lib/chef/property.rb
CHANGED
@@ -531,8 +531,6 @@ class Chef
|
|
531
531
|
end
|
532
532
|
end
|
533
533
|
|
534
|
-
protected
|
535
|
-
|
536
534
|
#
|
537
535
|
# The options this Property will use for get/set behavior and validation.
|
538
536
|
#
|
@@ -583,6 +581,7 @@ class Chef
|
|
583
581
|
(options.has_key?(:is) && resource.send(:_pv_is, { name => nil }, name, options[:is], raise_error: false))
|
584
582
|
end
|
585
583
|
|
584
|
+
# @api private
|
586
585
|
def get_value(resource)
|
587
586
|
if instance_variable_name
|
588
587
|
resource.instance_variable_get(instance_variable_name)
|
@@ -591,6 +590,7 @@ class Chef
|
|
591
590
|
end
|
592
591
|
end
|
593
592
|
|
593
|
+
# @api private
|
594
594
|
def set_value(resource, value)
|
595
595
|
if instance_variable_name
|
596
596
|
resource.instance_variable_set(instance_variable_name, value)
|
@@ -599,6 +599,7 @@ class Chef
|
|
599
599
|
end
|
600
600
|
end
|
601
601
|
|
602
|
+
# @api private
|
602
603
|
def value_is_set?(resource)
|
603
604
|
if instance_variable_name
|
604
605
|
resource.instance_variable_defined?(instance_variable_name)
|
@@ -607,6 +608,7 @@ class Chef
|
|
607
608
|
end
|
608
609
|
end
|
609
610
|
|
611
|
+
# @api private
|
610
612
|
def reset_value(resource)
|
611
613
|
if instance_variable_name
|
612
614
|
if value_is_set?(resource)
|
@@ -617,6 +619,8 @@ class Chef
|
|
617
619
|
end
|
618
620
|
end
|
619
621
|
|
622
|
+
private
|
623
|
+
|
620
624
|
def exec_in_resource(resource, proc, *args)
|
621
625
|
if resource
|
622
626
|
if proc.arity > args.size
|
data/lib/chef/provider.rb
CHANGED
@@ -423,9 +423,9 @@ class Chef
|
|
423
423
|
|
424
424
|
module DeprecatedLWRPClass
|
425
425
|
def const_missing(class_name)
|
426
|
-
if deprecated_constants[class_name.to_sym]
|
426
|
+
if Chef::Provider.deprecated_constants[class_name.to_sym]
|
427
427
|
Chef.log_deprecation("Using an LWRP provider by its name (#{class_name}) directly is no longer supported in Chef 12 and will be removed. Use Chef::ProviderResolver.new(node, resource, action) instead.")
|
428
|
-
deprecated_constants[class_name.to_sym]
|
428
|
+
Chef::Provider.deprecated_constants[class_name.to_sym]
|
429
429
|
else
|
430
430
|
raise NameError, "uninitialized constant Chef::Provider::#{class_name}"
|
431
431
|
end
|
@@ -438,13 +438,12 @@ class Chef
|
|
438
438
|
if Chef::Provider.const_defined?(class_name, false)
|
439
439
|
Chef::Log.warn "Chef::Provider::#{class_name} already exists! Cannot create deprecation class for #{provider_class}"
|
440
440
|
else
|
441
|
-
deprecated_constants[class_name.to_sym] = provider_class
|
441
|
+
Chef::Provider.deprecated_constants[class_name.to_sym] = provider_class
|
442
442
|
end
|
443
443
|
end
|
444
444
|
|
445
|
-
private
|
446
|
-
|
447
445
|
def deprecated_constants
|
446
|
+
raise "Deprecated constants should be called only on Chef::Provider" unless self == Chef::Provider
|
448
447
|
@deprecated_constants ||= {}
|
449
448
|
end
|
450
449
|
end
|
data/lib/chef/provider/batch.rb
CHANGED
@@ -29,7 +29,7 @@ class Chef
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def command
|
32
|
-
basepath = is_forced_32bit ? wow64_directory : run_context.node
|
32
|
+
basepath = is_forced_32bit ? wow64_directory : run_context.node["kernel"]["os_info"]["system_directory"]
|
33
33
|
|
34
34
|
interpreter_path = Chef::Util::PathHelper.join(basepath, interpreter)
|
35
35
|
|