puppet 3.0.2 → 3.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (320) hide show
  1. data/Gemfile +13 -11
  2. data/README.md +9 -7
  3. data/README_DEVELOPER.md +21 -30
  4. data/bin/extlookup2hiera +0 -0
  5. data/conf/auth.conf +42 -26
  6. data/conf/fileserver.conf +41 -0
  7. data/conf/tagmail.conf +16 -0
  8. data/examples/hiera/modules/data/manifests/common.pp +2 -1
  9. data/examples/hiera/modules/ntp/manifests/config.pp +4 -3
  10. data/examples/hiera/modules/ntp/manifests/data.pp +2 -1
  11. data/examples/hiera/modules/users/manifests/common.pp +2 -1
  12. data/examples/hiera/modules/users/manifests/dc1.pp +2 -1
  13. data/examples/hiera/modules/users/manifests/development.pp +2 -1
  14. data/examples/hiera/site.pp +1 -1
  15. data/ext/debian/fileserver.conf +39 -15
  16. data/ext/envpuppet +2 -0
  17. data/ext/gentoo/puppet/fileserver.conf +41 -12
  18. data/ext/ips/puppet-agent +1 -6
  19. data/ext/ips/puppetagent.xml +0 -4
  20. data/ext/osx/postflight.erb +109 -0
  21. data/ext/project_data.yaml +2 -2
  22. data/ext/redhat/fileserver.conf +41 -12
  23. data/ext/redhat/puppet.spec.erb +8 -13
  24. data/install.rb +2 -5
  25. data/lib/puppet.rb +30 -13
  26. data/lib/puppet/application.rb +34 -16
  27. data/lib/puppet/application/agent.rb +4 -4
  28. data/lib/puppet/application/master.rb +25 -5
  29. data/lib/puppet/defaults.rb +11 -7
  30. data/lib/puppet/dsl.rb +7 -3
  31. data/lib/puppet/dsl/actions.rb +283 -0
  32. data/lib/puppet/dsl/blank_slate.rb +55 -0
  33. data/lib/puppet/dsl/context.rb +393 -0
  34. data/lib/puppet/dsl/parser.rb +57 -0
  35. data/lib/puppet/dsl/resource_decorator.rb +56 -0
  36. data/lib/puppet/dsl/resource_reference.rb +95 -0
  37. data/lib/puppet/dsl/type_reference.rb +102 -0
  38. data/lib/puppet/error.rb +1 -1
  39. data/lib/puppet/face/help.rb +2 -4
  40. data/lib/puppet/face/man.rb +8 -2
  41. data/lib/puppet/feature/pson.rb +1 -3
  42. data/lib/puppet/indirector/catalog/active_record.rb +3 -0
  43. data/lib/puppet/indirector/catalog/compiler.rb +1 -2
  44. data/lib/puppet/indirector/catalog/queue.rb +4 -0
  45. data/lib/puppet/indirector/catalog/static_compiler.rb +30 -0
  46. data/lib/puppet/indirector/catalog/store_configs.rb +3 -0
  47. data/lib/puppet/indirector/certificate_request/rest.rb +1 -0
  48. data/lib/puppet/indirector/certificate_revocation_list/rest.rb +1 -0
  49. data/lib/puppet/indirector/certificate_status/file.rb +4 -0
  50. data/lib/puppet/indirector/certificate_status/rest.rb +1 -0
  51. data/lib/puppet/indirector/facts/active_record.rb +3 -0
  52. data/lib/puppet/indirector/facts/couch.rb +3 -0
  53. data/lib/puppet/indirector/facts/inventory_active_record.rb +4 -0
  54. data/lib/puppet/indirector/facts/store_configs.rb +3 -0
  55. data/lib/puppet/indirector/file_metadata/rest.rb +2 -0
  56. data/lib/puppet/indirector/instrumentation_data/local.rb +3 -0
  57. data/lib/puppet/indirector/instrumentation_data/rest.rb +3 -0
  58. data/lib/puppet/indirector/instrumentation_listener/local.rb +3 -0
  59. data/lib/puppet/indirector/instrumentation_listener/rest.rb +3 -0
  60. data/lib/puppet/indirector/instrumentation_probe/local.rb +3 -0
  61. data/lib/puppet/indirector/instrumentation_probe/rest.rb +3 -0
  62. data/lib/puppet/indirector/node/active_record.rb +3 -0
  63. data/lib/puppet/indirector/node/rest.rb +2 -2
  64. data/lib/puppet/indirector/node/store_configs.rb +3 -0
  65. data/lib/puppet/indirector/node/write_only_yaml.rb +32 -0
  66. data/lib/puppet/indirector/queue.rb +0 -1
  67. data/lib/puppet/indirector/request.rb +1 -2
  68. data/lib/puppet/indirector/resource/active_record.rb +4 -0
  69. data/lib/puppet/indirector/resource/ral.rb +3 -0
  70. data/lib/puppet/indirector/resource/rest.rb +3 -0
  71. data/lib/puppet/indirector/resource/store_configs.rb +3 -0
  72. data/lib/puppet/indirector/run/local.rb +3 -0
  73. data/lib/puppet/indirector/ssl_file.rb +16 -14
  74. data/lib/puppet/indirector/status/local.rb +3 -0
  75. data/lib/puppet/indirector/status/rest.rb +4 -0
  76. data/lib/puppet/interface.rb +78 -3
  77. data/lib/puppet/interface/action.rb +39 -3
  78. data/lib/puppet/interface/action_builder.rb +74 -1
  79. data/lib/puppet/interface/action_manager.rb +33 -3
  80. data/lib/puppet/interface/documentation.rb +116 -5
  81. data/lib/puppet/interface/face_collection.rb +6 -7
  82. data/lib/puppet/interface/option.rb +10 -1
  83. data/lib/puppet/interface/option_builder.rb +29 -1
  84. data/lib/puppet/interface/option_manager.rb +21 -6
  85. data/lib/puppet/metatype/manager.rb +47 -9
  86. data/lib/puppet/module_tool.rb +0 -1
  87. data/lib/puppet/network/formats.rb +0 -2
  88. data/lib/puppet/node.rb +2 -3
  89. data/lib/puppet/node/environment.rb +14 -1
  90. data/lib/puppet/parameter.rb +309 -44
  91. data/lib/puppet/parameter/package_options.rb +5 -0
  92. data/lib/puppet/parameter/path.rb +26 -3
  93. data/lib/puppet/parameter/value.rb +30 -6
  94. data/lib/puppet/parameter/value_collection.rb +82 -20
  95. data/lib/puppet/parser.rb +3 -0
  96. data/lib/puppet/parser/ast/definition.rb +2 -5
  97. data/lib/puppet/parser/ast/hostclass.rb +2 -3
  98. data/lib/puppet/parser/ast/node.rb +2 -5
  99. data/lib/puppet/parser/ast/resourceparam.rb +1 -1
  100. data/lib/puppet/parser/compiler.rb +10 -0
  101. data/lib/puppet/parser/functions.rb +111 -7
  102. data/lib/puppet/parser/functions/create_resources.rb +23 -2
  103. data/lib/puppet/parser/functions/defined.rb +1 -1
  104. data/lib/puppet/parser/functions/extlookup.rb +2 -1
  105. data/lib/puppet/parser/functions/fail.rb +1 -1
  106. data/lib/puppet/parser/functions/file.rb +1 -1
  107. data/lib/puppet/parser/functions/fqdn_rand.rb +1 -1
  108. data/lib/puppet/parser/functions/generate.rb +1 -1
  109. data/lib/puppet/parser/functions/hiera.rb +1 -1
  110. data/lib/puppet/parser/functions/hiera_array.rb +1 -1
  111. data/lib/puppet/parser/functions/hiera_hash.rb +1 -1
  112. data/lib/puppet/parser/functions/hiera_include.rb +1 -1
  113. data/lib/puppet/parser/functions/include.rb +1 -1
  114. data/lib/puppet/parser/functions/inline_template.rb +1 -1
  115. data/lib/puppet/parser/functions/md5.rb +1 -1
  116. data/lib/puppet/parser/functions/realize.rb +1 -1
  117. data/lib/puppet/parser/functions/regsubst.rb +54 -57
  118. data/lib/puppet/parser/functions/require.rb +1 -0
  119. data/lib/puppet/parser/functions/search.rb +1 -1
  120. data/lib/puppet/parser/functions/sha1.rb +1 -1
  121. data/lib/puppet/parser/functions/shellquote.rb +1 -1
  122. data/lib/puppet/parser/functions/split.rb +1 -2
  123. data/lib/puppet/parser/functions/sprintf.rb +7 -10
  124. data/lib/puppet/parser/functions/tag.rb +1 -1
  125. data/lib/puppet/parser/functions/tagged.rb +1 -1
  126. data/lib/puppet/parser/functions/template.rb +1 -1
  127. data/lib/puppet/parser/functions/versioncmp.rb +1 -5
  128. data/lib/puppet/parser/parser_support.rb +11 -27
  129. data/lib/puppet/parser/scope.rb +48 -4
  130. data/lib/puppet/parser/type_loader.rb +31 -7
  131. data/lib/puppet/property.rb +304 -70
  132. data/lib/puppet/property/ensure.rb +14 -1
  133. data/lib/puppet/property/keyvalue.rb +17 -8
  134. data/lib/puppet/property/list.rb +3 -0
  135. data/lib/puppet/property/ordered_list.rb +7 -0
  136. data/lib/puppet/provider.rb +275 -53
  137. data/lib/puppet/provider/augeas/augeas.rb +17 -3
  138. data/lib/puppet/provider/confiner.rb +30 -1
  139. data/lib/puppet/provider/group/pw.rb +2 -2
  140. data/lib/puppet/provider/package/pip.rb +0 -1
  141. data/lib/puppet/provider/package/pkgin.rb +2 -0
  142. data/lib/puppet/provider/service/bsd.rb +1 -1
  143. data/lib/puppet/provider/service/freebsd.rb +10 -6
  144. data/lib/puppet/provider/service/init.rb +1 -1
  145. data/lib/puppet/provider/service/service.rb +1 -1
  146. data/lib/puppet/provider/user/pw.rb +2 -2
  147. data/lib/puppet/provider/user/useradd.rb +2 -3
  148. data/lib/puppet/reference/configuration.rb +6 -0
  149. data/lib/puppet/reports.rb +44 -4
  150. data/lib/puppet/reports/tagmail.rb +1 -1
  151. data/lib/puppet/resource.rb +38 -25
  152. data/lib/puppet/resource/type.rb +14 -6
  153. data/lib/puppet/settings.rb +66 -142
  154. data/lib/puppet/settings/config_file.rb +99 -0
  155. data/lib/puppet/settings/file_setting.rb +92 -24
  156. data/lib/puppet/settings/value_translator.rb +15 -0
  157. data/lib/puppet/ssl/certificate_authority/interface.rb +2 -2
  158. data/lib/puppet/test/test_helper.rb +8 -3
  159. data/lib/puppet/transaction.rb +1 -2
  160. data/lib/puppet/transaction/report.rb +122 -13
  161. data/lib/puppet/type.rb +763 -150
  162. data/lib/puppet/type/augeas.rb +4 -0
  163. data/lib/puppet/type/file/ensure.rb +1 -1
  164. data/lib/puppet/type/file/group.rb +1 -1
  165. data/lib/puppet/type/file/mode.rb +2 -0
  166. data/lib/puppet/type/file/selcontext.rb +1 -0
  167. data/lib/puppet/type/group.rb +12 -0
  168. data/lib/puppet/type/mount.rb +2 -2
  169. data/lib/puppet/type/notify.rb +1 -1
  170. data/lib/puppet/type/router.rb +1 -1
  171. data/lib/puppet/type/service.rb +1 -0
  172. data/lib/puppet/type/ssh_authorized_key.rb +3 -1
  173. data/lib/puppet/type/user.rb +8 -1
  174. data/lib/puppet/util.rb +8 -0
  175. data/lib/puppet/util/autoload.rb +7 -10
  176. data/lib/puppet/util/classgen.rb +58 -33
  177. data/lib/puppet/util/command_line.rb +120 -77
  178. data/lib/puppet/util/constant_inflector.rb +2 -0
  179. data/lib/puppet/util/execution.rb +63 -33
  180. data/lib/puppet/util/filetype.rb +1 -1
  181. data/lib/puppet/util/manifest_filetype_helper.rb +22 -0
  182. data/lib/puppet/util/methodhelper.rb +19 -0
  183. data/lib/puppet/util/monkey_patches.rb +46 -0
  184. data/lib/puppet/util/plugins.rb +2 -2
  185. data/lib/puppet/util/provider_features.rb +24 -8
  186. data/lib/puppet/util/rubygems.rb +8 -1
  187. data/lib/puppet/util/zaml.rb +1 -1
  188. data/lib/puppet/version.rb +74 -3
  189. data/spec/integration/application/apply_spec.rb +1 -1
  190. data/spec/integration/defaults_spec.rb +1 -0
  191. data/spec/integration/dsl/classes_spec.rb +191 -0
  192. data/spec/integration/dsl/defaults_spec.rb +38 -0
  193. data/spec/integration/dsl/definitions_spec.rb +73 -0
  194. data/spec/integration/dsl/functions_spec.rb +95 -0
  195. data/spec/integration/dsl/nodes_spec.rb +96 -0
  196. data/spec/integration/dsl/params_spec.rb +146 -0
  197. data/spec/integration/dsl/relationships_spec.rb +46 -0
  198. data/spec/integration/dsl/resources_spec.rb +202 -0
  199. data/spec/integration/dsl/type_loading_spec.rb +64 -0
  200. data/spec/integration/indirector/catalog/queue_spec.rb +1 -1
  201. data/spec/integration/network/formats_spec.rb +32 -45
  202. data/spec/integration/parser/collector_spec.rb +105 -25
  203. data/spec/integration/parser/scope_spec.rb +64 -1
  204. data/spec/integration/resource/catalog_spec.rb +2 -4
  205. data/spec/integration/type/package_spec.rb +1 -1
  206. data/spec/lib/matchers/catalog.rb +50 -0
  207. data/spec/lib/puppet_spec/compiler.rb +11 -0
  208. data/spec/lib/puppet_spec/dsl.rb +29 -0
  209. data/spec/spec_helper.rb +17 -3
  210. data/spec/unit/application/agent_spec.rb +0 -1
  211. data/spec/unit/application/apply_spec.rb +1 -1
  212. data/spec/unit/application/face_base_spec.rb +11 -4
  213. data/spec/unit/application/indirection_base_spec.rb +4 -8
  214. data/spec/unit/application/kick_spec.rb +5 -2
  215. data/spec/unit/application/master_spec.rb +0 -6
  216. data/spec/unit/application_spec.rb +38 -14
  217. data/spec/unit/dsl/actions_spec.rb +402 -0
  218. data/spec/unit/dsl/blank_slate_spec.rb +27 -0
  219. data/spec/unit/dsl/context_spec.rb +678 -0
  220. data/spec/unit/dsl/parser_spec.rb +56 -0
  221. data/spec/unit/dsl/resource_decorator_spec.rb +94 -0
  222. data/spec/unit/dsl/resource_reference_spec.rb +150 -0
  223. data/spec/unit/dsl/type_reference_spec.rb +164 -0
  224. data/spec/unit/face/help_spec.rb +5 -7
  225. data/spec/unit/indirector/certificate_request/rest_spec.rb +4 -0
  226. data/spec/unit/indirector/certificate_revocation_list/rest_spec.rb +4 -0
  227. data/spec/unit/indirector/certificate_status/rest_spec.rb +4 -0
  228. data/spec/unit/indirector/file_metadata/rest_spec.rb +5 -0
  229. data/spec/unit/indirector/hiera_spec.rb +3 -1
  230. data/spec/unit/indirector/queue_spec.rb +1 -7
  231. data/spec/unit/indirector/ssl_file_spec.rb +66 -39
  232. data/spec/unit/module_spec.rb +1 -1
  233. data/spec/unit/network/authstore_spec.rb +22 -1
  234. data/spec/unit/network/formats_spec.rb +1 -1
  235. data/spec/unit/node/environment_spec.rb +13 -0
  236. data/spec/unit/parser/collector_spec.rb +1 -1
  237. data/spec/unit/parser/compiler_spec.rb +26 -0
  238. data/spec/unit/parser/functions/create_resources_spec.rb +12 -1
  239. data/spec/unit/parser/functions/extlookup_spec.rb +4 -4
  240. data/spec/unit/parser/functions/hiera_array_spec.rb +1 -1
  241. data/spec/unit/parser/functions/hiera_hash_spec.rb +1 -1
  242. data/spec/unit/parser/functions/hiera_include_spec.rb +1 -1
  243. data/spec/unit/parser/functions/hiera_spec.rb +1 -1
  244. data/spec/unit/parser/functions/regsubst_spec.rb +4 -4
  245. data/spec/unit/parser/functions/split_spec.rb +4 -4
  246. data/spec/unit/parser/functions/sprintf_spec.rb +2 -2
  247. data/spec/unit/parser/functions/versioncmp_spec.rb +4 -4
  248. data/spec/unit/parser/functions_spec.rb +51 -1
  249. data/spec/unit/parser/parser_spec.rb +0 -14
  250. data/spec/unit/parser/type_loader_spec.rb +15 -1
  251. data/spec/unit/provider/augeas/augeas_spec.rb +31 -0
  252. data/spec/unit/provider/package/apt_spec.rb +0 -2
  253. data/spec/unit/provider/package/pip_spec.rb +12 -2
  254. data/spec/unit/provider/service/freebsd_spec.rb +8 -0
  255. data/spec/unit/provider/service/gentoo_spec.rb +20 -20
  256. data/spec/unit/provider/service/openrc_spec.rb +20 -20
  257. data/spec/unit/provider/service/src_spec.rb +4 -4
  258. data/spec/unit/provider/service/systemd_spec.rb +0 -8
  259. data/spec/unit/provider/service/windows_spec.rb +1 -1
  260. data/spec/unit/provider/user/useradd_spec.rb +2 -9
  261. data/spec/unit/relationship_spec.rb +2 -2
  262. data/spec/unit/resource/catalog_spec.rb +2 -2
  263. data/spec/unit/resource/type_spec.rb +49 -25
  264. data/spec/unit/resource_spec.rb +34 -2
  265. data/spec/unit/settings/config_file_spec.rb +100 -0
  266. data/spec/unit/settings/file_setting_spec.rb +87 -84
  267. data/spec/unit/settings/value_translator_spec.rb +77 -0
  268. data/spec/unit/settings_spec.rb +96 -29
  269. data/spec/unit/type/file/ensure_spec.rb +75 -36
  270. data/spec/unit/type/file_spec.rb +0 -68
  271. data/spec/unit/type/group_spec.rb +10 -0
  272. data/spec/unit/util/autoload_spec.rb +6 -0
  273. data/spec/unit/util/command_line_spec.rb +54 -62
  274. data/spec/unit/util/manifest_filetype_helper_spec.rb +29 -0
  275. data/spec/unit/util/metric_spec.rb +0 -9
  276. data/spec/unit/util/posix_spec.rb +0 -4
  277. data/spec/unit/util/rdoc_spec.rb +0 -12
  278. data/spec/unit/util/zaml_spec.rb +188 -130
  279. data/spec/unit/version_spec.rb +42 -0
  280. metadata +123 -90
  281. data/README_HIERA.md +0 -148
  282. data/conf/epm.list +0 -8
  283. data/conf/namespaceauth.conf +0 -20
  284. data/conf/puppet-queue.conf +0 -10
  285. data/examples/allatonce +0 -13
  286. data/examples/assignments +0 -11
  287. data/examples/components +0 -73
  288. data/examples/etc/init.d/sleeper +0 -70
  289. data/examples/etc/otherfile +0 -0
  290. data/examples/etc/puppet/fileserver.conf +0 -13
  291. data/examples/etc/puppet/namespaceauth.conf +0 -20
  292. data/examples/etc/puppet/puppet.conf +0 -10
  293. data/examples/etc/puppet/tagmail.conf +0 -1
  294. data/examples/execs +0 -16
  295. data/examples/file.bl +0 -11
  296. data/examples/filedefaults +0 -10
  297. data/examples/fileparsing +0 -116
  298. data/examples/filerecursion +0 -15
  299. data/examples/functions +0 -3
  300. data/examples/groups +0 -7
  301. data/examples/head +0 -30
  302. data/examples/importing +0 -8
  303. data/examples/mac_dscl.pp +0 -28
  304. data/examples/mac_dscl_revert.pp +0 -26
  305. data/examples/mac_pkgdmg.pp +0 -7
  306. data/examples/modules/sample_module.pp +0 -10
  307. data/examples/modules/sample_module/lib/puppet/parser/functions/hostname_to_dn.rb +0 -36
  308. data/examples/modules/sample_module/manifests/init.pp +0 -12
  309. data/examples/modules/sample_module/templates/sample.erb +0 -5
  310. data/examples/nodes +0 -20
  311. data/examples/one +0 -8
  312. data/examples/relationships +0 -34
  313. data/examples/selectors +0 -28
  314. data/examples/simpletests +0 -11
  315. data/examples/svncommit +0 -13
  316. data/lib/puppet/dsl/resource_api.rb +0 -120
  317. data/lib/puppet/dsl/resource_type_api.rb +0 -34
  318. data/spec/integration/parser/ruby_manifest_spec.rb +0 -127
  319. data/spec/unit/dsl/resource_api_spec.rb +0 -180
  320. data/spec/unit/dsl/resource_type_api_spec.rb +0 -53
