puppet 4.8.2-universal-darwin → 4.9.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 (348) hide show
  1. checksums.yaml +15 -0
  2. data/CONTRIBUTING.md +25 -1
  3. data/Gemfile +6 -0
  4. data/Rakefile +1 -0
  5. data/ext/project_data.yaml +5 -1
  6. data/ext/windows/service/daemon.rb +2 -1
  7. data/install.rb +43 -6
  8. data/lib/hiera/puppet_function.rb +15 -17
  9. data/lib/hiera/scope.rb +12 -14
  10. data/lib/puppet/application/face_base.rb +4 -0
  11. data/lib/puppet/application/lookup.rb +4 -2
  12. data/lib/puppet/application/resource.rb +1 -1
  13. data/lib/puppet/data_providers/data_adapter.rb +6 -0
  14. data/lib/puppet/data_providers/data_function_support.rb +7 -0
  15. data/lib/puppet/data_providers/function_env_data_provider.rb +7 -0
  16. data/lib/puppet/data_providers/function_module_data_provider.rb +6 -0
  17. data/lib/puppet/data_providers/hiera_config.rb +31 -10
  18. data/lib/puppet/data_providers/hiera_env_data_provider.rb +6 -0
  19. data/lib/puppet/data_providers/hiera_interpolate.rb +2 -1
  20. data/lib/puppet/data_providers/hiera_module_data_provider.rb +6 -0
  21. data/lib/puppet/data_providers/hiera_support.rb +6 -0
  22. data/lib/puppet/data_providers/json_data_provider_factory.rb +12 -0
  23. data/lib/puppet/data_providers/yaml_data_provider_factory.rb +12 -0
  24. data/lib/puppet/data_providers.rb +6 -3
  25. data/lib/puppet/defaults.rb +25 -4
  26. data/lib/puppet/face/ca.rb +2 -0
  27. data/lib/puppet/face/certificate_request.rb +2 -0
  28. data/lib/puppet/face/certificate_revocation_list.rb +2 -0
  29. data/lib/puppet/face/file.rb +3 -0
  30. data/lib/puppet/face/help/face.erb +3 -0
  31. data/lib/puppet/face/help.rb +19 -17
  32. data/lib/puppet/face/key.rb +1 -0
  33. data/lib/puppet/face/man.rb +4 -2
  34. data/lib/puppet/face/module/generate.rb +1 -1
  35. data/lib/puppet/face/status.rb +2 -0
  36. data/lib/puppet/feature/base.rb +9 -2
  37. data/lib/puppet/feature/hocon.rb +3 -0
  38. data/lib/puppet/file_system/windows.rb +8 -0
  39. data/lib/puppet/file_system.rb +15 -3
  40. data/lib/puppet/forge/repository.rb +1 -2
  41. data/lib/puppet/forge.rb +6 -6
  42. data/lib/puppet/functions/binary_file.rb +4 -10
  43. data/lib/puppet/functions/hiera_array.rb +1 -1
  44. data/lib/puppet/functions/hiera_include.rb +1 -1
  45. data/lib/puppet/functions/hocon_data.rb +24 -0
  46. data/lib/puppet/functions/json_data.rb +18 -0
  47. data/lib/puppet/functions/yaml_data.rb +21 -0
  48. data/lib/puppet/generate/type.rb +1 -1
  49. data/lib/puppet/graph/simple_graph.rb +4 -2
  50. data/lib/puppet/indirector/file_bucket_file/file.rb +10 -2
  51. data/lib/puppet/indirector/request.rb +5 -1
  52. data/lib/puppet/interface/face_collection.rb +1 -1
  53. data/lib/puppet/interface.rb +14 -2
  54. data/lib/puppet/module.rb +14 -2
  55. data/lib/puppet/module_tool/applications/builder.rb +3 -2
  56. data/lib/puppet/module_tool/applications/installer.rb +14 -14
  57. data/lib/puppet/module_tool/applications/upgrader.rb +13 -13
  58. data/lib/puppet/module_tool/installed_modules.rb +7 -7
  59. data/lib/puppet/module_tool/local_tarball.rb +3 -3
  60. data/lib/puppet/module_tool/metadata.rb +1 -1
  61. data/lib/puppet/module_tool.rb +4 -4
  62. data/lib/puppet/network/http/connection.rb +2 -0
  63. data/lib/puppet/network/http/webrick.rb +2 -1
  64. data/lib/puppet/parser/functions/hiera.rb +14 -0
  65. data/lib/puppet/parser/functions/hiera_array.rb +14 -0
  66. data/lib/puppet/parser/functions/hiera_hash.rb +14 -0
  67. data/lib/puppet/parser/functions/hiera_include.rb +14 -0
  68. data/lib/puppet/parser/scope.rb +14 -20
  69. data/lib/puppet/plugins/data_providers/data_provider.rb +108 -17
  70. data/lib/puppet/plugins/data_providers/registry.rb +2 -36
  71. data/lib/puppet/plugins/data_providers.rb +2 -0
  72. data/lib/puppet/pops/adaptable.rb +0 -3
  73. data/lib/puppet/pops/binder/producers.rb +3 -3
  74. data/lib/puppet/pops/evaluator/access_operator.rb +4 -4
  75. data/lib/puppet/pops/evaluator/closure.rb +1 -1
  76. data/lib/puppet/pops/evaluator/compare_operator.rb +4 -4
  77. data/lib/puppet/pops/evaluator/evaluator_impl.rb +1 -1
  78. data/lib/puppet/pops/issues.rb +4 -0
  79. data/lib/puppet/pops/label_provider.rb +14 -0
  80. data/lib/puppet/pops/loader/loader_paths.rb +3 -1
  81. data/lib/puppet/pops/loader/module_loaders.rb +21 -7
  82. data/lib/puppet/pops/loader/typed_name.rb +0 -2
  83. data/lib/puppet/pops/loaders.rb +31 -12
  84. data/lib/puppet/pops/lookup/configured_data_provider.rb +87 -0
  85. data/lib/puppet/pops/lookup/context.rb +121 -71
  86. data/lib/puppet/pops/lookup/data_adapter.rb +27 -0
  87. data/lib/puppet/pops/lookup/data_dig_function_provider.rb +55 -0
  88. data/lib/puppet/pops/lookup/data_hash_function_provider.rb +111 -0
  89. data/lib/puppet/pops/lookup/data_provider.rb +102 -0
  90. data/lib/puppet/pops/lookup/environment_data_provider.rb +27 -0
  91. data/lib/puppet/pops/lookup/explainer.rb +122 -82
  92. data/lib/puppet/pops/lookup/function_provider.rb +82 -0
  93. data/lib/puppet/pops/lookup/global_data_provider.rb +49 -0
  94. data/lib/puppet/pops/lookup/hiera_config.rb +601 -0
  95. data/lib/puppet/pops/lookup/interpolation.rb +56 -35
  96. data/lib/puppet/pops/lookup/invocation.rb +179 -101
  97. data/lib/puppet/pops/lookup/location_resolver.rb +72 -0
  98. data/lib/puppet/pops/lookup/lookup_adapter.rb +451 -0
  99. data/lib/puppet/pops/lookup/lookup_key.rb +99 -0
  100. data/lib/puppet/pops/lookup/lookup_key_function_provider.rb +119 -0
  101. data/lib/puppet/pops/lookup/module_data_provider.rb +58 -0
  102. data/lib/puppet/pops/lookup/sub_lookup.rb +8 -4
  103. data/lib/puppet/pops/lookup.rb +4 -3
  104. data/lib/puppet/pops/merge_strategy.rb +120 -39
  105. data/lib/puppet/pops/parser/egrammar.ra +2 -0
  106. data/lib/puppet/pops/parser/eparser.rb +816 -808
  107. data/lib/puppet/pops/parser/locator.rb +3 -3
  108. data/lib/puppet/pops/parser/slurp_support.rb +4 -3
  109. data/lib/puppet/pops/pcore.rb +21 -12
  110. data/lib/puppet/pops/serialization/abstract_reader.rb +17 -7
  111. data/lib/puppet/pops/serialization/abstract_writer.rb +27 -12
  112. data/lib/puppet/pops/serialization/deserializer.rb +17 -4
  113. data/lib/puppet/pops/serialization/extension.rb +37 -8
  114. data/lib/puppet/pops/serialization/object.rb +14 -6
  115. data/lib/puppet/pops/serialization/rgen.rb +2 -1
  116. data/lib/puppet/pops/serialization/serializer.rb +30 -7
  117. data/lib/puppet/pops/types/implementation_registry.rb +1 -1
  118. data/lib/puppet/pops/types/p_object_type.rb +55 -12
  119. data/lib/puppet/pops/types/p_sem_ver_range_type.rb +27 -27
  120. data/lib/puppet/pops/types/p_sem_ver_type.rb +12 -12
  121. data/lib/puppet/pops/types/p_timespan_type.rb +6 -6
  122. data/lib/puppet/pops/types/p_timestamp_type.rb +2 -2
  123. data/lib/puppet/pops/types/p_type_set_type.rb +7 -16
  124. data/lib/puppet/pops/types/recursion_guard.rb +64 -20
  125. data/lib/puppet/pops/types/ruby_generator.rb +10 -0
  126. data/lib/puppet/pops/types/type_calculator.rb +23 -13
  127. data/lib/puppet/pops/types/type_factory.rb +20 -9
  128. data/lib/puppet/pops/types/type_formatter.rb +37 -17
  129. data/lib/puppet/pops/types/type_mismatch_describer.rb +7 -6
  130. data/lib/puppet/pops/types/type_parser.rb +6 -0
  131. data/lib/puppet/pops/types/types.rb +225 -132
  132. data/lib/puppet/pops/validation/checker4_0.rb +12 -2
  133. data/lib/puppet/pops/validation/validator_factory_4_0.rb +1 -0
  134. data/lib/puppet/pops/validation.rb +1 -1
  135. data/lib/puppet/pops/visitor.rb +4 -3
  136. data/lib/puppet/pops.rb +6 -9
  137. data/lib/puppet/provider/mcx/mcxcontent.rb +2 -1
  138. data/lib/puppet/provider/nameservice.rb +15 -0
  139. data/lib/puppet/provider/package/appdmg.rb +1 -1
  140. data/lib/puppet/provider/package/dnf.rb +1 -1
  141. data/lib/puppet/provider/package/pkg.rb +1 -1
  142. data/lib/puppet/provider/package/pkgdmg.rb +1 -1
  143. data/lib/puppet/provider/package/pkgng.rb +1 -1
  144. data/lib/puppet/provider/package/rpm.rb +2 -2
  145. data/lib/puppet/provider/service/smf.rb +3 -3
  146. data/lib/puppet/provider/service/systemd.rb +5 -1
  147. data/lib/puppet/provider/user/directoryservice.rb +1 -0
  148. data/lib/puppet/provider/user/user_role_add.rb +15 -0
  149. data/lib/puppet/provider/yumrepo/inifile.rb +2 -2
  150. data/lib/puppet/provider/zone/solaris.rb +4 -1
  151. data/lib/puppet/reference/indirection.rb +1 -1
  152. data/lib/puppet/resource/catalog.rb +12 -4
  153. data/lib/puppet/resource/type.rb +3 -3
  154. data/lib/puppet/resource.rb +2 -3
  155. data/lib/puppet/settings/config_file.rb +2 -1
  156. data/lib/puppet/settings/directory_setting.rb +6 -0
  157. data/lib/puppet/settings/environment_conf.rb +6 -2
  158. data/lib/puppet/settings/file_or_directory_setting.rb +6 -0
  159. data/lib/puppet/settings/file_setting.rb +10 -0
  160. data/lib/puppet/settings.rb +1 -1
  161. data/lib/puppet/ssl/certificate_authority.rb +13 -2
  162. data/lib/puppet/ssl/host.rb +23 -1
  163. data/lib/puppet/transaction/additional_resource_generator.rb +7 -0
  164. data/lib/puppet/type/user.rb +16 -3
  165. data/lib/puppet/util/execution.rb +3 -3
  166. data/lib/puppet/util/filetype.rb +11 -5
  167. data/lib/puppet/util/logging.rb +2 -1
  168. data/lib/puppet/util/network_device/config.rb +1 -1
  169. data/lib/puppet/util/plist.rb +6 -0
  170. data/lib/puppet/util/profiler/aggregate.rb +1 -1
  171. data/lib/puppet/util/rdoc/generators/puppet_generator.rb +2 -2
  172. data/lib/puppet/util/rdoc/parser/puppet_parser_core.rb +2 -1
  173. data/lib/puppet/util/windows/adsi.rb +15 -12
  174. data/lib/puppet/util.rb +1 -0
  175. data/lib/puppet/vendor/load_semantic_puppet.rb +1 -0
  176. data/lib/puppet/vendor/pathspec/lib/pathspec.rb +2 -1
  177. data/lib/puppet/vendor/require_vendored.rb +0 -1
  178. data/lib/puppet/vendor/{semantic/lib/semantic → semantic_puppet/lib/semantic_puppet}/dependency/graph.rb +2 -2
  179. data/lib/puppet/vendor/{semantic/lib/semantic → semantic_puppet/lib/semantic_puppet}/dependency/graph_node.rb +2 -2
  180. data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/dependency/module_release.rb +58 -0
  181. data/lib/puppet/vendor/{semantic/lib/semantic → semantic_puppet/lib/semantic_puppet}/dependency/source.rb +2 -2
  182. data/lib/puppet/vendor/{semantic/lib/semantic → semantic_puppet/lib/semantic_puppet}/dependency/unsatisfiable_graph.rb +2 -2
  183. data/lib/puppet/vendor/{semantic/lib/semantic → semantic_puppet/lib/semantic_puppet}/dependency.rb +7 -7
  184. data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/gem_version.rb +3 -0
  185. data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/locales/config.yaml +21 -0
  186. data/lib/puppet/vendor/{semantic/lib/semantic → semantic_puppet/lib/semantic_puppet}/version.rb +48 -21
  187. data/lib/puppet/vendor/{semantic/lib/semantic → semantic_puppet/lib/semantic_puppet}/version_range.rb +15 -17
  188. data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet.rb +17 -0
  189. data/lib/puppet/version.rb +1 -1
  190. data/lib/puppet.rb +52 -0
  191. data/lib/semver.rb +19 -12
  192. data/locales/config.yaml +29 -0
  193. data/locales/puppet.pot +79 -0
  194. data/man/man5/puppet.conf.5 +1 -1
  195. data/spec/fixtures/unit/application/environments/puppet_func_provider/functions/{data.pp → environment/data.pp} +0 -0
  196. data/spec/fixtures/unit/data_providers/environments/hiera_misc/data/common.yaml +2 -0
  197. data/spec/fixtures/unit/data_providers/environments/hiera_modules/modules/two/data/common.yaml +1 -1
  198. data/spec/fixtures/unit/data_providers/environments/sample/modules/backend/hiera.yaml +5 -0
  199. data/spec/fixtures/unit/data_providers/environments/sample/modules/backend/lib/puppet/bindings/backend/default.rb +9 -0
  200. data/spec/fixtures/unit/data_providers/environments/sample/modules/backend/lib/puppet_x/backend/special_data_provider_factory.rb +23 -0
  201. data/spec/fixtures/unit/data_providers/environments/sample/modules/backend/manifests/init.pp +5 -0
  202. data/spec/fixtures/unit/data_providers/environments/sample/modules/backend/metadata.json +9 -0
  203. data/spec/fixtures/unit/data_providers/environments/sample/modules/dataprovider/lib/puppet_x/helindbe/sample_env_data.rb +1 -0
  204. data/spec/fixtures/unit/data_providers/environments/sample/modules/dataprovider/manifests/init.pp +1 -1
  205. data/spec/fixtures/unit/functions/lookup/data/common.yaml +19 -0
  206. data/spec/fixtures/unit/functions/lookup_fixture/data/common.yaml +19 -0
  207. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/environment.conf +0 -0
  208. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/lib/puppet/functions/environment/data.rb +0 -0
  209. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/abc/lib/puppet/bindings/abc/default.rb +0 -0
  210. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/abc/lib/puppet/functions/abc/data.rb +0 -0
  211. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/abc/manifests/init.pp +0 -0
  212. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/bad_data/lib/puppet/bindings/bad_data/default.rb +0 -0
  213. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/bad_data/lib/puppet/functions/bad_data/data.rb +0 -0
  214. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/bad_data/manifests/init.pp +0 -0
  215. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/bca/lib/puppet/bindings/bca/default.rb +0 -0
  216. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/bca/lib/puppet/functions/bca/data.rb +0 -0
  217. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/bca/manifests/init.pp +0 -0
  218. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/empty_json/data/empty.json +0 -0
  219. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/empty_json/hiera.yaml +0 -0
  220. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/empty_json/manifests/init.pp +0 -0
  221. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/empty_json/metadata.json +0 -0
  222. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/empty_key_json/data/empty_key.json +0 -0
  223. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/empty_key_json/hiera.yaml +0 -0
  224. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/empty_key_json/manifests/init.pp +0 -0
  225. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/empty_key_json/metadata.json +0 -0
  226. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/empty_key_yaml/data/empty_key.yaml +0 -0
  227. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/empty_key_yaml/hiera.yaml +0 -0
  228. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/empty_key_yaml/manifests/init.pp +0 -0
  229. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/empty_key_yaml/metadata.json +0 -0
  230. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/empty_yaml/data/empty.yaml +0 -0
  231. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/empty_yaml/hiera.yaml +0 -0
  232. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/empty_yaml/manifests/init.pp +0 -0
  233. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/empty_yaml/metadata.json +0 -0
  234. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/hieraprovider/data/first.json +0 -0
  235. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/hieraprovider/hiera.yaml +0 -0
  236. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/hieraprovider/manifests/init.pp +0 -0
  237. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/hieraprovider/metadata.json +0 -0
  238. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/meta/lib/puppet/functions/meta/data.rb +0 -0
  239. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/meta/manifests/init.pp +0 -0
  240. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/meta/metadata.json +0 -0
  241. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/metawcp/lib/puppet/bindings/metawcp/default.rb +0 -0
  242. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/metawcp/lib/puppet_x/thallgren/sample_module_data.rb +0 -0
  243. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/metawcp/manifests/init.pp +0 -0
  244. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/metawcp/metadata.json +0 -0
  245. data/spec/fixtures/unit/functions/{lookup → lookup_fixture}/environments/production/modules/no_provider/manifests/init.pp +0 -0
  246. data/spec/integration/application/apply_spec.rb +88 -2
  247. data/spec/integration/application/lookup_spec.rb +155 -0
  248. data/spec/integration/data_binding_spec.rb +5 -5
  249. data/spec/integration/defaults_spec.rb +13 -0
  250. data/spec/integration/environments/default_manifest_spec.rb +16 -16
  251. data/spec/integration/environments/setting_hooks_spec.rb +1 -1
  252. data/spec/integration/test/test_helper_spec.rb +6 -2
  253. data/spec/integration/transaction_spec.rb +74 -0
  254. data/spec/integration/util/execution_spec.rb +8 -0
  255. data/spec/lib/puppet_spec/module_tool/shared_functions.rb +2 -2
  256. data/spec/lib/puppet_spec/module_tool/stub_source.rb +1 -1
  257. data/spec/lib/puppet_spec/unindent.rb +2 -2
  258. data/spec/unit/application/face_base_spec.rb +16 -0
  259. data/spec/unit/application/lookup_spec.rb +262 -227
  260. data/spec/unit/data_providers/{sample_data_provider_spec.rb → custom_data_provider_spec.rb} +14 -16
  261. data/spec/unit/data_providers/function_data_provider_spec.rb +2 -2
  262. data/spec/unit/data_providers/hiera_data_provider_spec.rb +60 -97
  263. data/spec/unit/defaults_spec.rb +1 -1
  264. data/spec/unit/face/ca_spec.rb +10 -0
  265. data/spec/unit/face/certificate_request_spec.rb +10 -0
  266. data/spec/unit/face/certificate_revocation_list_spec.rb +10 -0
  267. data/spec/unit/face/file_spec.rb +4 -0
  268. data/spec/unit/face/help_spec.rb +17 -0
  269. data/spec/unit/face/key_spec.rb +10 -0
  270. data/spec/unit/face/status_spec.rb +10 -0
  271. data/spec/unit/file_system_spec.rb +143 -6
  272. data/spec/unit/functions/binary_file_spec.rb +1 -1
  273. data/spec/unit/functions/hiera_spec.rb +257 -47
  274. data/spec/unit/functions/lookup_fixture_spec.rb +693 -0
  275. data/spec/unit/functions/lookup_spec.rb +1319 -608
  276. data/spec/unit/functions/new_spec.rb +3 -3
  277. data/spec/unit/graph/rb_tree_map_spec.rb +1 -1
  278. data/spec/unit/graph/simple_graph_spec.rb +1 -1
  279. data/spec/unit/hiera/scope_spec.rb +4 -4
  280. data/spec/unit/indirector/request_spec.rb +9 -0
  281. data/spec/unit/interface_spec.rb +27 -0
  282. data/spec/unit/man_spec.rb +1 -1
  283. data/spec/unit/module_spec.rb +1 -1
  284. data/spec/unit/module_tool/applications/builder_spec.rb +16 -1
  285. data/spec/unit/module_tool/applications/installer_spec.rb +1 -1
  286. data/spec/unit/module_tool/applications/upgrader_spec.rb +1 -1
  287. data/spec/unit/module_tool/installed_modules_spec.rb +6 -6
  288. data/spec/unit/module_tool_spec.rb +3 -3
  289. data/spec/unit/network/http/connection_spec.rb +10 -0
  290. data/spec/unit/network/http/webrick_spec.rb +1 -1
  291. data/spec/unit/pops/evaluator/access_ops_spec.rb +2 -2
  292. data/spec/unit/pops/evaluator/runtime3_converter_spec.rb +9 -9
  293. data/spec/unit/pops/loaders/environment_loader_spec.rb +172 -0
  294. data/spec/unit/pops/lookup/context_spec.rb +45 -16
  295. data/spec/unit/pops/lookup/interpolation_spec.rb +28 -20
  296. data/spec/unit/pops/lookup/lookup_spec.rb +197 -0
  297. data/spec/unit/pops/merge_strategy_spec.rb +18 -0
  298. data/spec/unit/pops/parser/lexer2_spec.rb +16 -1
  299. data/spec/unit/pops/parser/parse_site_spec.rb +4 -0
  300. data/spec/unit/pops/serialization/packer_spec.rb +4 -23
  301. data/spec/unit/pops/serialization/serialization_spec.rb +32 -8
  302. data/spec/unit/pops/types/p_object_type_spec.rb +68 -3
  303. data/spec/unit/pops/types/p_sem_ver_type_spec.rb +4 -4
  304. data/spec/unit/pops/types/p_type_set_type_spec.rb +31 -2
  305. data/spec/unit/pops/types/type_acceptor_spec.rb +18 -17
  306. data/spec/unit/pops/types/type_calculator_spec.rb +39 -40
  307. data/spec/unit/pops/types/type_factory_spec.rb +3 -3
  308. data/spec/unit/pops/types/type_formatter_spec.rb +7 -3
  309. data/spec/unit/pops/types/type_mismatch_describer_spec.rb +13 -2
  310. data/spec/unit/pops/types/types_spec.rb +25 -2
  311. data/spec/unit/pops/validator/validator_spec.rb +60 -4
  312. data/spec/unit/provider/nameservice_spec.rb +42 -0
  313. data/spec/unit/provider/package/aptrpm_spec.rb +1 -1
  314. data/spec/unit/provider/package/pkg_spec.rb +22 -0
  315. data/spec/unit/provider/package/pkgng_spec.rb +12 -0
  316. data/spec/unit/provider/package/rpm_spec.rb +8 -8
  317. data/spec/unit/provider/service/smf_spec.rb +13 -11
  318. data/spec/unit/provider/service/systemd_spec.rb +8 -1
  319. data/spec/unit/provider/user/useradd_spec.rb +1 -0
  320. data/spec/unit/puppet_spec.rb +14 -0
  321. data/spec/unit/resource/catalog_spec.rb +15 -9
  322. data/spec/unit/resource_spec.rb +20 -17
  323. data/spec/unit/semver_spec.rb +14 -0
  324. data/spec/unit/ssl/certificate_authority_spec.rb +12 -1
  325. data/spec/unit/transaction/additional_resource_generator_spec.rb +11 -0
  326. data/spec/unit/type/user_spec.rb +32 -6
  327. data/spec/unit/util/filetype_spec.rb +3 -3
  328. data/spec/unit/util/yaml_spec.rb +1 -1
  329. data/spec/unit/util_spec.rb +10 -2
  330. data/tasks/i18n.rake +20 -0
  331. metadata +2661 -2595
  332. data/lib/puppet/data_providers/lookup_adapter.rb +0 -254
  333. data/lib/puppet/vendor/load_semantic.rb +0 -1
  334. data/lib/puppet/vendor/semantic/Gemfile +0 -20
  335. data/lib/puppet/vendor/semantic/PUPPET_README.md +0 -6
  336. data/lib/puppet/vendor/semantic/Rakefile +0 -69
  337. data/lib/puppet/vendor/semantic/lib/semantic/dependency/module_release.rb +0 -60
  338. data/lib/puppet/vendor/semantic/lib/semantic.rb +0 -7
  339. data/lib/puppet/vendor/semantic/spec/spec_helper.rb +0 -24
  340. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/graph_node_spec.rb +0 -141
  341. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/graph_spec.rb +0 -162
  342. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/module_release_spec.rb +0 -143
  343. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/source_spec.rb +0 -5
  344. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/unsatisfiable_graph_spec.rb +0 -44
  345. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency_spec.rb +0 -383
  346. data/lib/puppet/vendor/semantic/spec/unit/semantic/version_range_spec.rb +0 -307
  347. data/lib/puppet/vendor/semantic/spec/unit/semantic/version_spec.rb +0 -608
  348. data/spec/fixtures/unit/data_providers/environments/sample/manifests/site.pp +0 -6
