puppet 3.1.1 → 3.2.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 (477) hide show
  1. data/CONTRIBUTING.md +2 -2
  2. data/Gemfile +32 -19
  3. data/README_DEVELOPER.md +332 -14
  4. data/Rakefile +9 -5
  5. data/ext/build_defaults.yaml +2 -3
  6. data/ext/debian/changelog.erb +6 -0
  7. data/ext/debian/control +6 -6
  8. data/ext/envpuppet +4 -4
  9. data/ext/project_data.yaml +1 -0
  10. data/ext/puppet-nm-dispatcher +13 -0
  11. data/ext/redhat/puppet.spec.erb +17 -0
  12. data/ext/suse/client.init +1 -1
  13. data/ext/systemd/puppetagent.service +2 -2
  14. data/ext/systemd/puppetmaster.service +2 -2
  15. data/lib/hiera/scope.rb +29 -11
  16. data/lib/hiera_puppet.rb +1 -3
  17. data/lib/puppet/agent.rb +3 -3
  18. data/lib/puppet/application.rb +2 -2
  19. data/lib/puppet/application/agent.rb +27 -12
  20. data/lib/puppet/application/apply.rb +11 -1
  21. data/lib/puppet/application/describe.rb +1 -1
  22. data/lib/puppet/application/doc.rb +13 -9
  23. data/lib/puppet/application/filebucket.rb +0 -1
  24. data/lib/puppet/application/kick.rb +1 -0
  25. data/lib/puppet/application/master.rb +16 -8
  26. data/lib/puppet/daemon.rb +19 -64
  27. data/lib/puppet/defaults.rb +61 -5
  28. data/lib/puppet/error.rb +15 -4
  29. data/lib/puppet/external/nagios/grammar.ry +1 -1
  30. data/lib/puppet/external/nagios/makefile +1 -1
  31. data/lib/puppet/external/nagios/parser.rb +185 -618
  32. data/lib/puppet/external/pson/pure/parser.rb +47 -1
  33. data/lib/puppet/face/certificate.rb +3 -3
  34. data/lib/puppet/face/module.rb +1 -1
  35. data/lib/puppet/face/module/changes.rb +3 -1
  36. data/lib/puppet/face/module/uninstall.rb +1 -1
  37. data/lib/puppet/face/node/clean.rb +5 -5
  38. data/lib/puppet/feature/base.rb +3 -1
  39. data/lib/puppet/feature/libuser.rb +8 -0
  40. data/lib/puppet/file_serving/fileset.rb +9 -1
  41. data/lib/puppet/forge.rb +28 -5
  42. data/lib/puppet/forge/errors.rb +34 -0
  43. data/lib/puppet/forge/repository.rb +1 -1
  44. data/lib/puppet/indirector.rb +4 -1
  45. data/lib/puppet/indirector/catalog/compiler.rb +37 -30
  46. data/lib/puppet/indirector/facts/inventory_active_record.rb +1 -0
  47. data/lib/puppet/indirector/indirection.rb +28 -15
  48. data/lib/puppet/indirector/rest.rb +18 -10
  49. data/lib/puppet/interface.rb +11 -4
  50. data/lib/puppet/interface/action.rb +1 -3
  51. data/lib/puppet/interface/action_builder.rb +0 -3
  52. data/lib/puppet/interface/action_manager.rb +0 -3
  53. data/lib/puppet/interface/face_collection.rb +0 -2
  54. data/lib/puppet/interface/option.rb +0 -2
  55. data/lib/puppet/interface/option_builder.rb +0 -2
  56. data/lib/puppet/interface/option_manager.rb +0 -2
  57. data/lib/puppet/metatype/manager.rb +1 -1
  58. data/lib/puppet/module_tool.rb +1 -0
  59. data/lib/puppet/module_tool/applications/application.rb +0 -3
  60. data/lib/puppet/module_tool/applications/builder.rb +8 -20
  61. data/lib/puppet/module_tool/applications/checksummer.rb +1 -1
  62. data/lib/puppet/module_tool/applications/installer.rb +1 -0
  63. data/lib/puppet/module_tool/applications/unpacker.rb +3 -11
  64. data/lib/puppet/module_tool/checksums.rb +1 -1
  65. data/lib/puppet/module_tool/errors/installer.rb +18 -1
  66. data/lib/puppet/module_tool/modulefile.rb +2 -2
  67. data/lib/puppet/module_tool/skeleton/templates/generator/Modulefile.erb +1 -1
  68. data/lib/puppet/module_tool/tar.rb +17 -0
  69. data/lib/puppet/module_tool/tar/gnu.rb +9 -0
  70. data/lib/puppet/module_tool/tar/mini.rb +39 -0
  71. data/lib/puppet/module_tool/tar/solaris.rb +5 -0
  72. data/lib/puppet/network/http.rb +1 -0
  73. data/lib/puppet/network/http/connection.rb +9 -23
  74. data/lib/puppet/network/http/handler.rb +38 -7
  75. data/lib/puppet/network/http/rack/rest.rb +14 -3
  76. data/lib/puppet/network/http/webrick.rb +3 -1
  77. data/lib/puppet/network/http/webrick/rest.rb +11 -2
  78. data/lib/puppet/node/environment.rb +3 -1
  79. data/lib/puppet/parameter.rb +32 -29
  80. data/lib/puppet/parameter/package_options.rb +1 -1
  81. data/lib/puppet/parameter/path.rb +1 -1
  82. data/lib/puppet/parameter/value.rb +1 -1
  83. data/lib/puppet/parameter/value_collection.rb +7 -3
  84. data/lib/puppet/parser/ast.rb +3 -1
  85. data/lib/puppet/parser/ast/arithmetic_operator.rb +56 -12
  86. data/lib/puppet/parser/ast/astarray.rb +1 -1
  87. data/lib/puppet/parser/ast/block_expression.rb +41 -0
  88. data/lib/puppet/parser/ast/function.rb +13 -2
  89. data/lib/puppet/parser/ast/lambda.rb +107 -0
  90. data/lib/puppet/parser/ast/leaf.rb +1 -2
  91. data/lib/puppet/parser/ast/method_call.rb +77 -0
  92. data/lib/puppet/parser/ast/vardef.rb +7 -0
  93. data/lib/puppet/parser/compiler.rb +27 -16
  94. data/lib/puppet/parser/e_parser_adapter.rb +120 -0
  95. data/lib/puppet/parser/files.rb +7 -6
  96. data/lib/puppet/parser/functions.rb +10 -8
  97. data/lib/puppet/parser/functions/collect.rb +43 -0
  98. data/lib/puppet/parser/functions/each.rb +96 -0
  99. data/lib/puppet/parser/functions/foreach.rb +96 -0
  100. data/lib/puppet/parser/functions/fqdn_rand.rb +2 -2
  101. data/lib/puppet/parser/functions/hiera.rb +20 -2
  102. data/lib/puppet/parser/functions/hiera_array.rb +21 -2
  103. data/lib/puppet/parser/functions/hiera_hash.rb +23 -2
  104. data/lib/puppet/parser/functions/hiera_include.rb +33 -2
  105. data/lib/puppet/parser/functions/inline_template.rb +4 -4
  106. data/lib/puppet/parser/functions/reduce.rb +74 -0
  107. data/lib/puppet/parser/functions/reject.rb +46 -0
  108. data/lib/puppet/parser/functions/select.rb +46 -0
  109. data/lib/puppet/parser/functions/slice.rb +96 -0
  110. data/lib/puppet/parser/functions/template.rb +2 -2
  111. data/lib/puppet/parser/grammar.ra +7 -4
  112. data/lib/puppet/parser/lexer.rb +10 -0
  113. data/lib/puppet/parser/methods.rb +69 -0
  114. data/lib/puppet/parser/parser.rb +855 -808
  115. data/lib/puppet/parser/parser_factory.rb +62 -0
  116. data/lib/puppet/parser/parser_support.rb +8 -2
  117. data/lib/puppet/parser/scope.rb +153 -47
  118. data/lib/puppet/parser/templatewrapper.rb +28 -21
  119. data/lib/puppet/parser/type_loader.rb +3 -1
  120. data/lib/puppet/pops.rb +40 -0
  121. data/lib/puppet/pops/adaptable.rb +190 -0
  122. data/lib/puppet/pops/adapters.rb +65 -0
  123. data/lib/puppet/pops/containment.rb +37 -0
  124. data/lib/puppet/pops/issues.rb +258 -0
  125. data/lib/puppet/pops/label_provider.rb +71 -0
  126. data/lib/puppet/pops/model/ast_transformer.rb +636 -0
  127. data/lib/puppet/pops/model/ast_tree_dumper.rb +378 -0
  128. data/lib/puppet/pops/model/factory.rb +804 -0
  129. data/lib/puppet/pops/model/model.rb +567 -0
  130. data/lib/puppet/pops/model/model_label_provider.rb +75 -0
  131. data/lib/puppet/pops/model/model_tree_dumper.rb +352 -0
  132. data/lib/puppet/pops/model/tree_dumper.rb +59 -0
  133. data/lib/puppet/pops/parser/egrammar.ra +723 -0
  134. data/lib/puppet/pops/parser/eparser.rb +2300 -0
  135. data/lib/puppet/pops/parser/grammar.ra +746 -0
  136. data/lib/puppet/pops/parser/lexer.rb +842 -0
  137. data/lib/puppet/pops/parser/makefile +13 -0
  138. data/lib/puppet/pops/parser/parser_support.rb +203 -0
  139. data/lib/puppet/pops/patterns.rb +35 -0
  140. data/lib/puppet/pops/utils.rb +104 -0
  141. data/lib/puppet/pops/validation.rb +297 -0
  142. data/lib/puppet/pops/validation/checker3_1.rb +551 -0
  143. data/lib/puppet/pops/validation/validator_factory_3_1.rb +41 -0
  144. data/lib/puppet/pops/visitable.rb +6 -0
  145. data/lib/puppet/pops/visitor.rb +50 -0
  146. data/lib/puppet/property.rb +37 -28
  147. data/lib/puppet/property/ensure.rb +2 -2
  148. data/lib/puppet/property/ordered_list.rb +1 -1
  149. data/lib/puppet/provider.rb +26 -30
  150. data/lib/puppet/provider/aixobject.rb +45 -44
  151. data/lib/puppet/provider/augeas/augeas.rb +0 -1
  152. data/lib/puppet/provider/confiner.rb +1 -1
  153. data/lib/puppet/provider/cron/crontab.rb +107 -67
  154. data/lib/puppet/provider/group/groupadd.rb +59 -3
  155. data/lib/puppet/provider/interface/cisco.rb +4 -4
  156. data/lib/puppet/provider/mount/parsed.rb +1 -1
  157. data/lib/puppet/provider/nameservice.rb +22 -6
  158. data/lib/puppet/provider/nameservice/pw.rb +1 -1
  159. data/lib/puppet/provider/package/aix.rb +28 -4
  160. data/lib/puppet/provider/package/gem.rb +0 -2
  161. data/lib/puppet/provider/package/macports.rb +1 -1
  162. data/lib/puppet/provider/package/nim.rb +249 -4
  163. data/lib/puppet/provider/package/opkg.rb +77 -0
  164. data/lib/puppet/provider/package/pacman.rb +2 -2
  165. data/lib/puppet/provider/package/rpm.rb +30 -16
  166. data/lib/puppet/provider/package/yum.rb +3 -3
  167. data/lib/puppet/provider/parsedfile.rb +80 -3
  168. data/lib/puppet/provider/selmodule/semodule.rb +2 -2
  169. data/lib/puppet/provider/service/debian.rb +0 -4
  170. data/lib/puppet/provider/service/freebsd.rb +2 -2
  171. data/lib/puppet/provider/service/gentoo.rb +0 -9
  172. data/lib/puppet/provider/service/init.rb +27 -2
  173. data/lib/puppet/provider/service/launchd.rb +1 -1
  174. data/lib/puppet/provider/service/openwrt.rb +36 -0
  175. data/lib/puppet/provider/service/redhat.rb +0 -9
  176. data/lib/puppet/provider/service/src.rb +38 -4
  177. data/lib/puppet/provider/service/systemd.rb +2 -2
  178. data/lib/puppet/provider/service/upstart.rb +1 -8
  179. data/lib/puppet/provider/user/aix.rb +4 -10
  180. data/lib/puppet/provider/user/pw.rb +6 -10
  181. data/lib/puppet/provider/user/useradd.rb +129 -31
  182. data/lib/puppet/provider/vlan/cisco.rb +4 -4
  183. data/lib/puppet/reference/function.rb +2 -2
  184. data/lib/puppet/reference/indirection.rb +46 -5
  185. data/lib/puppet/reference/metaparameter.rb +2 -2
  186. data/lib/puppet/reports.rb +5 -5
  187. data/lib/puppet/reports/rrdgraph.rb +4 -4
  188. data/lib/puppet/reports/tagmail.rb +1 -1
  189. data/lib/puppet/resource.rb +1 -1
  190. data/lib/puppet/resource/type.rb +13 -11
  191. data/lib/puppet/scheduler.rb +16 -0
  192. data/lib/puppet/scheduler/job.rb +53 -0
  193. data/lib/puppet/scheduler/scheduler.rb +45 -0
  194. data/lib/puppet/scheduler/splay_job.rb +32 -0
  195. data/lib/puppet/scheduler/timer.rb +13 -0
  196. data/lib/puppet/settings/base_setting.rb +1 -1
  197. data/lib/puppet/simple_graph.rb +4 -4
  198. data/lib/puppet/ssl/base.rb +12 -2
  199. data/lib/puppet/ssl/certificate.rb +4 -1
  200. data/lib/puppet/ssl/certificate_request.rb +4 -1
  201. data/lib/puppet/ssl/certificate_revocation_list.rb +4 -1
  202. data/lib/puppet/ssl/configuration.rb +32 -0
  203. data/lib/puppet/ssl/host.rb +18 -21
  204. data/lib/puppet/ssl/key.rb +4 -1
  205. data/lib/puppet/ssl/validator.rb +116 -0
  206. data/lib/puppet/transaction.rb +1 -1
  207. data/lib/puppet/transaction/event.rb +3 -10
  208. data/lib/puppet/transaction/event_manager.rb +8 -1
  209. data/lib/puppet/transaction/report.rb +17 -16
  210. data/lib/puppet/type.rb +77 -69
  211. data/lib/puppet/type/cron.rb +20 -8
  212. data/lib/puppet/type/exec.rb +9 -3
  213. data/lib/puppet/type/file.rb +95 -21
  214. data/lib/puppet/type/file/content.rb +1 -1
  215. data/lib/puppet/type/file/mode.rb +7 -1
  216. data/lib/puppet/type/file/source.rb +2 -2
  217. data/lib/puppet/type/group.rb +11 -0
  218. data/lib/puppet/type/scheduled_task.rb +5 -1
  219. data/lib/puppet/type/service.rb +1 -1
  220. data/lib/puppet/type/ssh_authorized_key.rb +2 -2
  221. data/lib/puppet/type/user.rb +24 -6
  222. data/lib/puppet/util.rb +12 -2
  223. data/lib/puppet/util/classgen.rb +4 -4
  224. data/lib/puppet/util/colors.rb +55 -0
  225. data/lib/puppet/util/command_line/trollop.rb +4 -4
  226. data/lib/puppet/util/errors.rb +39 -3
  227. data/lib/puppet/util/fileparsing.rb +5 -0
  228. data/lib/puppet/util/filetype.rb +11 -9
  229. data/lib/puppet/util/instrumentation/instrumentable.rb +2 -2
  230. data/lib/puppet/util/libuser.conf +15 -0
  231. data/lib/puppet/util/libuser.rb +12 -0
  232. data/lib/puppet/util/monkey_patches.rb +48 -0
  233. data/lib/puppet/util/network_device.rb +1 -1
  234. data/lib/puppet/util/network_device/base.rb +2 -2
  235. data/lib/puppet/util/network_device/cisco/device.rb +29 -19
  236. data/lib/puppet/util/network_device/config.rb +5 -2
  237. data/lib/puppet/util/network_device/ipcalc.rb +1 -1
  238. data/lib/puppet/util/network_device/transport/ssh.rb +4 -3
  239. data/lib/puppet/util/network_device/transport/telnet.rb +4 -2
  240. data/lib/puppet/util/plugins.rb +4 -4
  241. data/lib/puppet/util/posix.rb +1 -1
  242. data/lib/puppet/util/profiler.rb +28 -0
  243. data/lib/puppet/util/profiler/logging.rb +47 -0
  244. data/lib/puppet/util/profiler/none.rb +8 -0
  245. data/lib/puppet/util/profiler/object_counts.rb +17 -0
  246. data/lib/puppet/util/profiler/wall_clock.rb +34 -0
  247. data/lib/puppet/util/provider_features.rb +1 -1
  248. data/lib/puppet/util/rdoc/parser.rb +5 -5
  249. data/lib/puppet/util/ssl.rb +38 -0
  250. data/lib/puppet/util/subclass_loader.rb +1 -5
  251. data/lib/puppet/util/windows.rb +1 -0
  252. data/lib/puppet/util/windows/process.rb +3 -0
  253. data/lib/puppet/util/windows/root_certs.rb +86 -0
  254. data/lib/puppet/util/windows/security.rb +1 -0
  255. data/lib/puppet/version.rb +1 -1
  256. data/spec/fixtures/integration/provider/cron/crontab/create_normal_entry +19 -0
  257. data/spec/fixtures/integration/provider/cron/crontab/create_special_entry +18 -0
  258. data/spec/fixtures/integration/provider/cron/crontab/crontab_user1 +15 -0
  259. data/spec/fixtures/integration/provider/cron/crontab/crontab_user2 +4 -0
  260. data/spec/fixtures/integration/provider/cron/crontab/modify_entry +13 -0
  261. data/spec/fixtures/integration/provider/cron/crontab/moved_cronjob_input1 +15 -0
  262. data/spec/fixtures/integration/provider/cron/crontab/moved_cronjob_input2 +6 -0
  263. data/spec/fixtures/integration/provider/cron/crontab/remove_named_resource +12 -0
  264. data/spec/fixtures/integration/provider/cron/crontab/remove_unnamed_resource +14 -0
  265. data/spec/fixtures/unit/pops/parser/lexer/aliastest.pp +16 -0
  266. data/spec/fixtures/unit/pops/parser/lexer/append.pp +11 -0
  267. data/spec/fixtures/unit/pops/parser/lexer/argumentdefaults.pp +14 -0
  268. data/spec/fixtures/unit/pops/parser/lexer/arithmetic_expression.pp +8 -0
  269. data/spec/fixtures/unit/pops/parser/lexer/arraytrailingcomma.pp +3 -0
  270. data/spec/fixtures/unit/pops/parser/lexer/casestatement.pp +65 -0
  271. data/spec/fixtures/unit/pops/parser/lexer/classheirarchy.pp +15 -0
  272. data/spec/fixtures/unit/pops/parser/lexer/classincludes.pp +17 -0
  273. data/spec/fixtures/unit/pops/parser/lexer/classpathtest.pp +11 -0
  274. data/spec/fixtures/unit/pops/parser/lexer/collection.pp +10 -0
  275. data/spec/fixtures/unit/pops/parser/lexer/collection_override.pp +8 -0
  276. data/spec/fixtures/unit/pops/parser/lexer/collection_within_virtual_definitions.pp +20 -0
  277. data/spec/fixtures/unit/pops/parser/lexer/componentmetaparams.pp +11 -0
  278. data/spec/fixtures/unit/pops/parser/lexer/componentrequire.pp +8 -0
  279. data/spec/fixtures/unit/pops/parser/lexer/deepclassheirarchy.pp +23 -0
  280. data/spec/fixtures/unit/pops/parser/lexer/defineoverrides.pp +17 -0
  281. data/spec/fixtures/unit/pops/parser/lexer/emptyclass.pp +9 -0
  282. data/spec/fixtures/unit/pops/parser/lexer/emptyexec.pp +3 -0
  283. data/spec/fixtures/unit/pops/parser/lexer/emptyifelse.pp +9 -0
  284. data/spec/fixtures/unit/pops/parser/lexer/falsevalues.pp +3 -0
  285. data/spec/fixtures/unit/pops/parser/lexer/filecreate.pp +11 -0
  286. data/spec/fixtures/unit/pops/parser/lexer/fqdefinition.pp +5 -0
  287. data/spec/fixtures/unit/pops/parser/lexer/fqparents.pp +11 -0
  288. data/spec/fixtures/unit/pops/parser/lexer/funccomma.pp +5 -0
  289. data/spec/fixtures/unit/pops/parser/lexer/hash.pp +33 -0
  290. data/spec/fixtures/unit/pops/parser/lexer/ifexpression.pp +12 -0
  291. data/spec/fixtures/unit/pops/parser/lexer/implicititeration.pp +15 -0
  292. data/spec/fixtures/unit/pops/parser/lexer/multilinecomments.pp +10 -0
  293. data/spec/fixtures/unit/pops/parser/lexer/multipleclass.pp +9 -0
  294. data/spec/fixtures/unit/pops/parser/lexer/multipleinstances.pp +7 -0
  295. data/spec/fixtures/unit/pops/parser/lexer/multisubs.pp +13 -0
  296. data/spec/fixtures/unit/pops/parser/lexer/namevartest.pp +9 -0
  297. data/spec/fixtures/unit/pops/parser/lexer/scopetest.pp +13 -0
  298. data/spec/fixtures/unit/pops/parser/lexer/selectorvalues.pp +49 -0
  299. data/spec/fixtures/unit/pops/parser/lexer/simpledefaults.pp +5 -0
  300. data/spec/fixtures/unit/pops/parser/lexer/simpleselector.pp +38 -0
  301. data/spec/fixtures/unit/pops/parser/lexer/singleary.pp +19 -0
  302. data/spec/fixtures/unit/pops/parser/lexer/singlequote.pp +11 -0
  303. data/spec/fixtures/unit/pops/parser/lexer/singleselector.pp +22 -0
  304. data/spec/fixtures/unit/pops/parser/lexer/subclass_name_duplication.pp +11 -0
  305. data/spec/fixtures/unit/pops/parser/lexer/tag.pp +9 -0
  306. data/spec/fixtures/unit/pops/parser/lexer/tagged.pp +35 -0
  307. data/spec/fixtures/unit/pops/parser/lexer/virtualresources.pp +14 -0
  308. data/spec/fixtures/unit/provider/cron/crontab/single_line.yaml +4 -4
  309. data/spec/fixtures/unit/provider/cron/crontab/vixie_header.txt +3 -0
  310. data/spec/fixtures/unit/provider/cron/parsed/managed +6 -0
  311. data/spec/fixtures/unit/provider/cron/parsed/simple +9 -0
  312. data/spec/fixtures/unit/provider/parsedfile/simple.txt +4 -0
  313. data/spec/fixtures/unit/provider/service/systemd/list_units +18 -0
  314. data/spec/integration/parser/collector_spec.rb +1 -1
  315. data/spec/integration/parser/compiler_spec.rb +252 -227
  316. data/spec/integration/parser/parser_spec.rb +171 -53
  317. data/spec/integration/parser/scope_spec.rb +1 -1
  318. data/spec/integration/provider/cron/crontab_spec.rb +187 -0
  319. data/spec/integration/provider/service/systemd_spec.rb +20 -0
  320. data/spec/integration/type/file_spec.rb +21 -21
  321. data/spec/integration/type/package_spec.rb +1 -1
  322. data/spec/lib/puppet_spec/database.rb +2 -5
  323. data/spec/spec_helper.rb +6 -1
  324. data/spec/unit/application/apply_spec.rb +16 -1
  325. data/spec/unit/application/describe_spec.rb +1 -1
  326. data/spec/unit/application/doc_spec.rb +55 -32
  327. data/spec/unit/application/kick_spec.rb +8 -6
  328. data/spec/unit/application/master_spec.rb +4 -4
  329. data/spec/unit/daemon_spec.rb +1 -1
  330. data/spec/unit/forge/errors_spec.rb +40 -0
  331. data/spec/unit/forge/repository_spec.rb +11 -1
  332. data/spec/unit/forge_spec.rb +13 -3
  333. data/spec/unit/hiera/backend/puppet_backend_spec.rb +1 -0
  334. data/spec/unit/hiera/scope_spec.rb +48 -25
  335. data/spec/unit/indirector/catalog/active_record_spec.rb +6 -3
  336. data/spec/unit/indirector/catalog/compiler_spec.rb +3 -28
  337. data/spec/unit/indirector/catalog/static_compiler_spec.rb +1 -1
  338. data/spec/unit/indirector/facts/inventory_active_record_spec.rb +154 -150
  339. data/spec/unit/indirector/indirection_spec.rb +5 -0
  340. data/spec/unit/indirector/resource/active_record_spec.rb +5 -22
  341. data/spec/unit/indirector_spec.rb +7 -1
  342. data/spec/unit/interface/action_builder_spec.rb +1 -1
  343. data/spec/unit/interface/action_manager_spec.rb +0 -2
  344. data/spec/unit/interface/action_spec.rb +1 -1
  345. data/spec/unit/interface/documentation_spec.rb +0 -2
  346. data/spec/unit/interface/face_collection_spec.rb +1 -1
  347. data/spec/unit/interface/option_builder_spec.rb +1 -1
  348. data/spec/unit/interface/option_spec.rb +0 -1
  349. data/spec/unit/module_spec.rb +17 -19
  350. data/spec/unit/module_tool/application_spec.rb +1 -3
  351. data/spec/unit/module_tool/applications/builder_spec.rb +38 -0
  352. data/spec/unit/module_tool/applications/checksummer_spec.rb +134 -0
  353. data/spec/unit/module_tool/applications/installer_spec.rb +71 -91
  354. data/spec/unit/module_tool/applications/searcher_spec.rb +1 -3
  355. data/spec/unit/module_tool/applications/uninstaller_spec.rb +18 -26
  356. data/spec/unit/module_tool/applications/unpacker_spec.rb +19 -52
  357. data/spec/unit/module_tool/tar/gnu_spec.rb +19 -0
  358. data/spec/unit/module_tool/tar/mini_spec.rb +59 -0
  359. data/spec/unit/module_tool/tar/solaris_spec.rb +19 -0
  360. data/spec/unit/network/http/connection_spec.rb +17 -2
  361. data/spec/unit/network/http/handler_spec.rb +195 -167
  362. data/spec/unit/network/http/rack/rest_spec.rb +26 -4
  363. data/spec/unit/network/http/webrick/rest_spec.rb +28 -1
  364. data/spec/unit/network/http/webrick_spec.rb +12 -3
  365. data/spec/unit/node/environment_spec.rb +421 -404
  366. data/spec/unit/parser/ast/arithmetic_operator_spec.rb +98 -2
  367. data/spec/unit/parser/collector_spec.rb +4 -4
  368. data/spec/unit/parser/compiler_spec.rb +13 -13
  369. data/spec/unit/parser/eparser_adapter_spec.rb +407 -0
  370. data/spec/unit/parser/functions/extlookup_spec.rb +20 -17
  371. data/spec/unit/parser/functions/fqdn_rand_spec.rb +5 -0
  372. data/spec/unit/parser/functions/hiera_include_spec.rb +0 -2
  373. data/spec/unit/parser/functions/hiera_spec.rb +0 -2
  374. data/spec/unit/parser/functions_spec.rb +27 -15
  375. data/spec/unit/parser/methods/collect_spec.rb +110 -0
  376. data/spec/unit/parser/methods/each_spec.rb +91 -0
  377. data/spec/unit/parser/methods/foreach_spec.rb +91 -0
  378. data/spec/unit/parser/methods/reduce_spec.rb +67 -0
  379. data/spec/unit/parser/methods/reject_spec.rb +73 -0
  380. data/spec/unit/parser/methods/select_spec.rb +79 -0
  381. data/spec/unit/parser/methods/shared.rb +61 -0
  382. data/spec/unit/parser/methods/slice_spec.rb +97 -0
  383. data/spec/unit/parser/parser_spec.rb +2 -2
  384. data/spec/unit/parser/scope_spec.rb +39 -16
  385. data/spec/unit/parser/templatewrapper_spec.rb +6 -5
  386. data/spec/unit/parser/type_loader_spec.rb +191 -165
  387. data/spec/unit/pops/adaptable_spec.rb +143 -0
  388. data/spec/unit/pops/containment_spec.rb +25 -0
  389. data/spec/unit/pops/factory_rspec_helper.rb +77 -0
  390. data/spec/unit/pops/factory_spec.rb +329 -0
  391. data/spec/unit/pops/issues_spec.rb +26 -0
  392. data/spec/unit/pops/label_provider_spec.rb +42 -0
  393. data/spec/unit/pops/model/ast_transformer_spec.rb +65 -0
  394. data/spec/unit/pops/model/model_spec.rb +37 -0
  395. data/spec/unit/pops/parser/lexer_spec.rb +884 -0
  396. data/spec/unit/pops/parser/parse_basic_expressions_spec.rb +248 -0
  397. data/spec/unit/pops/parser/parse_calls_spec.rb +93 -0
  398. data/spec/unit/pops/parser/parse_conditionals_spec.rb +159 -0
  399. data/spec/unit/pops/parser/parse_containers_spec.rb +175 -0
  400. data/spec/unit/pops/parser/parse_resource_spec.rb +228 -0
  401. data/spec/unit/pops/parser/parser_rspec_helper.rb +11 -0
  402. data/spec/unit/pops/parser/parser_spec.rb +15 -0
  403. data/spec/unit/pops/parser/rgen_sanitycheck_spec.rb +16 -0
  404. data/spec/unit/pops/transformer/transform_basic_expressions_spec.rb +243 -0
  405. data/spec/unit/pops/transformer/transform_calls_spec.rb +80 -0
  406. data/spec/unit/pops/transformer/transform_conditionals_spec.rb +132 -0
  407. data/spec/unit/pops/transformer/transform_containers_spec.rb +182 -0
  408. data/spec/unit/pops/transformer/transform_resource_spec.rb +185 -0
  409. data/spec/unit/pops/transformer/transformer_rspec_helper.rb +27 -0
  410. data/spec/unit/pops/visitor_spec.rb +94 -0
  411. data/spec/unit/property_spec.rb +11 -0
  412. data/spec/unit/provider/augeas/augeas_spec.rb +3 -0
  413. data/spec/unit/provider/cron/crontab_spec.rb +97 -7
  414. data/spec/unit/provider/cron/parsed_spec.rb +325 -0
  415. data/spec/unit/provider/exec/posix_spec.rb +1 -1
  416. data/spec/unit/provider/group/groupadd_spec.rb +33 -3
  417. data/spec/unit/provider/group/pw_spec.rb +5 -5
  418. data/spec/unit/provider/nameservice_spec.rb +304 -0
  419. data/spec/unit/provider/package/aix_spec.rb +53 -11
  420. data/spec/unit/provider/package/aptrpm_spec.rb +6 -0
  421. data/spec/unit/provider/package/gem_spec.rb +6 -11
  422. data/spec/unit/provider/package/nim_spec.rb +216 -7
  423. data/spec/unit/provider/package/opkg_spec.rb +180 -0
  424. data/spec/unit/provider/package/rpm_spec.rb +149 -3
  425. data/spec/unit/provider/package/yum_spec.rb +6 -5
  426. data/spec/unit/provider/parsedfile_spec.rb +122 -28
  427. data/spec/unit/provider/service/freebsd_spec.rb +18 -0
  428. data/spec/unit/provider/service/init_spec.rb +108 -87
  429. data/spec/unit/provider/service/launchd_spec.rb +2 -2
  430. data/spec/unit/provider/service/openwrt_spec.rb +109 -0
  431. data/spec/unit/provider/service/src_spec.rb +117 -41
  432. data/spec/unit/provider/service/systemd_spec.rb +125 -17
  433. data/spec/unit/provider/service/upstart_spec.rb +1 -1
  434. data/spec/unit/provider/user/aix_spec.rb +42 -0
  435. data/spec/unit/provider/user/directoryservice_spec.rb +1 -0
  436. data/spec/unit/provider/user/pw_spec.rb +24 -12
  437. data/spec/unit/provider/user/user_role_add_spec.rb +1 -1
  438. data/spec/unit/provider/user/useradd_spec.rb +179 -15
  439. data/spec/unit/resource/type_spec.rb +3 -3
  440. data/spec/unit/scheduler/job_spec.rb +79 -0
  441. data/spec/unit/scheduler/scheduler_spec.rb +129 -0
  442. data/spec/unit/scheduler/splay_job_spec.rb +35 -0
  443. data/spec/unit/ssl/base_spec.rb +3 -9
  444. data/spec/unit/ssl/certificate_authority_spec.rb +1 -0
  445. data/spec/unit/ssl/certificate_request_spec.rb +3 -1
  446. data/spec/unit/ssl/certificate_spec.rb +3 -1
  447. data/spec/unit/ssl/configuration_spec.rb +74 -0
  448. data/spec/unit/ssl/host_spec.rb +28 -7
  449. data/spec/unit/ssl/validator_spec.rb +311 -0
  450. data/spec/unit/transaction/event_manager_spec.rb +49 -0
  451. data/spec/unit/transaction/event_spec.rb +20 -5
  452. data/spec/unit/transaction/report_spec.rb +8 -0
  453. data/spec/unit/type/cron_spec.rb +9 -0
  454. data/spec/unit/type/exec_spec.rb +11 -0
  455. data/spec/unit/type/file/content_spec.rb +20 -20
  456. data/spec/unit/type/file/mode_spec.rb +6 -0
  457. data/spec/unit/type/file/source_spec.rb +9 -7
  458. data/spec/unit/type/file_spec.rb +22 -3
  459. data/spec/unit/type/service_spec.rb +34 -21
  460. data/spec/unit/type_spec.rb +46 -1
  461. data/spec/unit/util/backups_spec.rb +2 -2
  462. data/spec/unit/util/execution_spec.rb +4 -1
  463. data/spec/unit/util/filetype_spec.rb +6 -0
  464. data/spec/unit/util/monkey_patches_spec.rb +18 -0
  465. data/spec/unit/util/network_device/cisco/device_spec.rb +37 -0
  466. data/spec/unit/util/network_device/config_spec.rb +14 -0
  467. data/spec/unit/util/network_device_spec.rb +3 -3
  468. data/spec/unit/util/profiler/logging_spec.rb +81 -0
  469. data/spec/unit/util/profiler/none_spec.rb +12 -0
  470. data/spec/unit/util/profiler/object_counts_spec.rb +14 -0
  471. data/spec/unit/util/profiler/wall_clock_spec.rb +13 -0
  472. data/spec/unit/util/pson_spec.rb +5 -0
  473. data/spec/unit/util/ssl_spec.rb +51 -0
  474. data/spec/unit/util/windows/root_certs_spec.rb +15 -0
  475. data/spec/unit/util_spec.rb +28 -0
  476. metadata +2593 -2307
  477. data/spec/unit/module_tool/applications/application_spec.rb +0 -19
