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
data/lib/puppet/parser.rb CHANGED
@@ -2,6 +2,7 @@
2
2
  module Puppet::Parser; end
3
3
 
4
4
  require 'puppet/parser/ast'
5
+ require 'puppet/parser/abstract_compiler'
5
6
  require 'puppet/parser/compiler'
6
7
  require 'puppet/parser/compiler/catalog_validator'
7
8
  require 'puppet/resource/type_collection'
@@ -0,0 +1,36 @@
1
+
2
+ module Puppet::Parser::AbstractCompiler
3
+
4
+ # Returns the catalog for a compilation. Must return a Puppet::Resource::Catalog or fail with an
5
+ # error if the specific compiler does not support catalog operations.
6
+ #
7
+ def catalog
8
+ raise Puppet::DevError("Class '#{self.class}' should have implemented 'catalog'")
9
+ end
10
+
11
+ # Returns the environment for the compilation
12
+ #
13
+ def environment
14
+ raise Puppet::DevError("Class '#{self.class}' should have implemented 'environment'")
15
+ end
16
+
17
+ # Produces a new scope
18
+ # This method is here if there are functions/logic that will call this for some other purpose than to create
19
+ # a named scope for a class. It may not have to be here. (TODO)
20
+ #
21
+ def newscope(scope, options)
22
+ raise Puppet::DevError("Class '#{self.class}' should have implemented 'newscope'")
23
+ end
24
+
25
+ # Returns a hash of all externally referenceable qualified variables
26
+ #
27
+ def qualified_variables
28
+ raise Puppet::DevError("Class '#{self.class}' should have implemented 'qualified_variables'")
29
+ end
30
+
31
+ # Returns the top scope instance
32
+ def topscope
33
+ raise Puppet::DevError("Class '#{self.class}' should have implemented 'topscope'")
34
+ end
35
+
36
+ end
@@ -1,7 +1,7 @@
1
1
  # The parent class of all AST objects that contain other AST objects.
2
2
  # Everything but the really simple objects descend from this. It is
3
3
  # important to note that Branch objects contain other AST objects only --
4
- # if you want to contain values, use a descendent of the AST::Leaf class.
4
+ # if you want to contain values, use a descendant of the AST::Leaf class.
5
5
  #
6
6
  # @api private
7
7
  class Puppet::Parser::AST::Branch < Puppet::Parser::AST
@@ -95,7 +95,8 @@ class Puppet::Parser::AST::PopsBridge
95
95
  # efficient as it avoids one full scan of all logic via recursive enumeration/yield)
96
96
  #
97
97
  def instantiate(modname)
98
- @program_model.definitions.collect do |d|
98
+
99
+ @program_model.definitions.map do |d|
99
100
  case d
100
101
  when Puppet::Pops::Model::HostClassDefinition
101
102
  instantiate_HostClassDefinition(d, modname)
@@ -107,25 +108,17 @@ class Puppet::Parser::AST::PopsBridge
107
108
  instantiate_NodeDefinition(d, modname)
108
109
  when Puppet::Pops::Model::SiteDefinition
109
110
  instantiate_SiteDefinition(d, modname)
110
- when Puppet::Pops::Model::FunctionDefinition
111
- # The 3x logic calling this will not know what to do with the result, it is compacted away at the end
112
- instantiate_FunctionDefinition(d, modname)
113
- next
114
- when Puppet::Pops::Model::TypeAlias
115
- # The 3x logic calling this will not know what to do with the result, it is compacted away at the end
116
- instantiate_TypeAlias(d, modname)
117
- next
118
- when Puppet::Pops::Model::TypeMapping
119
- # The 3x logic calling this will not know what to do with the result, it is compacted away at the end
120
- instantiate_TypeMapping(d, modname)
121
- next
122
111
  when Puppet::Pops::Model::Application
123
112
  instantiate_ApplicationDefinition(d, modname)