@@ -149,12 +149,15 @@ class Puppet::Interface
149
149
 
150
150
  # @api private
151
151
  def initialize(name, version, &block)
152
- unless SemVer.valid?(version)
152
+ unless SemanticPuppet::Version.valid?(version)
153
153
  raise ArgumentError, "Cannot create face #{name.inspect} with invalid version number '#{version}'!"
154
154
  end
155
155
 
156
156
  @name = Puppet::Interface::FaceCollection.underscorize(name)
157
- @version = SemVer.new(version)
157
+
158
+ # SemVer is deprecated but in 4.x we must use it here (the attr_reader is public api). The
159
+ # extra boolean argument suppresses the deprecation warning.
160
+ @version = SemVer.new(version, true)
158
161
 
159
162
  # The few bits of documentation we actually demand. The default license
160
163
  # is a favour to our end users; if you happen to get that in a core face
@@ -180,6 +183,15 @@ class Puppet::Interface
180
183
  "Puppet::Face[#{name.inspect}, #{version.inspect}]"
181
184
  end
182
185
 
186
+ # @return [void]
187
+ def deprecate
188
+ @deprecated = true
189
+ end
190
+
191
+ # @return [Boolean]
192
+ def deprecated?
193
+ @deprecated
194
+ end
183
195
  ########################################################################
