puppet 5.3.7-x64-mingw32 → 5.4.0-x64-mingw32

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 (454) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +42 -29
  3. data/README.md +8 -6
  4. data/ext/cert_inspector +2 -2
  5. data/ext/envpuppet +1 -1
  6. data/ext/gentoo/init.d/puppetmaster +4 -4
  7. data/ext/ips/puppet-agent +11 -11
  8. data/ext/ips/puppet-master +11 -11
  9. data/ext/puppet-test +1 -2
  10. data/ext/redhat/client.init +2 -2
  11. data/ext/redhat/logrotate +1 -1
  12. data/ext/solaris/smf/puppet +11 -11
  13. data/ext/solaris/smf/svc-puppetd +5 -5
  14. data/ext/solaris/smf/svc-puppetmasterd +5 -5
  15. data/ext/windows/service/daemon.rb +1 -1
  16. data/install.rb +2 -3
  17. data/lib/puppet/agent.rb +1 -1
  18. data/lib/puppet/application/cert.rb +1 -3
  19. data/lib/puppet/application/describe.rb +0 -1
  20. data/lib/puppet/application/device.rb +12 -99
  21. data/lib/puppet/application/filebucket.rb +32 -11
  22. data/lib/puppet/application/lookup.rb +1 -11
  23. data/lib/puppet/application/script.rb +261 -0
  24. data/lib/puppet/configurer.rb +3 -4
  25. data/lib/puppet/configurer/plugin_handler.rb +26 -9
  26. data/lib/puppet/context.rb +1 -1
  27. data/lib/puppet/datatypes.rb +213 -0
  28. data/lib/puppet/datatypes/error.rb +21 -0
  29. data/lib/puppet/datatypes/impl/error.rb +40 -0
  30. data/lib/puppet/defaults.rb +51 -20
  31. data/lib/puppet/environments.rb +17 -0
  32. data/lib/puppet/error.rb +17 -0
  33. data/lib/puppet/etc.rb +2 -2
  34. data/lib/puppet/external/pson/pure/generator.rb +1 -1
  35. data/lib/puppet/external/pson/pure/parser.rb +1 -1
  36. data/lib/puppet/face/config.rb +45 -0
  37. data/lib/puppet/face/epp.rb +3 -3
  38. data/lib/puppet/face/help/action.erb +3 -0
  39. data/lib/puppet/face/module/build.rb +1 -0
  40. data/lib/puppet/face/module/generate.rb +5 -0
  41. data/lib/puppet/face/module/install.rb +1 -0
  42. data/lib/puppet/face/module/search.rb +6 -2
  43. data/lib/puppet/face/module/uninstall.rb +1 -0
  44. data/lib/puppet/face/module/upgrade.rb +1 -0
  45. data/lib/puppet/face/parser.rb +0 -1
  46. data/lib/puppet/face/plugin.rb +1 -3
  47. data/lib/puppet/feature/base.rb +1 -1
  48. data/lib/puppet/feature/bolt.rb +3 -0
  49. data/lib/puppet/file_bucket/dipper.rb +1 -2
  50. data/lib/puppet/file_serving/http_metadata.rb +1 -1
  51. data/lib/puppet/file_system/uniquefile.rb +2 -2
  52. data/lib/puppet/forge.rb +6 -0
  53. data/lib/puppet/functions.rb +70 -88
  54. data/lib/puppet/functions/all.rb +6 -2
  55. data/lib/puppet/functions/annotate.rb +1 -1
  56. data/lib/puppet/functions/any.rb +7 -3
  57. data/lib/puppet/functions/contain.rb +6 -0
  58. data/lib/puppet/functions/convert_to.rb +32 -0
  59. data/lib/puppet/functions/defined.rb +0 -3
  60. data/lib/puppet/functions/each.rb +10 -6
  61. data/lib/puppet/functions/filter.rb +16 -10
  62. data/lib/puppet/functions/find_file.rb +0 -1
  63. data/lib/puppet/functions/include.rb +6 -0
  64. data/lib/puppet/functions/map.rb +12 -9
  65. data/lib/puppet/functions/module_directory.rb +41 -0
  66. data/lib/puppet/functions/new.rb +1 -4
  67. data/lib/puppet/functions/regsubst.rb +1 -1
  68. data/lib/puppet/functions/require.rb +6 -0
  69. data/lib/puppet/generate/type.rb +1 -1
  70. data/lib/puppet/gettext/config.rb +2 -2
  71. data/lib/puppet/gettext/stubs.rb +1 -1
  72. data/lib/puppet/indirector/catalog/compiler.rb +0 -1
  73. data/lib/puppet/indirector/file_bucket_file/file.rb +6 -2
  74. data/lib/puppet/indirector/file_server.rb +1 -1
  75. data/lib/puppet/indirector/node/ldap.rb +19 -3
  76. data/lib/puppet/indirector/request.rb +10 -6
  77. data/lib/puppet/indirector/rest.rb +11 -12
  78. data/lib/puppet/info_service/class_information_service.rb +1 -1
  79. data/lib/puppet/interface/action.rb +11 -0
  80. data/lib/puppet/interface/action_builder.rb +8 -0
  81. data/lib/puppet/interface/option_manager.rb +1 -1
  82. data/lib/puppet/loaders.rb +2 -0
  83. data/lib/puppet/module.rb +6 -2
  84. data/lib/puppet/module_tool/applications/builder.rb +4 -0
  85. data/lib/puppet/module_tool/applications/installer.rb +3 -0
  86. data/lib/puppet/module_tool/applications/uninstaller.rb +3 -0
  87. data/lib/puppet/module_tool/applications/unpacker.rb +1 -1
  88. data/lib/puppet/module_tool/applications/upgrader.rb +3 -0
  89. data/lib/puppet/module_tool/installed_modules.rb +1 -1
  90. data/lib/puppet/module_tool/metadata.rb +0 -1
  91. data/lib/puppet/network/authstore.rb +1 -1
  92. data/lib/puppet/network/http/api/indirected_routes.rb +1 -1
  93. data/lib/puppet/network/http/connection.rb +1 -9
  94. data/lib/puppet/network/http/factory.rb +0 -3
  95. data/lib/puppet/network/http/webrick.rb +1 -0
  96. data/lib/puppet/network/rights.rb +1 -1
  97. data/lib/puppet/node.rb +53 -0
  98. data/lib/puppet/node/environment.rb +1 -1
  99. data/lib/puppet/parameter/boolean.rb +1 -1
  100. data/lib/puppet/parser.rb +1 -0
  101. data/lib/puppet/parser/abstract_compiler.rb +36 -0
  102. data/lib/puppet/parser/ast/branch.rb +1 -1
  103. data/lib/puppet/parser/ast/pops_bridge.rb +8 -52
  104. data/lib/puppet/parser/compiler.rb +4 -54
  105. data/lib/puppet/parser/functions.rb +0 -1
  106. data/lib/puppet/parser/functions/create_resources.rb +6 -0
  107. data/lib/puppet/parser/functions/fqdn_rand.rb +6 -2
  108. data/lib/puppet/parser/functions/inline_template.rb +6 -0
  109. data/lib/puppet/parser/functions/new.rb +47 -32
  110. data/lib/puppet/parser/functions/realize.rb +6 -0
  111. data/lib/puppet/parser/functions/return.rb +1 -22
  112. data/lib/puppet/parser/functions/reverse_each.rb +1 -1
  113. data/lib/puppet/parser/functions/scanf.rb +1 -1
  114. data/lib/puppet/parser/functions/sha256.rb +5 -0
  115. data/lib/puppet/parser/functions/tag.rb +6 -0
  116. data/lib/puppet/parser/functions/tagged.rb +6 -0
  117. data/lib/puppet/parser/functions/template.rb +5 -0
  118. data/lib/puppet/parser/scope.rb +28 -4
  119. data/lib/puppet/parser/script_compiler.rb +118 -0
  120. data/lib/puppet/parser/type_loader.rb +1 -1
  121. data/lib/puppet/pops.rb +1 -1
  122. data/lib/puppet/pops/evaluator/access_operator.rb +38 -4
  123. data/lib/puppet/pops/evaluator/closure.rb +12 -4
  124. data/lib/puppet/pops/evaluator/compare_operator.rb +4 -4
  125. data/lib/puppet/pops/evaluator/epp_evaluator.rb +13 -0
  126. data/lib/puppet/pops/evaluator/evaluator_impl.rb +38 -10
  127. data/lib/puppet/pops/evaluator/literal_evaluator.rb +1 -1
  128. data/lib/puppet/pops/evaluator/runtime3_converter.rb +1 -1
  129. data/lib/puppet/pops/evaluator/runtime3_support.rb +2 -3
  130. data/lib/puppet/pops/functions/dispatch.rb +6 -5
  131. data/lib/puppet/pops/functions/function.rb +2 -2
  132. data/lib/puppet/pops/issues.rb +34 -2
  133. data/lib/puppet/pops/loader/base_loader.rb +10 -0
  134. data/lib/puppet/pops/loader/dependency_loader.rb +7 -0
  135. data/lib/puppet/pops/loader/loader.rb +21 -2
  136. data/lib/puppet/pops/loader/loader_paths.rb +180 -30
  137. data/lib/puppet/pops/loader/module_loaders.rb +202 -33
  138. data/lib/puppet/pops/loader/puppet_plan_instantiator.rb +84 -0
  139. data/lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb +9 -9
  140. data/lib/puppet/pops/loader/ruby_data_type_instantiator.rb +40 -0
  141. data/lib/puppet/pops/loader/runtime3_type_loader.rb +6 -1
  142. data/lib/puppet/pops/loader/static_loader.rb +23 -8
  143. data/lib/puppet/pops/loader/task_instantiator.rb +69 -0
  144. data/lib/puppet/pops/loader/type_definition_instantiator.rb +4 -0
  145. data/lib/puppet/pops/loaders.rb +122 -11
  146. data/lib/puppet/pops/lookup/data_dig_function_provider.rb +1 -1
  147. data/lib/puppet/pops/lookup/interpolation.rb +1 -1
  148. data/lib/puppet/pops/lookup/lookup_adapter.rb +0 -1
  149. data/lib/puppet/pops/model/ast.pp +3 -0
  150. data/lib/puppet/pops/model/ast.rb +34 -1
  151. data/lib/puppet/pops/model/factory.rb +30 -3
  152. data/lib/puppet/pops/model/model_label_provider.rb +1 -0
  153. data/lib/puppet/pops/model/model_tree_dumper.rb +12 -1
  154. data/lib/puppet/pops/model/tree_dumper.rb +1 -1
  155. data/lib/puppet/pops/parser/code_merger.rb +2 -2
  156. data/lib/puppet/pops/parser/egrammar.ra +44 -15
  157. data/lib/puppet/pops/parser/eparser.rb +1687 -1571
  158. data/lib/puppet/pops/parser/epp_support.rb +1 -3
  159. data/lib/puppet/pops/parser/evaluating_parser.rb +1 -1
  160. data/lib/puppet/pops/parser/interpolation_support.rb +2 -2
  161. data/lib/puppet/pops/parser/lexer2.rb +4 -4
  162. data/lib/puppet/pops/parser/lexer_support.rb +2 -2
  163. data/lib/puppet/pops/parser/locatable.rb +1 -1
  164. data/lib/puppet/pops/parser/locator.rb +7 -13
  165. data/lib/puppet/pops/parser/parser_support.rb +3 -3
  166. data/lib/puppet/pops/parser/slurp_support.rb +0 -3
  167. data/lib/puppet/pops/pcore.rb +45 -0
  168. data/lib/puppet/pops/resource/param.rb +1 -1
  169. data/lib/puppet/pops/resource/resource_type_impl.rb +1 -1
  170. data/lib/puppet/pops/serialization/abstract_reader.rb +4 -0
  171. data/lib/puppet/pops/serialization/abstract_writer.rb +6 -0
  172. data/lib/puppet/pops/serialization/extension.rb +1 -0
  173. data/lib/puppet/pops/serialization/from_data_converter.rb +64 -10
  174. data/lib/puppet/pops/serialization/json_path.rb +2 -1
  175. data/lib/puppet/pops/serialization/object.rb +3 -4
  176. data/lib/puppet/pops/serialization/serializer.rb +2 -1
  177. data/lib/puppet/pops/serialization/to_data_converter.rb +7 -3
  178. data/lib/puppet/pops/time/timespan.rb +1 -1
  179. data/lib/puppet/pops/types/iterable.rb +38 -9
  180. data/lib/puppet/pops/types/p_init_type.rb +1 -1
  181. data/lib/puppet/pops/types/p_meta_type.rb +4 -0
  182. data/lib/puppet/pops/types/p_object_type.rb +146 -14
  183. data/lib/puppet/pops/types/p_object_type_extension.rb +218 -0
  184. data/lib/puppet/pops/types/p_sem_ver_range_type.rb +0 -1
  185. data/lib/puppet/pops/types/p_sem_ver_type.rb +10 -2
  186. data/lib/puppet/pops/types/p_type_set_type.rb +0 -1
  187. data/lib/puppet/pops/types/p_uri_type.rb +190 -0
  188. data/lib/puppet/pops/types/puppet_object.rb +15 -1
  189. data/lib/puppet/pops/types/ruby_generator.rb +46 -54
  190. data/lib/puppet/pops/types/string_converter.rb +22 -1
  191. data/lib/puppet/pops/types/type_acceptor.rb +1 -1
  192. data/lib/puppet/pops/types/type_calculator.rb +13 -4
  193. data/lib/puppet/pops/types/type_factory.rb +29 -5
  194. data/lib/puppet/pops/types/type_formatter.rb +67 -4
  195. data/lib/puppet/pops/types/type_parser.rb +92 -4
  196. data/lib/puppet/pops/types/type_with_members.rb +43 -0
  197. data/lib/puppet/pops/types/types.rb +212 -80
  198. data/lib/puppet/pops/validation/checker4_0.rb +10 -6
  199. data/lib/puppet/pops/validation/tasks_checker.rb +60 -0
  200. data/lib/puppet/pops/validation/validator_factory_4_0.rb +6 -1
  201. data/lib/puppet/property.rb +1 -1
  202. data/lib/puppet/provider.rb +18 -8
  203. data/lib/puppet/provider/augeas/augeas.rb +3 -4
  204. data/lib/puppet/provider/exec.rb +0 -2
  205. data/lib/puppet/provider/group/groupadd.rb +25 -1
  206. data/lib/puppet/provider/group/windows_adsi.rb +7 -4
  207. data/lib/puppet/provider/mount.rb +25 -8
  208. data/lib/puppet/provider/nameservice.rb +9 -4
  209. data/lib/puppet/provider/nameservice/directoryservice.rb +3 -3
  210. data/lib/puppet/provider/nameservice/objectadd.rb +13 -24
  211. data/lib/puppet/provider/nameservice/pw.rb +14 -14
  212. data/lib/puppet/provider/package/appdmg.rb +0 -1
  213. data/lib/puppet/provider/package/apple.rb +0 -1
  214. data/lib/puppet/provider/package/gem.rb +2 -2
  215. data/lib/puppet/provider/package/macports.rb +2 -2
  216. data/lib/puppet/provider/package/pkg.rb +3 -0
  217. data/lib/puppet/provider/package/pkgdmg.rb +0 -1
  218. data/lib/puppet/provider/package/portage.rb +0 -1
  219. data/lib/puppet/provider/package/yum.rb +23 -8
  220. data/lib/puppet/provider/package/zypper.rb +2 -2
  221. data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +2 -2
  222. data/lib/puppet/provider/service/init.rb +1 -0
  223. data/lib/puppet/provider/service/launchd.rb +6 -7
  224. data/lib/puppet/provider/service/redhat.rb +3 -2
  225. data/lib/puppet/provider/service/systemd.rb +2 -2
  226. data/lib/puppet/provider/ssh_authorized_key/parsed.rb +1 -1
  227. data/lib/puppet/provider/user/aix.rb +3 -2
  228. data/lib/puppet/provider/user/openbsd.rb +1 -1
  229. data/lib/puppet/provider/user/pw.rb +1 -1
  230. data/lib/puppet/provider/user/user_role_add.rb +7 -1
  231. data/lib/puppet/provider/user/useradd.rb +36 -6
  232. data/lib/puppet/provider/user/windows_adsi.rb +1 -1
  233. data/lib/puppet/provider/yumrepo/inifile.rb +2 -4
  234. data/lib/puppet/provider/zfs/zfs.rb +23 -3
  235. data/lib/puppet/provider/zpool/zpool.rb +1 -1
  236. data/lib/puppet/reference/configuration.rb +0 -2
  237. data/lib/puppet/reference/type.rb +0 -1
  238. data/lib/puppet/resource.rb +1 -2
  239. data/lib/puppet/resource/catalog.rb +1 -1
  240. data/lib/puppet/resource/status.rb +0 -1
  241. data/lib/puppet/resource/type.rb +4 -4
  242. data/lib/puppet/resource/type_collection.rb +1 -1
  243. data/lib/puppet/settings/base_setting.rb +1 -1
  244. data/lib/puppet/settings/environment_conf.rb +0 -1
  245. data/lib/puppet/settings/ini_file.rb +66 -12
  246. data/lib/puppet/ssl/certificate_authority.rb +1 -1
  247. data/lib/puppet/ssl/certificate_request.rb +2 -2
  248. data/lib/puppet/ssl/certificate_revocation_list.rb +2 -1
  249. data/lib/puppet/ssl/certificate_signer.rb +11 -0
  250. data/lib/puppet/ssl/host.rb +2 -2
  251. data/lib/puppet/syntax_checkers/base64.rb +1 -1
  252. data/lib/puppet/transaction.rb +37 -14
  253. data/lib/puppet/transaction/report.rb +3 -1
  254. data/lib/puppet/type.rb +17 -4
  255. data/lib/puppet/type/cron.rb +1 -1
  256. data/lib/puppet/type/exec.rb +5 -4
  257. data/lib/puppet/type/file.rb +3 -3
  258. data/lib/puppet/type/file/checksum.rb +7 -1
  259. data/lib/puppet/type/file/checksum_value.rb +4 -3
  260. data/lib/puppet/type/group.rb +3 -0
  261. data/lib/puppet/type/k5login.rb +101 -0
  262. data/lib/puppet/type/macauthorization.rb +1 -1
  263. data/lib/puppet/type/mount.rb +6 -2
  264. data/lib/puppet/type/tidy.rb +6 -4
  265. data/lib/puppet/type/user.rb +26 -39
  266. data/lib/puppet/type/yumrepo.rb +9 -0
  267. data/lib/puppet/type/zfs.rb +4 -0
  268. data/lib/puppet/util.rb +8 -15
  269. data/lib/puppet/util/character_encoding.rb +2 -2
  270. data/lib/puppet/util/checksums.rb +82 -1
  271. data/lib/puppet/util/errors.rb +0 -2
  272. data/lib/puppet/util/filetype.rb +2 -2
  273. data/lib/puppet/util/json_lockfile.rb +1 -1
  274. data/lib/puppet/util/log.rb +1 -1
  275. data/lib/puppet/util/log/destinations.rb +10 -1
  276. data/lib/puppet/util/monkey_patches.rb +1 -1
  277. data/lib/puppet/util/network_device/cisco/device.rb +5 -5
  278. data/lib/puppet/util/network_device/config.rb +2 -3
  279. data/lib/puppet/util/platform.rb +13 -0
  280. data/lib/puppet/util/plist.rb +4 -4
  281. data/lib/puppet/util/rdoc/generators/puppet_generator.rb +2 -2
  282. data/lib/puppet/util/rdoc/parser/puppet_parser_rdoc2.rb +1 -1
  283. data/lib/puppet/util/reference.rb +8 -1
  284. data/lib/puppet/util/windows/adsi.rb +18 -15
  285. data/lib/puppet/util/windows/principal.rb +6 -7
  286. data/lib/puppet/util/windows/process.rb +1 -1
  287. data/lib/puppet/util/windows/registry.rb +2 -2
  288. data/lib/puppet/util/windows/sid.rb +7 -62
  289. data/lib/puppet/vendor/deep_merge/README.md +2 -2
  290. data/lib/puppet/vendor/pathspec/lib/pathspec/gitignorespec.rb +18 -18
  291. data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/version.rb +2 -2
  292. data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/version_range.rb +5 -5
  293. data/lib/puppet/vendor/semantic_puppet/locales/config.yaml +1 -1
  294. data/lib/puppet/version.rb +1 -1
  295. data/lib/puppet_pal.rb +874 -0
  296. data/locales/ja/puppet.po +140 -163
  297. data/locales/puppet.pot +940 -597
  298. data/man/man5/puppet.conf.5 +16 -91
  299. data/man/man8/puppet-agent.8 +2 -6
  300. data/man/man8/puppet-apply.8 +2 -2
  301. data/man/man8/puppet-ca.8 +1 -1
  302. data/man/man8/puppet-catalog.8 +1 -1
  303. data/man/man8/puppet-cert.8 +1 -1
  304. data/man/man8/puppet-certificate.8 +1 -1
  305. data/man/man8/puppet-certificate_request.8 +1 -1
  306. data/man/man8/puppet-certificate_revocation_list.8 +1 -1
  307. data/man/man8/puppet-config.8 +1 -1
  308. data/man/man8/puppet-describe.8 +1 -1
  309. data/man/man8/puppet-device.8 +11 -33
  310. data/man/man8/puppet-doc.8 +1 -1
  311. data/man/man8/puppet-epp.8 +1 -1
  312. data/man/man8/puppet-facts.8 +1 -1
  313. data/man/man8/puppet-filebucket.8 +4 -22
  314. data/man/man8/puppet-generate.8 +1 -1
  315. data/man/man8/puppet-help.8 +1 -1
  316. data/man/man8/puppet-key.8 +1 -1
  317. data/man/man8/puppet-lookup.8 +1 -1
  318. data/man/man8/puppet-man.8 +1 -1
  319. data/man/man8/puppet-master.8 +1 -1
  320. data/man/man8/puppet-module.8 +2 -11
  321. data/man/man8/puppet-node.8 +1 -1
  322. data/man/man8/puppet-parser.8 +1 -1
  323. data/man/man8/puppet-plugin.8 +1 -1
  324. data/man/man8/puppet-report.8 +1 -1
  325. data/man/man8/puppet-resource.8 +1 -1
  326. data/man/man8/puppet-status.8 +1 -1
  327. data/man/man8/puppet.8 +2 -2
  328. data/spec/integration/application/lookup_spec.rb +0 -21
  329. data/spec/integration/parser/compiler_spec.rb +18 -0
  330. data/spec/integration/parser/script_compiler_spec.rb +113 -0
  331. data/spec/integration/provider/mount_spec.rb +2 -0
  332. data/spec/integration/type/file_spec.rb +11 -3
  333. data/spec/integration/util/windows/adsi_spec.rb +1 -86
  334. data/spec/integration/util/windows/principal_spec.rb +1 -10
  335. data/spec/shared_contexts/checksum.rb +4 -1
  336. data/spec/shared_contexts/digests.rb +46 -1
  337. data/spec/shared_contexts/types_setup.rb +8 -3
  338. data/spec/unit/agent_spec.rb +2 -2
  339. data/spec/unit/application/cert_spec.rb +5 -17
  340. data/spec/unit/application/device_spec.rb +2 -96
  341. data/spec/unit/application/filebucket_spec.rb +18 -4
  342. data/spec/unit/configurer/plugin_handler_spec.rb +5 -32
  343. data/spec/unit/configurer_spec.rb +3 -3
  344. data/spec/unit/datatypes_spec.rb +304 -0
  345. data/spec/unit/defaults_spec.rb +41 -20
  346. data/spec/unit/face/config_spec.rb +46 -1
  347. data/spec/unit/face/epp_face_spec.rb +7 -3
  348. data/spec/unit/face/module/search_spec.rb +11 -0
  349. data/spec/unit/face/parser_spec.rb +2 -2
  350. data/spec/unit/file_bucket/dipper_spec.rb +12 -1
  351. data/spec/unit/forge/module_release_spec.rb +70 -0
  352. data/spec/unit/functions/break_spec.rb +34 -2
  353. data/spec/unit/functions/contain_spec.rb +1 -0
  354. data/spec/unit/functions/convert_to_spec.rb +22 -0
  355. data/spec/unit/functions/epp_spec.rb +5 -0
  356. data/spec/unit/functions/include_spec.rb +15 -0
  357. data/spec/unit/functions/module_directory_spec.rb +43 -0
  358. data/spec/unit/functions/new_spec.rb +14 -14
  359. data/spec/unit/functions/require_spec.rb +2 -0
  360. data/spec/unit/functions/shared.rb +12 -0
  361. data/spec/unit/functions/step_spec.rb +1 -1
  362. data/spec/unit/functions4_spec.rb +49 -4
  363. data/spec/unit/indirector/catalog/compiler_spec.rb +3 -3
  364. data/spec/unit/indirector/file_bucket_file/file_spec.rb +148 -94
  365. data/spec/unit/indirector/node/ldap_spec.rb +15 -12
  366. data/spec/unit/indirector/rest_spec.rb +0 -43
  367. data/spec/unit/interface/action_spec.rb +33 -0
  368. data/spec/unit/module_tool/applications/builder_spec.rb +7 -0
  369. data/spec/unit/module_tool/applications/installer_spec.rb +8 -0
  370. data/spec/unit/module_tool/applications/uninstaller_spec.rb +8 -0
  371. data/spec/unit/module_tool/applications/upgrader_spec.rb +6 -0
  372. data/spec/unit/network/http/connection_spec.rb +1 -1
  373. data/spec/unit/network/http/factory_spec.rb +28 -35
  374. data/spec/unit/parser/compiler_spec.rb +0 -8
  375. data/spec/unit/parser/environment_compiler_spec.rb +36 -0
  376. data/spec/unit/parser/functions/create_resources_spec.rb +9 -0
  377. data/spec/unit/parser/functions/inline_template_spec.rb +7 -0
  378. data/spec/unit/parser/functions/realize_spec.rb +9 -0
  379. data/spec/unit/parser/functions/tag_spec.rb +7 -0
  380. data/spec/unit/parser/functions/tagged_spec.rb +25 -0
  381. data/spec/unit/parser/functions/template_spec.rb +8 -0
  382. data/spec/unit/parser/scope_spec.rb +19 -0
  383. data/spec/unit/pops/evaluator/conditionals_spec.rb +1 -1
  384. data/spec/unit/pops/loaders/loader_spec.rb +516 -0
  385. data/spec/unit/pops/loaders/loaders_spec.rb +11 -0
  386. data/spec/unit/pops/loaders/module_loaders_spec.rb +43 -0
  387. data/spec/unit/pops/loaders/static_loader_spec.rb +15 -7
  388. data/spec/unit/pops/model/model_spec.rb +5 -0
  389. data/spec/unit/pops/parser/lexer2_spec.rb +15 -0
  390. data/spec/unit/pops/parser/locator_spec.rb +20 -0
  391. data/spec/unit/pops/parser/parse_basic_expressions_spec.rb +33 -0
  392. data/spec/unit/pops/parser/parse_calls_spec.rb +28 -0
  393. data/spec/unit/pops/parser/parse_conditionals_spec.rb +12 -0
  394. data/spec/unit/pops/parser/parse_plan_spec.rb +48 -0
  395. data/spec/unit/pops/serialization/packer_spec.rb +8 -0
  396. data/spec/unit/pops/serialization/serialization_spec.rb +30 -0
  397. data/spec/unit/pops/serialization/to_from_hr_spec.rb +31 -0
  398. data/spec/unit/pops/types/error_spec.rb +207 -0
  399. data/spec/unit/pops/types/p_init_type_spec.rb +98 -0
  400. data/spec/unit/pops/types/p_object_type_spec.rb +275 -10
  401. data/spec/unit/pops/types/p_uri_type_spec.rb +191 -0
  402. data/spec/unit/pops/types/ruby_generator_spec.rb +82 -44
  403. data/spec/unit/pops/types/task_spec.rb +353 -0
  404. data/spec/unit/pops/types/type_calculator_spec.rb +76 -5
  405. data/spec/unit/pops/types/type_formatter_spec.rb +31 -13
  406. data/spec/unit/pops/types/type_parser_spec.rb +13 -1
  407. data/spec/unit/pops/types/types_spec.rb +60 -0
  408. data/spec/unit/pops/validator/validator_spec.rb +76 -0
  409. data/spec/unit/provider/group/groupadd_spec.rb +77 -1
  410. data/spec/unit/provider/group/pw_spec.rb +4 -4
  411. data/spec/unit/provider/group/windows_adsi_spec.rb +22 -79
  412. data/spec/unit/provider/mount_spec.rb +18 -5
  413. data/spec/unit/provider/nameservice_spec.rb +5 -5
  414. data/spec/unit/provider/package/dnf_spec.rb +2 -2
  415. data/spec/unit/provider/package/gem_spec.rb +1 -1
  416. data/spec/unit/provider/package/pkg_spec.rb +3 -0
  417. data/spec/unit/provider/package/yum_spec.rb +40 -0
  418. data/spec/unit/provider/service/launchd_spec.rb +2 -1
  419. data/spec/unit/provider/service/redhat_spec.rb +5 -0
  420. data/spec/unit/provider/service/systemd_spec.rb +1 -1
  421. data/spec/unit/provider/user/hpux_spec.rb +2 -2
  422. data/spec/unit/provider/user/openbsd_spec.rb +2 -2
  423. data/spec/unit/provider/user/pw_spec.rb +14 -14
  424. data/spec/unit/provider/user/user_role_add_spec.rb +19 -2
  425. data/spec/unit/provider/user/useradd_spec.rb +188 -22
  426. data/spec/unit/provider/user/windows_adsi_spec.rb +4 -4
  427. data/spec/unit/provider/zfs/zfs_spec.rb +55 -1
  428. data/spec/unit/provider_spec.rb +48 -0
  429. data/spec/unit/puppet_pal_2pec.rb +1005 -0
  430. data/spec/unit/puppet_pal_spec.rb +11 -0
  431. data/spec/unit/settings/ini_file_spec.rb +313 -2
  432. data/spec/unit/ssl/certificate_request_spec.rb +42 -1
  433. data/spec/unit/ssl/certificate_revocation_list_spec.rb +2 -1
  434. data/spec/unit/transaction/report_spec.rb +1 -0
  435. data/spec/unit/transaction_spec.rb +112 -21
  436. data/spec/unit/type/file/checksum_spec.rb +20 -0
  437. data/spec/unit/type/file_spec.rb +8 -0
  438. data/spec/unit/type/group_spec.rb +8 -0
  439. data/spec/unit/type/k5login_spec.rb +22 -1
  440. data/spec/unit/type/scheduled_task_spec.rb +15 -0
  441. data/spec/unit/type/user_spec.rb +11 -1
  442. data/spec/unit/type/yumrepo_spec.rb +5 -0
  443. data/spec/unit/util/checksums_spec.rb +3 -3
  444. data/spec/unit/util/log/destinations_spec.rb +14 -0
  445. data/spec/unit/util/network_device/cisco/device_spec.rb +1 -1
  446. data/spec/unit/util/plist_spec.rb +3 -3
  447. data/spec/unit/util/windows/adsi_spec.rb +27 -31
  448. data/spec/unit/util/windows/sid_spec.rb +15 -86
  449. data/spec/unit/util_spec.rb +17 -3
  450. data/tasks/manpages.rake +1 -1
  451. metadata +220 -182
  452. data/lib/puppet/bindings.rb +0 -148
  453. data/lib/puppet/configurer/downloader_factory.rb +0 -44
  454. data/spec/unit/configurer/downloader_factory_spec.rb +0 -129