@@ -8,6 +8,11 @@ require 'puppet/parser/templatewrapper'
8
8
  require 'puppet/resource/type_collection_helper'
9
9
  require 'puppet/util/methodhelper'
10
10
 
11
+ # This class is part of the internal parser/evaluator/compiler functionality of Puppet.
12
+ # It is passed between the various classes that participate in evaluation.
13
+ # None of its methods are API except those that are clearly marked as such.
14
+ #
15
+ # @api public
11
16
  class Puppet::Parser::Scope
12
17
  extend Forwardable
13
18
  include Puppet::Util::MethodHelper
@@ -56,6 +61,9 @@ class Puppet::Parser::Scope
56
61
  # Initialize a new scope suitable for parser function testing. This method
57
62
  # should be considered a public API for external modules. A shared spec
58
63
  # helper should consume this API method.
64
+ #
65
+ # @api protected
66
+ #
59
67
  def self.new_for_test_harness(node_name)
60
68
  node = Puppet::Node.new(node_name)
61
69
  compiler = Puppet::Parser::Compiler.new(node)
@@ -235,6 +243,15 @@ class Puppet::Parser::Scope
235
243
  end
236
244
  end
237
245
 
246
+ # Lookup a variable within this scope using the Puppet language's
247
+ # scoping rules. Variables can be qualified using just as in a
248
+ # manifest.
249
+ #
250
+ # @param [String] name the variable name to lookup
251
+ #
252
+ # @return Object the value of the variable, or nil if it's not found
253
+ #
254
+ # @api public
238
255
  def lookupvar(name, options = {})