124
113
  else
125
- raise Puppet::ParseError, _("Internal Error: Unknown type of definition - got '%{name}'") % { name: d.class }
114
+ loaders = Puppet::Pops::Loaders.loaders
115
+ loaders.instantiate_definition(d, loaders.find_loader(modname))
116
+
117
+ # The 3x logic calling this will not know what to do with the result, it is compacted away at the end
118
+ nil
126
119
  end
127
120
  end.flatten().compact() # flatten since node definition may have returned an array
128
- # Compact since functions are not understood by compiler
121
+ # Compact since 4x definitions are not understood by compiler
129
122
  end
130
123
 
131
124
  def evaluate(scope)
@@ -261,43 +254,6 @@ class Puppet::Parser::AST::PopsBridge
261
254
  Puppet::Resource::Type.new(:site, 'site', @context.merge(args))
262
255
  end
263
256
 
264
- # Propagates a found Function to the appropriate loader.
265
- # This is for 4x evaluator/loader
266
- #
267
- def instantiate_FunctionDefinition(function_definition, modname)
268
- loader = Puppet::Pops::Loaders.find_loader(modname)
269
-
270
- # Instantiate Function, and store it in the loader
271
- typed_name, f = Puppet::Pops::Loader::PuppetFunctionInstantiator.create_from_model(function_definition, loader)
272
- loader.set_entry(typed_name, f, function_definition.locator.to_uri(function_definition))
273
-
274
- nil # do not want the function to inadvertently leak into 3x
275
- end
276
-
277
- # Propagates a found TypeAlias to the appropriate loader.
278
- # This is for 4x evaluator/loader
279
- #
280
- def instantiate_TypeAlias(type_alias, modname)
281
- loader = Puppet::Pops::Loaders.find_loader(modname)
282
-
283
- # Bind the type alias to the loader using the alias
284
- Puppet::Pops::Loader::TypeDefinitionInstantiator.create_from_model(type_alias, loader)
285
-
286
- nil # do not want the type alias to inadvertently leak into 3x
287
- end
288
-
289
- # Adds the TypeMapping to the ImplementationRegistry
290
- # This is for 4x evaluator/loader
291
- #
292
- def instantiate_TypeMapping(type_mapping, modname)
293
- loader = Puppet::Pops::Loaders.find_loader(modname)
294
- tf = Puppet::Pops::Types::TypeParser.singleton
295
- lhs = tf.interpret(type_mapping.type_expr, loader)
296
- rhs = tf.interpret_any(type_mapping.mapping_expr, loader)
297
- Puppet::Pops::Loaders.implementation_registry.register_type_mapping(lhs, rhs, loader)
298
- nil
299
- end
300
-
301
257
  def code()
302
258
  Expression.new(:value => @value)
303
259
  end
@@ -10,6 +10,8 @@ require 'puppet/pops'
10
10
  # Maintain a graph of scopes, along with a bunch of data
11
11
  # about the individual catalog we're compiling.
12
12
  class Puppet::Parser::Compiler
13
+ include Puppet::Parser::AbstractCompiler
14
+
13
15
  extend Forwardable
14
16
 
15
17
  include Puppet::Util
@@ -719,6 +721,7 @@ class Puppet::Parser::Compiler
719
721
  Puppet.override( @context_overrides , _("For initializing compiler")) do
720
722
  # THE MAGIC STARTS HERE ! This triggers parsing, loading etc.
721
723
  @catalog.version = environment.known_resource_types.version
724
+ @loaders.pre_load
722
725
  end
723
726
 
724
727
  @catalog.add_resource(Puppet::Parser::Resource.new("stage", :main, :scope => @topscope))
@@ -737,69 +740,16 @@ class Puppet::Parser::Compiler
737
740
  end
738
741
 
739
742
  def sanitize_node(node)