@@ -138,6 +138,23 @@ module Puppet::Environments
138
138
  end
139
139
  end
140
140
 
141
+ class StaticDirectory < Static
142
+ # Accepts a single environment in the given directory having the given name (not required to be reflected as the name
143
+ # of the directory)
144
+ #
145
+ def initialize(env_name, env_dir, environment)
146
+ super(environment)
147
+ @env_dir = env_dir
148
+ @env_name = env_name
149
+ end
150
+
151
+ # @!macro loader_get_conf
152
+ def get_conf(name)
153
+ return nil unless name == @env_name
154
+ Puppet::Settings::EnvironmentConf.load_from(@env_dir, '')
155
+ end
156
+ end
157
+
141
158
  # Reads environments from a directory on disk. Each environment is
142
159
  # represented as a sub-directory. The environment's manifest setting is the
143
160
  # `manifest` directory of the environment directory. The environment's
@@ -68,6 +68,23 @@ module Puppet
68
68
  msg = _("%{message} on node %{node}") % { message: msg, node: node } if node
69
69
  msg
70
70
  end
71
+
72
+ def self.from_issue_and_stack(issue, args = {})
73
+ stacktrace = Puppet::Pops::PuppetStack.stacktrace()
74
+ if stacktrace.size > 0
75
+ filename, line = stacktrace[0]
76
+ else
77
+ filename = nil
78
+ line = nil
79
+ end
80
+ self.new(
81
+ issue.format(args),
82
+ filename,
83
+ line,
84
+ nil,
85
+ nil,
86
+ issue.issue_code)
87
+ end
71
88
  end
