chef 14.6.47-universal-mingw32 → 14.7.17-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/chef-universal-mingw32.gemspec +1 -0
- data/lib/chef/application/apply.rb +6 -4
- data/lib/chef/knife/config_list_profiles.rb +1 -1
- data/lib/chef/knife/list.rb +1 -1
- data/lib/chef/knife/raw.rb +1 -1
- data/lib/chef/knife/role_env_run_list_clear.rb +1 -1
- data/lib/chef/knife/role_env_run_list_remove.rb +1 -1
- data/lib/chef/knife/role_env_run_list_replace.rb +1 -1
- data/lib/chef/knife/role_env_run_list_set.rb +1 -1
- data/lib/chef/knife/role_run_list_clear.rb +1 -1
- data/lib/chef/knife/role_run_list_remove.rb +1 -1
- data/lib/chef/knife/role_run_list_replace.rb +1 -1
- data/lib/chef/knife/role_run_list_set.rb +1 -1
- data/lib/chef/knife/show.rb +1 -1
- data/lib/chef/knife/upload.rb +1 -1
- data/lib/chef/knife/xargs.rb +1 -1
- data/lib/chef/node/attribute.rb +189 -185
- data/lib/chef/platform/rebooter.rb +1 -0
- data/lib/chef/property.rb +25 -1
- data/lib/chef/provider/windows_task.rb +19 -6
- data/lib/chef/resource.rb +17 -2
- data/lib/chef/resource/apt_preference.rb +2 -1
- data/lib/chef/resource/apt_repository.rb +1 -1
- data/lib/chef/resource/apt_update.rb +1 -0
- data/lib/chef/resource/build_essential.rb +1 -1
- data/lib/chef/resource/cab_package.rb +1 -1
- data/lib/chef/resource/chef_gem.rb +1 -1
- data/lib/chef/resource/cookbook_file.rb +2 -1
- data/lib/chef/resource/cron_d.rb +1 -1
- data/lib/chef/resource/dmg_package.rb +52 -40
- data/lib/chef/resource/execute.rb +2 -2
- data/lib/chef/resource/file.rb +1 -1
- data/lib/chef/resource/group.rb +2 -2
- data/lib/chef/resource/homebrew_cask.rb +3 -2
- data/lib/chef/resource/homebrew_tap.rb +2 -2
- data/lib/chef/resource/hostname.rb +2 -2
- data/lib/chef/resource/kernel_module.rb +19 -13
- data/lib/chef/resource/locale.rb +1 -0
- data/lib/chef/resource/macos_userdefaults.rb +7 -6
- data/lib/chef/resource/mdadm.rb +3 -2
- data/lib/chef/resource/mount.rb +3 -3
- data/lib/chef/resource/openssl_dhparam.rb +1 -1
- data/lib/chef/resource/openssl_ec_private_key.rb +1 -1
- data/lib/chef/resource/openssl_ec_public_key.rb +3 -3
- data/lib/chef/resource/openssl_rsa_private_key.rb +2 -2
- data/lib/chef/resource/openssl_rsa_public_key.rb +3 -3
- data/lib/chef/resource/openssl_x509_certificate.rb +1 -1
- data/lib/chef/resource/openssl_x509_crl.rb +1 -1
- data/lib/chef/resource/openssl_x509_request.rb +1 -1
- data/lib/chef/resource/package.rb +1 -1
- data/lib/chef/resource/powershell_package.rb +1 -1
- data/lib/chef/resource/remote_directory.rb +2 -2
- data/lib/chef/resource/rhsm_errata.rb +1 -1
- data/lib/chef/resource/rhsm_errata_level.rb +1 -1
- data/lib/chef/resource/rhsm_register.rb +7 -7
- data/lib/chef/resource/rhsm_repo.rb +1 -1
- data/lib/chef/resource/rhsm_subscription.rb +1 -1
- data/lib/chef/resource/sudo.rb +8 -8
- data/lib/chef/resource/swap_file.rb +1 -1
- data/lib/chef/resource/sysctl.rb +2 -2
- data/lib/chef/resource/systemd_unit.rb +19 -11
- data/lib/chef/resource/timezone.rb +60 -32
- data/lib/chef/resource/windows_ad_join.rb +1 -1
- data/lib/chef/resource/windows_auto_run.rb +1 -1
- data/lib/chef/resource/windows_certificate.rb +269 -0
- data/lib/chef/resource/windows_env.rb +12 -3
- data/lib/chef/resource/windows_feature.rb +6 -11
- data/lib/chef/resource/windows_feature_dism.rb +2 -2
- data/lib/chef/resource/windows_feature_powershell.rb +5 -9
- data/lib/chef/resource/windows_firewall_rule.rb +205 -0
- data/lib/chef/resource/windows_path.rb +3 -1
- data/lib/chef/resource/windows_printer.rb +2 -2
- data/lib/chef/resource/windows_printer_port.rb +3 -3
- data/lib/chef/resource/windows_service.rb +1 -0
- data/lib/chef/resource/windows_share.rb +315 -0
- data/lib/chef/resource/windows_task.rb +4 -0
- data/lib/chef/resource/windows_workgroup.rb +6 -4
- data/lib/chef/resource/yum_repository.rb +13 -7
- data/lib/chef/resource/zypper_package.rb +2 -2
- data/lib/chef/resource/zypper_repository.rb +2 -1
- data/lib/chef/resource_inspector.rb +4 -4
- data/lib/chef/resources.rb +3 -0
- data/lib/chef/version.rb +1 -1
- data/spec/functional/resource/windows_task_spec.rb +39 -0
- data/spec/support/platform_helpers.rb +2 -1
- data/spec/unit/resource/windows_certificate.rb +46 -0
- data/spec/unit/resource/windows_firewall_rule_spec.rb +401 -0
- data/spec/unit/resource/windows_share.rb +39 -0
- metadata +24 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9be735cf1e06242e8769af292fd4fdf773e45d9a63c3590474b5402b592cd5a2
|
4
|
+
data.tar.gz: 409f58ef97a76f840f9b062bbe6a695c2e483fe3f485571d4a9f390b61c2c9c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03f823b4b540570f1f0f6814952f2fff5d2c3f3e2e3d4366eecc0d0a5569e9ee0c436bbff27b34f865cdd6435b59591a1a87ad91eb925c820b8bbcab01f9d55f
|
7
|
+
data.tar.gz: '09b67f8b5ffe3caff4c45ac9d388bac6fbb26ce50e4a9abf32961a84e331caaa2f92f8d1b5ff979dbdcac741b605b0f4a5b5825b1c4d53548eb1c88b1d3eb1b4'
|
@@ -16,6 +16,7 @@ gemspec.add_dependency "windows-api", "~> 0.4.4"
|
|
16
16
|
gemspec.add_dependency "wmi-lite", "~> 1.0"
|
17
17
|
gemspec.add_dependency "win32-taskscheduler", "~> 2.0"
|
18
18
|
gemspec.add_dependency "iso8601", "~> 0.12.1"
|
19
|
+
gemspec.add_dependency "win32-certstore", ">= 0.1.8"
|
19
20
|
gemspec.extensions << "ext/win32-eventlog/Rakefile"
|
20
21
|
gemspec.files += Dir.glob("{distro,ext}/**/*")
|
21
22
|
|
@@ -191,10 +191,12 @@ class Chef::Application::Apply < Chef::Application
|
|
191
191
|
recipe, run_context = get_recipe_and_run_context
|
192
192
|
recipe.instance_eval(@recipe_text, @recipe_filename, 1)
|
193
193
|
runner = Chef::Runner.new(run_context)
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
194
|
+
catch(:end_client_run_early) do
|
195
|
+
begin
|
196
|
+
runner.converge
|
197
|
+
ensure
|
198
|
+
@recipe_fh.close
|
199
|
+
end
|
198
200
|
end
|
199
201
|
Chef::Platform::Rebooter.reboot_if_needed!(runner)
|
200
202
|
end
|
data/lib/chef/knife/list.rb
CHANGED
data/lib/chef/knife/raw.rb
CHANGED
@@ -28,7 +28,7 @@ class Chef
|
|
28
28
|
require "chef/json_compat"
|
29
29
|
end
|
30
30
|
|
31
|
-
banner "knife role env_run_list clear [ROLE] [ENVIRONMENT]"
|
31
|
+
banner "knife role env_run_list clear [ROLE] [ENVIRONMENT] (options)"
|
32
32
|
def clear_env_run_list(role, environment)
|
33
33
|
nlist = []
|
34
34
|
role.env_run_lists_add(environment => nlist)
|
@@ -27,7 +27,7 @@ class Chef
|
|
27
27
|
require "chef/json_compat"
|
28
28
|
end
|
29
29
|
|
30
|
-
banner "knife role env_run_list remove [ROLE] [ENVIRONMENT] [ENTRIES]"
|
30
|
+
banner "knife role env_run_list remove [ROLE] [ENVIRONMENT] [ENTRIES] (options)"
|
31
31
|
|
32
32
|
def remove_from_env_run_list(role, environment, item_to_remove)
|
33
33
|
nlist = []
|
@@ -28,7 +28,7 @@ class Chef
|
|
28
28
|
require "chef/json_compat"
|
29
29
|
end
|
30
30
|
|
31
|
-
banner "knife role env_run_list replace [ROLE] [ENVIRONMENT] [OLD_ENTRY] [NEW_ENTRY] "
|
31
|
+
banner "knife role env_run_list replace [ROLE] [ENVIRONMENT] [OLD_ENTRY] [NEW_ENTRY] (options)"
|
32
32
|
|
33
33
|
def replace_in_env_run_list(role, environment, old_entry, new_entry)
|
34
34
|
nlist = []
|
@@ -28,7 +28,7 @@ class Chef
|
|
28
28
|
require "chef/json_compat"
|
29
29
|
end
|
30
30
|
|
31
|
-
banner "knife role env_run_list set [ROLE] [ENVIRONMENT] [ENTRIES]"
|
31
|
+
banner "knife role env_run_list set [ROLE] [ENVIRONMENT] [ENTRIES] (optionss)"
|
32
32
|
|
33
33
|
# Clears out any existing env_run_list_items and sets them to the
|
34
34
|
# specified entries
|
@@ -28,7 +28,7 @@ class Chef
|
|
28
28
|
require "chef/json_compat"
|
29
29
|
end
|
30
30
|
|
31
|
-
banner "knife role run_list replace [ROLE] [OLD_ENTRY] [NEW_ENTRY] "
|
31
|
+
banner "knife role run_list replace [ROLE] [OLD_ENTRY] [NEW_ENTRY] (options)"
|
32
32
|
|
33
33
|
def replace_in_env_run_list(role, environment, old_entry, new_entry)
|
34
34
|
nlist = []
|
data/lib/chef/knife/show.rb
CHANGED
data/lib/chef/knife/upload.rb
CHANGED
data/lib/chef/knife/xargs.rb
CHANGED
data/lib/chef/node/attribute.rb
CHANGED
@@ -78,113 +78,117 @@ class Chef
|
|
78
78
|
:@force_override,
|
79
79
|
].freeze
|
80
80
|
|
81
|
-
[
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
81
|
+
ENUM_METHODS = [
|
82
|
+
:all?,
|
83
|
+
:any?,
|
84
|
+
:assoc,
|
85
|
+
:chunk,
|
86
|
+
:collect,
|
87
|
+
:collect_concat,
|
88
|
+
:compare_by_identity,
|
89
|
+
:compare_by_identity?,
|
90
|
+
:count,
|
91
|
+
:cycle,
|
92
|
+
:detect,
|
93
|
+
:drop,
|
94
|
+
:drop_while,
|
95
|
+
:each,
|
96
|
+
:each_cons,
|
97
|
+
:each_entry,
|
98
|
+
:each_key,
|
99
|
+
:each_pair,
|
100
|
+
:each_slice,
|
101
|
+
:each_value,
|
102
|
+
:each_with_index,
|
103
|
+
:each_with_object,
|
104
|
+
:empty?,
|
105
|
+
:entries,
|
106
|
+
:except,
|
107
|
+
:fetch,
|
108
|
+
:find,
|
109
|
+
:find_all,
|
110
|
+
:find_index,
|
111
|
+
:first,
|
112
|
+
:flat_map,
|
113
|
+
:flatten,
|
114
|
+
:grep,
|
115
|
+
:group_by,
|
116
|
+
:has_value?,
|
117
|
+
:include?,
|
118
|
+
:index,
|
119
|
+
:inject,
|
120
|
+
:invert,
|
121
|
+
:key,
|
122
|
+
:keys,
|
123
|
+
:length,
|
124
|
+
:map,
|
125
|
+
:max,
|
126
|
+
:max_by,
|
127
|
+
:merge,
|
128
|
+
:min,
|
129
|
+
:min_by,
|
130
|
+
:minmax,
|
131
|
+
:minmax_by,
|
132
|
+
:none?,
|
133
|
+
:one?,
|
134
|
+
:partition,
|
135
|
+
:rassoc,
|
136
|
+
:reduce,
|
137
|
+
:reject,
|
138
|
+
:reverse_each,
|
139
|
+
:select,
|
140
|
+
:size,
|
141
|
+
:slice_before,
|
142
|
+
:sort,
|
143
|
+
:sort_by,
|
144
|
+
:store,
|
145
|
+
:symbolize_keys,
|
146
|
+
:take,
|
147
|
+
:take_while,
|
148
|
+
:to_a,
|
149
|
+
:to_h,
|
150
|
+
:to_hash,
|
151
|
+
:to_set,
|
152
|
+
:value?,
|
153
|
+
:values,
|
154
|
+
:values_at,
|
155
|
+
:zip,
|
156
|
+
].freeze
|
157
|
+
|
158
|
+
ENUM_METHODS.each do |delegated_method|
|
159
|
+
define_method(delegated_method) do |*args, &block|
|
160
|
+
merged_attributes.send(delegated_method, *args, &block)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
# return the cookbook level default attribute component
|
161
165
|
attr_reader :default
|
162
166
|
|
163
|
-
|
167
|
+
# return the role level default attribute component
|
164
168
|
attr_reader :role_default
|
165
169
|
|
166
|
-
|
170
|
+
# return the environment level default attribute component
|
167
171
|
attr_reader :env_default
|
168
172
|
|
169
|
-
|
173
|
+
# return the force_default level attribute component
|
170
174
|
attr_reader :force_default
|
171
175
|
|
172
|
-
|
176
|
+
# return the "normal" level attribute component
|
173
177
|
attr_reader :normal
|
174
178
|
|
175
|
-
|
179
|
+
# return the cookbook level override attribute component
|
176
180
|
attr_reader :override
|
177
181
|
|
178
|
-
|
182
|
+
# return the role level override attribute component
|
179
183
|
attr_reader :role_override
|
180
184
|
|
181
|
-
|
185
|
+
# return the enviroment level override attribute component
|
182
186
|
attr_reader :env_override
|
183
187
|
|
184
|
-
|
188
|
+
# return the force override level attribute component
|
185
189
|
attr_reader :force_override
|
186
190
|
|
187
|
-
|
191
|
+
# return the automatic level attribute component
|
188
192
|
attr_reader :automatic
|
189
193
|
|
190
194
|
def initialize(normal, default, override, automatic, node = nil)
|
@@ -205,15 +209,15 @@ class Chef
|
|
205
209
|
super(nil, self, node, :merged)
|
206
210
|
end
|
207
211
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
212
|
+
# Debug what's going on with an attribute. +args+ is a path spec to the
|
213
|
+
# attribute you're interested in. For example, to debug where the value
|
214
|
+
# of `node[:network][:default_interface]` is coming from, use:
|
215
|
+
# debug_value(:network, :default_interface).
|
216
|
+
# The return value is an Array of Arrays. The Arrays
|
217
|
+
# are pairs of `["precedence_level", value]`, where precedence level is
|
218
|
+
# the component, such as role default, normal, etc. and value is the
|
219
|
+
# attribute value set at that precedence level. If there is no value at
|
220
|
+
# that precedence level, +value+ will be the symbol +:not_present+.
|
217
221
|
def debug_value(*args)
|
218
222
|
COMPONENTS.map do |component|
|
219
223
|
value =
|
@@ -226,49 +230,49 @@ class Chef
|
|
226
230
|
end
|
227
231
|
end
|
228
232
|
|
229
|
-
|
233
|
+
# Set the cookbook level default attribute component to +new_data+.
|
230
234
|
def default=(new_data)
|
231
235
|
reset
|
232
236
|
@default = VividMash.new(new_data, self, __node__, :default)
|
233
237
|
end
|
234
238
|
|
235
|
-
|
239
|
+
# Set the role level default attribute component to +new_data+
|
236
240
|
def role_default=(new_data)
|
237
241
|
reset
|
238
242
|
@role_default = VividMash.new(new_data, self, __node__, :role_default)
|
239
243
|
end
|
240
244
|
|
241
|
-
|
245
|
+
# Set the environment level default attribute component to +new_data+
|
242
246
|
def env_default=(new_data)
|
243
247
|
reset
|
244
248
|
@env_default = VividMash.new(new_data, self, __node__, :env_default)
|
245
249
|
end
|
246
250
|
|
247
|
-
|
251
|
+
# Set the force_default (+default!+) level attributes to +new_data+
|
248
252
|
def force_default=(new_data)
|
249
253
|
reset
|
250
254
|
@force_default = VividMash.new(new_data, self, __node__, :force_default)
|
251
255
|
end
|
252
256
|
|
253
|
-
|
257
|
+
# Set the normal level attribute component to +new_data+
|
254
258
|
def normal=(new_data)
|
255
259
|
reset
|
256
260
|
@normal = VividMash.new(new_data, self, __node__, :normal)
|
257
261
|
end
|
258
262
|
|
259
|
-
|
263
|
+
# Set the cookbook level override attribute component to +new_data+
|
260
264
|
def override=(new_data)
|
261
265
|
reset
|
262
266
|
@override = VividMash.new(new_data, self, __node__, :override)
|
263
267
|
end
|
264
268
|
|
265
|
-
|
269
|
+
# Set the role level override attribute component to +new_data+
|
266
270
|
def role_override=(new_data)
|
267
271
|
reset
|
268
272
|
@role_override = VividMash.new(new_data, self, __node__, :role_override)
|
269
273
|
end
|
270
274
|
|
271
|
-
|
275
|
+
# Set the environment level override attribute component to +new_data+
|
272
276
|
def env_override=(new_data)
|
273
277
|
reset
|
274
278
|
@env_override = VividMash.new(new_data, self, __node__, :env_override)
|
@@ -284,11 +288,11 @@ class Chef
|
|
284
288
|
@automatic = VividMash.new(new_data, self, __node__, :automatic)
|
285
289
|
end
|
286
290
|
|
287
|
-
|
288
|
-
|
289
|
-
|
291
|
+
#
|
292
|
+
# Deleting attributes
|
293
|
+
#
|
290
294
|
|
291
|
-
|
295
|
+
# clears attributes from all precedence levels
|
292
296
|
def rm(*args)
|
293
297
|
with_deep_merged_return_value(self, *args) do
|
294
298
|
rm_default(*args)
|
@@ -297,11 +301,11 @@ class Chef
|
|
297
301
|
end
|
298
302
|
end
|
299
303
|
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
304
|
+
# clears attributes from all default precedence levels
|
305
|
+
#
|
306
|
+
# similar to: force_default!['foo']['bar'].delete('baz')
|
307
|
+
# - does not autovivify
|
308
|
+
# - does not trainwreck if interior keys do not exist
|
305
309
|
def rm_default(*args)
|
306
310
|
with_deep_merged_return_value(combined_default, *args) do
|
307
311
|
default.unlink(*args)
|
@@ -311,20 +315,20 @@ class Chef
|
|
311
315
|
end
|
312
316
|
end
|
313
317
|
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
318
|
+
# clears attributes from normal precedence
|
319
|
+
#
|
320
|
+
# equivalent to: normal!['foo']['bar'].delete('baz')
|
321
|
+
# - does not autovivify
|
322
|
+
# - does not trainwreck if interior keys do not exist
|
319
323
|
def rm_normal(*args)
|
320
324
|
normal.unlink(*args)
|
321
325
|
end
|
322
326
|
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
327
|
+
# clears attributes from all override precedence levels
|
328
|
+
#
|
329
|
+
# equivalent to: force_override!['foo']['bar'].delete('baz')
|
330
|
+
# - does not autovivify
|
331
|
+
# - does not trainwreck if interior keys do not exist
|
328
332
|
def rm_override(*args)
|
329
333
|
with_deep_merged_return_value(combined_override, *args) do
|
330
334
|
override.unlink(*args)
|
@@ -344,37 +348,37 @@ class Chef
|
|
344
348
|
|
345
349
|
private :with_deep_merged_return_value
|
346
350
|
|
347
|
-
|
348
|
-
|
349
|
-
|
351
|
+
#
|
352
|
+
# Replacing attributes without merging
|
353
|
+
#
|
350
354
|
|
351
|
-
|
352
|
-
|
353
|
-
|
355
|
+
# sets default attributes without merging
|
356
|
+
#
|
357
|
+
# - this API autovivifies (and cannot trainwreck)
|
354
358
|
def default!(*args)
|
355
359
|
return Decorator::Unchain.new(self, :default!) unless args.length > 0
|
356
360
|
write(:default, *args)
|
357
361
|
end
|
358
362
|
|
359
|
-
|
360
|
-
|
361
|
-
|
363
|
+
# sets normal attributes without merging
|
364
|
+
#
|
365
|
+
# - this API autovivifies (and cannot trainwreck)
|
362
366
|
def normal!(*args)
|
363
367
|
return Decorator::Unchain.new(self, :normal!) unless args.length > 0
|
364
368
|
write(:normal, *args)
|
365
369
|
end
|
366
370
|
|
367
|
-
|
368
|
-
|
369
|
-
|
371
|
+
# sets override attributes without merging
|
372
|
+
#
|
373
|
+
# - this API autovivifies (and cannot trainwreck)
|
370
374
|
def override!(*args)
|
371
375
|
return Decorator::Unchain.new(self, :override!) unless args.length > 0
|
372
376
|
write(:override, *args)
|
373
377
|
end
|
374
378
|
|
375
|
-
|
376
|
-
|
377
|
-
|
379
|
+
# clears from all default precedence levels and then sets force_default
|
380
|
+
#
|
381
|
+
# - this API autovivifies (and cannot trainwreck)
|
378
382
|
def force_default!(*args)
|
379
383
|
return Decorator::Unchain.new(self, :force_default!) unless args.length > 0
|
380
384
|
value = args.pop
|
@@ -382,7 +386,7 @@ class Chef
|
|
382
386
|
write(:force_default, *args, value)
|
383
387
|
end
|
384
388
|
|
385
|
-
|
389
|
+
# clears from all override precedence levels and then sets force_override
|
386
390
|
def force_override!(*args)
|
387
391
|
return Decorator::Unchain.new(self, :force_override!) unless args.length > 0
|
388
392
|
value = args.pop
|
@@ -390,14 +394,13 @@ class Chef
|
|
390
394
|
write(:force_override, *args, value)
|
391
395
|
end
|
392
396
|
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
397
|
+
#
|
398
|
+
# Accessing merged attributes.
|
399
|
+
#
|
400
|
+
# Note that merged_attributes('foo', 'bar', 'baz') can be called to compute only the
|
401
|
+
# deep merge of node['foo']['bar']['baz'], but in practice we currently always compute
|
402
|
+
# all of node['foo'] even if the user only requires node['foo']['bar']['baz'].
|
403
|
+
#
|
401
404
|
def merged_attributes(*path)
|
402
405
|
merge_all(path)
|
403
406
|
end
|
@@ -430,7 +433,8 @@ class Chef
|
|
430
433
|
instance_variable_get(component_ivar).key?(key)
|
431
434
|
end
|
432
435
|
end
|
433
|
-
|
436
|
+
|
437
|
+
# method-style access to attributes (has to come after the prepended ImmutablizeHash)
|
434
438
|
|
435
439
|
def read(*path)
|
436
440
|
merged_attributes.read(*path)
|
@@ -479,16 +483,16 @@ class Chef
|
|
479
483
|
|
480
484
|
private
|
481
485
|
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
486
|
+
# Helper method for merge_all/merge_defaults/merge_overrides.
|
487
|
+
#
|
488
|
+
# apply_path(thing, [ "foo", "bar", "baz" ]) = thing["foo"]["bar"]["baz"]
|
489
|
+
#
|
490
|
+
# The path value can be nil in which case the whole component is returned.
|
491
|
+
#
|
492
|
+
# It returns nil (does not raise an exception) if it walks off the end of an Mash/Hash/Array, it does not
|
493
|
+
# raise any TypeError if it attempts to apply a hash key to an Integer/String/TrueClass, and just returns
|
494
|
+
# nil in that case.
|
495
|
+
#
|
492
496
|
def apply_path(component, path)
|
493
497
|
path ||= []
|
494
498
|
path.inject(component) do |val, path_arg|
|
@@ -509,20 +513,20 @@ class Chef
|
|
509
513
|
end
|
510
514
|
end
|
511
515
|
|
512
|
-
|
516
|
+
# For elements like Fixnums, true, nil...
|
513
517
|
def safe_dup(e)
|
514
518
|
e.dup
|
515
519
|
rescue TypeError
|
516
520
|
e
|
517
521
|
end
|
518
522
|
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
523
|
+
# Deep merge all attribute levels using hash-only merging between different precidence
|
524
|
+
# levels (so override arrays completely replace arrays set at any default level).
|
525
|
+
#
|
526
|
+
# The path allows for selectively deep-merging a subtree of the node object.
|
527
|
+
#
|
528
|
+
# @param path [Array] Array of args to method chain to descend into the node object
|
529
|
+
# @return [attr] Deep Merged values (may be VividMash, Hash, Array, etc) from the node object
|
526
530
|
def merge_all(path)
|
527
531
|
components = [
|
528
532
|
merge_defaults(path),
|
@@ -537,12 +541,12 @@ class Chef
|
|
537
541
|
ret == NIL ? nil : ret
|
538
542
|
end
|
539
543
|
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
544
|
+
# Deep merge the default attribute levels with array merging.
|
545
|
+
#
|
546
|
+
# The path allows for selectively deep-merging a subtree of the node object.
|
547
|
+
#
|
548
|
+
# @param path [Array] Array of args to method chain to descend into the node object
|
549
|
+
# @return [attr] Deep Merged values (may be VividMash, Hash, Array, etc) from the node object
|
546
550
|
def merge_defaults(path)
|
547
551
|
ret = DEFAULT_COMPONENTS.inject(NIL) do |merged, component_ivar|
|
548
552
|
component_value = apply_path(instance_variable_get(component_ivar), path)
|
@@ -551,12 +555,12 @@ class Chef
|
|
551
555
|
ret == NIL ? nil : ret
|
552
556
|
end
|
553
557
|
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
558
|
+
# Deep merge the override attribute levels with array merging.
|
559
|
+
#
|
560
|
+
# The path allows for selectively deep-merging a subtree of the node object.
|
561
|
+
#
|
562
|
+
# @param path [Array] Array of args to method chain to descend into the node object
|
563
|
+
# @return [attr] Deep Merged values (may be VividMash, Hash, Array, etc) from the node object
|
560
564
|
def merge_overrides(path)
|
561
565
|
ret = OVERRIDE_COMPONENTS.inject(NIL) do |merged, component_ivar|
|
562
566
|
component_value = apply_path(instance_variable_get(component_ivar), path)
|
@@ -565,7 +569,7 @@ class Chef
|
|
565
569
|
ret == NIL ? nil : ret
|
566
570
|
end
|
567
571
|
|
568
|
-
|
572
|
+
# needed for __path__
|
569
573
|
def convert_key(key)
|
570
574
|
key.kind_of?(Symbol) ? key.to_s : key
|
571
575
|
end
|
@@ -592,11 +596,11 @@ class Chef
|
|
592
596
|
elsif merge_onto.kind_of?(Array) && merge_with.kind_of?(Array)
|
593
597
|
merge_onto |= merge_with
|
594
598
|
|
595
|
-
|
599
|
+
# If merge_with is nil, don't replace merge_onto
|
596
600
|
elsif merge_with.nil?
|
597
601
|
merge_onto
|
598
602
|
|
599
|
-
|
603
|
+
# In all other cases, replace merge_onto with merge_with
|
600
604
|
else
|
601
605
|
if merge_with.kind_of?(Hash)
|
602
606
|
Chef::Node::ImmutableMash.new(merge_with)
|
@@ -625,11 +629,11 @@ class Chef
|
|
625
629
|
end
|
626
630
|
merge_onto
|
627
631
|
|
628
|
-
|
632
|
+
# If merge_with is nil, don't replace merge_onto
|
629
633
|
elsif merge_with.nil?
|
630
634
|
merge_onto
|
631
635
|
|
632
|
-
|
636
|
+
# In all other cases, replace merge_onto with merge_with
|
633
637
|
else
|
634
638
|
if merge_with.kind_of?(Hash)
|
635
639
|
Chef::Node::ImmutableMash.new(merge_with)
|