740
- # Resurrect "trusted information" that comes from node/fact terminus.
741
- # The current way this is done in puppet db (currently the only one)
742
- # is to store the node parameter 'trusted' as a hash of the trusted information.
743
- #
744
- # Thus here there are two main cases:
745
- # 1. This terminus was used in a real agent call (only meaningful if someone curls the request as it would
746
- # fail since the result is a hash of two catalogs).
747
- # 2 It is a command line call with a given node that use a terminus that:
748
- # 2.1 does not include a 'trusted' fact - use local from node trusted information
749
- # 2.2 has a 'trusted' fact - this in turn could be
750
- # 2.2.1 puppet db having stored trusted node data as a fact (not a great design)
751
- # 2.2.2 some other terminus having stored a fact called "trusted" (most likely that would have failed earlier, but could
752
- # be spoofed).
753
- #
754
- # For the reasons above, the resurrection of trusted node data with authenticated => true is only performed
755
- # if user is running as root, else it is resurrected as unauthenticated.
756
- #
757
- trusted_param = node.parameters['trusted']
758
- if trusted_param
759
- # Blows up if it is a parameter as it will be set as $trusted by the compiler as if it was a variable
760
- node.parameters.delete('trusted')
761
- unless trusted_param.is_a?(Hash) && %w{authenticated certname extensions}.all? {|key| trusted_param.has_key?(key) }
762
- # trusted is some kind of garbage, do not resurrect
763
- trusted_param = nil
764
- end
765
- else
766
- # trusted may be Boolean false if set as a fact by someone
767
- trusted_param = nil
768
- end
769
-
770
- # The options for node.trusted_data in priority order are:
771
- # 1) node came with trusted_data so use that
772
- # 2) else if there is :trusted_information in the puppet context
773
- # 3) else if the node provided a 'trusted' parameter (parsed out above)
774
- # 4) last, fallback to local node trusted information
775
- #
776
- # Note that trusted_data should be a hash, but (2) and (4) are not
777
- # hashes, so we to_h at the end
778
- if !node.trusted_data
779
- trusted = Puppet.lookup(:trusted_information) do
780
- trusted_param || Puppet::Context::TrustedInformation.local(node)
781
- end
782
-
783
- # Ruby 1.9.3 can't apply to_h to a hash, so check first
784
- node.trusted_data = trusted.is_a?(Hash) ? trusted : trusted.to_h
785
- end
786
-
743
+ node.sanitize
787
744
  node
788
745
  end
789
746
 
790
747
  # Set the node's parameters into the top-scope as variables.
791
748
  def set_node_parameters
792
749
  node.parameters.each do |param, value|
793
- # We don't want to set @topscope['environment'] from the parameters,
794
- # instead we want to get that from the node's environment itself in
795
- # case a custom node terminus has done any mucking about with
796
- # node.parameters.
797
- next if param.to_s == 'environment'
798
750
  # Ensure node does not leak Symbol instances in general
799
751
  @topscope[param.to_s] = value.is_a?(Symbol) ? value.to_s : value
800
752
  end
801
- @topscope['environment'] = node.environment.name.to_s
802
-
803
753
  # These might be nil.
804
754
  catalog.client_version = node.parameters["clientversion"]
805
755
  catalog.server_version = node.parameters["serverversion"]
@@ -198,7 +198,6 @@ module Puppet::Parser::Functions
198
198
  def self.function(name, environment = Puppet.lookup(:current_environment))
199
199
  name = name.intern
200
200
 
201
- func = nil
202
201
  unless func = get_function(name, environment)
203
202
  autoloader.load(name, environment)
204
203
  func = get_function(name, environment)