data/lib/puppet/type.rb CHANGED
@@ -16,7 +16,7 @@ require 'puppet/util/tagging'
16
16
 
17
17
  module Puppet
18
18
  # The base class for all Puppet types.
19
- #
19
+ #
20
20
  # A type describes:
21
21
  #--
22
22
  # * **Attributes** - properties, parameters, and meta-parameters are different types of attributes of a type.
@@ -30,7 +30,7 @@ module Puppet
30
30
  # * **Parameters** - additional attributes of the type (that does not directly related to an instance of the managed
31
31
  # resource; if an operation is recursive or not, where to look for things, etc.). A Parameter (in contrast to Property)
32
32
  # has one current value where a Property has two (current-state and wanted-state).
33
- # * **Meta-Parameters** - parameters that are available across all types. A meta-parameter typically has
33
+ # * **Meta-Parameters** - parameters that are available across all types. A meta-parameter typically has
34
34
  # additional semantics; like the `require` meta-parameter. A new type typically does not add new meta-parameters,
35
35
  # but you need to be aware of their existence so you do not inadvertently shadow an existing meta-parameters.
36
36
  # * **Parent** - a type can have a super type (that it inherits from).
@@ -40,7 +40,7 @@ module Puppet
40
40
  # by a provider) into an internal representation and vice versa. A Type supports adding custom logic for these.