184
196
  # Action decoration, whee! You are not expected to care about this code,
185
197
  # which exists to support face building and construction. I marked these
data/lib/puppet/module.rb CHANGED
@@ -206,6 +206,17 @@ class Puppet::Module
206
206
  @metadata_file = File.join(path, "metadata.json")
207
207
  end
208
208
 
209
+ def hiera_conf_file
210
+ unless defined?(@hiera_conf_file)
211
+ @hiera_conf_file = path.nil? ? nil : File.join(path, Puppet::Pops::Lookup::HieraConfig::CONFIG_FILE_NAME)
212
+ end
213
+ @hiera_conf_file
214
+ end
215
+
216
+ def has_hiera_conf?
217
+ hiera_conf_file.nil? ? false : Puppet::FileSystem.exist?(hiera_conf_file)
218
+ end
219
+
209
220
  def modulepath
210
221
  File.dirname(path) if path
211
222
  end
@@ -309,8 +320,9 @@ class Puppet::Module
309
320
 
310
321
  if version_string
311
322
  begin
312
- required_version_semver_range = SemVer[version_string]
313
- actual_version_semver = SemVer.new(dep_mod.version)
323
+ # Suppress deprecation warnings from SemVer in 4.9. In 5.0, this will be SemanticPuppet instead
324
+ required_version_semver_range = SemVer[version_string, true]
325
+ actual_version_semver = SemVer.new(dep_mod.version, true)
314
326
  rescue ArgumentError
