chef 14.6.47 → 14.7.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/chef-universal-mingw32.gemspec +1 -0
  3. data/lib/chef/application/apply.rb +6 -4
  4. data/lib/chef/knife/config_list_profiles.rb +1 -1
  5. data/lib/chef/knife/list.rb +1 -1
  6. data/lib/chef/knife/raw.rb +1 -1
  7. data/lib/chef/knife/role_env_run_list_clear.rb +1 -1
  8. data/lib/chef/knife/role_env_run_list_remove.rb +1 -1
  9. data/lib/chef/knife/role_env_run_list_replace.rb +1 -1
  10. data/lib/chef/knife/role_env_run_list_set.rb +1 -1
  11. data/lib/chef/knife/role_run_list_clear.rb +1 -1
  12. data/lib/chef/knife/role_run_list_remove.rb +1 -1
  13. data/lib/chef/knife/role_run_list_replace.rb +1 -1
  14. data/lib/chef/knife/role_run_list_set.rb +1 -1
  15. data/lib/chef/knife/show.rb +1 -1
  16. data/lib/chef/knife/upload.rb +1 -1
  17. data/lib/chef/knife/xargs.rb +1 -1
  18. data/lib/chef/node/attribute.rb +189 -185
  19. data/lib/chef/platform/rebooter.rb +1 -0
  20. data/lib/chef/property.rb +25 -1
  21. data/lib/chef/provider/windows_task.rb +19 -6
  22. data/lib/chef/resource.rb +17 -2
  23. data/lib/chef/resource/apt_preference.rb +2 -1
  24. data/lib/chef/resource/apt_repository.rb +1 -1
  25. data/lib/chef/resource/apt_update.rb +1 -0
  26. data/lib/chef/resource/build_essential.rb +1 -1
  27. data/lib/chef/resource/cab_package.rb +1 -1
  28. data/lib/chef/resource/chef_gem.rb +1 -1
  29. data/lib/chef/resource/cookbook_file.rb +2 -1
  30. data/lib/chef/resource/cron_d.rb +1 -1
  31. data/lib/chef/resource/dmg_package.rb +52 -40
  32. data/lib/chef/resource/execute.rb +2 -2
  33. data/lib/chef/resource/file.rb +1 -1
  34. data/lib/chef/resource/group.rb +2 -2
  35. data/lib/chef/resource/homebrew_cask.rb +3 -2
  36. data/lib/chef/resource/homebrew_tap.rb +2 -2
  37. data/lib/chef/resource/hostname.rb +2 -2
  38. data/lib/chef/resource/kernel_module.rb +19 -13
  39. data/lib/chef/resource/locale.rb +1 -0
  40. data/lib/chef/resource/macos_userdefaults.rb +7 -6
  41. data/lib/chef/resource/mdadm.rb +3 -2
  42. data/lib/chef/resource/mount.rb +3 -3
  43. data/lib/chef/resource/openssl_dhparam.rb +1 -1
  44. data/lib/chef/resource/openssl_ec_private_key.rb +1 -1
  45. data/lib/chef/resource/openssl_ec_public_key.rb +3 -3
  46. data/lib/chef/resource/openssl_rsa_private_key.rb +2 -2
  47. data/lib/chef/resource/openssl_rsa_public_key.rb +3 -3
  48. data/lib/chef/resource/openssl_x509_certificate.rb +1 -1
  49. data/lib/chef/resource/openssl_x509_crl.rb +1 -1
  50. data/lib/chef/resource/openssl_x509_request.rb +1 -1
  51. data/lib/chef/resource/package.rb +1 -1
  52. data/lib/chef/resource/powershell_package.rb +1 -1
  53. data/lib/chef/resource/remote_directory.rb +2 -2
  54. data/lib/chef/resource/rhsm_errata.rb +1 -1
  55. data/lib/chef/resource/rhsm_errata_level.rb +1 -1
  56. data/lib/chef/resource/rhsm_register.rb +7 -7
  57. data/lib/chef/resource/rhsm_repo.rb +1 -1
  58. data/lib/chef/resource/rhsm_subscription.rb +1 -1
  59. data/lib/chef/resource/sudo.rb +8 -8
  60. data/lib/chef/resource/swap_file.rb +1 -1
  61. data/lib/chef/resource/sysctl.rb +2 -2
  62. data/lib/chef/resource/systemd_unit.rb +19 -11
  63. data/lib/chef/resource/timezone.rb +60 -32
  64. data/lib/chef/resource/windows_ad_join.rb +1 -1
  65. data/lib/chef/resource/windows_auto_run.rb +1 -1
  66. data/lib/chef/resource/windows_certificate.rb +269 -0
  67. data/lib/chef/resource/windows_env.rb +12 -3
  68. data/lib/chef/resource/windows_feature.rb +6 -11
  69. data/lib/chef/resource/windows_feature_dism.rb +2 -2
  70. data/lib/chef/resource/windows_feature_powershell.rb +5 -9
  71. data/lib/chef/resource/windows_firewall_rule.rb +205 -0
  72. data/lib/chef/resource/windows_path.rb +3 -1
  73. data/lib/chef/resource/windows_printer.rb +2 -2
  74. data/lib/chef/resource/windows_printer_port.rb +3 -3
  75. data/lib/chef/resource/windows_service.rb +1 -0
  76. data/lib/chef/resource/windows_share.rb +315 -0
  77. data/lib/chef/resource/windows_task.rb +4 -0
  78. data/lib/chef/resource/windows_workgroup.rb +6 -4
  79. data/lib/chef/resource/yum_repository.rb +13 -7
  80. data/lib/chef/resource/zypper_package.rb +2 -2
  81. data/lib/chef/resource/zypper_repository.rb +2 -1
  82. data/lib/chef/resource_inspector.rb +4 -4
  83. data/lib/chef/resources.rb +3 -0
  84. data/lib/chef/version.rb +1 -1
  85. data/spec/functional/resource/windows_task_spec.rb +39 -0
  86. data/spec/support/platform_helpers.rb +2 -1
  87. data/spec/unit/resource/windows_certificate.rb +46 -0
  88. data/spec/unit/resource/windows_firewall_rule_spec.rb +401 -0
  89. data/spec/unit/resource/windows_share.rb +39 -0
  90. metadata +10 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a8d51e830e9cccfff4ec27af2c3e3bd92e5ae45f0c43d2d4142b4663744d73d0