41
41
  # * **Auto Requirements** - a type can specify automatic relationships to resources to ensure that if they are being
42
42
  # managed, they will be processed before this type.
43
- # * **Providers** - a provider is an implementation of a type's behavior - the management of a resource in the
43
+ # * **Providers** - a provider is an implementation of a type's behavior - the management of a resource in the
44
44
  # system being managed. A provider is often platform specific and is selected at runtime based on
45
45
  # criteria/predicates specified in the configured providers. See {Puppet::Provider} for details.
46
46
  # * **Device Support** - A type has some support for being applied to a device; i.e. something that is managed
@@ -55,12 +55,12 @@ module Puppet
55
55
  # its interface (what can be said/what is known about a resource of this type),
56
56
  # * **Managed Entity** - This is not a term in general use, but is used here when there is a need to make
57
57
  # a distinction between a resource (a description of what/how something should be managed), and what it is
58
- # managing (a file in the file system). The term _managed entity_ is a reference to the "file in the file system"
58
+ # managing (a file in the file system). The term _managed entity_ is a reference to the "file in the file system"
59
59
  # * **Isomorphism** - the quality of being _isomorphic_ means that two resource instances with the same name
60
60
  # refers to the same managed entity. Or put differently; _an isomorphic name is the identity of a resource_.