315
327
  error_details[:reason] = :non_semantic_version
316
328
  unmet_dependencies << error_details
@@ -131,11 +131,12 @@ module Puppet::ModuleTool
131
131
  # TODO: This may necessarily change the order in which the metadata.json
132
132
  # file is packaged from what was written by the user. This is a
133
133
  # regretable, but required for now.
134
- File.open(metadata_path, 'w') do |f|
134
+ Puppet::FileSystem.open(metadata_path, nil, 'w:UTF-8') do |f|
135
135
  f.write(metadata.to_json)
136
136
  end
137
137
 
138
- File.open(File.join(build_path, 'checksums.json'), 'w') do |f|
138
+ # PSON.pretty_generate is a BINARY string
139
+ Puppet::FileSystem.open(File.join(build_path, 'checksums.json'), nil, 'wb') do |f|
139
140
  f.write(PSON.pretty_generate(Checksums.new(build_path)))
140
141
  end
141
142
  end
@@ -34,19 +34,19 @@ module Puppet::ModuleTool
34
34
  release = local_tarball_source.release
35
35
  @name = release.name
36
36
  options[:version] = release.version.to_s
37
- Semantic::Dependency.add_source(local_tarball_source)
37
+ SemanticPuppet::Dependency.add_source(local_tarball_source)
38
38
 