239
256
  unless name.is_a? String
240
257
  raise Puppet::DevError, "Scope variable name is a #{name.class}, not a string"
@@ -263,7 +280,20 @@ class Puppet::Parser::Scope
263
280
  nil
264
281
  end
265
282
  end
266
- alias [] lookupvar
283
+
284
+ # Retrieves the variable value assigned to the name given as an argument. The name must be a String,
285
+ # and namespace can be qualified with '::'. The value is looked up in this scope, its parent scopes,
286
+ # or in a specific visible named scope.
287
+ #
288
+ # @param varname [String] the name of the variable (may be a qualified name using `(ns'::')*varname`
289
+ # @param options [Hash] Additional options, not part of api.
290
+ # @return [Object] the value assigned to the given varname
291
+ # @see #[]=
292
+ # @api public
293
+ #
294
+ def [](varname, options={})
295
+ lookupvar(varname, options)
296
+ end
267
297
 
268
298
  def qualified_scope(classname)
269
299
  raise "class #{classname} could not be found" unless klass = find_hostclass(classname)
@@ -349,11 +379,25 @@ class Puppet::Parser::Scope
349
379
 
350
380
  if options[:append]
351
381
  table[name] = append_value(undef_as('', self[name]), value)
352
- else
382
+ else
353
383
  table[name] = value
