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
@@ -292,6 +292,10 @@ class PAnyType < TypedModelObject
292
292
  simple_name
293
293
  end
294
294
 
295
+ def create(*args)
296
+ Loaders.find_loader(nil).load(:function, 'new').call({}, self, *args)
297
+ end
298
+
295
299
  def new_function(loader)
296
300
  self.class.new_function(self, loader)
297
301
  end
@@ -550,7 +554,7 @@ class PUndefType < PAnyType
550
554
  end
551
555
 
552
556
  def instance?(o, guard = nil)
553
- o.nil? || o == :undef
557
+ o.nil? || :undef == o
554
558
  end
555
559
 
556
560
  # @api private
@@ -701,6 +705,16 @@ class PEnumType < PScalarType
701
705
  block_given? ? r.each(&block) : r
702
706
  end
703
707
 
708
+ def generalize
709
+ # General form of an Enum is a String
710
+ if @values.empty?
711
+ PStringType::DEFAULT
712
+ else
713
+ range = @values.map(&:size).minmax
714
+ PStringType.new(PIntegerType.new(range.min, range.max))
715
+ end
716
+ end
717
+
704
718
  def iterable?(guard = nil)
705
719
  true
706
720
  end
@@ -731,8 +745,9 @@ class PEnumType < PScalarType
731
745
  end
732
746
  case o
733
747
  when PStringType
734
- # if the set of strings are all found in the set of enums
735
- !o.values.empty? && o.values.all? { |s| svalues.any? { |e| e == s }}
748
+ # if the contained string is found in the set of enums
749
+ v = o.value
750
+ !v.nil? && svalues.any? { |e| e == v }
736
751
  when PEnumType
737
752
  !o.values.empty? && o.values.all? { |s| svalues.any? {|e| e == s }}
738
753
  else
@@ -807,8 +822,8 @@ end
807
822
  class PNumericType < PAbstractRangeType
808
823
  def self.register_ptype(loader, ir)
809
824
  create_ptype(loader, ir, 'ScalarType',
810
- 'from' => { KEY_TYPE => PNumericType::DEFAULT, KEY_VALUE => :default },
811
- 'to' => { KEY_TYPE => PNumericType::DEFAULT, KEY_VALUE => :default }
825
+ 'from' => { KEY_TYPE => POptionalType.new(PNumericType::DEFAULT), KEY_VALUE => nil },
826
+ 'to' => { KEY_TYPE => POptionalType.new(PNumericType::DEFAULT), KEY_VALUE => nil }
812
827
  )
813
828
  end
814
829
 
@@ -1153,58 +1168,36 @@ end
1153
1168
  class PCollectionType < PAnyType
1154
1169
  def self.register_ptype(loader, ir)