4
- data.tar.gz: 07d9387a39d2e53d2b81120cebfa00276e74bcb583826605c3a16eede5773da1
3
+ metadata.gz: 72ed54db28d5229e29a1d6c6611636d777a5a291bd49cdc7909105fe8018208d
4
+ data.tar.gz: e52fd041a354f764f5aa4fa8ff52b0f65b524f7614c87fda5888de50d3745656
5
5
  SHA512:
6
- metadata.gz: 85186af3f82ce9835901e31b66b3f134a8a131a28bab7ea8fcd663f073c8a866e04062e891c2765c0f07197e02b7b412a89aafb4ea4607c705f35940603ec93e
7
- data.tar.gz: 49d21188f23f5492bfce0dc2058d1abeb9daf87b12edb70de46dcc9809e25c6db345a5e1e5c5d5a67674922ca4323ece9573572c5c6d95311ab1926d32512fc5
6
+ metadata.gz: 1b6ddeb455f54fbd683dc4456f3c4aeb7e6e35179781c57c7a5cccc96dfa6eba03129746a333fd03522c771916b8ef4c99c172c2e6201cb57f72873ccecb3b51
7
+ data.tar.gz: 3fe50c3a56e2900692a15e0134453af0395790b1f020d91c7e14477a8c3e9293feef1987ee6f4bc0dff40bb1d891b0596aea5d8ec15de1b9ff79b4d503006118
@@ -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
- begin
195
- runner.converge
196
- ensure
197
- @recipe_fh.close
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
@@ -21,7 +21,7 @@ require "chef/workstation_config_loader"
21
21
  class Chef
