puppet 5.3.7-universal-darwin → 5.4.0-universal-darwin

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 +218 -180
  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
@@ -82,6 +82,19 @@ class Puppet::Pops::Evaluator::EppEvaluator
82
82
  enforce_parameters = true
83
83
  end
84
84
 
85
+ # filter out all qualified names and set them in qualified_variables
86
+ # only pass unqualified (filtered) variable names to the the template
87
+ filtered_args = {}
88
+ template_args.each_pair do |k, v|
89
+ if k =~ /::/
90
+ k = k[2..-1] if k.start_with?('::')
91
+ scope[k] = v
92
+ else
93
+ filtered_args[k] = v
94
+ end
95
+ end
96
+ template_args = filtered_args
97
+
85
98
  # inline_epp() logic sees all local variables, epp() all global
86
99
  if use_global_scope_only
87
100
  scope.with_global_scope do |global_scope|
@@ -178,6 +178,15 @@ class EvaluatorImpl
178
178
  end
179
179
  end
180
180
 
181
+ # Implementation of case option matching.
182
+ #
183
+ # This is the type of matching performed in a case option, using == for every type
184
+ # of value except regular expression where a match is performed.
185
+ #
186
+ def match?(left, right)
187
+ @@compare_operator.match(left, right, nil)
188
+ end
189
+
181
190
  protected
182
191
 
183
192
  def lvalue_VariableExpression(o, scope)
@@ -232,6 +241,9 @@ class EvaluatorImpl
232
241
  o, scope)
233
242
  end
234
243
  elsif values.is_a?(Puppet::Pops::Types::PClassType)
244
+ if Puppet[:tasks]
245
+ fail(Issues::CATALOG_OPERATION_NOT_SUPPORTED_WHEN_SCRIPTING, o, {:operation => _('multi var assignment from class')})
246
+ end
235
247
  # assign variables from class variables
236
248
  # lookup class resource and return one or more parameter values
237
249
  # TODO: behavior when class_name is nil
@@ -392,7 +404,9 @@ class EvaluatorImpl
392
404
  end
393
405
 
394
406
  left_o = bin_expr.left_expr
395
- if (left.is_a?(Array) || left.is_a?(Hash)) && COLLECTION_OPERATORS.include?(operator)
407
+ if left.is_a?(URI) && operator == '+'
408
+ concatenate(left, right)
409
+ elsif (left.is_a?(Array) || left.is_a?(Hash)) && COLLECTION_OPERATORS.include?(operator)
396
410
  # Handle operation on collections
397
411
  case operator
398
412
  when '+'
@@ -428,9 +442,9 @@ class EvaluatorImpl
428
442
  end
429
443
  end
430
444
  result = left.send(operator, right)
431
- rescue NoMethodError => e
445
+ rescue NoMethodError
432
446
  fail(Issues::OPERATOR_NOT_APPLICABLE, left_o, {:operator => operator, :left_value => left})
433
- rescue ZeroDivisionError => e
447
+ rescue ZeroDivisionError
434
448
  fail(Issues::DIV_BY_ZERO, bin_expr.right_expr)
435
449
  end
436
450
  case result
@@ -689,7 +703,7 @@ class EvaluatorImpl
689
703
  end
690
704
 
691
705
  # Evaluates a CollectExpression by creating a collector transformer. The transformer
692
- # will evaulate the collection, create the appropriate collector, and hand it off
706
+ # will evaluate the collection, create the appropriate collector, and hand it off
693
707
  # to the compiler to collect the resources specified by the query.
694
708
  #
695
709
  def eval_CollectExpression o, scope
@@ -934,7 +948,7 @@ class EvaluatorImpl
934
948
 
935
949
  obj = receiver[0]
936
950
  receiver_type = Types::TypeCalculator.infer(obj)
937
- if receiver_type.is_a?(Types::PObjectType)
951
+ if receiver_type.is_a?(Types::TypeWithMembers)
938
952
  member = receiver_type[name]
939
953
  unless member.nil?
940
954
  args = unfold([], o.arguments || [], scope)
@@ -1117,7 +1131,11 @@ class EvaluatorImpl
1117
1131
  # * Hash => a merge, where entries in `y` overrides