72
89
 
73
90
  # An error that already contains location information in the message text
@@ -109,7 +109,7 @@ module Puppet::Etc
109
109
  # Defines Puppet::Etc::Passwd struct class. Contains all of the original
110
110
  # member fields of Etc::Passwd, and additional "canonical_" versions of
111
111
  # these fields as well. API compatible with Etc::Passwd. Because Struct.new
112
- # defines a new Class object, we memozie to avoid superfluous extra Class
112
+ # defines a new Class object, we memoize to avoid superfluous extra Class
113
113
  # instantiations.
114
114
  def puppet_etc_passwd_class
115
115
  @password_class ||= Struct.new(*Etc::Passwd.members, *Etc::Passwd.members.map { |member| "canonical_#{member}".to_sym })
@@ -133,7 +133,7 @@ module Puppet::Etc
133
133
  # @api private
134
134
  # @param [Etc::Passwd or Etc::Group struct]
135
135
  # @return [Puppet::Etc::Passwd or Puppet::Etc::Group struct] a new struct
136
- # object with the original struct values overidden to UTF-8, if valid. For
136
+ # object with the original struct values overridden to UTF-8, if valid. For
137
137
  # invalid values originating in UTF-8, invalid characters are replaced with
138
138
  # '?'. For each member the struct also contains a corresponding