354
384
  end
355
385
  end
356
- alias []= setvar
386
+
387
+ # Sets the variable value of the name given as an argument to the given value. The value is
388
+ # set in the current scope and may shadow a variable with the same name in a visible outer scope.
389
+ # It is illegal to re-assign a variable in the same scope. It is illegal to set a variable in some other
390
+ # scope/namespace than the scope passed to a method.
391
+ #
392
+ # @param varname [String] The variable name to which the value is assigned. Must not contain `::`
393
+ # @param value [String] The value to assign to the given variable name.
394
+ # @param options [Hash] Additional options, not part of api.
395
+ #
396
+ # @api public
397
+ #
398
+ def []=(varname, value, options = {})
399
+ setvar(varname, value, options = {})
400
+ end
357
401
 
358
402
  def append_value(bound_value, new_value)
359
403
  case new_value
@@ -363,7 +407,7 @@ class Puppet::Parser::Scope
363
407
  bound_value.merge(new_value)
364
408
  else
365
409
  if bound_value.is_a?(Hash)
366
- raise ArgumentError, "Trying to append to a hash with something which is not a hash is unsupported"
410
+ raise ArgumentError, "Trying to append to a hash with something which is not a hash is unsupported"
367
411
  end
368
412
  bound_value + new_value
369
413
  end
@@ -1,6 +1,8 @@
1
1
  require 'find'
2
2
  require 'forwardable'
3
3
  require 'puppet/node/environment'
4
+ require 'puppet/dsl/parser'
5
+ require 'puppet/util/manifest_filetype_helper'
4
6
 
5
7
  class Puppet::Parser::TypeLoader
6
8
  extend Forwardable
@@ -82,17 +84,38 @@ class Puppet::Parser::TypeLoader
82
84
  end
83
85
 
84
86
  loaded_asts = []
87
+ loaded_ruby_types = []
85
88
  files.each do |file|
86
- unless Puppet::Util.absolute_path?(file)
87
- file = File.join(dir, file)
88
- end
89
+ file = File.join dir, file unless Puppet::Util.absolute_path? file
90
+
89
91
  @loading_helper.do_once(file) do
90
- loaded_asts << parse_file(file)
92
+ if Puppet::Util::ManifestFiletypeHelper.is_ruby_filename? file
93
+ known_before = known_resource_types.definitions.values +
94
+ known_resource_types.nodes.values +
95
+ known_resource_types.hostclasses.values
96
+
97
+ type = Puppet::Resource::Type.new(:hostclass, '')
98
+ begin
99
+ Puppet::DSL::Parser.prepare_for_evaluation type, File.read(file), file
100
+ rescue => e
101
+ raise Puppet::ParseError, e.message
102
+ end
103
+ type.ruby_code.each { |c| c.evaluate(nil, known_resource_types) }
104
+
105
+ known_now = known_resource_types.definitions.values +
106
+ known_resource_types.nodes.values +
107
+ known_resource_types.hostclasses.values
108
+ loaded_ruby_types = known_now - known_before
109
+ else
110
+ loaded_asts << parse_file(file)
111
+ end
91
112
  end
92
113
  end
93
- loaded_asts.inject([]) do |loaded_types, ast|
114
+
115
+ loaded_puppet_types = loaded_asts.inject([]) do |loaded_types, ast|
94
116
  loaded_types + known_resource_types.import_ast(ast, modname)
95
117
  end
118
+ loaded_ruby_types + loaded_puppet_types
96
119
  end
97
120
 
98
121
  def import_all
@@ -101,7 +124,8 @@ class Puppet::Parser::TypeLoader
101
124
  # given first/foo and second/foo, only files from first/foo will be loaded.
102
125
  environment.modules.each do |mod|
103
126
  Find.find(mod.manifests) do |path|