61
61
  # As an example, `exec` resources (that executes some command) have the command (i.e. the command line string) as
62
62
  # their name, and these resources are said to be non-isomorphic.
63
- #
63
+ #
64
64
  # @note The Type class deals with multiple concerns; some methods provide an internal DSL for convenient definition
65
65
  # of types, other methods deal with various aspects while running; wiring up a resource (expressed in Puppet DSL
66
66
  # or Ruby DSL) with its _resource type_ (i.e. an instance of Type) to enable validation, transformation of values
@@ -70,7 +70,7 @@ module Puppet
70
70
  # documentation of this class, you will be switching between these concepts, as well as switching between
71
71
  # the conceptual level "a resource is an instance of a resource-type" and the actual implementation classes
72
72
  # (Type, Resource, Provider, and various utility and helper classes).
73
- #
73
+ #
74
74
  # @api public
75
75
  #
76
76
  #
@@ -83,7 +83,7 @@ class Type
83
83
 
84
84
  # Comparing type instances.
85
85
  include Comparable
86
-
86
+
87
87
  # Compares this type against the given _other_ (type) and returns -1, 0, or +1 depending on the order.
88
88
  # @param other [Object] the object to compare against (produces nil, if not kind of Type}
89
89
  # @return [-1, 0, +1, nil] produces -1 if this type is before the given _other_ type, 0 if equals, and 1 if after.