22
22
  class Knife
23
23
  class ConfigListProfiles < Knife
24
- banner "knife config list-profiles"
24
+ banner "knife config list-profiles (options)"
25
25
 
26
26
  option :ignore_knife_rb,
27
27
  short: "-i",
@@ -19,7 +19,7 @@ require "chef/chef_fs/knife"
19
19
  class Chef
20
20
  class Knife
21
21
  class List < Chef::ChefFS::Knife
22
- banner "knife list [-dfR1p] [PATTERN1 ... PATTERNn]"
22
+ banner "knife list [-dfR1p] [PATTERN1 ... PATTERNn] (options)"
23
23
 
24
24
  category "path-based"
25
25
 
@@ -20,7 +20,7 @@ require "chef/http"
20
20
  class Chef
21
21
  class Knife
22
22
  class Raw < Chef::Knife
23
- banner "knife raw REQUEST_PATH"
23
+ banner "knife raw REQUEST_PATH (options)"
24
24
 
25
25
  deps do
26
26
  require "chef/json_compat"
@@ -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 clear [ROLE]"
31
+ banner "knife role run_list clear [ROLE] (options)"
32
32
  def clear_env_run_list(role, environment)
33
33
  nlist = []
34
34
  role.env_run_lists_add(environment => nlist)
@@ -26,7 +26,7 @@ class Chef
26
26
  require "chef/role"
27
27
  end
28
28
 
29
- banner "knife role run_list remove [ROLE] [ENTRY]"
29
+ banner "knife role run_list remove [ROLE] [ENTRY] (options)"
30
30
 
31
31
  def remove_from_env_run_list(role, environment, item_to_remove)
32
32
  nlist = []
@@ -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 = []
@@ -27,7 +27,7 @@ class Chef
27
27
  require "chef/role"
28
28
  end
29
29
 
30
- banner "knife role run_list set [ROLE] [ENTRIES]"
30
+ banner "knife role run_list set [ROLE] [ENTRIES] (options)"
31
31
 
32
32
  # Clears out any existing env_run_list_items and sets them to the
33
33
  # specified entries
@@ -19,7 +19,7 @@ require "chef/chef_fs/knife"
19
19
  class Chef
20
20
  class Knife
21
21
  class Show < Chef::ChefFS::Knife
22
- banner "knife show [PATTERN1 ... PATTERNn]"
22
+ banner "knife show [PATTERN1 ... PATTERNn] (options)"
23
23
 
24
24
  category "path-based"
25
25
 
@@ -19,7 +19,7 @@ require "chef/chef_fs/knife"
19
19
  class Chef
20
20
  class Knife
21
21
  class Upload < Chef::ChefFS::Knife
22
- banner "knife upload PATTERNS"
22
+ banner "knife upload PATTERNS (options)"
23
23
 
24
24
  category "path-based"
25
25
 
@@ -19,7 +19,7 @@ require "chef/chef_fs/knife"
19
19
  class Chef
20
20
  class Knife
21
21
  class Xargs < Chef::ChefFS::Knife
22
- banner "knife xargs [COMMAND]"
22
+ banner "knife xargs [COMMAND] (options)"
23
23
 
24
24
  category "path-based"
25
25
 
@@ -78,113 +78,117 @@ class Chef
78
78
  :@force_override,
79
79
  ].freeze
80
80
 