39
39
  # If we're operating on a local tarball and ignoring dependencies, we
40
40
  # don't need to search any additional sources. This will cut down on
41
41
  # unnecessary network traffic.
42
42
  unless @ignore_dependencies
43
- Semantic::Dependency.add_source(installed_modules_source)
44
- Semantic::Dependency.add_source(module_repository)
43
+ SemanticPuppet::Dependency.add_source(installed_modules_source)
44
+ SemanticPuppet::Dependency.add_source(module_repository)
45
45
  end
46
46
 
47
47
  else
48
- Semantic::Dependency.add_source(installed_modules_source) unless forced?
49
- Semantic::Dependency.add_source(module_repository)
48
+ SemanticPuppet::Dependency.add_source(installed_modules_source) unless forced?
49
+ SemanticPuppet::Dependency.add_source(module_repository)
50
50
  end
51
51
  end
52
52
 
@@ -59,7 +59,7 @@ module Puppet::ModuleTool
59
59
  begin
60
60
  if installed_module = installed_modules[name]
61
61
  unless forced?
62
- if Semantic::VersionRange.parse(version).include? installed_module.version
62
+ if SemanticPuppet::VersionRange.parse(version).include? installed_module.version
63
63
  results[:result] = :noop
64
64
  results[:version] = installed_module.version
65
65
  return results
@@ -103,7 +103,7 @@ module Puppet::ModuleTool
103
103
  # locking it to upgrades within the same major version.
104
104
  installed_range = ">=#{version} #{version.major}.x"
105
105
  graph.add_constraint('installed', mod, installed_range) do |node|
106
- Semantic::VersionRange.parse(installed_range).include? node.version
106
+ SemanticPuppet::VersionRange.parse(installed_range).include? node.version
107
107
  end
108
108
 
109
109
  release.mod.dependencies.each do |dep|
@@ -111,7 +111,7 @@ module Puppet::ModuleTool
111
111
 
112
112
  range = dep['version_requirement']
113
113
  graph.add_constraint("#{mod} constraint", dep_name, range) do |node|
114
- Semantic::VersionRange.parse(range).include? node.version
114
+ SemanticPuppet::VersionRange.parse(range).include? node.version
115
115
  end
116
116
  end
117
117
  end
@@ -125,8 +125,8 @@ module Puppet::ModuleTool
125
125
 
126
126
  begin
127
127
  Puppet.info "Resolving dependencies ..."