139
139
  # :canonical_<member name> struct member.
@@ -341,7 +341,7 @@ module PSON
341
341
  '"' << PSON.utf8_to_pson(self) << '"'
342
342
  end
343
343
 
344
- # Module that holds the extinding methods if, the String module is
344
+ # Module that holds the extending methods if, the String module is
345
345
  # included.
346
346
  module Extend
347
347
  # Raw Strings are PSON Objects (the raw bytes are stored in an array for the
@@ -44,7 +44,7 @@ module PSON
44
44
  /(?=\*/) # single slash before this comment's end
45
45
  )*
46
46
  \*/ # the End of this comment
47
- |[ \t\r\n]+ # whitespaces: space, horicontal tab, lf, cr
47
+ |[ \t\r\n]+ # whitespaces: space, horizontal tab, lf, cr
48
48
  )+
49
49
  )mx
50
50
 
@@ -129,4 +129,49 @@ https://puppet.com/docs/puppet/latest/configuration.html#environment
129
129
  nil
130
130
  end
131
131
  end
132
+
133
+ action(:delete) do
134
+ summary _("Delete a Puppet setting.")
135
+ arguments _("(<setting>")
136
+ #TRANSLATORS 'main' is a specific section name and should not be translated
137
+ description "Deletes a setting from the specified section. (The default is the section 'main')."
138
+ notes <<-'EOT'
139
+ By default, this action deletes the configuration setting from the 'main'
140
+ configuration domain. Use the '--section' flags to delete settings from other
141
+ configuration domains.
142
+ EOT
143
+ examples <<-'EOT'
144
+ Delete the setting 'setting_name' from the 'main' configuration domain:
145
+
146
+ $ puppet config delete setting_name
147
+
148
+ Delete the setting 'setting_name' from the 'master' configuration domain:
149
+
150
+ $ puppet config delete setting_name --section master
151
+ EOT
152
+
153
+ when_invoked do |name, options|
154
+ options[:section] = options[:section].to_s # If value was left as default - set to default string
155
+
156
+ path = Puppet::FileSystem.pathname(Puppet.settings.which_configuration_file)
157
+ if Puppet::FileSystem.exist?(path)
158
+ Puppet::FileSystem.open(path, nil, 'r+:UTF-8') do |file|
159
+ Puppet::Settings::IniFile.update(file) do |config|
160
+ setting_string = config.delete(options[:section], name)
161
+ if setting_string
162
+ puts(_("Deleted setting from '%{section_name}': '%{setting_string}'") %
163
+ { section_name: options[:section], name: name, setting_string: setting_string.strip })
164
+ else
165
+ Puppet.warning(_("No setting found in configuration file for section '%{section_name}' setting name '%{name}'") %
166
+ { section_name: options[:section], name: name })
167
+ end
168
+ end
169
+ end
170
+ else
171
+ #TRANSLATORS the 'puppet.conf' is a specific file and should not be translated
172
+ Puppet.warning(_("The puppet.conf file does not exist %{puppet_conf}") % { puppet_conf: path })
173
+ end
174
+ nil
175
+ end
176
+ end
132
177
  end