81
- [:all?,
82
- :any?,
83
- :assoc,
84
- :chunk,
85
- :collect,
86
- :collect_concat,
87
- :compare_by_identity,
88
- :compare_by_identity?,
89
- :count,
90
- :cycle,
91
- :detect,
92
- :drop,
93
- :drop_while,
94
- :each,
95
- :each_cons,
96
- :each_entry,
97
- :each_key,
98
- :each_pair,
99
- :each_slice,
100
- :each_value,
101
- :each_with_index,
102
- :each_with_object,
103
- :empty?,
104
- :entries,
105
- :except,
106
- :fetch,
107
- :find,
108
- :find_all,
109
- :find_index,
110
- :first,
111
- :flat_map,
112
- :flatten,
113
- :grep,
114
- :group_by,
115
- :has_value?,
116
- :include?,
117
- :index,
118
- :inject,
119
- :invert,
120
- :key,
121
- :keys,
122
- :length,
123
- :map,
124
- :max,
125
- :max_by,
126
- :merge,
127
- :min,
128
- :min_by,
129
- :minmax,
130
- :minmax_by,
131
- :none?,
132
- :one?,
133
- :partition,
134
- :rassoc,
135
- :reduce,
136
- :reject,
137
- :reverse_each,
138
- :select,
139
- :size,
140
- :slice_before,
141
- :sort,
142
- :sort_by,
143
- :store,
144
- :symbolize_keys,
145
- :take,
146
- :take_while,
147
- :to_a,
148
- :to_h,
149
- :to_hash,
150
- :to_set,
151
- :value?,
152
- :values,
153
- :values_at,
154
- :zip].each do |delegated_method|
155
- define_method(delegated_method) do |*args, &block|
156
- merged_attributes.send(delegated_method, *args, &block)
157
- end
158
- end
159
-
160
- # return the cookbook level default attribute component
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
- # return the role level default attribute component
167
+ # return the role level default attribute component
164
168
  attr_reader :role_default
165
169
 
166
- # return the environment level default attribute component
170
+ # return the environment level default attribute component
167
171
  attr_reader :env_default
168
172
 
169
- # return the force_default level attribute component
173
+ # return the force_default level attribute component
170
174
  attr_reader :force_default
171
175
 
172
- # return the "normal" level attribute component
176
+ # return the "normal" level attribute component
173
177
  attr_reader :normal
174
178
 
175
- # return the cookbook level override attribute component
179
+ # return the cookbook level override attribute component
176
180
  attr_reader :override
177
181
 
178
- # return the role level override attribute component
182
+ # return the role level override attribute component
179
183
  attr_reader :role_override
180
184
 
181
- # return the enviroment level override attribute component
185
+ # return the enviroment level override attribute component
182
186
  attr_reader :env_override
183
187
 
184
- # return the force override level attribute component
188
+ # return the force override level attribute component
185
189
  attr_reader :force_override
186
190
 
187
- # return the automatic level attribute component
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
- # Debug what's going on with an attribute. +args+ is a path spec to the
209
- # attribute you're interested in. For example, to debug where the value
210
- # of `node[:network][:default_interface]` is coming from, use:
211
- # debug_value(:network, :default_interface).
212
- # The return value is an Array of Arrays. The Arrays
213
- # are pairs of `["precedence_level", value]`, where precedence level is
214
- # the component, such as role default, normal, etc. and value is the
215
- # attribute value set at that precedence level. If there is no value at
216
- # that precedence level, +value+ will be the symbol +:not_present+.
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
- # Set the cookbook level default attribute component to +new_data+.
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
- # Set the role level default attribute component to +new_data+
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
- # Set the environment level default attribute component to +new_data+
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
- # Set the force_default (+default!+) level attributes to +new_data+
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
- # Set the normal level attribute component to +new_data+
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
- # Set the cookbook level override attribute component to +new_data+
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
- # Set the role level override attribute component to +new_data+
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
- # Set the environment level override attribute component to +new_data+
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
- # Deleting attributes
289
- #
291
+ #
292
+ # Deleting attributes
293
+ #
290
294
 