128
- releases = Semantic::Dependency.resolve(graph)
129
- rescue Semantic::Dependency::UnsatisfiableGraph
128
+ releases = SemanticPuppet::Dependency.resolve(graph)
129
+ rescue SemanticPuppet::Dependency::UnsatisfiableGraph
130
130
  raise NoVersionsSatisfyError, results.merge(:requested_name => name)
131
131
  end
132
132
 
@@ -205,15 +205,15 @@ module Puppet::ModuleTool
205
205
  end
206
206
 
207
207
  def build_single_module_graph(name, version)
208
- range = Semantic::VersionRange.parse(version)
209
- graph = Semantic::Dependency::Graph.new(name => range)
210
- releases = Semantic::Dependency.fetch_releases(name)
208
+ range = SemanticPuppet::VersionRange.parse(version)
209
+ graph = SemanticPuppet::Dependency::Graph.new(name => range)
210
+ releases = SemanticPuppet::Dependency.fetch_releases(name)
211
211
  releases.each { |release| release.dependencies.clear }
212
212
  graph << releases
213
213
  end
214
214
 
215
215
  def build_dependency_graph(name, version)
216
- Semantic::Dependency.query(name => version)
216
+ SemanticPuppet::Dependency.query(name => version)
217
217
  end
218
218
 
219
219
  def build_install_graph(release, installed, graphed = [])
@@ -21,8 +21,8 @@ module Puppet::ModuleTool
21
21
  @ignore_changes = forced? || options[:ignore_changes]
22
22
  @ignore_dependencies = forced? || options[:ignore_dependencies]
23
23
 
24
- Semantic::Dependency.add_source(installed_modules_source)
25
- Semantic::Dependency.add_source(module_repository)
24
+ SemanticPuppet::Dependency.add_source(installed_modules_source)
25
+ SemanticPuppet::Dependency.add_source(module_repository)
26
26
  end
27
27
 
28
28
  def run
@@ -48,7 +48,7 @@ module Puppet::ModuleTool
48
48
 
49
49
  installed_release = installed_modules[name]
50
50
 
51
- # `priority` is an attribute of a `Semantic::Dependency::Source`,
51
+ # `priority` is an attribute of a `SemanticPuppet::Dependency::Source`,
52
52
  # which is delegated through `ModuleRelease` instances for the sake of
53
53
  # comparison (sorting). By default, the `InstalledModules` source has
54
54
  # a priority of 10 (making it the most preferable source, so that
@@ -66,7 +66,7 @@ module Puppet::ModuleTool
66
66
  end
67
67
 
68
68
  mod = installed_release.mod
69
- results[:installed_version] = Semantic::Version.parse(mod.version)
69
+ results[:installed_version] = SemanticPuppet::Version.parse(mod.version)
70
70
  dir = Pathname.new(mod.modulepath)
71
71
 
72
72
  vstring = mod.version ? "v#{mod.version}" : '???'
@@ -90,7 +90,7 @@ module Puppet::ModuleTool
90
90
  if available_versions.empty?
91
91
  raise NoCandidateReleasesError, results.merge(:module_name => name, :source => module_repository.host)
92
92
  elsif results[:requested_version] != :latest
93
- requested = Semantic::VersionRange.parse(results[:requested_version])
93
+ requested = SemanticPuppet::VersionRange.parse(results[:requested_version])
94
94
  unless available_versions.any? {|m| requested.include? m.version}
95
95
  raise NoCandidateReleasesError, results.merge(:module_name => name, :source => module_repository.host)
96
96
  end
@@ -119,7 +119,7 @@ module Puppet::ModuleTool
119
119
  # module, locking it to upgrades within the same major version.
120
120
  installed_range = ">=#{version} #{version.major}.x"
121
121
  graph.add_constraint('installed', installed_module, installed_range) do |node|
122
- Semantic::VersionRange.parse(installed_range).include? node.version
122
+ SemanticPuppet::VersionRange.parse(installed_range).include? node.version
123
123
  end
124
124
 
125
125
  release.mod.dependencies.each do |dep|
@@ -127,7 +127,7 @@ module Puppet::ModuleTool
127
127
 
128
128
  range = dep['version_requirement']
129
129
  graph.add_constraint("#{installed_module} constraint", dep_name, range) do |node|
130
- Semantic::VersionRange.parse(range).include? node.version
130
+ SemanticPuppet::VersionRange.parse(range).include? node.version
131
131
  end
132
132
  end
133
133
  end
@@ -135,8 +135,8 @@ module Puppet::ModuleTool
135
135
 
136
136
  begin
137
137
  Puppet.info "Resolving dependencies ..."
138
- releases = Semantic::Dependency.resolve(graph)
139
- rescue Semantic::Dependency::UnsatisfiableGraph
138
+ releases = SemanticPuppet::Dependency.resolve(graph)
139
+ rescue SemanticPuppet::Dependency::UnsatisfiableGraph
140
140
  raise NoVersionsSatisfyError, results.merge(:requested_name => name)
141
141
  end
142
142
 
@@ -227,15 +227,15 @@ module Puppet::ModuleTool
227
227
  end
228
228
 
229
229
  def build_single_module_graph(name, version)
230
- range = Semantic::VersionRange.parse(version)
231
- graph = Semantic::Dependency::Graph.new(name => range)
232
- releases = Semantic::Dependency.fetch_releases(name)
230
+ range = SemanticPuppet::VersionRange.parse(version)
231
+ graph = SemanticPuppet::Dependency::Graph.new(name => range)
232
+ releases = SemanticPuppet::Dependency.fetch_releases(name)
233
233
  releases.each { |release| release.dependencies.clear }
234
234
  graph << releases
235
235
  end
236
236
 
237
237
  def build_dependency_graph(name, version)
238
- Semantic::Dependency.query(name => version)
238
+ SemanticPuppet::Dependency.query(name => version)
239
239
  end
240
240
 
241
241
  def build_install_graph(release, installed, graphed = [])
@@ -4,7 +4,7 @@ require 'puppet/forge'
4
4
  require 'puppet/module_tool'
5
5
 
6
6
  module Puppet::ModuleTool
7
- class InstalledModules < Semantic::Dependency::Source
7
+ class InstalledModules < SemanticPuppet::Dependency::Source
8
8
  attr_reader :modules, :by_name
9
9
 
10
10
  def priority
@@ -33,9 +33,9 @@ module Puppet::ModuleTool
33
33
  # Fetches {ModuleRelease} entries for each release of the named module.
34
34
  #
35
35
  # @param name [String] the module name to look up
36
- # @return [Array<Semantic::Dependency::ModuleRelease>] a list of releases for
36
+ # @return [Array<SemanticPuppet::Dependency::ModuleRelease>] a list of releases for
37
37
  # the given name