@@ -102,7 +102,7 @@ class Type
102
102
  class << self
103
103
  include Puppet::Util::ClassGen
104
104
  include Puppet::Util::Warnings
105
-
105
+
106
106
  # @return [Array<Puppet::Property>] The list of declared properties for the resource type.
107
107
  # The returned lists contains instances if Puppet::Property or its subclasses.
108
108
  attr_reader :properties
@@ -154,7 +154,7 @@ class Type
154
154
 
155
155
  @attrtypes[attr]
156
156
  end
157
-
157
+
158
158
  # Provides iteration over meta-parameters.
159
159
  # @yieldparam p [Puppet::Parameter] each meta parameter
160
160
  # @return [void]
@@ -179,10 +179,10 @@ class Type
179
179
  # @overload ensurable({|| ... })
180
180
  # @yield [ ] A block evaluated in scope of the new Parameter
181
181
  # @yieldreturn [void]
182
- # @return [void]
182
+ # @return [void]
183
183
  # @dsl type
184
184
  # @api public
185
- #
185
+ #
186
186
  def self.ensurable(&block)
187
187
  if block_given?
188
188
  self.newproperty(:ensure, :parent => Puppet::Property::Ensure, &block)
@@ -193,7 +193,7 @@ class Type
193
193
  end
194
194
  end
195
195
 