104
- if path =~ /\.pp$/ or path =~ /\.rb$/
127
+ if Puppet::Util::ManifestFiletypeHelper.is_ruby_filename? path or
128
+ Puppet::Util::ManifestFiletypeHelper.is_puppet_filename? path
105
129
  import(path)
106
130
  end
107
131
  end
@@ -139,7 +163,7 @@ class Puppet::Parser::TypeLoader
139
163
  Puppet.debug("importing '#{file}' in environment #{environment}")
140
164
  parser = Puppet::Parser::Parser.new(environment)
141
165
  parser.file = file
142
- return parser.parse
166
+ parser.parse
143
167
  end
144
168
 
145
169
  private
@@ -4,27 +4,98 @@
4
4
  require 'puppet'
5
5
  require 'puppet/parameter'
6
6
 
7
+ # The Property class is the implementation of a resource's attributes of _property_ kind.
8
+ # A Property is a specialized Resource Type Parameter that has both an 'is' (current) state, and
9
+ # a 'should' (wanted state). However, even if this is conceptually true, the current _is_ value is
10
+ # obtained by asking the associated provider for the value, and hence it is not actually part of a
11
+ # property's state, and only available when a provider has been selected and can obtain the value (i.e. when
12
+ # running on an agent).
13
+ #
14
+ # A Property (also in contrast to a parameter) is intended to describe a managed attribute of
15
+ # some system entity, such as the name or mode of a file.
16
+ #
17
+ # The current value _(is)_ is read and written with the methods {#retrieve} and {#set}, and the wanted
18
+ # value _(should)_ is read and written with the methods {#value} and {#value=} which delegate to
19
+ # {#should} and {#should=}, i.e. when a property is used like any other parameter, it is the _should_ value
20
+ # that is operated on.
21
+ #
22
+ # All resource type properties in the puppet system are derived from this class.
23
+ #
24
+ # The intention is that new parameters are created by using the DSL method {Puppet::Type.newproperty}.
25
+ #
26
+ # @abstract
27
+ # @note Properties of Types are expressed using subclasses of this class. Such a class describes one
28
+ # named property of a particular Type (as opposed to describing a type of property in general). This
29
+ # limits the use of one (concrete) property class instance to occur only once for a given type's inheritance
30
+ # chain. An instance of a Property class is the value holder of one instance of the resource type (e.g. the
31
+ # mode of a file resource instance).
32
+ # A Property class may server as the superclass _(parent)_ of another; e.g. a Size property that describes
33
+ # handling of measurements such as kb, mb, gb. If a type requires two different size measurements it requires
34
+ # one concrete class per such measure; e.g. MinSize (:parent => Size), and MaxSize (:parent => Size).
35
+ #
36
+ # @todo Describe meta-parameter shadowing. This concept can not be understood by just looking at the descriptions
37
+ # of the methods involved.
38
+ #
39
+ # @see Puppet::Type
40
+ # @see Puppet::Parameter
41
+ #
42
+ # @api public
43
+ #
7
44
  class Puppet::Property < Puppet::Parameter
8
45
  require 'puppet/property/ensure'
9
46
 
10
- # Because 'should' uses an array, we have a special method for handling
11
- # it. We also want to keep copies of the original values, so that
12
- # they can be retrieved and compared later when merging.
47
+ # Returns the original wanted value(s) _(should)_ unprocessed by munging/unmunging.
48
+ # The original values are set by {#value=} or {#should=}.
49
+ # @return (see #should)
50
+ #
13
51
  attr_reader :shouldorig
14
52
 
53
+ # The noop mode for this property.
54
+ # By setting a property's noop mode to `true`, any management of this property is inhibited. Calculation
55
+ # and reporting still takes place, but if a change of the underlying managed entity's state
56
+ # should take place it will not be carried out. This noop
57
+ # setting overrides the overall `Puppet[:noop]` mode as well as the noop mode in the _associated resource_
58
+ #
15
59
  attr_writer :noop
16
60
 
17
61
  class << self
62
+ # @todo Figure out what this is used for. Can not find any logic in the puppet code base that
63
+ # reads or writes this attribute.
64
+ # ??? Probably Unused
18
65
  attr_accessor :unmanaged
66
+
67
+ # @return [Symbol] The name of the property as given when the property was created.
68
+ #
19
69
  attr_reader :name
20
70
 
21
- # Return array matching info, defaulting to just matching
22
- # the first value.
71
+ # @!attribute [rw] array_matching
72
+ # @comment note that $#46; is a period - char code require to not terminate sentence.
73
+ # The `is` vs&#46; `should` array matching mode; `:first`, or `:all`.
74
+ #
75
+ # @comment there are two blank chars after the symbols to cause a break - do not remove these.
76
+ # * `:first`
77
+ # This is primarily used for single value properties. When matched against an array of values
78
+ # a match is true if the `is` value matches any of the values in the `should` array. When the `is` value
79
+ # is also an array, the matching is performed against the entire array as the `is` value.
80
+ # * `:all`
81
+ # : This is primarily used for multi-valued properties. When matched against an array of
82
+ # `should` values, the size of `is` and `should` must be the same, and all values in `is` must match
83
+ # a value in `should`.
84
+ #
85
+ # @note The semantics of these modes are implemented by the method {#insync?}. That method is the default
86
+ # implementation and it has a backwards compatible behavior that imposes additional constraints
87
+ # on what constitutes a positive match. A derived property may override that method.
88
+ # @return [Symbol] (:first) the mode in which matching is performed
89
+ # @see #insync?
90
+ # @dsl type
91
+ # @api public
92
+ #
23
93
  def array_matching
24
94
  @array_matching ||= :first
25
95
  end
26
96
 
27
- # Set whether properties should match all values or just the first one.
97
+ # @comment This is documented as an attribute - see the {array_matching} method.
98
+ #
28
99
  def array_matching=(value)
29
100
  value = value.intern if value.is_a?(String)
30
101
  raise ArgumentError, "Supported values for Property#array_matching are 'first' and 'all'" unless [:first, :all].include?(value)
@@ -32,33 +103,56 @@ class Puppet::Property < Puppet::Parameter
32
103
  end
33
104
  end
34
105
 
35
- # Look up a value's name, so we can find options and such.
106
+ # Looks up a value's name among valid values, to enable option lookup with result as a key.
107
+ # @param name [Object] the parameter value to match against valid values (names).
108
+ # @return {Symbol, Regexp} a value matching predicate
109
+ # @api private
110
+ #
36
111
  def self.value_name(name)
37
112
  if value = value_collection.match?(name)
38
113
  value.name
39
114
  end
40
115
  end
41
116
 
42
- # Retrieve an option set when a value was defined.
117
+ # Returns the value of the given option (set when a valid value with the given "name" was defined).
118
+ # @param name [Symbol, Regexp] the valid value predicate as returned by {value_name}
119
+ # @param option [Symbol] the name of the wanted option
120
+ # @return [Object] value of the option
121
+ # @raise [NoMethodError] if the option is not supported
122
+ # @todo Guessing on result of passing a non supported option (it performs send(option)).
123
+ # @api private
124
+ #
43
125
  def self.value_option(name, option)