@@ -63,7 +63,7 @@ Puppet::Face.define(:epp, '0.0.1') do
63
63
  when_invoked do |*args|
64
64
  options = args.pop
65
65
  # pass a dummy node, as facts are not needed for validation
66
- options[:node] = node = Puppet::Node.new("testnode", :facts => Puppet::Node::Facts.new("facts", {}))
66
+ options[:node] = Puppet::Node.new("testnode", :facts => Puppet::Node::Facts.new("facts", {}))
67
67
  compiler = create_compiler(options)
68
68
 
69
69
  status = true # no validation error yet
@@ -145,7 +145,7 @@ Puppet::Face.define(:epp, '0.0.1') do
145
145
  require 'puppet/pops'
146
146
  options = args.pop
147
147
  # pass a dummy node, as facts are not needed for dump
148
- options[:node] = node = Puppet::Node.new("testnode", :facts => Puppet::Node::Facts.new("facts", {}))
148
+ options[:node] = Puppet::Node.new("testnode", :facts => Puppet::Node::Facts.new("facts", {}))
149
149
  options[:header] = options[:header].nil? ? true : options[:header]
150
150
  options[:validate] = options[:validate].nil? ? true : options[:validate]
151
151
 
@@ -176,7 +176,7 @@ Puppet::Face.define(:epp, '0.0.1') do
176
176
  end