196
- # Returns true if the type implements the default behavior expected by being _ensurable_ "by default".
196
+ # Returns true if the type implements the default behavior expected by being _ensurable_ "by default".
197
197
  # A type is _ensurable_ by default if it responds to `:exists`, `:create`, and `:destroy`.
198
198
  # If a type implements these methods and have not already specified that it is _ensurable_, it will be
199
199
  # made so with the defaults specified in {ensurable}.
@@ -248,7 +248,7 @@ class Type
248
248
 
249
249
  # Returns true if this type is applicable to the given target.
250
250
  # @param target [Symbol] should be :device, :host or :target, if anything else, :host is enforced
251
- # @return [Boolean] true
251
+ # @return [Boolean] true
252
252
  # @api private
253
253
  #
254
254
  def self.can_apply_to(target)
@@ -313,7 +313,7 @@ class Type
313
313
  # This creates a new meta-parameter that is added to all types.
314
314
  # @param name [Symbol] the name of the parameter
315
315
  # @param options [Hash] a hash with options.
316
- # @option options [Class<inherits Puppet::Parameter>] :parent (Puppet::Parameter) the super class of this parameter
316
+ # @option options [Class<inherits Puppet::Parameter>] :parent (Puppet::Parameter) the super class of this parameter
317
317
  # @option options [Hash{String => Object}] :attributes a hash that is applied to the generated class
318
318
  # by calling setter methods corresponding to this hash's keys/value pairs. This is done before the given
319
319
  # block is evaluated.
@@ -352,7 +352,7 @@ class Type
352
352
  end
353
353
 
354
354
  # Returns parameters that act as a key.
355
- # All parameters that return true from #isnamevar? or is named `:name` are included in the returned result.
355
+ # All parameters that return true from #isnamevar? or is named `:name` are included in the returned result.
356
356
  # @todo would like a better explanation
357
357
  # @return Array<??? Puppet::Parameter>
358
358
  #
@@ -383,10 +383,10 @@ class Type
383
383
  # These advanced options are rarely used (only one of the built in puppet types use this, and then only
384
384
  # a small part of the available functionality), and the support for these advanced mappings is not
385
385
  # implemented in a straight forward way. For these reasons, this method has been marked as private).
386
- #
386
+ #
387
387
  # @raise [Puppet::DevError] if there is no title pattern and there are two or more key attributes
388
388
  # @return [Array<Array<Regexp, Array<Array <Symbol, Proc>>>>, nil] a structure with a regexp and the first key_attribute ???
389
- # @comment This wonderful piece of logic creates a structure used by Resource.parse_title which
389
+ # @comment This wonderful piece of logic creates a structure used by Resource.parse_title which
390
390
  # has the capability to assign parts of the title to one or more attributes; It looks like an implementation
391
391
  # of a composite identity key (all parts of the key_attributes array are in the key). This can also
392
392
  # be seen in the method uniqueness_key.
@@ -396,7 +396,7 @@ class Type
396
396
  # as it raises an exception if there is more than 1. Note that in puppet, it is only File that uses this
397
397
  # to create a different pattern for assigning to the :path attribute
398
398
  # This requires further digging.
399
- # The entire construct is somewhat strange, since resource checks if the method "title_patterns" is
399
+ # The entire construct is somewhat strange, since resource checks if the method "title_patterns" is
400
400
  # implemented (it seems it always is) - why take this more expensive regexp mathching route for all
401
401
  # other types?
402
402
  # @api private
@@ -422,7 +422,7 @@ class Type
422
422
  # Creates a new parameter.
423
423
  # @param name [Symbol] the name of the parameter
424
424
  # @param options [Hash] a hash with options.
425
- # @option options [Class<inherits Puppet::Parameter>] :parent (Puppet::Parameter) the super class of this parameter
425
+ # @option options [Class<inherits Puppet::Parameter>] :parent (Puppet::Parameter) the super class of this parameter
426
426
  # @option options [Hash{String => Object}] :attributes a hash that is applied to the generated class
427
427
  # by calling setter methods corresponding to this hash's keys/value pairs. This is done before the given
428
428
  # block is evaluated.
@@ -462,7 +462,7 @@ class Type
462
462
  # @param options [Hash] a hash with options.
463
463
  # @option options [Symbol] :array_matching (:first) specifies how the current state is matched against
464
464
  # the wanted state. Use `:first` if the property is single valued, and (`:all`) otherwise.
465
- # @option options [Class<inherits Puppet::Property>] :parent (Puppet::Property) the super class of this property
465
+ # @option options [Class<inherits Puppet::Property>] :parent (Puppet::Property) the super class of this property
466
466
  # @option options [Hash{String => Object}] :attributes a hash that is applied to the generated class
467
467
  # by calling setter methods corresponding to this hash's keys/value pairs. This is done before the given
468
468
  # block is evaluated.
@@ -474,7 +474,7 @@ class Type
474
474
  # @yield [ ] a required block that is evaluated in the scope of the new property
475
475
  # @api public
476
476
  # @dsl type
477
- #
477
+ #
478
478
  def self.newproperty(name, options = {}, &block)
479
479
  name = name.intern
480
480
 
@@ -604,7 +604,7 @@ class Type
604
604
  # The logic caches the name of the namevar if it is a single name, but otherwise always
605
605
  # calls key_attributes, and then caches the first if there was only one, otherwise it returns
606
606
  # false and caches this (which is then subsequently returned as a cache hit).
607
- #
607
+ #
608
608
  def name_var
609
609
  return @name_var_cache unless @name_var_cache.nil?
610
610
  key_attributes = self.class.key_attributes
@@ -634,8 +634,10 @@ class Type
634
634
  end
635
635
 
636
636
  # Sets the 'should' (wanted state) value of a property, or the value of a parameter.
637
- # @return
637
+ # @return
638
638
  # @raise [Puppet::Error] if the setting of the value fails, or if the given name is nil.
639
+ # @raise [Puppet::ResourceError] when the parameter validation raises Puppet::Error or
640
+ # ArgumentError
639
641
  def []=(name,value)
640
642
  name = name.intern
641
643
 
@@ -652,9 +654,9 @@ class Type
652
654
  begin
653
655
  # make sure the parameter doesn't have any errors
654
656
  property.value = value
655
- rescue => detail
656
- error = Puppet::Error.new("Parameter #{name} failed on #{ref}: #{detail}")
657
- error.set_backtrace(detail.backtrace)
657
+ rescue Puppet::Error, ArgumentError => detail
658
+ error = Puppet::ResourceError.new("Parameter #{name} failed on #{ref}: #{detail}")
659
+ adderrorcontext(error, detail)
658
660
  raise error
659
661
  end
660
662
  end
@@ -667,8 +669,8 @@ class Type
667
669
  # @todo Incomprehensible - the comment says "Remove a property", the code refers to @parameters, and
668
670
  # the method parameter is called "attr" - What is it, property, parameter, both (i.e an attribute) or what?
669
671
  # @todo Don't know what the attr is (name or Property/Parameter?). Guessing it is a String name...
670
- # @todo Is it possible to delete a meta-parameter?
671
- # @todo What does delete mean? Is it deleted from the type or is its value state 'is'/'should' deleted?
672
+ # @todo Is it possible to delete a meta-parameter?
673
+ # @todo What does delete mean? Is it deleted from the type or is its value state 'is'/'should' deleted?
672
674
  # @param attr [String] the attribute to delete from this object. WHAT IS THE TYPE?
673
675
  # @raise [Puppet::DecError] when an attempt is made to delete an attribute that does not exists.
674
676
  #
@@ -700,13 +702,13 @@ class Type
700
702
  # @todo Needs a better explanation "Why should I care who is calling this method?", What do I need to know
701
703
  # about events and how they work? Where can I read about them?
702
704
  # @param options [Hash] options merged with a fixed set of options defined by this method, passed on to {Puppet::Transaction::Event}.
703
- # @return [Puppet::Transaction::Event] the created event
705
+ # @return [Puppet::Transaction::Event] the created event
704
706
  def event(options = {})
705
707
  Puppet::Transaction::Event.new({:resource => self, :file => file, :line => line, :tags => tags}.merge(options))
706
708
  end
707
709
 