1118
1132
  # * any other => error
1119
1133
  #
1120
- # When x is something else, wrap it in an array first.
1134
+ # When x is a URI, y of type produces:
1135
+ #
1136
+ # * String => merge of URI interpreted x + URI(y) using URI merge semantics
1137
+ # * URI => merge of URI interpreted x + y using URI merge semantics
1138
+ # * any other => error
1121
1139
  #
1122
1140
  # When x is nil, an empty array is used instead.
1123
1141
  #
@@ -1147,11 +1165,18 @@ class EvaluatorImpl
1147
1165
  # @param hsh_x [Hash] the hash to merge to
1148
1166
  # @param hsh_y [Hash] hash merged with `hsh_x`
1149
1167
  # @return [Hash] new hash with `hsh_x` merged with `hsh_y`
1168
+ # @overload concatenate(uri_x, uri_y)
1169
+ # @param uri_x [URI] the uri to merge to
1170
+ # @param uri_y [URI] uri to merged with `uri_x`
1171
+ # @return [URI] new uri with `uri_x` merged with `uri_y`
1172
+ # @overload concatenate(uri_x, string_y)
1173
+ # @param uri_x [URI] the uri to merge to
1174
+ # @param string_y [String] string to merge with `uri_x`
1175
+ # @return [URI] new uri with `uri_x` merged with `string_y`
1150
1176
  # @raise [ArgumentError] when `xxx_x` is neither an Array nor a Hash
1151
1177
  # @raise [ArgumentError] when `xxx_x` is a Hash, and `xxx_y` is neither Array nor Hash.
1152
1178
  #
1153
1179
  def concatenate(x, y)
1154
- x = [x] unless x.is_a?(Array) || x.is_a?(Hash)
1155
1180
  case x
1156
1181
  when Array
1157
1182
  y = case y
@@ -1169,7 +1194,7 @@ class EvaluatorImpl
1169
1194
  # Hash[a,1,b,2] => {a => 1, b => 2}
1170
1195
  # Hash[[a,1], [b,2]] => {[a,1] => [b,2]}
1171
1196
  # Hash[[[a,1], [b,2]]] => {a => 1, b => 2}
1172
- # Use type calcultor to determine if array is Array[Array[?]], and if so use second form
1197
+ # Use type calculator to determine if array is Array[Array[?]], and if so use second form
1173
1198
  # of call
1174
1199
  t = @@type_calculator.infer(y)
1175
1200
  if t.element_type.is_a? Types::PArrayType
@@ -1178,11 +1203,14 @@ class EvaluatorImpl
1178
1203
  Hash[*y]
1179
1204
  end
1180
1205
  else
1181
- raise ArgumentError.new(_("Can only append Array or Hash to a Hash"))
1206
+ raise ArgumentError.new(_('Can only append Array or Hash to a Hash'))
1182
1207
  end
1183
1208
  x.merge y # new hash with overwrite
1209
+ when URI
1210
+ raise ArgumentError.new(_('An URI can only be merged with an URI or String')) unless y.is_a?(String) || y.is_a?(URI)
1211
+ x + y
1184
1212
  else
1185
- raise ArgumentError.new(_("Can only append to an Array or a Hash."))
1213
+ concatenate([x], y)
1186
1214
  end
1187
1215
  end
1188
1216
 
@@ -9,7 +9,7 @@ module Evaluator
9
9
  # Hash
10
10
  # QualifiedName
11
11
  # Default (produced :default)
12
- # Regular Expression (produces ruby reqular expression)
12
+ # Regular Expression (produces ruby regular expression)
13
13
  #
14
14
  # Not considered literal
15
15
  # QualifiedReference # i.e. File, FooBar
@@ -166,7 +166,7 @@ end
166
166
  class Runtime3FunctionArgumentConverter < Runtime3Converter
167
167
 
168
168
  def convert_Regexp(o, scope, undef_value)
169
- # Puppet 3x cannot handle parameter values that are reqular expressions. Turn into regexp string in
169
+ # Puppet 3x cannot handle parameter values that are regular expressions. Turn into regexp string in
170
170
  # source form