@@ -47,6 +47,12 @@ Puppet::Parser::Functions::newfunction(:create_resources, :arity => -3, :doc =>
47
47
  final value of a parameter (just as when setting a parameter to `undef` in a puppet language
48
48
  resource declaration).
49
49
  ENDHEREDOC
50
+ if Puppet[:tasks]
51
+ raise Puppet::ParseErrorWithIssue.from_issue_and_stack(
52
+ Puppet::Pops::Issues::CATALOG_OPERATION_NOT_SUPPORTED_WHEN_SCRIPTING,
53
+ {:operation => 'create_resources'})
54
+ end
55
+
50
56
  raise ArgumentError, (_("create_resources(): wrong number of arguments (%{count}; must be 2 or 3)") % { count: args.length }) if args.length > 3
51
57
  raise ArgumentError, (_('create_resources(): second argument must be a hash')) unless args[1].is_a?(Hash)
52
58
  if args.length == 3
@@ -1,4 +1,4 @@
1
- require 'digest/md5'
1
+ require 'digest/sha2'
2
2
 
3
3
  Puppet::Parser::Functions::newfunction(:fqdn_rand, :arity => -2, :type => :rvalue, :doc =>
4
4
  "Usage: `fqdn_rand(MAX, [SEED])`. MAX is required and must be a positive
@@ -16,6 +16,10 @@ Puppet::Parser::Functions::newfunction(:fqdn_rand, :arity => -2, :type => :rvalu
16
16
  node. (For example, `fqdn_rand(30)`, `fqdn_rand(30, 'expensive job 1')`, and
17
17
  `fqdn_rand(30, 'expensive job 2')` will produce totally different numbers.)") do |args|
18
18
  max = args.shift.to_i
19
- seed = Digest::MD5.hexdigest([self['::fqdn'],max,args].join(':')).hex
19
+
20
+ # We are consciously not using different hash algs based on fips mode here
21
+ # since the randomness is not guaranteed to be predictable for a given node
22
+ # It just needs to be unique for a given node
23
+ seed = Digest::SHA256.hexdigest([self['::fqdn'],max,args].join(':')).hex
20
24
  Puppet::Util.deterministic_rand_int(seed,max)
21
25
  end
@@ -4,6 +4,12 @@ Puppet::Parser::Functions::newfunction(:inline_template, :type => :rvalue, :arit
4
4
  more information. Note that if multiple template strings are specified, their
5
5
  output is all concatenated and returned as the output of the function.") do |vals|
6
6
 
7
+ if Puppet[:tasks]
8
+ raise Puppet::ParseErrorWithIssue.from_issue_and_stack(
9
+ Puppet::Pops::Issues::FEATURE_NOT_SUPPORTED_WHEN_SCRIPTING,
10
+ {:feature => 'ERB inline_template'})
11
+ end
12
+
7
13
  require 'erb'
8
14
 
9
15
  vals.collect do |string|
@@ -56,14 +56,16 @@ Would fail with an assertion error (since value is less than 0).
56
56
  The following sections show the arguments and conversion rules
57
57
  per data type built into the Puppet Type System.
58
58
 
59
- ### Conversion to Optional[T] and NotUndef[T]
59
+ Conversion to Optional[T] and NotUndef[T]
60
+ -----------------------------------------
60
61
 
61
62
  Conversion to these data types is the same as a conversion to the type argument `T`.
62
63
  In the case of `Optional[T]` it is accepted that the argument to convert may be `undef`.
63
64
  It is however not acceptable to give other arguments (than `undef`) that cannot be
64
65
  converted to `T`.
65
66
 
66
- ### Conversion to Integer
67
+ Conversion to Integer
68
+ ---------------------
67
69
 
68
70
  A new `Integer` can be created from `Integer`, `Float`, `Boolean`, and `String` values.
69
71
  For conversion from `String` it is possible to specify the radix (base).
@@ -111,7 +113,8 @@ $a_number = Integer(true) # results in 1
111
113
  $a_number = Integer(-38, 10, true) # results in 38
112
114
  ```
113
115
 
114
- ### Conversion to Float
116
+ Conversion to Float
117
+ -------------------
115
118
 
116
119
  A new `Float` can be created from `Integer`, `Float`, `Boolean`, and `String` values.
117
120
  For conversion from `String` both float and integer formats are supported.
@@ -123,13 +126,15 @@ function Float.new(
123
126
  )
124
127
  ```
125
128
 
129
+
126
130
  * For an integer, the floating point fraction of `.0` is added to the value.
127
131
  * A `Boolean` `true` is converted to 1.0, and a `false` to 0.0
128
132
  * In `String` format, integer prefixes for hex and binary are understood (but not octal since
129
133
  floating point in string format may start with a '0').
130
134
  * When `abs` is set to `true`, the result will be an absolute floating point value.
131
135
 
132
- ### Conversion to Numeric
136
+ Conversion to Numeric
137
+ ---------------------
133
138
 
134
139
  A new `Integer` or `Float` can be created from `Integer`, `Float`, `Boolean` and
135
140
  `String` values.
@@ -158,7 +163,8 @@ $a_number = Numeric(-42.3, true) # results in 42.3
158
163
  $a_number = Numeric(-42, true) # results in 42
159
164
  ```
160
165
 
161
- ### Conversion to Timespan
166
+ Conversion to Timespan
167
+ -------------------
162
168
 
163
169
  A new `Timespan` can be created from `Integer`, `Float`, `String`, and `Hash` values. Several variants of the constructor are provided.
164
170
 
@@ -172,7 +178,7 @@ function Timespan.new(
172
178
  )
173
179
  ```
174
180
 
175
- #### Timespan from days, hours, mintues, seconds, and fractions of a second
181
+ #### Timespan from days, hours, minutes, seconds, and fractions of a second
176
182
 
177
183
  The arguments can be passed separately in which case the first four, days, hours, minutes, and seconds are mandatory and the rest are optional.
178
184
  All values may overflow and/or be negative. The internal 128-bit nano-second integer is calculated as:
@@ -275,7 +281,8 @@ $duration = Timespan('10:03.5', '%M:%S.%L') # 10 minutes, 3 seconds, and 5 milli
275
281
  $duration = Timespan('10:03.5', '%M:%S.%N') # 10 minutes, 3 seconds, and 5 nano-seconds
276
282
  ```
277
283
 
278
- ### Conversion to Timestamp
284
+ Conversion to Timestamp
285
+ -------------------
279
286
 
280
287
  A new `Timestamp` can be created from `Integer`, `Float`, `String`, and `Hash` values. Several variants of the constructor are provided.
281
288
 
@@ -468,8 +475,8 @@ $ts = Timestamp('2016-08-24T12:13:14', default, 'PST') # 2016-08-24 20:13:14.0
468
475
 
469
476
  ```
470
477
 
471
- ### Conversion to Type
472
-
478
+ Conversion to Type
479
+ ------------------
473
480
  A new `Type` can be create from its `String` representation.
474
481
 
475
482
  **Example:** Creating a type from a string
@@ -478,7 +485,8 @@ A new `Type` can be create from its `String` representation.
478
485
  $t = Type.new('Integer[10]')
479
486
  ```
480
487
 
481
- ### Conversion to String
488
+ Conversion to String
489
+ --------------------
482
490
 
483
491
  Conversion to `String` is the most comprehensive conversion as there are many
484
492
  use cases where a string representation is wanted. The defaults for the many options
@@ -521,7 +529,7 @@ included in a string format.
521
529
  Note that all data type supports the formats `s` and `p` with the meaning "default string representation" and
522
530
  "default programmatic string representation" (which for example means that a String is quoted in 'p' format).
523
531
 
524
- #### Signatures of String conversion
532
+ ### Signatures of String conversion
525
533
 
526
534
  ```puppet
527
535
  type Format = Pattern[/^%([\s\+\-#0\[\{<\(\|]*)([1-9][0-9]*)?(?:\.([0-9]+))?([a-zA-Z])/]
@@ -579,7 +587,7 @@ $str = String([1,2,3], $formats) # produces '(0x1, 0x2, 0x3)'
579
587
  The given formats are merged with the default formats, and matching of values to convert against format is based on
580
588
  the specificity of the mapped type; for example, different formats can be used for short and long arrays.
581
589
 
582
- #### Integer to String
590
+ ### Integer to String
583
591
 
584
592
  | Format | Integer Formats
585
593
  | ------ | ---------------
@@ -594,7 +602,7 @@ the specificity of the mapped type; for example, different formats can be used f
594
602
 
595
603
  Defaults to `d`.
596
604
 
597
- #### Float to String
605
+ ### Float to String
598
606
 
599
607
  | Format | Float formats
600
608
  | ------ | -------------
@@ -608,7 +616,7 @@ Defaults to `d`.
608
616
 
609
617
  Defaults to `p`.
610
618
 
611
- #### String to String
619
+ ### String to String
612
620
 
613
621
  | Format | String
614
622
  | ------ | ------
@@ -622,7 +630,7 @@ Defaults to `p`.
622
630
 
623
631
  Defaults to `s` at top level and `p` inside array or hash.
624
632
 
625
- #### Boolean to String
633
+ ### Boolean to String
626
634
 
627
635
  | Format | Boolean Formats
628
636
  | ---- | -------------------
@@ -633,14 +641,14 @@ Defaults to `s` at top level and `p` inside array or hash.
633
641
  | s | String 'true' / 'false'.
634
642
  | p | String 'true' / 'false'.
635
643
 
636
- #### Regexp to String
644
+ ### Regexp to String
637
645
 
638
646
  | Format | Regexp Formats
639
647
  | ---- | --------------
640
648
  | s | No delimiters, quoted if alternative flag `#` is used.
641
649
  | p | Delimiters `/ /`.
642
650
 
643
- #### Undef to String
651
+ ### Undef to String
644
652
 
645
653
  | Format | Undef formats
646
654
  | ------ | -------------
@@ -653,7 +661,7 @@ Defaults to `s` at top level and `p` inside array or hash.
653
661
  | V | String 'N/A'.
654
662
  | u | String 'undef', or 'undefined' if alternative `#` flag is used.
655
663
 
656
- #### Default value to String
664
+ ### Default value to String
657
665
 
658
666
  | Format | Default formats
659
667
  | ------ | ---------------
@@ -661,7 +669,7 @@ Defaults to `s` at top level and `p` inside array or hash.
661
669
  | s | Same as d.
662
670
  | p | Same as d.
663
671
 
664
- #### Binary value to String
672
+ ### Binary value to String
665
673
 
666
674
  | Format | Default formats
667
675
  | ------ | ---------------
@@ -678,7 +686,7 @@ Defaults to `s` at top level and `p` inside array or hash.
678
686
  as hex escaped characters on the form `\\xHH` where `H` is a hex digit.
679
687
  * The width and precision values are applied to the text part only in `%p` format.
680
688
 
681
- #### Array & Tuple to String
689
+ ### Array & Tuple to String
682
690
 
683
691
  | Format | Array/Tuple Formats
684
692
  | ------ | -------------
@@ -693,7 +701,7 @@ The alternate form flag `#` will cause indentation of nested array or hash conta
693
701
  it is taken as the maximum allowed length of a sequence of elements (not including delimiters). If this max length
694
702
  is exceeded, each element will be indented.
695
703
 
696
- #### Hash & Struct to String
704
+ ### Hash & Struct to String
697
705
 
698
706
  | Format | Hash/Struct Formats
699
707
  | ------ | -------------
@@ -707,14 +715,14 @@ more information about options.
707
715
 
708
716
  The alternate form flag `#` will format each hash key/value entry indented on a separate line.
709
717
 
710
- #### Type to String
718
+ ### Type to String
711
719
 
712
720
  | Format | Array/Tuple Formats
713
721
  | ------ | -------------
714
722
  | s | The same as `p`, quoted if alternative flag `#` is used.
715
723
  | p | Outputs the type in string form as specified by the Puppet Language.
716
724
 
717
- #### Flags
725
+ ### Flags
718
726
 
719
727
  | Flag | Effect
720
728
  | ------ | ------
@@ -725,7 +733,8 @@ The alternate form flag `#` will format each hash key/value entry indented on a
725
733
  | 0 | Pad with 0 instead of space for widths larger than value.
726
734
  | <[({\| | Defines an enclosing pair <> [] () {} or \| \| when used with a container type.
727
735
 
728
- ### Conversion to Boolean
736
+ Conversion to Boolean
737
+ ---
729
738
 
730
739
  Accepts a single value as argument:
731
740
 
@@ -736,7 +745,8 @@ Accepts a single value as argument:
736
745
  * `false` if 'false', 'no', 'n' (case independent compare)
737
746
  * Boolean is already boolean and is simply returned
738
747
 
739
- ### Conversion to Array and Tuple
748
+ Conversion to Array and Tuple
749
+ ---
740
750
 
741
751
  When given a single value as argument:
742
752
 
@@ -761,7 +771,8 @@ $arr = Array($value, true)
761
771
  Conversion to a `Tuple` works exactly as conversion to an `Array`, only that the constructed array is
762
772
  asserted against the given tuple type.
763
773
 
764
- ### Conversion to Hash and Struct
774
+ Conversion to Hash and Struct
775
+ ---
765
776
 
766
777
  Accepts a single value as argument:
767
778
 
@@ -800,8 +811,8 @@ Would notice the hash `{a => {b => {x => wine}}, b => {y => wine}}`
800
811
  Conversion to a `Struct` works exactly as conversion to a `Hash`, only that the constructed hash is
801
812
  asserted against the given struct type.
802
813
 
803
- ### Conversion to a Regexp
804
-
814
+ Conversion to a Regexp
815
+ ---
805
816
  A `String` can be converted into a `Regexp`
806
817
 
807
818
  **Example**: Converting a String into a Regexp
@@ -813,7 +824,8 @@ if('foo.com' =~ $r) {
813
824
  }
814
825
  ```
815
826
 
816
- ### Creating a SemVer
827
+ Creating a SemVer
828
+ ---
817
829
 
818
830
  A SemVer object represents a single [Semantic Version](http://semver.org/).
819
831
  It can be created from a String, individual values for its parts, or a hash specifying the value per part.
@@ -862,7 +874,8 @@ notice(SemVer('2.3.4') =~ $t) # false
862
874
  notice(SemVer('3.4.5') =~ $t) # true
863
875
  ```
864
876
 
865
- ### Creating a SemVerRange
877
+ Creating a SemVerRange
878
+ ---
866
879
 
867
880
  A `SemVerRange` object represents a range of `SemVer`. It can be created from
868
881
  a `String`, or from two `SemVer` instances, where either end can be given as
@@ -896,9 +909,10 @@ function SemVerRange.new(
896
909
  )
897
910
  ```
898
911
 
899
- For examples of `SemVerRange` use, see "Creating a SemVer".
912
+ For examples of `SemVerRange` use see "Creating a SemVer"
900
913
 
901
- ### Creating a Binary
914
+ Creating a Binary
915
+ ---
902
916
 
903
917
  A `Binary` object represents a sequence of bytes and it can be created from a String in Base64 format,
904
918
  an Array containing byte values. A Binary can also be created from a Hash containing the value to convert to
@@ -918,6 +932,7 @@ function Binary.new(
918
932
  Optional[Base64Format] $format
919
933
  )
920
934
 
935
+
921
936
  function Binary.new(
922
937
  Array[ByteInteger] $byte_array
923
938
  }