177
177
 
178
178
  show_filename = templates.count > 1
179
- dumps = templates.each do |file|
179
+ templates.each do |file|
180
180
  buffer.print dump_parse(Puppet::FileSystem.read(file, :encoding => 'utf-8'), file, options, show_filename)
181
181
  end
182
182
 
@@ -1,4 +1,7 @@
1
1
  <%# encoding: UTF-8%>
2
+ <% if action.deprecated? -%>
3
+ <%= "Warning: 'puppet #{action.face.name} #{action.name}' is deprecated and will be removed in a future release." %>
4
+ <% end %>
2
5
  <% if action.synopsis -%>
3
6
  USAGE: <%= action.synopsis %>
4
7
 
@@ -4,6 +4,7 @@ Puppet::Face.define(:module, '1.0.0') do
4
4
  description <<-EOT
5
5
  Prepares a local module for release on the Puppet Forge by building a
6
6
  ready-to-upload archive file.
7
+ Note: Module build uses MD5 checksums, which are prohibited on FIPS enabled systems.
7
8
 
8
9
  This action uses the metadata.json file in the module directory to set metadata
9
10
  used by the Forge. See <https://docs.puppetlabs.com/puppet/latest/reference/modules_publishing.html> for more
@@ -129,6 +129,8 @@ Puppet::Face.define(:module, '1.0.0') do
129
129
  puts _("Finished; module generated in %{path}.") % { path: path }
130
130
  result.join("\n")
131
131
  end
132
+
133
+ deprecate
132
134
  end
133
135
  end
134
136
 
@@ -136,6 +138,9 @@ module Puppet::ModuleTool::Generate
136
138
  module_function
137
139
 
138
140
  def generate(metadata, skip_interview = false)
141
+ #TRANSLATORS 'puppet module generate' is the name of the puppet command and 'Puppet Development Kit' is the name of the software package replacing this action and should not be translated.
142
+ Puppet.deprecation_warning _("`puppet module generate` is deprecated and will be removed in a future release. This action has been replaced by Puppet Development Kit. For more information visit https://puppet.com/docs/pdk/latest/pdk.html.")
143
+
139
144
  interview(metadata) unless skip_interview
140
145
  destination = duplicate_skeleton(metadata)
141
146
  all_files = destination.basename + '**/*'
@@ -8,6 +8,7 @@ Puppet::Face.define(:module, '1.0.0') do
8
8
  summary _("Install a module from the Puppet Forge or a release archive.")
9
9
  description <<-EOT
10
10
  Installs a module from the Puppet Forge or from a release archive file.
11
+ Note: Module install uses MD5 checksums, which are prohibited on FIPS enabled systems.
11
12
 
12
13
  The specified module will be installed into the directory
13
14
  specified with the `--target-dir` option, which defaults to the first
@@ -44,13 +44,15 @@ Puppet::Face.define(:module, '1.0.0') do
44
44
  min_widths = Hash[ *headers.map { |k,v| [k, v.length] }.flatten ]
45
45
  min_widths['full_name'] = min_widths['author'] = 12
46
46
 
47
- min_width = min_widths.inject(0) { |sum,pair| sum += pair.last } + (padding.length * (headers.length - 1))
47
+ min_width = min_widths.inject(0) { |sum,pair| sum + pair.last } + (padding.length * (headers.length - 1))
48
48
 
49
49
  terminal_width = [Puppet::Util::Terminal.width, min_width].max
50
50
 
51
51
  columns = results[:answers].inject(min_widths) do |hash, result|