171
171
  o.inspect
172
172
  end
@@ -330,8 +330,7 @@ module Runtime3Support
330
330
  end
331
331
 
332
332
  def convert(value, scope, undef_value)
333
- converter = scope.environment.rich_data? ? Runtime3Converter.instance : Runtime3FunctionArgumentConverter.instance
334
- converter.convert(value, scope, undef_value)
333
+ Runtime3Converter.instance.convert(value, scope, undef_value)
335
334
  end
336
335
 
337
336
  def create_resources(o, scope, virtual, exported, type_name, resource_titles, evaluated_parameters)
@@ -375,7 +374,7 @@ module Runtime3Support
375
374
  evaluated_parameters = evaluated_parameters.flatten
376
375
  evaluated_resources.each do |r|
377
376
  unless r.is_a?(Types::PResourceType) && r.type_name != 'class'
378
- fail(Issues::ILLEGAL_OVERRIDEN_TYPE, o, {:actual => r} )
377
+ fail(Issues::ILLEGAL_OVERRIDDEN_TYPE, o, {:actual => r} )
379
378
  end
380
379
  t = Runtime3ResourceSupport.find_resource_type(scope, r.type_name)
381
380
  resource = Puppet::Parser::Resource.new(
@@ -72,14 +72,15 @@ class Dispatch < Evaluator::CallableSignature
72
72
  new_args = []
73
73
  @weaving.each do |knit|
74
74
  if knit.is_a?(Array)
75
- injection_data = @injections[knit[0]]
75
+ injection_name = @injections[knit[0]]
76
76
  new_args <<
77
- case injection_data[3]
78
- when :dispatcher_internal
79
- # currently only supports :scope injection
77
+ case injection_name
78
+ when :scope
80
79
  scope
80
+ when :pal_script_compiler
81
+ Puppet.lookup(:pal_script_compiler)
81
82
  else
82
- raise_error ArgumentError, _("Unknown injection %{detail}") % { detail: injection_data[3] }
83
+ raise ArgumentError, _("Unknown injection %{injection_name}") % { injection_name: injection_name }
83
84
  end
84
85
  else
85
86
  # Careful so no new nil arguments are added since they would override default
@@ -49,13 +49,13 @@ class Puppet::Pops::Functions::Function
49
49
  rescue Puppet::Pops::Evaluator::Next => jumper
50
50
  begin
51
51
  throw :next, jumper.value
52
- rescue Puppet::Parser::Scope::UNCAUGHT_THROW_EXCEPTION => uncaught
52
+ rescue Puppet::Parser::Scope::UNCAUGHT_THROW_EXCEPTION
53
53
  raise Puppet::ParseError.new("next() from context where this is illegal", jumper.file, jumper.line)
54
54
  end
55
55
  rescue Puppet::Pops::Evaluator::Return => jumper
56
56
  begin
57
57
  throw :return, jumper
58
- rescue Puppet::Parser::Scope::UNCAUGHT_THROW_EXCEPTION => uncaught
58
+ rescue Puppet::Parser::Scope::UNCAUGHT_THROW_EXCEPTION
59
59
  raise Puppet::ParseError.new("return() from context where this is illegal", jumper.file, jumper.line)
60
60
  end
61
61
  end
@@ -354,7 +354,7 @@ module Issues
354
354
  # Issues when a variable is not a NAME
355
355
  #
356
356
  ILLEGAL_VARIABLE_EXPRESSION = hard_issue :ILLEGAL_VARIABLE_EXPRESSION do
357
- _("Illegal variable expression. %{expresion} did not produce a variable name (String or Numeric).") % { expression: label.a_an_uc(semantic) }
357
+ _("Illegal variable expression. %{expression} did not produce a variable name (String or Numeric).") % { expression: label.a_an_uc(semantic) }
358
358
  end
359
359
 
360
360
  # Issues when an expression is used illegally in a query.
@@ -617,7 +617,7 @@ module Issues
617
617
  _("Node inheritance is not supported in Puppet >= 4.0.0. See http://links.puppet.com/puppet-node-inheritance-deprecation")
618
618
  end
619
619
 
620
- ILLEGAL_OVERRIDEN_TYPE = issue :ILLEGAL_OVERRIDEN_TYPE, :actual do
620
+ ILLEGAL_OVERRIDDEN_TYPE = issue :ILLEGAL_OVERRIDDEN_TYPE, :actual do
621
621
  _("Resource Override can only operate on resources, got: %{actual}") % { actual: label.label(actual) }
622
622
  end
623
623
 
@@ -749,6 +749,14 @@ module Issues
749
749
  _("Illegal %{format} Byte Order mark at beginning of input: %{bom} - remove these from the puppet source") % { format: format_name, bom: bytes }
750
750
  end
751
751
 
752
+ NO_SUCH_FILE_OR_DIRECTORY = hard_issue :NO_SUCH_FILE_OR_DIRECTORY, :file do
753
+ _('No such file or directory: %{file}') % { file: file }
754
+ end
755
+
756
+ NOT_A_FILE = hard_issue :NOT_A_FILE, :file do
757
+ _('%{file} is not a file') % { file: file }
758
+ end
759
+
752
760
  NUMERIC_OVERFLOW = hard_issue :NUMERIC_OVERFLOW, :value do
753
761
  if value > 0
754
762
  _("%{expression} resulted in a value outside of Puppet Integer max range, got '%{value}'") % { expression: label.a_an_uc(semantic), value: ("%#+x" % value) }
@@ -862,5 +870,29 @@ module Issues
862
870
  SERIALIZATION_UNKNOWN_KEY_CONVERTED_TO_STRING = issue :SERIALIZATION_UNKNOWN_KEY_CONVERTED_TO_STRING, :path, :klass, :value do
863
871
  _("%{path} contains a hash with %{klass} key. It will be converted to the String '%{value}'") % { path: path, klass: label.a_an(klass), value: value }
864
872
  end
873
+
874
+ FEATURE_NOT_SUPPORTED_WHEN_SCRIPTING = issue :NOT_SUPPORTED_WHEN_SCRIPTING, :feature do
875
+ _("The feature '%{feature}' is only available when compiling a catalog") % { feature: feature }
876
+ end
877
+
878
+ CATALOG_OPERATION_NOT_SUPPORTED_WHEN_SCRIPTING = issue :CATALOG_OPERATION_NOT_SUPPORTED_WHEN_SCRIPTING, :operation do
879
+ _("The catalog operation '%{operation}' is only available when compiling a catalog") % { operation: operation }
880
+ end
881
+
882
+ TASK_OPERATION_NOT_SUPPORTED_WHEN_COMPILING = issue :TASK_OPERATION_NOT_SUPPORTED_WHEN_COMPILING, :operation do
883
+ _("The task operation '%{operation}' is not available when compiling a catalog") % { operation: operation }
884
+ end
885
+
886
+ TASK_MISSING_BOLT = issue :TASK_MISSING_BOLT, :action do
887
+ _("The 'bolt' library is required to %{action}") % { action: action }
888
+ end
889
+
890
+ UNKNOWN_TASK = issue :UNKNOWN_TASK, :type_name do
891
+ _('Task not found: %{type_name}') % { type_name: type_name }
892
+ end
893
+
894
+ LOADER_FAILURE = issue :LOADER_FAILURE, :type do
895
+ _('Failed to load: %{type_name}') % { type: type }
896
+ end
865
897
  end
866
898
  end
@@ -20,6 +20,16 @@ class BaseLoader < Loader
20
20
  @last_result = nil # the value of the last name (optimization)
21
21
  end
22
22
 
23
+ def discover(type, error_collector = nil, name_authority = Pcore::RUNTIME_NAME_AUTHORITY, &block)
24
+ result = []
25
+ @named_values.each_pair do |key, entry|
26
+ result << key unless entry.nil? || entry.value.nil? || key.type != type || (block_given? && !yield(key))
27
+ end
28
+ result.concat(parent.discover(type, error_collector, name_authority, &block))
29
+ result.uniq!
30
+ result
31
+ end
32
+
23
33
  # @api public
24
34
  #
25
35
  def load_typed(typed_name)
@@ -23,6 +23,13 @@ class Puppet::Pops::Loader::DependencyLoader < Puppet::Pops::Loader::BaseLoader
23
23
  @dependency_loaders = dependency_loaders
24
24
  end
25
25
 
26
+ def discover(type, error_collector = nil, name_authority = Puppet::Pops::Pcore::RUNTIME_NAME_AUTHORITY, &block)
27
+ result = []
28
+ @dependency_loaders.each { |loader| result.concat(loader.discover(type, error_collector, name_authority, &block)) }
29
+ result.concat(super)
30
+ result
31
+ end
32
+
26
33
  # Finds name in a loader this loader depends on / can see
27
34
  #
28
35
  def find(typed_name)
@@ -29,13 +29,32 @@ class Loader
29
29
  attr_reader :loader_name
30
30
 
31
31
  # Describes the kinds of things that loaders can load
32
- LOADABLE_KINDS = [:func_4x, :func_4xpp, :type_pp, :resource_type_pp].freeze
32
+ LOADABLE_KINDS = [:func_4x, :func_4xpp, :datatype, :type_pp, :resource_type_pp, :plan, :task].freeze
33
33
 
34
34
  # @param [String] name the name of the loader. Must be unique among all loaders maintained by a {Loader} instance
35
35
  def initialize(loader_name)
36
36
  @loader_name = loader_name.freeze
37
37
  end
38
38
 
39
+ # Search all places where this loader would find values of a given type and return a list the
40
+ # found values for which the given block returns true. All found entries will be returned if no
41
+ # block is given.
42
+ #
43
+ # Errors that occur function discovery will either be logged as warnings or collected by the optional
44
+ # `error_collector` array. When provided, it will receive {Puppet::DataTypes::Error} instances describing
45
+ # each error in detail and no warnings will be logged.
46
+ #
47
+ # @param type [Symbol] the type of values to search for
48
+ # @param error_collector [Array<Puppet::DataTypes::Error>] an optional array that will receive errors during load
49
+ # @param name_authority [String] the name authority, defaults to the pcore runtime
50
+ # @yield [typed_name] optional block to filter the results
51
+ # @yieldparam [TypedName] typed_name the typed name of a found entry
52
+ # @yieldreturn [Boolean] `true` to keep the entry, `false` to discard it.
53
+ # @return [Array<TypedName>] the list of names of discovered values
54
+ def discover(type, error_collector = nil, name_authority = Pcore::RUNTIME_NAME_AUTHORITY, &block)
55
+ return EMPTY_ARRAY
56
+ end
57
+
39
58
  # Produces the value associated with the given name if already loaded, or available for loading
40
59
  # by this loader, one of its parents, or other loaders visible to this loader.
41
60
  # This is the method an external party should use to "get" the named element.
@@ -71,7 +90,7 @@ class Loader
71
90
  # of the given type/name.
72
91
  #
73
92
  # @param typed_name [TypedName] - the type, name combination to lookup
74
- # @param check_dependencies [Boolean] - if dependencies should be checked in additiona to here and parent
93
+ # @param check_dependencies [Boolean] - if dependencies should be checked in addition to here and parent
75
94
  # @return [NamedEntry, nil] the entry containing the loaded value, or nil if not found
76
95
  # @api public
77
96
  #
@@ -6,7 +6,10 @@
6
6
  #
7
7
  # TODO: Currently only supports loading of functions (2 kinds)
8
8
  #
9
- module Puppet::Pops::Loader::LoaderPaths
9
+ module Puppet::Pops
10
+ module Loader
11
+ module LoaderPaths
12
+
10
13
  # Returns an array of SmartPath, each instantiated with a reference to the given loader (for root path resolution
11
14
  # and existence checks). The smart paths in the array appear in precedence order. The returned array may be
12
15
  # mutated.
@@ -23,7 +26,12 @@ module Puppet::Pops::Loader::LoaderPaths
23
26
  result << FunctionPathPP.new(loader)
24
27
  end
25
28
  # When wanted also add FunctionPath3x to load 3x functions
29
+ when :plan
30
+ result << PlanPathPP.new(loader)
31
+ when :task
32
+ result << TaskPath.new(loader) if Puppet[:tasks] && loader.loadables.include?(:task)
26
33
  when :type
34
+ result << DataTypePath.new(loader) if loader.loadables.include?(:datatype)
27
35
  result << TypePathPP.new(loader) if loader.loadables.include?(:type_pp)
28
36
  when :resource_type_pp
29
37
  result << ResourceTypeImplPP.new(loader) if loader.loadables.include?(:resource_type_pp)
@@ -52,28 +60,58 @@ module Puppet::Pops::Loader::LoaderPaths
52
60
  @loader = loader
53
61
  end
54
62
 
55
- def generic_path()
63
+ def generic_path
56
64
  return @generic_path unless @generic_path.nil?
57
65
 
58
- the_root_path = root_path() # @loader.path
66
+ the_root_path = root_path # @loader.path
59
67
  @generic_path = (the_root_path.nil? ? relative_path : File.join(the_root_path, relative_path))
60
68
  end
61
69
 
70
+ def match_many?
71
+ false
72
+ end
73
+
62
74
  def root_path
63
75
  @loader.path
64
76
  end
65
77
 
78
+ def lib_root?
79
+ @loader.lib_root?
80
+ end
81
+
66
82
  # Effective path is the generic path + the name part(s) + extension.
67
83
  #
68
84
  def effective_path(typed_name, start_index_in_name)
69
85
  "#{File.join(generic_path, typed_name.name_parts)}#{extension}"
70
86
  end
71
87
 
72
- def relative_path()
88
+ def typed_name(type, name_authority, relative_path, module_name)
89
+ # Module name is assumed to be included in the path and therefore not added here
90
+ n = ''
91
+ unless extension.empty?
92
+ # Remove extension
93
+ relative_path = relative_path[0..-(extension.length+1)]
94
+ end
95
+ relative_path.split('/').each do |segment|
96
+ n << '::' if n.size > 0
97
+ n << segment
98
+ end
99
+ TypedName.new(type, n, name_authority)
100
+ end
101
+
102
+ def valid_path?(path)
103
+ path.end_with?(extension) && path.start_with?(generic_path)
104
+ end
105
+
106
+ def valid_name?(typed_name)
107
+ true
108
+ end
109
+
110
+ def relative_path
73
111
  raise NotImplementedError.new
74
112
  end
75
113
 
76
- def instantiator()
114
+ def instantiator
77
115
  raise NotImplementedError.new
78
116
  end
79
117
  end
@@ -101,10 +139,6 @@ module Puppet::Pops::Loader::LoaderPaths
101
139
  EXTENSION
102
140
  end
103
141
 
104
- def root_path
105
- Puppet::FileSystem.dir_string(@loader.path)
106
- end
107
-
108
142
  # Duplication of extension information, but avoids one call
109
143
  def effective_path(typed_name, start_index_in_name)
110
144
  # Puppet name to path always skips the name-space as that is part of the generic path
@@ -114,61 +148,144 @@ module Puppet::Pops::Loader::LoaderPaths
114
148
  return nil if start_index_in_name >= parts.size
115
149
  parts = parts[start_index_in_name..-1]
116
150
  end
117
- "#{File.join(generic_path, parts)}.pp"
151
+ "#{File.join(generic_path, parts)}#{extension}"
152
+ end
153
+
154
+ def typed_name(type, name_authority, relative_path, module_name)
155
+ n = ''
156
+ n << module_name unless module_name.nil?
157
+ unless extension.empty?
158
+ # Remove extension
159
+ relative_path = relative_path[0..-(extension.length+1)]
160
+ end
161
+ relative_path.split('/').each do |segment|
162
+ n << '::' if n.size > 0
163
+ n << segment
164
+ end
165
+ TypedName.new(type, n, name_authority)
118
166
  end
119
167
  end
120
168
 
121
169
  class FunctionPath4x < RubySmartPath
122
- FUNCTION_PATH_4X = File.join('puppet', 'functions')
170
+ SYSTEM_FUNCTION_PATH_4X = File.join('puppet', 'functions').freeze
171
+ FUNCTION_PATH_4X = File.join('lib', SYSTEM_FUNCTION_PATH_4X).freeze
123
172
 
124
173
  def relative_path
125
- FUNCTION_PATH_4X
174
+ lib_root? ? SYSTEM_FUNCTION_PATH_4X : FUNCTION_PATH_4X
126
175
  end
127
176
 
128
- def instantiator()
129
- Puppet::Pops::Loader::RubyFunctionInstantiator
177
+ def instantiator
178
+ RubyFunctionInstantiator
130
179
  end
131
180
  end
132
181
 
133
182
  class FunctionPath3x < RubySmartPath
134
- FUNCTION_PATH_3X = File.join('puppet', 'parser', 'functions')
183
+ SYSTEM_FUNCTION_PATH_3X = File.join('puppet', 'parser', 'functions').freeze
184
+ FUNCTION_PATH_3X = File.join('lib', SYSTEM_FUNCTION_PATH_3X).freeze
135
185
 
136
186
  def relative_path
137
- FUNCTION_PATH_3X
187
+ lib_root? ? SYSTEM_FUNCTION_PATH_3X : FUNCTION_PATH_3X
138
188
  end
139
189
 
140
- def instantiator()
141
- Puppet::Pops::Loader::RubyLegacyFunctionInstantiator
190
+ def instantiator
191
+ RubyLegacyFunctionInstantiator
142
192
  end
143
193
  end
144
194
 
145
195
  class FunctionPathPP < PuppetSmartPath
146
- # Navigate to directory where 'lib' is, then down again
147
- FUNCTION_PATH_PP = File.join('functions')
196
+ FUNCTION_PATH_PP = 'functions'.freeze
148
197
 
149
198
  def relative_path
150
199
  FUNCTION_PATH_PP
151
200
  end
152
201
 
153
- def instantiator()
154
- Puppet::Pops::Loader::PuppetFunctionInstantiator
202
+ def instantiator
203
+ PuppetFunctionInstantiator
204
+ end
205
+ end
206
+
207
+ class DataTypePath < RubySmartPath
208
+ SYSTEM_TYPE_PATH = File.join('puppet', 'datatypes').freeze
209
+ TYPE_PATH = File.join('lib', SYSTEM_TYPE_PATH).freeze
210
+
211
+ def relative_path
212
+ lib_root? ? SYSTEM_TYPE_PATH : TYPE_PATH
213
+ end
214
+
215
+ def instantiator
216
+ RubyDataTypeInstantiator
155
217
  end
156
218
  end
157
219
 
158
220
  class TypePathPP < PuppetSmartPath
159
- TYPE_PATH_PP = File.join('types')
221
+ TYPE_PATH_PP = 'types'.freeze
160
222
 
161
223
  def relative_path
162
224
  TYPE_PATH_PP
163
225
  end
164
226
 
165
- def instantiator()
166
- Puppet::Pops::Loader::TypeDefinitionInstantiator
227
+ def instantiator
228
+ TypeDefinitionInstantiator
229
+ end
230
+ end
231
+
232
+ # TaskPath is like PuppetSmartPath but it does not use an extension and may
233
+ # match more than one path with one name
234
+ class TaskPath < PuppetSmartPath
235
+ TASKS_PATH = 'tasks'.freeze
236
+ FORBIDDEN_EXTENSIONS = %w{.conf .md}.freeze
237
+
238
+ def extension
239
+ EMPTY_STRING
240
+ end
241
+
242
+ def match_many?
243
+ true
244
+ end
245
+
246
+ def relative_path
247
+ TASKS_PATH
248
+ end
249
+
250
+ def typed_name(type, name_authority, relative_path, module_name)
251
+ n = ''
252
+ n << module_name unless module_name.nil?
253
+
254
+ # Remove the file extension, defined as everything after the *last* dot.
255
+ relative_path = relative_path.sub(%r{\.[^/.]*\z}, '')
256
+
257
+ if relative_path == 'init' && !(module_name.nil? || module_name.empty?)
258
+ TypedName.new(type, module_name, name_authority)
259
+ else
260
+ relative_path.split('/').each do |segment|
261
+ n << '::' if n.size > 0
262
+ n << segment
263
+ end
264
+ TypedName.new(type, n, name_authority)
265
+ end
266
+ end
267
+
268
+ def instantiator
269
+ require_relative 'task_instantiator'
270
+ TaskInstantiator
271
+ end
272
+
273
+ def valid_name?(typed_name)
274
+ # TODO: Remove when PE has proper namespace handling
275
+ typed_name.name_parts.size <= 2
276
+ end
277
+
278
+ def valid_path?(path)
279
+ path.start_with?(generic_path) && is_task_name?(File.basename(path, '.*')) && !FORBIDDEN_EXTENSIONS.any? { |ext| path.end_with?(ext) }
280
+ end
281
+
282
+ def is_task_name?(name)
283
+ !!(name =~ /^[a-z][a-z0-9_]*$/)
167
284
  end
168
285
  end
169
286
 
170
287
  class ResourceTypeImplPP < PuppetSmartPath
171
- RESOURCE_TYPES_PATH_PP = File.join('.resource_types')
288
+ RESOURCE_TYPES_PATH_PP = '.resource_types'.freeze
172
289
 
173
290
  def relative_path
174
291
  RESOURCE_TYPES_PATH_PP
@@ -178,8 +295,8 @@ module Puppet::Pops::Loader::LoaderPaths
178
295
  @loader.path
179
296
  end
180
297
 
181
- def instantiator()
182
- Puppet::Pops::Loader::PuppetResourceTypeImplInstantiator
298
+ def instantiator
299
+ PuppetResourceTypeImplInstantiator
183
300
  end
184
301
 
185
302
  # The effect paths for resource type impl is the full name
@@ -188,11 +305,41 @@ module Puppet::Pops::Loader::LoaderPaths
188
305
  #
189
306
  def effective_path(typed_name, start_index_in_name)
190
307
  # Resource type to name does not skip the name-space
191
- # i.e. <module>/mymodule/resource_types/foo.pp is the reource type foo
308
+ # i.e. <module>/mymodule/resource_types/foo.pp is the resource type foo
192
309
  "#{File.join(generic_path, typed_name.name_parts)}.pp"
193
310
  end
194
311
  end
195
312
 
313
+ class PlanPathPP < PuppetSmartPath
314
+ PLAN_PATH_PP = File.join('plans')
315
+
316
+ def relative_path
317
+ PLAN_PATH_PP
318
+ end
319
+
320
+ def instantiator()
321
+ Puppet::Pops::Loader::PuppetPlanInstantiator
322
+ end
323
+
324
+ def typed_name(type, name_authority, relative_path, module_name)
325
+ if relative_path == 'init.pp' && !(module_name.nil? || module_name.empty?)
326
+ TypedName.new(type, module_name, name_authority)
327
+ else
328
+ n = ''
329
+ n << module_name unless module_name.nil?
330
+ unless extension.empty?
331
+ # Remove extension
332
+ relative_path = relative_path[0..-(extension.length+1)]
333
+ end
334
+ relative_path.split('/').each do |segment|
335
+ n << '::' if n.size > 0
336
+ n << segment
337
+ end
338
+ TypedName.new(type, n, name_authority)
339
+ end
340
+ end
341
+ end
342
+
196
343
  # SmartPaths
197
344
  # ===
198
345
  # Holds effective SmartPath instances per type
@@ -215,7 +362,7 @@ module Puppet::Pops::Loader::LoaderPaths
215
362
  unless effective_paths = smart_paths[type]
216
363
  # type not yet processed, does the various directories for the type exist ?
217
364
  # Get the relative dirs for the type
218
- paths_for_type = Puppet::Pops::Loader::LoaderPaths.relative_paths_for_type(type, loader)
365
+ paths_for_type = LoaderPaths.relative_paths_for_type(type, loader)
219
366
  # Check which directories exist in the loader's content/index
220
367
  effective_paths = smart_paths[type] = paths_for_type.select { |sp| loader.meaningful_to_search?(sp) }
221
368
  end
@@ -223,3 +370,6 @@ module Puppet::Pops::Loader::LoaderPaths
223
370
  end
224
371
  end
225
372
  end
373
+ end
374
+ end
375
+