44
126
  if value = value_collection.value(name)
45
127
  value.send(option)
46
128
  end
47
129
  end
48
130
 
49
- # Define a new valid value for a property. You must provide the value itself,
50
- # usually as a symbol, or a regex to match the value.
131
+ # Defines a new valid value for this property.
132
+ # A valid value is specified as a literal (typically a Symbol), but can also be
133
+ # specified with a Regexp.
51
134
  #
52
- # The first argument to the method is either the value itself or a regex.
53
- # The second argument is an option hash; valid options are:
54
- # * <tt>:method</tt>: The name of the method to define. Defaults to 'set_<value>'.
55
- # * <tt>:required_features</tt>: A list of features this value requires.
56
- # * <tt>:event</tt>: The event that should be returned when this value is set.
57
- # * <tt>:call</tt>: When to call any associated block. The default value
58
- # is `instead`, which means to call the value instead of calling the
59
- # provider. You can also specify `before` or `after`, which will
60
- # call both the block and the provider, according to the order you specify
61
- # (the `first` refers to when the block is called, not the provider).
135
+ # @param name [Symbol, Regexp] a valid literal value, or a regexp that matches a value
136
+ # @param options [Hash] a hash with options
137
+ # @option options [Symbol] :event The event that should be emitted when this value is set.
138
+ # @todo Option :event original comment says "event should be returned...", is "returned" the correct word
139
+ # to use?
140
+ # @option options [Symbol] :call When to call any associated block. The default value is `:instead` which
141
+ # means that the block should be called instead of the provider. In earlier versions (before 20081031) it
142
+ # was possible to specify a value of `:before` or `:after` for the purpose of calling
143
+ # both the block and the provider. Use of these deprecated options will now raise an exception later
144
+ # in the process when the _is_ value is set (see #set).
145
+ # @option options [Object] any Any other option is treated as a call to a setter having the given
146
+ # option name (e.g. `:required_features` calls `required_features=` with the option's value as an
147
+ # argument).
148
+ # @todo The original documentation states that the option `:method` will set the name of the generated
149
+ # setter method, but this is not implemented. Is the documentatin or the implementation in error?
150
+ # (The implementation is in Puppet::Parameter::ValueCollection#new_value).
151
+ # @todo verify that the use of :before and :after have been deprecated (or rather - never worked, and
152
+ # was never in use. (This means, that the option :call could be removed since calls are always :instead).
153
+ #
154
+ # @dsl type
155
+ # @api public
62
156
  def self.newvalue(name, options = {}, &block)
63
157
  value = value_collection.newvalue(name, options, &block)
64
158
 
@@ -66,7 +160,12 @@ class Puppet::Property < Puppet::Parameter
66
160
  value
67
161
  end
68
162
 
69
- # Call the provider method.
163
+ # Calls the provider setter method for this property with the given value as argument.
164
+ # @return [Object] what the provider returns when calling a setter for this property's name
165
+ # @raise [Puppet::Error] when the provider can not handle this property.
166
+ # @see #set
167
+ # @api private
168
+ #
70
169
  def call_provider(value)
71
170
  method = self.class.name.to_s + "="
72
171
  unless provider.respond_to? method
@@ -75,8 +174,19 @@ class Puppet::Property < Puppet::Parameter
75
174
  provider.send(method, value)
76
175
  end
77
176
 
78
- # Call the dynamically-created method associated with our value, if
79
- # there is one.
177
+ # Sets the value of this property to the given value by calling the dynamically created setter method associated with the "valid value" referenced by the given name.
178
+ # @param name [Symbol, Regexp] a valid value "name" as returned by {value_name}
179
+ # @param value [Object] the value to set as the value of the property
180
+ # @raise [Puppet::DevError] if there was no method to call
181
+ # @raise [Puppet::Error] if there were problems setting the value
182
+ # @raise [Puppet::ResourceError] if there was a problem setting the value and it was not raised
183
+ # as a Puppet::Error. The original exception is wrapped and logged.
184
+ # @todo The check for a valid value option called `:method` does not seem to be fully supported
185
+ # as it seems that this option is never consulted when the method is dynamically created. Needs to
186
+ # be investigated. (Bug, or documentation needs to be changed).
187
+ # @see #set
188
+ # @api private
189
+ #
80
190
  def call_valuemethod(name, value)
81
191
  if method = self.class.value_option(name, :method) and self.respond_to?(method)
82
192
  begin
@@ -98,7 +208,11 @@ class Puppet::Property < Puppet::Parameter
98
208
  end
99
209
  end
100
210
 
101
- # How should a property change be printed as a string?
211
+ # Formats a message for a property change from the given `current_value` to the given `newvalue`.
212
+ # @return [String] a message describing the property change.
213
+ # @note If called with equal values, this is reported as a change.
214
+ # @raise [Puppet::DevError] if there were issues formatting the message
215
+ #
102
216
  def change_to_s(current_value, newvalue)
103
217
  begin
104
218
  if current_value == :absent
@@ -117,7 +231,12 @@ class Puppet::Property < Puppet::Parameter
117
231
  end
118
232
  end
119
233
 
120
- # Figure out which event to return.
234
+ # Produces the name of the event to use to describe a change of this property's value.
235
+ # The produced event name is either the event name configured for this property, or a generic
236
+ # event based on the name of the property with suffix `_changed`, or if the property is
237
+ # `:ensure`, the name of the resource type and one of the suffixes `_created`, `_removed`, or `_changed`.
238
+ # @return [String] the name of the event that describes the change
239
+ #
121
240
  def event_name
122
241
  value = self.should
123
242
 
@@ -133,14 +252,35 @@ class Puppet::Property < Puppet::Parameter
133
252
  end).to_sym
134
253
  end
135
254
 
136
- # Return a modified form of the resource event.
255
+ # Produces an event describing a change of this property.
256
+ # In addition to the event attributes set by the resource type, this method adds:
257
+ #
258
+ # * `:name` - the event_name
259
+ # * `:desired_value` - a.k.a _should_ or _wanted value_
260
+ # * `:property` - reference to this property
261
+ # * `:source_description` - the _path_ (?? See todo)
262
+ #
263
+ # @todo What is the intent of this method? What is the meaning of the :source_description passed in the
264
+ # options to the created event?
265
+ # @return [Puppet::Transaction::Event] the created event
266
+ # @see Puppet::Type#event
137
267
  def event
138
268
  resource.event :name => event_name, :desired_value => should, :property => self, :source_description => path
139
269
  end
140
270
 
271
+ # @todo What is this?
272
+ # What is this used for?
141
273
  attr_reader :shadow
142
274
 
143
- # initialize our property
275
+ # Initializes a Property the same way as a Parameter and handles the special case when a property is shadowing a meta-parameter.
276
+ # @todo There is some special initialization when a property is not a metaparameter but
277
+ # Puppet::Type.metaparamclass(for this class's name) is not nil - if that is the case a
278
+ # setup_shadow is performed for that class.
279
+ #
280
+ # @param hash [Hash] options passed to the super initializer {Puppet::Parameter#initialize}
281
+ # @note New properties of a type should be created via the DSL method {Puppet::Type.newproperty}.
282
+ # @see Puppet::Parameter#initialize description of Parameter initialize options.
283
+ # @api private
144
284
  def initialize(hash = {})