291
- # clears attributes from all precedence levels
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
- # clears attributes from all default precedence levels
301
- #
302
- # similar to: force_default!['foo']['bar'].delete('baz')
303
- # - does not autovivify
304
- # - does not trainwreck if interior keys do not exist
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
- # clears attributes from normal precedence
315
- #
316
- # equivalent to: normal!['foo']['bar'].delete('baz')
317
- # - does not autovivify
318
- # - does not trainwreck if interior keys do not exist
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
- # clears attributes from all override precedence levels
324
- #
325
- # equivalent to: force_override!['foo']['bar'].delete('baz')
326
- # - does not autovivify
327
- # - does not trainwreck if interior keys do not exist
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
- # Replacing attributes without merging
349
- #
351
+ #
352
+ # Replacing attributes without merging
353
+ #
350
354
 
351
- # sets default attributes without merging
352
- #
353
- # - this API autovivifies (and cannot trainwreck)
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
- # sets normal attributes without merging
360
- #
361
- # - this API autovivifies (and cannot trainwreck)
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
- # sets override attributes without merging
368
- #
369
- # - this API autovivifies (and cannot trainwreck)
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
- # clears from all default precedence levels and then sets force_default
376
- #
377
- # - this API autovivifies (and cannot trainwreck)
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
- # clears from all override precedence levels and then sets force_override
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
- # Accessing merged attributes.
395
- #
396
- # Note that merged_attributes('foo', 'bar', 'baz') can be called to compute only the
397
- # deep merge of node['foo']['bar']['baz'], but in practice we currently always compute
398
- # all of node['foo'] even if the user only requires node['foo']['bar']['baz'].
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
- # method-style access to attributes (has to come after the prepended ImmutablizeHash)
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
- # Helper method for merge_all/merge_defaults/merge_overrides.
483
- #
484
- # apply_path(thing, [ "foo", "bar", "baz" ]) = thing["foo"]["bar"]["baz"]
485
- #
486
- # The path value can be nil in which case the whole component is returned.
487
- #
488
- # It returns nil (does not raise an exception) if it walks off the end of an Mash/Hash/Array, it does not
489
- # raise any TypeError if it attempts to apply a hash key to an Integer/String/TrueClass, and just returns
490
- # nil in that case.
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
- # For elements like Fixnums, true, nil...
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
- # Deep merge all attribute levels using hash-only merging between different precidence
520
- # levels (so override arrays completely replace arrays set at any default level).
521
- #
522
- # The path allows for selectively deep-merging a subtree of the node object.
523
- #
524
- # @param path [Array] Array of args to method chain to descend into the node object
525
- # @return [attr] Deep Merged values (may be VividMash, Hash, Array, etc) from the node object
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
- # Deep merge the default attribute levels with array merging.
541
- #
542
- # The path allows for selectively deep-merging a subtree of the node object.
543
- #
544
- # @param path [Array] Array of args to method chain to descend into the node object
545
- # @return [attr] Deep Merged values (may be VividMash, Hash, Array, etc) from the node object
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
- # Deep merge the override attribute levels with array merging.
555
- #
556
- # The path allows for selectively deep-merging a subtree of the node object.
557
- #
558
- # @param path [Array] Array of args to method chain to descend into the node object
559
- # @return [attr] Deep Merged values (may be VividMash, Hash, Array, etc) from the node object
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
- # needed for __path__
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
- # If merge_with is nil, don't replace merge_onto
599
+ # If merge_with is nil, don't replace merge_onto
596
600
  elsif merge_with.nil?
597
601
  merge_onto
598
602
 
599
- # In all other cases, replace merge_onto with merge_with
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
- # If merge_with is nil, don't replace merge_onto
632
+ # If merge_with is nil, don't replace merge_onto
629
633
  elsif merge_with.nil?
630
634
  merge_onto
631
635
 
632
- # In all other cases, replace merge_onto with merge_with
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)