52
+ deprecated_buffer = result['deprecated_at'].nil? ? 0 : 11 # ' DEPRECATED'.length
53
+
52
54
  {
53
- 'full_name' => [ hash['full_name'], result['full_name'].length ].max,
55
+ 'full_name' => [ hash['full_name'], result['full_name'].length + deprecated_buffer ].max,
54
56
  'desc' => [ hash['desc'], result['desc'].length ].max,
55
57
  'author' => [ hash['author'], "@#{result['author']}".length ].max,
56
58
  'tag_list' => [ hash['tag_list'], result['tag_list'].join(' ').length ].max,
@@ -80,12 +82,14 @@ Puppet::Face.define(:module, '1.0.0') do
80
82
  highlight = proc do |s|
81
83
  s = s.gsub(term, colorize(:green, term))
82
84
  s = s.gsub(term.gsub('/', '-'), colorize(:green, term.gsub('/', '-'))) if term =~ /\//
85
+ s = s.gsub(' DEPRECATED', colorize(:red, ' DEPRECATED'))
83
86
  s
84
87
  end
85
88
 
86
89
  format % [ headers['full_name'], headers['desc'], headers['author'], headers['tag_list'] ] +
87
90
  results[:answers].map do |match|
88
91
  name, desc, author, keywords = %w{full_name desc author tag_list}.map { |k| match[k] }
92
+ name += ' DEPRECATED' unless match['deprecated_at'].nil?
89
93
  desc = desc[0...(columns['desc'] - 3)] + '...' if desc.length > columns['desc']
90
94
  highlight[format % [ name.sub('/', '-'), desc, "@#{author}", [keywords].flatten.join(' ') ]]
91
95
  end.join
@@ -4,6 +4,7 @@ Puppet::Face.define(:module, '1.0.0') do
4
4
  description <<-EOT
5
5
  Uninstalls a puppet module from the modulepath (or a specific
6
6
  target directory).
7
+ Note: Module uninstall uses MD5 checksums, which are prohibited on FIPS enabled systems.
7
8
  EOT
8
9
 
9
10
  returns _("Hash of module objects representing uninstalled modules and related errors.")
@@ -5,6 +5,7 @@ Puppet::Face.define(:module, '1.0.0') do
5
5
  summary _("Upgrade a puppet module.")
6
6
  description <<-EOT
7
7
  Upgrades a puppet module.
8
+ Note: Module upgrade uses MD5 checksums, which are prohibited on FIPS enabled systems.
8
9
  EOT
9
10
 
10
11
  returns "Hash"
@@ -99,7 +99,6 @@ Puppet::Face.define(:parser, '0.0.1') do
99
99
  raise Puppet::Error, _("No input to parse given on command line or stdin")
100
100
  end
101
101
  else
102
- missing_files = []
103
102
  files = args
104
103
  available_files = files.select do |file|
105
104
  Puppet::FileSystem.exist?(file)
@@ -1,5 +1,4 @@
1
1
  require 'puppet/face'
2
- require 'puppet/configurer/downloader_factory'
3
2
  require 'puppet/configurer/plugin_handler'
4
3
 
5
4
  Puppet::Face.define(:plugin, '0.0.1') do
@@ -42,8 +41,7 @@ Puppet::Face.define(:plugin, '0.0.1') do
42
41
  when_invoked do |options|
43
42
  remote_environment_for_plugins = Puppet::Node::Environment.remote(Puppet[:environment])
44
43
 
45
- factory = Puppet::Configurer::DownloaderFactory.new
46
- handler = Puppet::Configurer::PluginHandler.new(factory)
44
+ handler = Puppet::Configurer::PluginHandler.new()
47
45
  handler.download_plugins(remote_environment_for_plugins)
48
46
  end
49
47
 
@@ -83,7 +83,7 @@ Puppet.features.add(:manages_symlinks) do
83
83
  attach_function :CreateSymbolicLinkW, [:lpwstr, :lpwstr, :dword], :boolean
84
84
 
85
85
  true
86
- rescue LoadError => err
86
+ rescue LoadError
87
87
  Puppet.debug("CreateSymbolicLink is not available")
88
88
  false
89
89
  end
@@ -0,0 +1,3 @@
1
+ require 'puppet/util/feature'
2
+
3
+ Puppet.features.add(:bolt, :libs => ['bolt'])
@@ -17,7 +17,6 @@ class Puppet::FileBucket::Dipper
17
17
  # Emulate the XMLRPC client
18
18
  server = hash[:Server]
19
19
  port = hash[:Port] || Puppet[:masterport]
20
- environment = Puppet[:environment]
21
20
 
22
21
  if hash.include?(:Path)
23
22
  @local_path = hash[:Path]
@@ -46,7 +45,7 @@ class Puppet::FileBucket::Dipper
46
45
 
47
46
  # Make a HEAD request for the file so that we don't waste time
48
47
  # uploading it if it already exists in the bucket.
49
- unless Puppet::FileBucket::File.indirection.head(file_bucket_path)
48
+ unless Puppet::FileBucket::File.indirection.head(file_bucket_path, :bucket_path => file_bucket_file.bucket_path)
50
49
  Puppet::FileBucket::File.indirection.save(file_bucket_file, dest_path)
51
50
  end
52
51
 
@@ -37,7 +37,7 @@ class Puppet::FileServing::HttpMetadata < Puppet::FileServing::Metadata
37
37
  def collect
38
38
  # Prefer the checksum_type from the indirector request options
39
39
  # but fall back to the alternative otherwise
40
- [ @checksum_type, :md5, :mtime ].each do |type|
40
+ [ @checksum_type, :md5, :sha256, :sha384, :sha512, :sha224, :mtime ].each do |type|
41
41
  @checksum_type = type
42
42
  @checksum = @checksums[type]
43
43
  return if @checksum
@@ -144,7 +144,7 @@ class Puppet::FileSystem::Uniquefile < DelegateClass(File)
144
144
  def try_convert_to_hash(h)
145
145
  begin
146
146
  h.to_hash
147
- rescue NoMethodError => e
147
+ rescue NoMethodError
148
148
  nil
149
149
  end
150
150
  end
@@ -154,7 +154,7 @@ class Puppet::FileSystem::Uniquefile < DelegateClass(File)
154
154
  def tmpdir
155
155
  tmp = '.'
156
156
  if $SAFE > 0
157
- tmp = @@systmpdir
157
+ @@systmpdir
158
158
  else
159
159
  for dir in [ Puppet::Util.get_env('TMPDIR'), Puppet::Util.get_env('TMP'), Puppet::Util.get_env('TEMP'), @@systmpdir, '/tmp']
160
160
  if dir and stat = File.stat(dir) and stat.directory? and stat.writable?
@@ -167,6 +167,8 @@ class Puppet::Forge < SemanticPuppet::Dependency::Source
167
167
  def prepare
168
168
  return @unpacked_into if @unpacked_into
169
169
 
170
+ Puppet.warning "#{@metadata['name']} has been deprecated by its author! View module on Puppet Forge for more info." if deprecated?
171
+
170
172
  download(@data['file_uri'], tmpfile)
171
173
  validate_checksum(tmpfile, @data['file_md5'])
172
174
  unpack(tmpfile, tmpdir)
@@ -210,6 +212,10 @@ class Puppet::Forge < SemanticPuppet::Dependency::Source
210
212
  raise RuntimeError, _("Could not extract contents of module archive: %{message}") % { message: e.message }
211
213
  end
212
214
  end
215
+
216
+ def deprecated?
217
+ @data['module'] && (@data['module']['deprecated_at'] != nil)
218
+ end
213
219
  end
214
220
 
215
221
  private
@@ -186,8 +186,12 @@ module Puppet::Functions
186
186
  # and it will fail unless protected with an if defined? if the local
187
187
  # variable does not exist in the block's binder.
188
188
  #
189
- loader = block.binding.eval('loader_injected_arg if defined?(loader_injected_arg)')
190
- create_loaded_function(func_name, loader, function_base, &block)
189
+ begin
190
+ loader = block.binding.eval('loader_injected_arg if defined?(loader_injected_arg)')
191
+ create_loaded_function(func_name, loader, function_base, &block)
192
+ rescue StandardError => e
193
+ raise ArgumentError, _("Function Load Error for function '%{function_name}': %{message}") % {function_name: func_name, message: e.message}
194
+ end
191
195
  end
192
196
 
193
197
  # Creates a function in, or in a local loader under the given loader.
@@ -474,8 +478,8 @@ module Puppet::Functions
474
478
  type = @all_callables
475
479
  name = type_and_name[0]
476
480
  when 2
477
- type_string, name = type_and_name
478
- type = Puppet::Pops::Types::TypeParser.singleton.parse(type_string, loader)
481
+ type, name = type_and_name
482
+ type = Puppet::Pops::Types::TypeParser.singleton.parse(type, loader) unless type.is_a?(Puppet::Pops::Types::PAnyType)
479
483
  else
480
484
  raise ArgumentError, _("block_param accepts max 2 arguments (type, name), got %{size}.") % { size: type_and_name.size }
481
485
  end
@@ -513,7 +517,9 @@ module Puppet::Functions
513
517
  #
514
518
  # @api public
515
519
  def return_type(type)
516
- raise ArgumentError, _("Argument to 'return_type' must be a String reference to a Puppet Data Type. Got %{type_class}") % { type_class: type.class } unless type.is_a?(String)
520
+ unless type.is_a?(String) || type.is_a?(Puppet::Pops::Types::PAnyType)
521
+ raise ArgumentError, _("Argument to 'return_type' must be a String reference to a Puppet Data Type. Got %{type_class}") % { type_class: type.class }
522
+ end
517
523
  @return_type = type
518
524
  end
519
525
 
@@ -528,7 +534,7 @@ module Puppet::Functions
528
534
  raise ArgumentError, _("Parameter name argument must be a Symbol. Got %{name_class}") % { name_class: name.class }
529
535
  end
530
536
 
531
- if type.is_a?(String)
537
+ if type.is_a?(String) || type.is_a?(Puppet::Pops::Types::PAnyType)
532
538
  @types << type
533
539
  @names << name
534
540
  # mark what should be picked for this position when dispatching
@@ -571,14 +577,27 @@ module Puppet::Functions
571
577
  # @api private
572
578
  def create_callable(types, block_type, return_type, from, to)
573
579
  mapped_types = types.map do |t|
574
- Puppet::Pops::Types::TypeParser.singleton.parse(t, loader)
580
+ t.is_a?(Puppet::Pops::Types::PAnyType) ? t : internal_type_parse(t, loader)
575
581
  end
576
582
  param_types = Puppet::Pops::Types::PTupleType.new(mapped_types, from > 0 && from == to ? nil : Puppet::Pops::Types::PIntegerType.new(from, to))
577
- return_type = Puppet::Pops::Types::TypeParser.singleton.parse(return_type, loader) unless return_type.nil?
583
+ return_type = internal_type_parse(return_type, loader) unless return_type.nil? || return_type.is_a?(Puppet::Pops::Types::PAnyType)
578
584
  Puppet::Pops::Types::PCallableType.new(param_types, block_type, return_type)
579
585
  end
586
+
587
+ def internal_type_parse(type_string, loader)
588
+ begin
589
+ Puppet::Pops::Types::TypeParser.singleton.parse(type_string, loader)
590
+ rescue StandardError => e
591
+ raise ArgumentError, _("Parsing of type string '\"%{type_string}\"' failed with message: <%{message}>.\n") % {
592
+ type_string: type_string,
593
+ message: e.message
594
+ }
595
+ end
596
+ end
597
+ private :internal_type_parse
580
598
  end
581
599
 
600
+
582
601
  # The LocalTypeAliasBuilder is used by the 'local_types' method to collect the individual
583
602
  # type aliases given by the function's author.
584
603
  #
@@ -601,9 +620,31 @@ module Puppet::Functions
601
620
  # @api public
602
621
  #
603
622
  def type(assignment_string)
604
- result = parser.parse_string("type #{assignment_string}", nil) # no file source :-(
623
+ # Get location to use in case of error - this produces ruby filename and where call to 'type' occurred
624
+ # but strips off the rest of the internal "where" as it is not meaningful to user.
625
+ #
626
+ rb_location = caller[0]
627
+
628
+ begin
629
+ result = parser.parse_string("type #{assignment_string}", nil)
630
+ rescue StandardError => e
631
+ rb_location = rb_location.gsub(/:in.*$/, '')
632
+ # Create a meaningful location for parse errors - show both what went wrong with the parsing
633
+ # and in which ruby file it was found.
634
+ raise ArgumentError, _("Parsing of 'type \"%{assignment_string}\"' failed with message: <%{message}>.\n" +
635
+ "Called from <%{ruby_file_location}>") % {
636
+ assignment_string: assignment_string,
637
+ message: e.message,
638
+ ruby_file_location: rb_location
639
+ }
640
+ end
605
641
  unless result.body.kind_of?(Puppet::Pops::Model::TypeAlias)
606
- raise ArgumentError, _("Expected a type alias assignment on the form 'AliasType = T', got '%{assignment_string}'") % { assignment_string: assignment_string }
642
+ rb_location = rb_location.gsub(/:in.*$/, '')
643
+ raise ArgumentError, _("Expected a type alias assignment on the form 'AliasType = T', got '%{assignment_string}'.\n"+
644
+ "Called from <%{ruby_file_location}>") % {
645
+ assignment_string: assignment_string,
646
+ ruby_file_location: rb_location
647
+ }
607
648
  end
608
649
  @local_types << result.body
609
650
  end
@@ -616,30 +657,7 @@ module Puppet::Functions
616
657
  #
617
658
  # This is a private, internal, system for creating functions. It supports
618
659
  # everything that the public function definition system supports as well as a
619
- # few extra features.
620
- #
621
- # Injection Support
622
- # ===
623
- # The Function API supports injection of data and services. It is possible to
624
- # make injection that takes effect when the function is loaded (for services
625
- # and runtime configuration that does not change depending on how/from where
626
- # in what context the function is called. It is also possible to inject and
627
- # weave argument values into a call.
628
- #
629
- # Injection of attributes
630
- # ---
631
- # Injection of attributes is performed by one of the methods `attr_injected`,
632
- # and `attr_injected_producer`. The injected attributes are available via
633
- # accessor method calls.
634
- #
635
- # @example using injected attributes
636
- # Puppet::Functions.create_function('test') do
637
- # attr_injected String, :larger, 'message_larger'
638
- # attr_injected String, :smaller, 'message_smaller'
639
- # def test(a, b)
640
- # a > b ? larger() : smaller()
641
- # end
642
- # end
660
+ # few extra features such as injection of well known parameters.
643
661
  #
644
662
  # @api private
645
663
  class InternalFunction < Function
@@ -663,26 +681,22 @@ module Puppet::Functions
663
681
  end
664
682
  end
665
683
 
666
- # @note WARNING: This style of creating functions is not public. It is a system
667
- # under development that will be used for creating "system" functions.
668
- #
669
684
  # Injection and Weaving of parameters
670
685
  # ---
671
- # It is possible to inject and weave parameters into a call. These extra
672
- # parameters are not part of the parameters passed from the Puppet logic, and
673
- # they can not be overridden by parameters given as arguments in the call.
674
- # They are invisible to the Puppet Language.
686
+ # It is possible to inject and weave a set of well known parameters into a call.
687
+ # These extra parameters are not part of the parameters passed from the Puppet
688
+ # logic, and they can not be overridden by parameters given as arguments in the
689
+ # call. They are invisible to the Puppet Language.
675
690
  #
676
691
  # @example using injected parameters
677
692
  # Puppet::Functions.create_function('test') do
678
693
  # dispatch :test do
679
694
  # param 'Scalar', 'a'
680
695
  # param 'Scalar', 'b'
681
- # injected_param 'String', 'larger', 'message_larger'
682
- # injected_param 'String', 'smaller', 'message_smaller'
696
+ # scope_param
683
697
  # end
684
- # def test(a, b, larger, smaller)
685
- # a > b ? larger : smaller
698
+ # def test(a, b, scope)
699
+ # a > b ? scope['a'] : scope['b']
686
700
  # end
687
701
  # end
688
702
  #
@@ -690,54 +704,22 @@ module Puppet::Functions
690
704
  #
691
705
  # test(10, 20)
692
706
  #
693
- # Using injected value as default
694
- # ---
695
- # Default value assignment is handled by using the regular Ruby mechanism (a
696
- # value is assigned to the variable). The dispatch simply indicates that the
697
- # value is optional. If the default value should be injected, it can be
698
- # handled different ways depending on what is desired:
699
- #
700
- # * by calling the accessor method for an injected Function class attribute.
701
- # This is suitable if the value is constant across all instantiations of the
702
- # function, and across all calls.
703
- # * by injecting a parameter into the call
704
- # to the left of the parameter, and then assigning that as the default value.
705
- # * One of the above forms, but using an injected producer instead of a
706
- # directly injected value.
707
- #
708
- # @example method with injected default values
709
- # Puppet::Functions.create_function('test') do
710
- # dispatch :test do
711
- # injected_param String, 'b_default', 'b_default_value_key'
712
- # param 'Scalar', 'a'
713
- # param 'Scalar', 'b'
714
- # end
715
- # def test(b_default, a, b = b_default)
716
- # # ...
717
- # end
718
- # end
719
- #
720
707
  # @api private
721
708
  class InternalDispatchBuilder < DispatcherBuilder
722
- def scope_param()
723
- @injections << [:scope, 'scope', '', :dispatcher_internal]
724
- # mark what should be picked for this position when dispatching
725
- @weaving << [@injections.size()-1]
709
+ # Inject parameter for `Puppet::Parser::Scope`
710
+ def scope_param
711
+ inject(:scope)
726
712
  end
727
- # TODO: is param name really needed? Perhaps for error messages? (it is unused now)
728
- #
729
- # @api private
730
- def injected_param(type, name, injection_name = '')
731
- @injections << [type, name, injection_name]
732
- # mark what should be picked for this position when dispatching
733
- @weaving << [@injections.size() -1]
713
+
714
+ # Inject parameter for `Puppet::Pal::ScriptCompiler`
715
+ def script_compiler_param
716
+ inject(:pal_script_compiler)
734
717
  end
735
718
 
736
- # TODO: is param name really needed? Perhaps for error messages? (it is unused now)
737
- #
738
- # @api private
739
- def injected_producer_param(type, name, injection_name = '')
740
- @injections << [type, name, injection_name, :producer]
719
+ private
720
+
721
+ def inject(injection_name)
722
+ @injections << injection_name
741
723
  # mark what should be picked for this position when dispatching
742
724
  @weaving << [@injections.size()-1]
743
725
  end