145
285
  super
146
286
 
@@ -149,14 +289,14 @@ class Puppet::Property < Puppet::Parameter
149
289
  end
150
290
  end
151
291
 
152
- # Determine whether the property is in-sync or not. If @should is
153
- # not defined or is set to a non-true value, then we do not have
154
- # a valid value for it and thus consider the property to be in-sync
155
- # since we cannot fix it. Otherwise, we expect our should value
156
- # to be an array, and if @is matches any of those values, then
157
- # we consider it to be in-sync.
292
+ # Determines whether the property is in-sync or not in a way that is protected against missing value.
293
+ # @note If the wanted value _(should)_ is not defined or is set to a non-true value then this is
294
+ # a state that can not be fixed and the property is reported to be in sync.
295
+ # @return [Boolean] the protected result of `true` or the result of calling {#insync?}.
296
+ #
297
+ # @api private
298
+ # @note Do not override this method.
158
299
  #
159
- # Don't override this method.
160
300
  def safe_insync?(is)
161
301
  # If there is no @should value, consider the property to be in sync.
162
302
  return true unless @should
@@ -165,15 +305,34 @@ class Puppet::Property < Puppet::Parameter
165
305
  insync?(is)
166
306
  end
167
307
 
308
+ # Protects against override of the {#safe_insync?} method.
309
+ # @raise [RuntimeError] if the added method is `:safe_insync?`
310
+ # @api private
311
+ #
168
312
  def self.method_added(sym)
169
313
  raise "Puppet::Property#safe_insync? shouldn't be overridden; please override insync? instead" if sym == :safe_insync?
170
314
  end
171
315
 
172
- # This method may be overridden by derived classes if necessary
173
- # to provide extra logic to determine whether the property is in
174
- # sync. In most cases, however, only `property_matches?` needs to be
175
- # overridden to give the correct outcome - without reproducing all the array
176
- # matching logic, etc, found here.
316
+ # Checks if the current _(is)_ value is in sync with the wanted _(should)_ value.
317
+ # The check if the two values are in sync is controlled by the result of {#match_all?} which
318
+ # specifies a match of `:first` or `:all`). The matching of the _is_ value against the entire _should_ value
319
+ # or each of the _should_ values (as controlled by {#match_all?} is performed by {#property_matches?}.
320
+ #
321
+ # A derived property typically only needs to override the {#property_matches?} method, but may also
322
+ # override this method if there is a need to have more control over the array matching logic.
323
+ #
324
+ # @note The array matching logic in this method contains backwards compatible logic that performs the
325
+ # comparison in `:all` mode by checking equality and equality of _is_ against _should_ converted to array of String,
326
+ # and that the lengths are equal, and in `:first` mode by checking if one of the _should_ values
327
+ # is included in the _is_ values. This means that the _is_ value needs to be carefully arranged to
328
+ # match the _should_.
329
+ # @todo The implementation should really do return is.zip(@should).all? {|a, b| property_matches?(a, b) }
330
+ # instead of using equality check and then check against an array with converted strings.
331
+ # @param is [Object] The current _(is)_ value to check if it is in sync with the wanted _(should)_ value(s)
332
+ # @return [Boolean] whether the values are in sync or not.
333
+ # @raise [Puppet::DevError] if wanted value _(should)_ is not an array.
334
+ # @api public
335
+ #
177
336
  def insync?(is)
178
337
  self.devfail "#{self.class.name}'s should is not array" unless @should.is_a?(Array)
179
338
 
@@ -211,10 +370,16 @@ class Puppet::Property < Puppet::Parameter
211
370
  end
212
371
  end
213
372
 
214
- # Compare the current and desired value of a property in a property-specific
215
- # way. Invoked by `insync?`; this should be overridden if your property
216
- # has a different comparison type but does not actually differentiate the
217
- # overall insync? logic.
373
+ # Checks if the given current and desired values are equal.
374
+ # This default implementation performs this check in a backwards compatible way where
375
+ # the equality of the two values is checked, and then the equality of current with desired
376
+ # converted to a string.
377
+ #
378
+ # A derived implementation may override this method to perform a property specific equality check.
379
+ #
380
+ # The intent of this method is to provide an equality check suitable for checking if the property
381
+ # value is in sync or not. It is typically called from {#insync?}.
382
+ #
218
383
  def property_matches?(current, desired)
219
384
  # This preserves the older Puppet behaviour of doing raw and string
220
385
  # equality comparisons for all equality. I am not clear this is globally
@@ -222,15 +387,20 @@ class Puppet::Property < Puppet::Parameter
222
387
  current == desired or current == desired.to_s
223
388
  end
224
389
 
225
- # because the @should and @is vars might be in weird formats,
226
- # we need to set up a mechanism for pretty printing of the values
227
- # default to just the values, but this way individual properties can
228
- # override these methods
390
+ # Produces a pretty printing string for the given value.
391
+ # This default implementation simply returns the given argument. A derived implementation
392
+ # may perform property specific pretty printing when the _is_ and _should_ values are not
393
+ # already in suitable form.
394
+ # @return [String] a pretty printing string
229
395
  def is_to_s(currentvalue)
230
396
  currentvalue
231
397
  end
232
398
 
233
- # Send a log message.
399
+ # Emits a log message at the log level specified for the associated resource.
400
+ # The log entry is associated with this property.
401
+ # @param msg [String] the message to log
402
+ # @return [void]
403
+ #
234
404
  def log(msg)
235
405
  Puppet::Util::Log.create(
236
406
  :level => resource[:loglevel],
@@ -239,27 +409,36 @@ class Puppet::Property < Puppet::Parameter
239
409
  )
240
410
  end
241
411
 
242
- # Should we match all values, or just the first?
412
+ # @return [Boolean] whether the {array_matching} mode is set to `:all` or not
243
413
  def match_all?
244
414
  self.class.array_matching == :all
245
415
  end
246
416
 
247
- # Execute our shadow's munge code, too, if we have one.
417
+ # (see Puppet::Parameter#munge)
418
+ # If this property is a meta-parameter shadow, the shadow's munge is also called.
419
+ # @todo Incomprehensible ! The concept of "meta-parameter-shadowing" needs to be explained.
420
+ #
248
421
  def munge(value)
249
422
  self.shadow.munge(value) if self.shadow
250
423
 
251
424
  super
252
425
  end
253
426
 
254
- # each property class must define the name method, and property instances
255
- # do not change that name
256
- # this implicitly means that a given object can only have one property
257
- # instance of a given property class
427
+ # @return [Symbol] the name of the property as stated when the property was created.
428
+ # @note A property class (just like a parameter class) describes one specific property and
429
+ # can only be used once within one type's inheritance chain.
258
430
  def name
259
431
  self.class.name
260
432
  end
261
433
 