38
- # @see Semantic::Dependency::Source#fetch
38
+ # @see SemanticPuppet::Dependency::Source#fetch
39
39
  def fetch(name)
40
40
  name = name.tr('/', '-')
41
41
 
@@ -51,7 +51,7 @@ module Puppet::ModuleTool
51
51
  @fetched
52
52
  end
53
53
 
54
- class ModuleRelease < Semantic::Dependency::ModuleRelease
54
+ class ModuleRelease < SemanticPuppet::Dependency::ModuleRelease
55
55
  attr_reader :mod, :metadata
56
56
 
57
57
  def initialize(source, mod)
@@ -59,10 +59,10 @@ module Puppet::ModuleTool
59
59
  @metadata = mod.metadata
60
60
  name = mod.forge_name.tr('/', '-')
61
61
  begin
62
- version = Semantic::Version.parse(mod.version)
63
- rescue Semantic::Version::ValidationFailure => e
62
+ version = SemanticPuppet::Version.parse(mod.version)
63
+ rescue SemanticPuppet::Version::ValidationFailure => e
64
64
  Puppet.warning "#{mod.name} (#{mod.path}) has an invalid version number (#{mod.version}). The version has been set to 0.0.0. If you are the maintainer for this module, please update the metadata.json with a valid Semantic Version (http://semver.org)."
65
- version = Semantic::Version.parse("0.0.0")
65
+ version = SemanticPuppet::Version.parse("0.0.0")
66
66
  end
67
67
  release = "#{name}@#{version}"
68
68
 
@@ -5,7 +5,7 @@ require 'puppet/forge'
5
5
  require 'puppet/module_tool'
6
6
 
7
7
  module Puppet::ModuleTool
8
- class LocalTarball < Semantic::Dependency::Source
8
+ class LocalTarball < SemanticPuppet::Dependency::Source
9
9
  attr_accessor :release
10
10
 
11
11
  def initialize(filename)
@@ -40,14 +40,14 @@ module Puppet::ModuleTool
40
40
  FileUtils.mv(staging_dir, module_dir)
41
41
  end
42
42
 
43
- class ModuleRelease < Semantic::Dependency::ModuleRelease
43
+ class ModuleRelease < SemanticPuppet::Dependency::ModuleRelease
44
44
  attr_reader :mod, :install_dir, :metadata
45
45
 
46
46
  def initialize(source, mod)
47
47
  @mod = mod
48
48
  @metadata = mod.metadata
49
49
  name = mod.forge_name.tr('/', '-')
50
- version = Semantic::Version.parse(mod.version)
50
+ version = SemanticPuppet::Version.parse(mod.version)
51
51
  release = "#{name}@#{version}"
52
52
 
53
53
  if mod.dependencies
@@ -213,7 +213,7 @@ module Puppet::ModuleTool
213
213
 
214
214
  # Validates that the version range can be parsed by Semantic.
215
215
  def validate_version_range(version_range)
216
- Semantic::VersionRange.parse(version_range)
216
+ SemanticPuppet::VersionRange.parse(version_range)
217
217
  rescue ArgumentError => e
218
218
  raise ArgumentError, "Invalid 'version_range' field in metadata.json: #{e}"
219
219
  end
@@ -157,12 +157,12 @@ module Puppet
157
157
  end
158
158
 
159
159
  # Handles parsing of module dependency expressions into proper
160
- # {Semantic::VersionRange}s, including reasonable error handling.
160
+ # {SemanticPuppet::VersionRange}s, including reasonable error handling.
161
161
  #
162
162
  # @param where [String] a description of the thing we're parsing the
163
163
  # dependency expression for
164
164
  # @param dep [Hash] the dependency description to parse
165
- # @return [Array(String, Semantic::VersionRange, String)] a tuple of the
165
+ # @return [Array(String, SemanticPuppet::VersionRange, String)] a tuple of the
166
166
  # dependent module's name, the version range dependency, and the
167
167
  # unparsed range expression.
168
168
  def self.parse_module_dependency(where, dep)
@@ -170,10 +170,10 @@ module Puppet
170
170
  range = dep['version_requirement'] || '>= 0.0.0'
171
171
 
172
172
  begin
173
- parsed_range = Semantic::VersionRange.parse(range)
173
+ parsed_range = SemanticPuppet::VersionRange.parse(range)
174
174
  rescue ArgumentError => e
175
175
  Puppet.debug "Error in #{where} parsing dependency #{dep_name} (#{e.message}); using empty range."
176
- parsed_range = Semantic::VersionRange::EMPTY_RANGE
176
+ parsed_range = SemanticPuppet::VersionRange::EMPTY_RANGE
177
177
  end
178
178
 
179
179
  [ dep_name, parsed_range, range ]
@@ -197,6 +197,8 @@ module Puppet::Network::HTTP
197
197
  end
198
198
 
199
199
  def apply_options_to(request, options)
200
+ request["User-Agent"] = Puppet[:http_user_agent]
201
+
200
202
  if options[:basic_auth]
201
203
  request.basic_auth(options[:basic_auth][:user], options[:basic_auth][:password])
202
204
  end
@@ -73,7 +73,8 @@ class Puppet::Network::HTTP::WEBrick
73
73
  file = Puppet[:masterhttplog]
74
74
 
75
75
  # open the log manually to prevent file descriptor leak
76
- file_io = ::File.open(file, "a+")
76
+ # webrick logged strings may contain UTF-8
77
+ file_io = ::File.open(file, "a+:UTF-8")
77
78
  file_io.sync = true
78
79
  if defined?(Fcntl::FD_CLOEXEC)
79
80
  file_io.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
@@ -77,6 +77,20 @@ $users = hiera('users') | $key | { "Key \'${key}\' not found" }
77
77
  The returned value's data type depends on the types of the results. In the example
78
78
  above, Hiera matches the 'users' key and returns it as a hash.
79
79
 
80
+ The `hiera` function is deprecated in favor of using `lookup` and will be removed in 6.0.0.
81
+ See https://docs.puppet.com/puppet/#{Puppet.version}/reference/deprecated_language.html.
82
+ Replace the calls as follows:
83
+
84
+ | from | to |
85
+ | ---- | ---|
86
+ | hiera($key) | lookup($key) |
87
+ | hiera($key, $default) | lookup($key, { 'default_value' => $default }) |
88
+ | hiera($key, $default, $level) | override level not supported |
89
+
90
+ Note that calls using the 'override level' option are not directly supported by 'lookup' and the produced
91
+ result must be post processed to get exactly the same result, for example using simple hash/array `+` or
92
+ with calls to stdlib's `deep_merge` function depending on kind of hiera call and setting of merge in hiera.yaml.
93
+
80
94
  See