1155
1170
  create_ptype(loader, ir, 'AnyType',
1156
- 'element_type' => {
1157
- KEY_TYPE => POptionalType.new(PType::DEFAULT),
1171
+ 'size_type' => {
1172
+ KEY_TYPE => POptionalType.new(PType.new(PIntegerType::DEFAULT)),
1158
1173
  KEY_VALUE => nil
1159
1174
  }
1160
1175
  )
1161
1176
  end
1162
1177
 
1163
- attr_reader :element_type, :size_type
1178
+ attr_reader :size_type
1164
1179
 
1165
- def initialize(element_type, size_type = nil)
1180
+ def initialize(size_type)
1166
1181
  @size_type = size_type
1167
- if !size_type.nil? && size_type.from == 0 && size_type.to == 0
1168
- @element_type = PUnitType::DEFAULT
1169
- else
1170
- @element_type = element_type
1171
- end
1172
1182
  end
1173
1183
 
1174
1184
  def accept(visitor, guard)
1175
1185
  super
1176
1186
  @size_type.accept(visitor, guard) unless @size_type.nil?
1177
- @element_type.accept(visitor, guard) unless @element_type.nil?
1178
1187
  end
1179
1188
 
1180
1189
  def generalize
1181
- if @element_type.nil?
1182
- DEFAULT
1183
- else
1184
- ge_type = @element_type.generalize
1185
- @size_type.nil? && @element_type.equal?(ge_type) ? self : self.class.new(ge_type, nil)
1186
- end
1190
+ DEFAULT
1187
1191
  end
1188
1192
 
1189
1193
  def normalize(guard = nil)
1190
- if @element_type.nil?
1191
- DEFAULT
1192
- else
1193
- ne_type = @element_type.normalize(guard)
1194
- @element_type.equal?(ne_type) ? self : self.class.new(ne_type, @size_type)
1195
- end
1194
+ DEFAULT
1196
1195
  end
1197
1196
 
1198
1197
  def instance?(o, guard = nil)
1199
1198
  assignable?(TypeCalculator.infer(o), guard)
1200
1199
  end
1201
1200
 
1202
- def resolve(type_parser, loader)
1203
- relement_type = @element_type
1204
- relement_type = relement_type.resolve(type_parser, loader) unless relement_type.nil?
1205
- relement_type.equal?(@element_type) ? self : self.class.new(relement_type, @size_type)
1206
- end
1207
-
1208
1201
  # Returns an array with from (min) size to (max) size
1209
1202
  def size_range
1210
1203
  (@size_type || DEFAULT_SIZE).range
@@ -1216,19 +1209,15 @@ class PCollectionType < PAnyType
1216
1209
  end
1217
1210
 
1218
1211
  def hash
1219
- @element_type.hash ^ @size_type.hash
1212
+ @size_type.hash
1220
1213
  end
1221
1214
 
1222
1215
  def iterable?(guard = nil)
1223
1216
  true
1224
1217
  end
1225
1218
 
1226
- def iterable_type(guard = nil)
1227
- @element_type.nil? ? PIterableType::DEFAULT : PIterableType.new(@element_type)
1228
- end
1229
-
1230
1219
  def eql?(o)
1231
- self.class == o.class && @element_type == o.element_type && @size_type == o.size_type
1220
+ self.class == o.class && @size_type == o.size_type
1232
1221
  end
1233
1222
 
1234
1223
 
@@ -1266,7 +1255,7 @@ end
1266
1255
  class PIterableType < PTypeWithContainedType
1267
1256
  def self.register_ptype(loader, ir)
1268
1257
  create_ptype(loader, ir, 'AnyType',
1269
- 'element_type' => {
1258
+ 'type' => {
1270
1259
  KEY_TYPE => POptionalType.new(PType::DEFAULT),
1271
1260
  KEY_VALUE => nil
1272
1261
  }
@@ -1324,7 +1313,7 @@ end
1324
1313
  class PIteratorType < PTypeWithContainedType
1325
1314
  def self.register_ptype(loader, ir)
1326
1315
  create_ptype(loader, ir, 'AnyType',
1327
- 'element_type' => {
1316
+ 'type' => {
1328
1317
  KEY_TYPE => POptionalType.new(PType::DEFAULT),
1329
1318
  KEY_VALUE => nil
1330
1319
  }
@@ -1362,27 +1351,27 @@ end
1362
1351
  class PStringType < PScalarType
1363
1352
  def self.register_ptype(loader, ir)
1364
1353
  create_ptype(loader, ir, 'ScalarType',
1365
- 'size_type' => {
1366
- KEY_TYPE => POptionalType.new(PType.new(PIntegerType::DEFAULT)),
1367
- KEY_VALUE => nil
1368
- },
1369
- 'values' => {
1370
- KEY_TYPE => PArrayType.new(PStringType::DEFAULT),
1371
- KEY_VALUE => EMPTY_ARRAY
1372
- }
1373
- )
1354
+ 'size_type_or_value' => {
1355
+ KEY_TYPE => POptionalType.new(PVariantType.new([PStringType::DEFAULT, PType.new(PIntegerType::DEFAULT)])),
1356
+ KEY_VALUE => nil
1357
+ })
1374
1358
  end
1375
1359
 
1376
- attr_reader :size_type, :values
1360
+ attr_reader :size_type_or_value
1377
1361
 
1378
- def initialize(size_type, values = EMPTY_ARRAY)
1379
- @size_type = size_type
1380
- @values = values.sort.freeze
1362
+ def initialize(size_type_or_value, deprecated_multi_args = EMPTY_ARRAY)
1363
+ unless deprecated_multi_args.empty?
1364
+ if Puppet[:strict] != :off
1365
+ Puppet.warn_once(:deprecatation, "PStringType#initialize_multi_args", "Passing more than one argument to PStringType#initialize is deprecated")
1366
+ end
1367
+ size_type_or_value = deprecated_multi_args[0]
1368
+ end
1369
+ @size_type_or_value = size_type_or_value
1381
1370
  end
1382
1371
 
1383
1372
  def accept(visitor, guard)
1384
1373
  super
1385
- @size_type.accept(visitor, guard) unless @size_type.nil?
1374
+ @size_type_or_value.accept(visitor, guard) if @size_type_or_value.is_a?(PIntegerType)
1386
1375
  end
1387
1376
 
1388
1377
  def generalize
@@ -1390,7 +1379,7 @@ class PStringType < PScalarType
1390
1379
  end
1391
1380
 
1392
1381
  def hash
1393
- @size_type.hash ^ @values.hash
1382
+ @size_type_or_value.hash
1394
1383
  end
1395
1384
 
1396
1385
  def iterable?(guard = nil)
@@ -1402,18 +1391,54 @@ class PStringType < PScalarType
1402
1391
  end
1403
1392
 
1404
1393
  def eql?(o)
1405
- self.class == o.class && @size_type == o.size_type && @values == o.values
1394
+ self.class == o.class && @size_type_or_value == o.size_type_or_value
1406
1395
  end
1407
1396
 
1408
1397
  def instance?(o, guard = nil)
1409
1398
  # true if size compliant
1410
- if o.is_a?(String) && (@size_type.nil? || @size_type.instance?(o.size, guard))
1411
- @values.empty? || @values.include?(o)
1399
+ if o.is_a?(String)
1400
+ if @size_type_or_value.is_a?(PIntegerType)
1401
+ @size_type_or_value.instance?(o.size, guard)
1402
+ else
1403
+ @size_type_or_value.nil? ? true : o == value
1404
+ end
1412
1405
  else
1413
1406
  false
1414
1407
  end
1415
1408
  end
1416
1409
 
1410
+ def value
1411
+ @size_type_or_value.is_a?(PIntegerType) ? nil : @size_type_or_value
1412
+ end
1413
+
1414
+ # @deprecated
1415
+ # @api private
1416
+ def values
1417
+ if Puppet[:strict] != :off
1418
+ Puppet.warn_once(:deprecatation, "PStringType#values", "Method PStringType#values is deprecated. Use #value instead")
1419
+ end
1420
+ @value.is_a?(String) ? [@value] : EMPTY_ARRAY
1421
+ end
1422
+
1423
+ def size_type
1424
+ @size_type_or_value.is_a?(PIntegerType) ? @size_type_or_value : nil
1425
+ end
1426
+
1427
+ def size_type
1428
+ @size_type_or_value.is_a?(PIntegerType) ? @size_type_or_value : nil
1429
+ end
1430
+
1431
+ def derived_size_type
1432
+ if @size_type_or_value.is_a?(PIntegerType)
1433
+ @size_type_or_value
1434
+ elsif @size_type_or_value.is_a?(String)
1435
+ sz = @size_type_or_value.size
1436
+ PIntegerType.new(sz, sz)
1437
+ else
1438
+ PCollectionType::DEFAULT_SIZE
1439
+ end
1440
+ end
1441
+
1417
1442
  def self.new_function(_, loader)
1418
1443
  @new_function ||= Puppet::Functions.create_loaded_function(:new_string, loader) do
1419
1444
  local_types do
@@ -1450,44 +1475,48 @@ class PStringType < PScalarType
1450
1475
 
1451
1476
  # @api private
1452
1477
  def _assignable?(o, guard)
1453
- if values.empty?
1478
+ if @size_type_or_value.is_a?(PIntegerType)
1454
1479
  # A general string is assignable by any other string or pattern restricted string
1455
1480
  # if the string has a size constraint it does not match since there is no reasonable way
1456
1481
  # to compute the min/max length a pattern will match. For enum, it is possible to test that
1457
1482
  # each enumerator value is within range
1458
1483
  case o
1459
- when PStringType
1460
- # true if size compliant
1461
- (@size_type || PCollectionType::DEFAULT_SIZE).assignable?(
1462
- o.size_type || PCollectionType::DEFAULT_SIZE, guard)
1463
-
1464
- when PPatternType
1465
- # true if size constraint is at least 0 to +Infinity (which is the same as the default)
1466
- @size_type.nil? || @size_type.assignable?(PCollectionType::DEFAULT_SIZE, guard)
1467
-
1468
- when PEnumType
1469
- if o.values.empty?
1470
- # enum represents all enums, and thus all strings, a sized constrained string can thus not
1471
- # be assigned any enum (unless it is max size).
1472
- @size_type.nil? || @size_type.assignable?(PCollectionType::DEFAULT_SIZE, guard)
1473
- else
1474
- # true if all enum values are within range
1475
- orange = o.values.map(&:size).minmax
1476
- srange = (@size_type || PCollectionType::DEFAULT_SIZE).range
1477
- # If o min and max are within the range of t
1478
- srange[0] <= orange[0] && srange[1] >= orange[1]
1479
- end
1484
+ when PStringType
1485
+ @size_type_or_value.assignable?(o.derived_size_type, guard)
1486
+
1487
+ when PEnumType
1488
+ if o.values.empty?
1489
+ # enum represents all enums, and thus all strings, a sized constrained string can thus not
1490
+ # be assigned any enum (unless it is max size).
1491
+ @size_type_or_value.assignable?(PCollectionType::DEFAULT_SIZE, guard)
1480
1492
  else
1481
- # no other type matches string
1482
- false
1493
+ # true if all enum values are within range
1494
+ orange = o.values.map(&:size).minmax
1495
+ srange = @size_type_or_value.range
1496
+ # If o min and max are within the range of t
1497
+ srange[0] <= orange[0] && srange[1] >= orange[1]
1498
+ end
1499
+
1500
+ when PPatternType
1501
+ # true if size constraint is at least 0 to +Infinity (which is the same as the default)
1502
+ @size_type_or_value.assignable?(PCollectionType::DEFAULT_SIZE, guard)
1503
+ else
1504
+ # no other type matches string
1505
+ false
1483
1506
  end
1484
- elsif o.is_a?(PStringType)
1485
- # A specific string acts as a set of strings - must have exactly the same strings
1486
- # In this case, size does not matter since the definition is very precise anyway
1487
- values == o.values
1488
1507
  else
1489
- # All others are false, since no other type describes the same set of specific strings
1490
- false
1508
+ case o
1509
+ when PStringType
1510
+ # Must match exactly when value is a string
1511
+ @size_type_or_value.nil? || @size_type_or_value == o.size_type_or_value
1512
+ when PEnumType
1513
+ @size_type_or_value.nil? ? true : o.values.size == 1 && @size_type_or_value == o.values[0]
1514
+ when PPatternType
1515
+ @size_type_or_value.nil?
1516
+ else
1517
+ # All others are false, since no other type describes the same set of specific strings
1518
+ false
1519
+ end
1491
1520
  end
1492
1521
  end
1493
1522
  end
@@ -1574,16 +1603,28 @@ class PPatternType < PScalarType
1574
1603
  def _assignable?(o, guard)
1575
1604
  return true if self == o
1576
1605
  case o
1577
- when PStringType, PEnumType
1606
+ when PStringType
1607
+ v = o.value
1608
+ if v.nil?
1609
+ # Strings cannot all match a pattern, but if there is no pattern it is ok
1610
+ # (There should really always be a pattern, but better safe than sorry).
1611
+ @patterns.empty?
1612
+ else
1613
+ # the string in String type must match one of the patterns in Pattern type,
1614
+ # or Pattern represents all Patterns == all Strings
1615
+ regexps = @patterns.map { |p| p.regexp }
1616
+ regexps.empty? || regexps.any? { |re| re.match(v) }
1617
+ end
1618
+ when PEnumType
1578
1619
  if o.values.empty?
1579
- # Strings / Enums (unknown which ones) cannot all match a pattern, but if there is no pattern it is ok
1620
+ # Enums (unknown which ones) cannot all match a pattern, but if there is no pattern it is ok
1580
1621
  # (There should really always be a pattern, but better safe than sorry).
1581
1622
  @patterns.empty?
1582
1623
  else
1583
1624
  # all strings in String/Enum type must match one of the patterns in Pattern type,
1584
1625
  # or Pattern represents all Patterns == all Strings
1585
1626
  regexps = @patterns.map { |p| p.regexp }
1586
- regexps.empty? || o.values.all? { |v| regexps.any? {|re| re.match(v) } }
1627
+ regexps.empty? || o.values.all? { |s| regexps.any? {|re| re.match(s) } }
1587
1628
  end
1588
1629
  when PPatternType
1589
1630
  @patterns.empty?
@@ -1668,7 +1709,7 @@ class PStructElement < TypedModelObject
1668
1709
  def name
1669
1710
  k = key_type
1670
1711
  k = k.optional_type if k.is_a?(POptionalType)
1671
- k.values[0]
1712
+ k.value
1672
1713
  end
1673
1714
 
1674
1715
  def initialize(key_type, value_type)
@@ -1841,7 +1882,7 @@ class PStructType < PAnyType
1841
1882
  true
1842
1883
  else
1843
1884
  required += 1
1844
- if e.value_type.assignable?(o.element_type, guard)
1885
+ if e.value_type.assignable?(o.value_type, guard)
1845
1886
  # Hash must have something that is assignable. We don't care about the name or size of the key though
1846
1887
  # because we have no instance of a hash to compare against.
1847
1888
  key_type.generalize.assignable?(o.key_type)
@@ -2040,7 +2081,7 @@ class PTupleType < PAnyType
2040
2081
  return false unless size_s.assignable?(size_o, guard)
2041
2082
  unless s_types.empty?
2042
2083
  o_types = o.types
2043
- return false if o_types.empty?
2084
+ return size_s.numeric_from == 0 if o_types.empty?
2044
2085
  o_types.size.times do |index|
2045
2086
  return false unless (s_types[index] || s_types[-1]).assignable?(o_types[index], guard)
2046
2087
  end
@@ -2073,6 +2114,10 @@ class PCallableType < PAnyType
2073
2114
  'block_type' => {
2074
2115
  KEY_TYPE => POptionalType.new(PCallableType::DEFAULT),
2075
2116
  KEY_VALUE => nil
2117
+ },
2118
+ 'return_type' => {
2119
+ KEY_TYPE => POptionalType.new(PType::DEFAULT),
2120
+ KEY_VALUE => PAnyType::DEFAULT
2076
2121
  }
2077
2122
  )
2078
2123
  end
@@ -2212,13 +2257,29 @@ class PArrayType < PCollectionType
2212
2257
 
2213
2258
  def self.register_ptype(loader, ir)
2214
2259
  create_ptype(loader, ir, 'CollectionType',
2215
- 'size_type' => {
2216
- KEY_TYPE => POptionalType.new(PType.new(PIntegerType::DEFAULT)),
2260
+ 'element_type' => {
2261
+ KEY_TYPE => POptionalType.new(PType::DEFAULT),
2217
2262
  KEY_VALUE => nil
2218
2263
  }
2219
2264
  )
2220
2265
  end
2221
2266
 
2267
+ attr_reader :element_type
2268
+
2269
+ def initialize(element_type, size_type = nil)
2270
+ super(size_type)
2271
+ if !size_type.nil? && size_type.from == 0 && size_type.to == 0
2272
+ @element_type = PUnitType::DEFAULT
2273
+ else
2274
+ @element_type = element_type
2275
+ end
2276
+ end
2277
+
2278
+ def accept(visitor, guard)
2279
+ super
2280
+ @element_type.accept(visitor, guard) unless @element_type.nil?
2281
+ end
2282
+
2222
2283
  # @api private
2223
2284
  def callable_args?(callable, guard = nil)
2224
2285
  param_t = callable.param_types
@@ -2230,19 +2291,39 @@ class PArrayType < PCollectionType
2230
2291
  def generalize
2231
2292
  if self == DATA
2232
2293
  self
2294
+ elsif @element_type.nil?
2295
+ DEFAULT
2233
2296
  else
2234
- super
2297
+ ge_type = @element_type.generalize
2298
+ @size_type.nil? && @element_type.equal?(ge_type) ? self : self.class.new(ge_type, nil)
2235
2299
  end
2236
2300
  end
2237
2301
 
2302
+ def eql?(o)
2303
+ super && @element_type == o.element_type
2304
+ end
2305
+
2306
+ def hash
2307
+ super ^ @element_type.hash
2308
+ end
2309
+
2238
2310
  def normalize(guard = nil)
2239
2311
  if self == DATA
2240
2312
  self
2313
+ elsif @element_type.nil?
2314
+ DEFAULT
2241
2315
  else
2242
- super
2316
+ ne_type = @element_type.normalize(guard)
2317
+ @element_type.equal?(ne_type) ? self : self.class.new(ne_type, @size_type)
2243
2318
  end
2244
2319
  end
2245
2320
 
2321
+ def resolve(type_parser, loader)
2322
+ relement_type = @element_type
2323
+ relement_type = relement_type.resolve(type_parser, loader) unless relement_type.nil?
2324
+ relement_type.equal?(@element_type) ? self : self.class.new(relement_type, @size_type)
2325
+ end
2326
+
2246
2327
  def instance?(o, guard = nil)
2247
2328
  return false unless o.is_a?(Array)
2248
2329
  element_t = element_type
@@ -2251,6 +2332,10 @@ class PArrayType < PCollectionType
2251
2332
  size_t.nil? || size_t.instance?(o.size, guard)
2252
2333
  end
2253
2334
 
2335
+ def iterable_type(guard = nil)
2336
+ @element_type.nil? ? PIterableType::DEFAULT : PIterableType.new(@element_type)
2337
+ end
2338
+
2254
2339
  # Returns a new function that produces an Array
2255
2340
  #
2256
2341
  def self.new_function(_, loader)
@@ -2335,33 +2420,38 @@ class PHashType < PCollectionType
2335
2420
  KEY_TYPE => POptionalType.new(PType::DEFAULT),
2336
2421
  KEY_VALUE => nil
2337
2422
  },
2338
- 'element_type' => {
2423
+ 'value_type' => {
2339
2424
  KEY_TYPE => POptionalType.new(PType::DEFAULT),
2340
2425
  KEY_VALUE => nil,
2341
- KEY_OVERRIDE => true
2342
- },
2343
- 'size_type' => {
2344
- KEY_TYPE => POptionalType.new(PType.new(PIntegerType::DEFAULT)),
2345
- KEY_VALUE => nil
2346
2426
  }
2347
2427
  )
2348
2428
  end
2349
2429
 
2350
- attr_accessor :key_type
2351
- alias value_type element_type
2430
+ attr_accessor :key_type, :value_type
2352
2431
 
2353
2432
  def initialize(key_type, value_type, size_type = nil)
2354
- super(value_type, size_type)
2433
+ super(size_type)
2355
2434
  if !size_type.nil? && size_type.from == 0 && size_type.to == 0
2356
2435
  @key_type = PUnitType::DEFAULT
2436
+ @value_type = PUnitType::DEFAULT
2357
2437
  else
2358
2438
  @key_type = key_type
2439
+ @value_type = value_type
2359
2440
  end
2360
2441
  end
2361
2442
 
2362
2443
  def accept(visitor, guard)
2363
2444
  super
2364
2445
  @key_type.accept(visitor, guard) unless @key_type.nil?
2446
+ @value_type.accept(visitor, guard) unless @value_type.nil?
2447
+ end
2448
+
2449
+ def element_type
2450
+ if Puppet[:strict] != :off
2451
+ Puppet.warn_once(:deprecation, 'Puppet::Pops::Types::PHashType#element_type',
2452
+ 'Puppet::Pops::Types::PHashType#element_type is deprecated, use #value_type instead')
2453
+ end
2454
+ @value_type
2365
2455
  end
2366
2456
 
2367
2457
  def generalize
@@ -2370,9 +2460,9 @@ class PHashType < PCollectionType
2370
2460
  else
2371
2461
  key_t = @key_type
2372
2462
  key_t = key_t.generalize unless key_t.nil?
2373
- value_t = @element_type
2463
+ value_t = @value_type
2374
2464
  value_t = value_t.generalize unless value_t.nil?
2375
- @size_type.nil? && @key_type.equal?(key_t) && @element_type.equal?(value_t) ? self : PHashType.new(key_t, value_t, nil)
2465
+ @size_type.nil? && @key_type.equal?(key_t) && @value_type.equal?(value_t) ? self : PHashType.new(key_t, value_t, nil)
2376
2466
  end
2377
2467
  end
2378
2468
 
@@ -2382,22 +2472,22 @@ class PHashType < PCollectionType
2382
2472
  else
2383
2473
  key_t = @key_type
2384
2474
  key_t = key_t.normalize(guard) unless key_t.nil?
2385
- value_t = @element_type
2475
+ value_t = @value_type
2386
2476
  value_t = value_t.normalize(guard) unless value_t.nil?
2387
- @size_type.nil? && @key_type.equal?(key_t) && @element_type.equal?(value_t) ? self : PHashType.new(key_t, value_t, nil)
2477
+ @size_type.nil? && @key_type.equal?(key_t) && @value_type.equal?(value_t) ? self : PHashType.new(key_t, value_t, nil)
2388
2478
  end
2389
2479
  end
2390
2480
 
2391
2481
  def hash
2392
- super ^ @key_type.hash
2482
+ super ^ @key_type.hash ^ @value_type.hash
2393
2483
  end
2394
2484
 
2395
2485
  def instance?(o, guard = nil)
2396
2486
  return false unless o.is_a?(Hash)
2397
2487
  key_t = key_type
2398
- element_t = element_type
2488
+ value_t = value_type
2399
2489
  if (key_t.nil? || o.keys.all? {|key| key_t.instance?(key, guard) }) &&
2400
- (element_t.nil? || o.values.all? {|value| element_t.instance?(value, guard) })
2490
+ (value_t.nil? || o.values.all? {|value| value_t.instance?(value, guard) })
2401
2491
  size_t = size_type
2402
2492
  size_t.nil? || size_t.instance?(o.size, guard)
2403
2493
  else
@@ -2413,12 +2503,12 @@ class PHashType < PCollectionType
2413
2503
  if self == DEFAULT || self == EMPTY
2414
2504
  PIterableType.new(DEFAULT_KEY_PAIR_TUPLE)
2415
2505
  else
2416
- PIterableType.new(PTupleType.new([@key_type, @element_type], KEY_PAIR_TUPLE_SIZE))
2506
+ PIterableType.new(PTupleType.new([@key_type, @value_type], KEY_PAIR_TUPLE_SIZE))
2417
2507
  end
2418
2508
  end
2419
2509
 
2420
2510
  def eql?(o)
2421
- super && @key_type == o.key_type
2511
+ super && @key_type == o.key_type && @value_type == o.value_type
2422
2512
  end
2423
2513
 
2424
2514
  def is_the_empty_hash?
@@ -2428,9 +2518,9 @@ class PHashType < PCollectionType
2428
2518
  def resolve(type_parser, loader)
2429
2519
  rkey_type = @key_type
2430
2520
  rkey_type = rkey_type.resolve(type_parser, loader) unless rkey_type.nil?
2431
- rvalue_type = @element_type
2521
+ rvalue_type = @value_type
2432
2522
  rvalue_type = rvalue_type.resolve(type_parser, loader) unless rvalue_type.nil?
2433
- rkey_type.equal?(@key_type) && rvalue_type.equal?(@element_type) ? self : self.class.new(rkey_type, rvalue_type, @size_type)
2523
+ rkey_type.equal?(@key_type) && rvalue_type.equal?(@value_type) ? self : self.class.new(rkey_type, rvalue_type, @size_type)
2434
2524
  end
2435
2525
 
2436
2526
  # Returns a new function that produces a Hash
@@ -2495,7 +2585,7 @@ class PHashType < PCollectionType
2495
2585
  when PHashType
2496
2586
  size_s = size_type
2497
2587
  return true if (size_s.nil? || size_s.from == 0) && o.is_the_empty_hash?
2498
- return false unless (key_type.nil? || key_type.assignable?(o.key_type, guard)) && (element_type.nil? || element_type.assignable?(o.element_type, guard))
2588
+ return false unless (key_type.nil? || key_type.assignable?(o.key_type, guard)) && (value_type.nil? || value_type.assignable?(o.value_type, guard))
2499
2589
  super
2500
2590
  when PStructType
2501
2591
  # hash must accept String as key type
@@ -2503,7 +2593,7 @@ class PHashType < PCollectionType
2503
2593
  # hash must accept the size of the struct
2504
2594
  o_elements = o.elements
2505
2595
  (size_type || DEFAULT_SIZE).instance?(o_elements.size, guard) &&
2506
- o_elements.all? {|e| (key_type.nil? || key_type.instance?(e.name, guard)) && (element_type.nil? || element_type.assignable?(e.value_type, guard)) }
2596
+ o_elements.all? {|e| (key_type.nil? || key_type.instance?(e.name, guard)) && (value_type.nil? || value_type.assignable?(e.value_type, guard)) }
2507
2597
  else
2508
2598
  false
2509
2599
  end
@@ -2700,11 +2790,11 @@ class PVariantType < PAnyType
2700
2790
  # @api private
2701
2791
  def merge_enums(array)
2702
2792
  if array.size > 1
2703
- parts = array.partition {|t| t.is_a?(PEnumType) || t.is_a?(PStringType) && !t.values.empty? }
2793
+ parts = array.partition {|t| t.is_a?(PEnumType) && !t.values.empty? || t.is_a?(PStringType) && !t.value.nil? }
2704
2794
  enums = parts[0]
2705
2795
  if enums.size > 1
2706
2796
  others = parts[1]
2707
- others << PEnumType.new(enums.map { |enum| enum.values }.flatten.uniq)
2797
+ others << PEnumType.new(enums.map { |enum| enum.is_a?(PStringType) ? enum.value : enum.values }.flatten.uniq)
2708
2798
  array = others
2709
2799
  end
2710
2800
  end
@@ -2883,7 +2973,7 @@ end
2883
2973
  class POptionalType < PTypeWithContainedType
2884
2974
 
2885
2975
  def self.register_ptype(loader, ir)
2886
- create_ptype(loader, ir, 'CatalogEntryType',
2976
+ create_ptype(loader, ir, 'AnyType',
2887
2977
  'type' => {
2888
2978
  KEY_TYPE => POptionalType.new(PType::DEFAULT),
2889
2979
  KEY_VALUE => nil
@@ -3017,9 +3107,10 @@ class PTypeAliasType < PAnyType
3017
3107
  def assignable?(o, guard = nil)
3018
3108
  if @self_recursion
3019
3109
  guard ||= RecursionGuard.new
3020
- return true if guard.add_this(self) == RecursionGuard::SELF_RECURSION_IN_BOTH
3110
+ guard.with_this(self) { |state| state == RecursionGuard::SELF_RECURSION_IN_BOTH ? true : super(o, guard) }
3111
+ else
3112
+ super(o, guard)
3021
3113
  end
3022
- super(o, guard)
3023
3114
  end
3024
3115
 
3025
3116
  # Returns the resolved type. The type must have been resolved by a call prior to calls to this
@@ -3070,7 +3161,7 @@ class PTypeAliasType < PAnyType
3070
3161
  end
3071
3162
 
3072
3163
  def visit(type, _)
3073
- unless type.is_a?(PTypeAliasType) || type.is_a?(PVariantType) || type.is_a?(PTypeReferenceType)
3164
+ unless type.is_a?(PTypeAliasType) || type.is_a?(PVariantType)
3074
3165
  @other_type_detected = true
3075
3166
  end
3076
3167
  end
@@ -3183,10 +3274,12 @@ class PTypeAliasType < PAnyType
3183
3274
  def really_instance?(o, guard = nil)
3184
3275
  if @self_recursion
3185
3276
  guard ||= RecursionGuard.new
3186
- guard.add_that(o)
3187
- return 0 if guard.add_this(self) == RecursionGuard::SELF_RECURSION_IN_BOTH
3277
+ guard.with_that(o) do
3278
+ guard.with_this(self) { |state| state == RecursionGuard::SELF_RECURSION_IN_BOTH ? 0 : resolved_type.really_instance?(o, guard) }
3279
+ end
3280
+ else
3281
+ resolved_type.really_instance?(o, guard)
3188
3282
  end
3189
- resolved_type.really_instance?(o, guard)
3190
3283
  end
3191
3284
 
3192
3285
  # @return `nil` to prevent serialization of the type_expr used when first initializing this instance
@@ -3210,7 +3303,7 @@ class PTypeAliasType < PAnyType
3210
3303
  def guarded_recursion(guard, dflt)
3211
3304
  if @self_recursion
3212
3305
  guard ||= RecursionGuard.new
3213
- (guard.add_this(self) & RecursionGuard::SELF_RECURSION_IN_THIS) == 0 ? yield(guard) : dflt
3306
+ guard.with_this(self) { |state| (state & RecursionGuard::SELF_RECURSION_IN_THIS) == 0 ? yield(guard) : dflt }
3214
3307
  else
3215
3308
  yield(guard)
3216
3309
  end
@@ -3223,7 +3316,7 @@ class PTypeAliasType < PAnyType
3223
3316
  real_types = resolved_types.select do |type|
3224
3317
  next false if type == self
3225
3318
  real_type_asserter = AssertOtherTypeAcceptor.new
3226
- accept(real_type_asserter, RecursionGuard.new)
3319
+ type.accept(real_type_asserter, RecursionGuard.new)
3227
3320
  real_type_asserter.other_type_detected?
3228
3321
  end
3229
3322
  if real_types.size != resolved_types.size