708
710
  # @return [Object, nil] Returns the 'should' (wanted state) value for a specified property, or nil if the
709
- # given attribute name is not a property (i.e. if it is a parameter, meta-parameter, or does not exist).
711
+ # given attribute name is not a property (i.e. if it is a parameter, meta-parameter, or does not exist).
710
712
  def should(name)
711
713
  name = name.intern
712
714
  (prop = @parameters[name] and prop.is_a?(Puppet::Property)) ? prop.should : nil
@@ -785,7 +787,7 @@ class Type
785
787
  # to self.class.attrclass to produce a class on which a check is made if it has a method class :default (does
786
788
  # not seem to support an array...
787
789
  # @return [void]
788
- #
790
+ #
789
791
  def set_default(attr)
790
792
  return unless klass = self.class.attrclass(attr)
791
793
  return unless klass.method_defined?(:default)
@@ -802,7 +804,7 @@ class Type
802
804
 
803
805
  # @todo the comment says: "Convert our object to a hash. This just includes properties."
804
806
  # @todo this is confused, again it is the @parameters instance variable that is consulted, and
805
- # each value is copied - does it contain "properties" and "parameters" or both? Does it contain
807
+ # each value is copied - does it contain "properties" and "parameters" or both? Does it contain
806
808
  # meta-parameters?
807
809
  #
808
810
  # @return [Hash{ ??? => ??? }] a hash of WHAT?. The hash is a shallow copy, any changes to the
@@ -901,7 +903,6 @@ class Type
901
903
  ###############################
902
904
  # Code related to the container behaviour.
903
905
 
904
-
905
906
  # Returns true if the search should be done in depth-first order.
906
907
  # This implementation always returns false.
907
908
  # @todo What is this used for?
@@ -940,7 +941,6 @@ class Type
940
941
  ###############################
941
942
  # Code related to evaluating the resources.
942
943
 
943
-
944
944
  # Returns the ancestors - WHAT?
945
945
  # This implementation always returns an empty list.
946
946
  # @todo WHAT IS THIS ?
@@ -1068,7 +1068,7 @@ class Type
1068
1068
  end
1069
1069
  end
1070
1070
 
1071
- # Returns the `noop` run mode status of this.
1071
+ # Returns the `noop` run mode status of this.
1072
1072
  # @return [Boolean] true if running in noop mode.
1073
1073
  def noop?
1074
1074
  # If we're not a host_config, we're almost certainly part of
@@ -1088,7 +1088,7 @@ class Type
1088
1088
  end
1089
1089
 
1090
1090
  # Retrieves all known instances.
1091
- # @todo Retrieves them from where? Known to whom?
1091
+ # @todo Retrieves them from where? Known to whom?
1092
1092
  # Either requires providers or must be overridden.
1093
1093
  # @raise [Puppet::DevError] when there are no providers and the implementation has not overridded this method.
1094
1094
  def self.instances
@@ -1375,7 +1375,7 @@ class Type
1375
1375
 
1376
1376
  # RelationshipMetaparam is an implementation supporting the meta-parameters `:require`, `:subscribe`,
1377
1377
  # `:notify`, and `:before`.
1378
- #
1378
+ #
1379
1379
  #
1380
1380
  class RelationshipMetaparam < Puppet::Parameter
1381
1381
  class << self
@@ -1417,13 +1417,13 @@ class Type
1417
1417
  # The `:in` relationships are specified by the event-receivers, and `:out`
1418
1418
  # relationships are specified by the event generator.
1419
1419
  # @todo references to "event-receivers" and "event generator" means in this context - are those just
1420
- # the resources at the two ends of the relationship?
1420
+ # the resources at the two ends of the relationship?
1421
1421
  # This way 'source' and 'target' are consistent terms in both edges
1422
1422
  # and events, i.e. an event targets edges whose source matches
1423
1423
  # the event's source. The direction of the relationship determines
1424
1424
  # which resource is applied first and which resource is considered
1425
1425
  # to be the event generator.
1426
- # @return [Array<Puppet::Relationship>]
1426
+ # @return [Array<Puppet::Relationship>]
1427
1427
  # @raise [???fail] when a reference can not be resolved
1428
1428
  #
1429
1429
  def to_edges
@@ -1465,7 +1465,7 @@ class Type
1465
1465
  end
1466
1466
 
1467
1467
  # @todo document this, have no clue what this does... it retuns "RelationshipMetaparam.subclasses"
1468
- #
1468
+ #
1469
1469
  def self.relationship_params
1470
1470
  RelationshipMetaparam.subclasses
1471
1471
  end
@@ -1630,7 +1630,7 @@ class Type
1630
1630
  # @api private
1631
1631
  #
1632
1632
  attr_accessor :providerloader
1633
-
1633
+
1634
1634
  # @todo Don't know if this is a name, or a reference to a Provider instance (now marked up as an instance
1635
1635
  # of Provider.
1636
1636
  # @return [Puppet::Provider, nil] The default provider for this type, or nil if non is defines
@@ -1705,7 +1705,7 @@ class Type
1705
1705
  # this type.
1706
1706
  # @todo How does the provider know if it is suitable for the type? Is it just suitable for the platform/
1707
1707
  # environment where this method is executing?
1708
- # @param name [String] the name of the provider for which validity is checked
1708
+ # @param name [String] the name of the provider for which validity is checked
1709
1709
  # @return [Boolean] true if the given name references a provider that is suitable
1710
1710
  #
1711
1711
  def self.validprovider?(name)
@@ -1720,12 +1720,12 @@ class Type
1720
1720
  # Is this a new provider of a Type (metatype), or a provider of an instance of Type (a resource), or
1721
1721
  # a Provider (the implementation of a Type's behavior). CONFUSED. It calls magically named methods like
1722
1722
  # "providify" ...
1723
- # @param name [String, Symbol] the name of the WHAT? provider? type?
1723
+ # @param name [String, Symbol] the name of the WHAT? provider? type?
1724
1724
  # @param options [Hash{Symbol => Object}] a hash of options, used by this method, and passed on to {#genclass}, (see
1725
1725
  # it for additional options to pass).
1726
1726
  # @option options [Puppet::Provider] :parent the parent provider (what is this?)
1727
1727
  # @option options [Puppet::Type] :resource_type the resource type, defaults to this type if unspecified
1728
- # @return [Puppet::Provider] a provider ???
1728
+ # @return [Puppet::Provider] a provider ???
1729
1729
  # @raise [Puppet::DevError] when the parent provider could not be found.
1730
1730
  #
1731
1731
  def self.provide(name, options = {}, &block)
@@ -1849,7 +1849,7 @@ class Type
1849
1849
  rmclass(name, :hash => provider_hash, :prefix => "Provider")
1850
1850
  end
1851
1851
 
1852
- # Returns a list of suitable providers for the given type.
1852
+ # Returns a list of suitable providers for the given type.
1853
1853
  # A call to this method will load all providers if not already loaded and ask each if it is
1854
1854
  # suitable - those that are are included in the result.
1855
1855
  # @note This method also does some special processing which rejects a provider named `:fake` (for testing purposes).
@@ -1866,7 +1866,7 @@ class Type
1866
1866
 
1867
1867
  # @return [Boolean] Returns true if this is something else than a `:provider`, or if it
1868
1868
  # is a provider and it is suitable, or if there is a default provider. Otherwise, false is returned.
1869
- #
1869
+ #
1870
1870
  def suitable?
1871
1871
  # If we don't use providers, then we consider it suitable.
1872
1872
  return true unless self.class.paramclass(:provider)
@@ -1909,11 +1909,10 @@ class Type
1909
1909
  ###############################
1910
1910
  # All of the relationship code.
1911
1911
 
1912
-
1913
1912
  # Adds a block producing a single name (or list of names) of the given resource type name to autorequire.
1914
1913
  # @example Autorequire the files File['foo', 'bar']
1915
1914
  # autorequire( 'file', {|| ['foo', 'bar'] })
1916
- #
1915
+ #
1917
1916
  # @todo original = _"Specify a block for generating a list of objects to autorequire.
1918
1917
  # This makes it so that you don't have to manually specify things that you clearly require."_
1919
1918
  # @param name [String] the name of a type of which one or several resources should be autorequired e.g. "file"