81
95
  [the documentation](https://docs.puppetlabs.com/hiera/latest/puppet.html#hiera-lookup-functions)
82
96
  for more information about Hiera lookup functions.
@@ -65,6 +65,20 @@ $allusers = hiera_array('users') | $key | { "Key \'${key}\' not found" }
65
65
  `hiera_array` expects that all values returned will be strings or arrays. If any matched
66
66
  value is a hash, Puppet raises a type mismatch error.
67
67
 
68
+ `hiera_array` is deprecated in favor of using `lookup` and will be removed in 6.0.0.
69
+ See https://docs.puppet.com/puppet/#{Puppet.version}/reference/deprecated_language.html.
70
+ Replace the calls as follows:
71
+
72
+ | from | to |
73
+ | ---- | ---|
74
+ | hiera_array($key) | lookup($key, { 'merge' => 'unique' }) |
75
+ | hiera_array($key, $default) | lookup($key, { 'default_value' => $default, 'merge' => 'unique' }) |
76
+ | hiera_array($key, $default, $level) | override level not supported |
77
+
78
+ Note that calls using the 'override level' option are not directly supported by 'lookup' and the produced
79
+ result must be post processed to get exactly the same result, for example using simple hash/array `+` or
80
+ with calls to stdlib's `deep_merge` function depending on kind of hiera call and setting of merge in hiera.yaml.
81
+
68
82
  See
69
83
  [the documentation](https://docs.puppetlabs.com/hiera/latest/puppet.html#hiera-lookup-functions)
70
84
  for more information about Hiera lookup functions.
@@ -75,6 +75,20 @@ $allusers = hiera_hash('users') | $key | { "Key \'${key}\' not found" }
75
75
  `hiera_hash` expects that all values returned will be hashes. If any of the values
76
76
  found in the data sources are strings or arrays, Puppet raises a type mismatch error.
77
77
 
78
+ `hiera_hash` is deprecated in favor of using `lookup` and will be removed in 6.0.0.
79
+ See https://docs.puppet.com/puppet/#{Puppet.version}/reference/deprecated_language.html.
80
+ Replace the calls as follows:
81
+
82
+ | from | to |
83
+ | ---- | ---|
84
+ | hiera_hash($key) | lookup($key, { 'merge' => 'hash' }) |
85
+ | hiera_hash($key, $default) | lookup($key, { 'default_value' => $default, 'merge' => 'hash' }) |
86
+ | hiera_hash($key, $default, $level) | override level not supported |
87
+
88
+ Note that calls using the 'override level' option are not directly supported by 'lookup' and the produced
89
+ result must be post processed to get exactly the same result, for example using simple hash/array `+` or
90
+ with calls to stdlib's `deep_merge` function depending on kind of hiera call and setting of merge in hiera.yaml.
91
+
78
92
  See
79
93
  [the documentation](https://docs.puppetlabs.com/hiera/latest/puppet.html#hiera-lookup-functions)
80
94
  for more information about Hiera lookup functions.
@@ -75,6 +75,20 @@ hiera_include('classes') | $key | {"Key \'${key}\' not found" }
75
75
  # "Key 'classes' not found".
76
76
  ~~~
77
77
 
78
+ `hiera_include` is deprecated in favor of using a combination of `include`and `lookup` and will be
79
+ removed in 6.0.0. See https://docs.puppet.com/puppet/#{Puppet.version}/reference/deprecated_language.html.
80
+ Replace the calls as follows:
81
+
82
+ | from | to |
83
+ | ---- | ---|
84
+ | hiera_include($key) | include(lookup($key, { 'merge' => 'unique' })) |
85
+ | hiera_include($key, $default) | include(lookup($key, { 'default_value' => $default, 'merge' => 'unique' })) |
86
+ | hiera_include($key, $default, $level) | override level not supported |
87
+
88
+ Note that calls using the 'override level' option are not directly supported by 'lookup' and the produced
89
+ result must be post processed to get exactly the same result, for example using simple hash/array `+` or
90
+ with calls to stdlib's `deep_merge` function depending on kind of hiera call and setting of merge in hiera.yaml.
91
+
78
92
  See [the documentation](http://links.puppetlabs.com/hierainclude) for more information
79
93
  and a more detailed example of how `hiera_include` uses array merge lookups to classify
80
94
  nodes.
@@ -23,6 +23,7 @@ class Puppet::Parser::Scope
23
23
 
24
24
  # Variables that always exist with nil value even if not set
25
25
  BUILT_IN_VARS = ['module_name'.freeze, 'caller_module_name'.freeze].freeze
26
+ EMPTY_HASH = {}.freeze
26
27
 
27
28
  Puppet::Util.logmethods(self)
28
29
 
@@ -83,11 +84,8 @@ class Puppet::Parser::Scope
83
84
  end
84
85
 
85
86
  def [](name)
86
- if @symbols.include?(name)
87
- @symbols[name]
88
- else
89
- super
90
- end
87
+ val = @symbols[name]
88
+ val.nil? && !@symbols.include?(val) ? super : val
91
89
  end
92
90
 
93
91
  def is_local_scope?
@@ -486,28 +484,24 @@ class Puppet::Parser::Scope
486
484
  # @return Object the value of the variable, or nil if it's not found
487
485
  #
488
486
  # @api public
489
- def lookupvar(name, options = {})
487
+ def lookupvar(name, options = EMPTY_HASH)
490
488
  unless name.is_a? String
491
489
  raise Puppet::ParseError, "Scope variable name #{name.inspect} is a #{name.class}, not a string"
492
490
  end
493
491
 
494
- table = @ephemeral.last
495
-
496
492
  if name =~ /^(.*)::(.+)$/
497
- class_name = $1
498
- variable_name = $2
499
- lookup_qualified_variable(class_name, variable_name, options)
493
+ return lookup_qualified_variable($1, $2, options)
494
+ end
495
+
496
+ table = @ephemeral.last
497
+ val = table[name]
498
+ return val unless val.nil? && !table.include?(name)
500
499
 
501
- # TODO: optimize with an assoc instead, this searches through scopes twice for a hit
502
- elsif table.include?(name)
503
- table[name]
500
+ next_scope = inherited_scope || enclosing_scope
501
+ if next_scope
502
+ next_scope.lookupvar(name, options)
504
503
  else
505
- next_scope = inherited_scope || enclosing_scope
506
- if next_scope
507
- next_scope.lookupvar(name, options)
508
- else
509
- variable_not_found(name)
510
- end
504
+ variable_not_found(name)
511
505
  end
512
506
  end
513
507