262
- # for testing whether we should actually do anything
434
+ # @return [Boolean] whether this property is in noop mode or not.
435
+ # Returns whether this property is in noop mode or not; if a difference between the
436
+ # _is_ and _should_ values should be acted on or not.
437
+ # The noop mode is a transitive setting. The mode is checked in this property, then in
438
+ # the _associated resource_ and finally in Puppet[:noop].
439
+ # @todo This logic is different than Parameter#noop in that the resource noop mode overrides
440
+ # the property's mode - in parameter it is the other way around. Bug or feature?
441
+ #
263
442
  def noop
264
443
  # This is only here to make testing easier.
265
444
  if @resource.respond_to?(:noop?)
@@ -273,14 +452,33 @@ class Puppet::Property < Puppet::Parameter
273
452
  end
274
453
  end
275
454
 
276
- # By default, call the method associated with the property name on our
277
- # provider. In other words, if the property name is 'gid', we'll call
278
- # 'provider.gid' to retrieve the current value.
455
+ # Retrieves the current value _(is)_ of this property from the provider.
456
+ # This implementation performs this operation by calling a provider method with the
457
+ # same name as this property (i.e. if the property name is 'gid', a call to the
458
+ # 'provider.gid' is expected to return the current value.
459
+ # @return [Object] what the provider returns as the current value of the property
460
+ #
279
461
  def retrieve
280
462
  provider.send(self.class.name)
281
463
  end
282
464
 
283
- # Set our value, using the provider, an associated block, or both.
465
+ # Sets the current _(is)_ value of this property.
466
+ # The value is set using the provider's setter method for this property ({#call_provider}) if nothing
467
+ # else has been specified. If the _valid value_ for the given value defines a `:call` option with the
468
+ # value `:instead`, the
469
+ # value is set with {#call_valuemethod} which invokes a block specified for the valid value.
470
+ #
471
+ # @note In older versions (before 20081031) it was possible to specify the call types `:before` and `:after`
472
+ # which had the effect that both the provider method and the _valid value_ block were called.
473
+ # This is no longer supported.
474
+ #
475
+ # @param value [Object] the value to set as the value of this property
476
+ # @return [Object] returns what {#call_valuemethod} or {#call_provider} returns
477
+ # @raise [Puppet::Error] when the provider setter should be used but there is no provider set in the _associated
478
+ # resource_
479
+ # @raise [Puppet::DevError] when a deprecated call form was specified (e.g. `:before` or `:after`).
480
+ # @api public
481
+ #
284
482
  def set(value)
285
483
  # Set a name for looking up associated options like the event.
286
484
  name = self.class.value_name(value)
@@ -305,15 +503,29 @@ class Puppet::Property < Puppet::Parameter
305
503
  end
306
504
  end
307
505
 
308
- # If there's a shadowing metaparam, instantiate it now.
309
- # This allows us to create a property or parameter with the
310
- # same name as a metaparameter, and the metaparam will only be
311
- # stored as a shadow.
506
+ # Sets up a shadow property for a shadowing meta-parameter.
507
+ # This construct allows the creation of a property with the
508
+ # same name as a meta-parameter. The metaparam will only be stored as a shadow.
509
+ # @param klass [Class<inherits Puppet::Parameter>] the class of the shadowed meta-parameter
510
+ # @return [Puppet::Parameter] an instance of the given class (a parameter or property)
511
+ #
312
512
  def setup_shadow(klass)
313
513
  @shadow = klass.new(:resource => self.resource)
314
514
  end
315
515
 
316
- # Only return the first value
516
+ # Returns the wanted _(should)_ value of this property.
517
+ # If the _array matching mode_ {#match_all?} is true, an array of the wanted values in unmunged format
518
+ # is returned, else the first value in the array of wanted values in unmunged format is returned.
519
+ # @return [Array<Object>, Object, nil] Array of values if {#match_all?} else a single value, or nil if there are no
520
+ # wanted values.
521
+ # @raise [Puppet::DevError] if the wanted value is non nil and not an array
522
+ #
523
+ # @note This method will potentially return different values than the original values as they are
524
+ # converted via munging/unmunging. If the original values are wanted, call {#shouldorig}.
525
+ #
526
+ # @see #shouldorig
527
+ # @api public
528
+ #
317
529
  def should
318
530
  return nil unless defined?(@should)
319
531
 
@@ -326,7 +538,14 @@ class Puppet::Property < Puppet::Parameter
326
538
  end
327
539
  end
328
540
 
329
- # Set the should value.
541
+ # Sets the wanted _(should)_ value of this property.
542
+ # If the given value is not already an Array, it will be wrapped in one before being set.
543
+ # This method also sets the cached original _should_ values returned by {#shouldorig}.
544
+ #
545
+ # @param values [Array<Object>, Object] the value(s) to set as the wanted value(s)
546
+ # @raise [StandardError] when validation of a value fails (see {#validate}).
547
+ # @api public
548
+ #
330
549
  def should=(values)
331
550
  values = [values] unless values.is_a?(Array)
332
551
 
@@ -336,23 +555,39 @@ class Puppet::Property < Puppet::Parameter
336
555
  @should = values.collect { |val| self.munge(val) }
337
556
  end
338
557
 
558
+ # Formats the given newvalue (following _should_ type conventions) for inclusion in a string describing a change.
559
+ # @return [String] Returns the given newvalue in string form with space separated entries if it is an array.
560
+ # @see #change_to_s
561
+ #
339
562
  def should_to_s(newvalue)
340
563
  [newvalue].flatten.join(" ")
341
564
  end
342
565
 
566
+ # Synchronizes the current value _(is)_ and the wanted value _(should)_ by calling {#set}.
567
+ # @raise [Puppet::DevError] if {#should} is nil
568
+ # @todo The implementation of this method is somewhat inefficient as it computes the should
569
+ # array twice.
343
570
  def sync
344
571
  devfail "Got a nil value for should" unless should
345
572
  set(should)
346
573
  end
347
574
 
348
- # Verify that the passed value is valid.
575
+ # Asserts that the given value is valid.
349
576
  # If the developer uses a 'validate' hook, this method will get overridden.
577
+ # @raise [Exception] if the value is invalid, or value can not be handled.
578
+ # @return [void]
579
+ # @api private
580
+ #
350
581
  def unsafe_validate(value)
351
582
  super
352
583
  validate_features_per_value(value)
353
584
  end
354
585
 
355
- # Make sure that we've got all of the required features for a given value.
586
+ # Asserts that all required provider features are present for the given property value.
587
+ # @raise [ArgumentError] if a required feature is not present
588
+ # @return [void]
589
+ # @api private
590
+ #
356
591
  def validate_features_per_value(value)
357
592
  if features = self.class.value_option(self.class.value_name(value), :required_features)
358
593
  features = Array(features)
@@ -361,13 +596,12 @@ class Puppet::Property < Puppet::Parameter
361
596
  end
362
597
  end
363
598
 
364
- # Just return any should value we might have.
599
+ # @return [Object, nil] Returns the wanted _(should)_ value of this property.
365
600
  def value
366
601
  self.should
367
602
  end
368
603
 
369
- # Match the Parameter interface, but we really just use 'should' internally.
370
- # Note that the should= method does all of the validation and such.
604
+ # (see #should=)
371
605
  def value=(value)
372
606
  self.should = value
373
607
  end