@@ -1944,9 +1943,9 @@ class Type
1944
1943
  # See {autorequire} for how to add an auto-requirement.
1945
1944
  # @todo needs details - see the param rel_catalog, and type of this param
1946
1945
  # @param rel_catalog [Puppet::Catalog, nil] the catalog to add dependencies to. Defaults to the
1947
- # catalog (TODO: what is the type of the catalog).
1946
+ # catalog (TODO: what is the type of the catalog).
1948
1947
  # @raise [Puppet::DevError] if there is no catalog
1949
- #
1948
+ #
1950
1949
  def autorequire(rel_catalog = nil)
1951
1950
  rel_catalog ||= catalog
1952
1951
  raise(Puppet::DevError, "You cannot add relationships without a catalog") unless rel_catalog
@@ -2005,7 +2004,7 @@ class Type
2005
2004
  # are orphaned ... I think they can just be removed as what they say should be covered
2006
2005
  # by the now added yardoc. <irony>(Yo! to quote some of the other actual awsome specific comments applicable
2007
2006
  # to objects called from elsewhere, or not. ;-)</irony>
2008
- #
2007
+ #
2009
2008
  # @comment Types (which map to resources in the languages) are entirely composed of
2010
2009
  # attribute value pairs. Generally, Puppet calls any of these things an
2011
2010
  # 'attribute', but these attributes always take one of three specific
@@ -2014,13 +2013,12 @@ class Type
2014
2013
  # @comment In naming methods, I have tried to consistently name the method so
2015
2014
  # that it is clear whether it operates on all attributes (thus has 'attr' in
2016
2015
  # the method name, or whether it operates on a specific type of attributes.
2017
-
2018
-
2016
+
2019
2017
  # The title attribute of WHAT ???
2020
2018
  # @todo Figure out what this is the title attribute of (it appears on line 1926 currently).
2021
2019
  # @return [String] the title
2022
2020
  attr_writer :title
2023
-
2021
+
2024
2022
  # The noop attribute of WHAT ??? does WHAT???
2025
2023
  # @todo Figure out what this is the noop attribute of (it appears on line 1931 currently).
2026
2024
  # @return [???] the noop WHAT ??? (mode? if so of what, or noop for an instance of the type, or for all
@@ -2039,7 +2037,7 @@ class Type
2039
2037
  # @return [String] the name of the resource type; e.g., "File"
2040
2038
  #
2041
2039
  attr_reader :name
2042
-
2040
+
2043
2041
  # @return [Boolean] true if the type should send itself a refresh event on change.
2044
2042
  #
2045
2043
  attr_accessor :self_refresh
@@ -2051,7 +2049,7 @@ class Type
2051
2049
  end
2052
2050
 
2053
2051
  # Initializes all of the variables that must be initialized for each subclass.
2054
- # @todo Does the explanation make sense?
2052
+ # @todo Does the explanation make sense?
2055
2053
  # @return [void]
2056
2054
  def self.initvars
2057
2055
  # all of the instances of this class
@@ -2084,7 +2082,7 @@ class Type
2084
2082
  # The returned name is on the form "Puppet::Type::<name>", where the first letter of name is
2085
2083
  # capitalized.
2086
2084
  # @return [String] the fully qualified name Puppet::Type::<name> where the first letter of name is captialized
2087
- #
2085
+ #
2088
2086
  def self.to_s
2089
2087
  if defined?(@name)
2090
2088
  "Puppet::Type::#{@name.to_s.capitalize}"
@@ -2111,7 +2109,7 @@ class Type
2111
2109
 
2112
2110
  # @return [String] The file from which this type originates from
2113
2111
  attr_accessor :file
2114
-
2112
+
2115
2113
  # @return [Integer] The line in {#file} from which this type originates from
2116
2114
  attr_accessor :line
2117
2115
 
@@ -2160,9 +2158,13 @@ class Type
2160
2158
  # causes the title to be resource.ref ("for components") - what is a component?
2161
2159
  #
2162
2160
  # @overaload initialize(hsh)
2163
- # @param hsh [Hash]
2161
+ # @param hsh [Hash]
2162
+ # @raise [Puppet::ResourceError] when the type validation raises
2163
+ # Puppet::Error or ArgumentError
2164
2164
  # @overload initialize(resource)
2165
2165
  # @param resource [Puppet:Resource]
2166
+ # @raise [Puppet::ResourceError] when the type validation raises
2167
+ # Puppet::Error or ArgumentError
2166
2168
  #
2167
2169
  def initialize(resource)
2168
2170
  resource = self.class.hash2resource(resource) unless resource.is_a?(Puppet::Resource)
@@ -2195,7 +2197,13 @@ class Type
2195
2197
 
2196
2198
  set_parameters(@original_parameters)
2197
2199
 
2198
- self.validate if self.respond_to?(:validate)
2200
+ begin
2201
+ self.validate if self.respond_to?(:validate)
2202
+ rescue Puppet::Error, ArgumentError => detail
2203
+ error = Puppet::ResourceError.new("Validation of #{ref} failed: #{detail}")
2204
+ adderrorcontext(error, detail)
2205
+ raise error
2206
+ end
2199
2207
  end
2200
2208
 
2201
2209
  private
@@ -2205,9 +2213,9 @@ class Type
2205
2213
  # given by the corresponding entry in the given hash - e.g. if name_var appoints the name `:path` the value
2206
2214
  # of `:path` is set to the value at the key `:path` in the given hash. As a side effect this key/value is then
2207
2215
  # removed from the given hash.
2208
- #
2216
+ #
2209
2217
  # @note This method mutates the given hash by removing the entry with a key equal to the value
2210
- # returned from name_var!
2218
+ # returned from name_var!
2211
2219
  # @param hash [Hash] a hash of what
2212
2220
  # @return [void]
2213
2221
  def set_name(hash)
@@ -2215,7 +2223,7 @@ class Type
2215
2223
  end
2216
2224
 
2217
2225
  # Sets parameters from the given hash.
2218
- # Values are set in _attribute order_ i.e. higher priority attributes before others, otherwise in
2226
+ # Values are set in _attribute order_ i.e. higher priority attributes before others, otherwise in
2219
2227
  # the order they were specified (as opposed to just setting them in the order they happen to appear in
2220
2228
  # when iterating over the given hash).
2221
2229
  #
@@ -2257,12 +2265,12 @@ class Type
2257
2265
  public
2258
2266
 
2259
2267
  # Finishes any outstanding processing.
2260
- # This method should be called as a final step in setup,
2268
+ # This method should be called as a final step in setup,
2261
2269
  # to allow the parameters that have associated auto-require needs to be processed.
2262
- #
2270
+ #
2263
2271
  # @todo what is the expected sequence here - who is responsible for calling this? When?
2264
2272
  # Is the returned type correct?
2265
- # @return [Array<Puppet::Parameter>] the validated list/set of attributes
2273
+ # @return [Array<Puppet::Parameter>] the validated list/set of attributes
2266
2274
  #
2267
2275
  def finish
2268
2276
  # Make sure all of our relationships are valid. Again, must be done
@@ -2349,9 +2357,9 @@ class Type
2349
2357
  # @todo it is somewhat confusing that if the name_var is a valid parameter, it is assumed to
2350
2358
  # be the name_var called :name, but if it is a property, it uses the name_var.
2351
2359
  # It is further confusing as Type in some respects supports multiple namevars.
2352
- #
2360
+ #
2353
2361
  # @return [String] Returns the title of this object, or it's name if title was not explicetly set.
2354
- # @raise [??? devfail] if title is not set, and name_var can not be found.
2362
+ # @raise [??? devfail] if title is not set, and name_var can not be found.
2355
2363
  def title
2356
2364
  unless @title
2357
2365
  if self.class.validparameter?(name_var)
@@ -2375,7 +2383,7 @@ class Type
2375
2383
 
2376
2384
  # @todo What to resource? Which one of the resource forms is prroduced? returned here?
2377
2385
  # @return [??? Resource] a resource that WHAT???
2378
- #
2386
+ #
2379
2387
  def to_resource
2380
2388
  resource = self.retrieve_resource
2381
2389
  resource.tag(*self.tags)