puppet 4.2.3 → 4.3.0

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 (337) hide show
  1. data/Gemfile +3 -0
  2. data/README.md +1 -1
  3. data/ext/debian/puppet.init +0 -1
  4. data/ext/debian/puppet.logrotate +14 -5
  5. data/ext/osx/puppet.plist +0 -2
  6. data/ext/redhat/client.init +13 -5
  7. data/ext/redhat/logrotate +15 -3
  8. data/ext/redhat/puppet.spec.erb +5 -1
  9. data/ext/redhat/server.init +1 -1
  10. data/ext/systemd/puppet.service +1 -0
  11. data/lib/puppet.rb +12 -0
  12. data/lib/puppet/agent.rb +4 -4
  13. data/lib/puppet/agent/locker.rb +11 -2
  14. data/lib/puppet/application/agent.rb +5 -1
  15. data/lib/puppet/application/apply.rb +4 -0
  16. data/lib/puppet/application/filebucket.rb +78 -4
  17. data/lib/puppet/application/lookup.rb +356 -0
  18. data/lib/puppet/application/master.rb +3 -0
  19. data/lib/puppet/configurer.rb +9 -5
  20. data/lib/puppet/context.rb +16 -1
  21. data/lib/puppet/context/trusted_information.rb +21 -1
  22. data/lib/puppet/daemon.rb +17 -13
  23. data/lib/puppet/data_binding.rb +4 -2
  24. data/lib/puppet/data_providers.rb +12 -13
  25. data/lib/puppet/data_providers/data_adapter.rb +7 -68
  26. data/lib/puppet/data_providers/data_function_support.rb +5 -26
  27. data/lib/puppet/data_providers/function_env_data_provider.rb +0 -10
  28. data/lib/puppet/data_providers/function_module_data_provider.rb +0 -22
  29. data/lib/puppet/data_providers/hiera_config.rb +106 -0
  30. data/lib/puppet/data_providers/hiera_env_data_provider.rb +18 -0
  31. data/lib/puppet/data_providers/hiera_interpolate.rb +97 -0
  32. data/lib/puppet/data_providers/hiera_module_data_provider.rb +23 -0
  33. data/lib/puppet/data_providers/hiera_support.rb +37 -0
  34. data/lib/puppet/data_providers/json_data_provider_factory.rb +31 -0
  35. data/lib/puppet/data_providers/lookup_adapter.rb +200 -0
  36. data/lib/puppet/data_providers/yaml_data_provider_factory.rb +32 -0
  37. data/lib/puppet/defaults.rb +12 -2
  38. data/lib/puppet/error.rb +4 -0
  39. data/lib/puppet/face/module/changes.rb +2 -1
  40. data/lib/puppet/feature/cfacter.rb +1 -0
  41. data/lib/puppet/file_bucket/dipper.rb +58 -2
  42. data/lib/puppet/functions.rb +2 -4
  43. data/lib/puppet/functions/assert_type.rb +48 -12
  44. data/lib/puppet/functions/defined.rb +79 -48
  45. data/lib/puppet/functions/each.rb +85 -27
  46. data/lib/puppet/functions/filter.rb +58 -23
  47. data/lib/puppet/functions/hiera.rb +76 -3
  48. data/lib/puppet/functions/hiera_array.rb +65 -3
  49. data/lib/puppet/functions/hiera_hash.rb +74 -2
  50. data/lib/puppet/functions/hiera_include.rb +75 -2
  51. data/lib/puppet/functions/lookup.rb +19 -17
  52. data/lib/puppet/functions/map.rb +56 -21
  53. data/lib/puppet/functions/match.rb +29 -12
  54. data/lib/puppet/functions/reduce.rb +95 -58
  55. data/lib/puppet/functions/versioncmp.rb +36 -0
  56. data/lib/puppet/functions/with.rb +15 -7
  57. data/lib/puppet/indirector/catalog/compiler.rb +3 -3
  58. data/lib/puppet/indirector/catalog/static_compiler.rb +46 -30
  59. data/lib/puppet/indirector/data_binding/none.rb +4 -1
  60. data/lib/puppet/indirector/file_bucket_file/file.rb +58 -1
  61. data/lib/puppet/indirector/hiera.rb +4 -0
  62. data/lib/puppet/indirector/json.rb +1 -1
  63. data/lib/puppet/indirector/msgpack.rb +1 -1
  64. data/lib/puppet/indirector/request.rb +7 -8
  65. data/lib/puppet/indirector/resource_type/parser.rb +5 -3
  66. data/lib/puppet/info_service.rb +7 -0
  67. data/lib/puppet/info_service/class_information_service.rb +111 -0
  68. data/lib/puppet/module_tool/metadata.rb +32 -9
  69. data/lib/puppet/module_tool/skeleton/templates/generator/README.md.erb +42 -38
  70. data/lib/puppet/network/authconfig.rb +21 -1
  71. data/lib/puppet/network/authorization.rb +8 -1
  72. data/lib/puppet/network/http/api/master/v3.rb +7 -1
  73. data/lib/puppet/network/http/api/master/v3/environment.rb +59 -0
  74. data/lib/puppet/node/environment.rb +9 -2
  75. data/lib/puppet/parser.rb +3 -0
  76. data/lib/puppet/parser/ast/pops_bridge.rb +39 -1
  77. data/lib/puppet/parser/compiler.rb +302 -12
  78. data/lib/puppet/parser/compiler/catalog_validator.rb +33 -0
  79. data/lib/puppet/parser/compiler/catalog_validator/env_relationship_validator.rb +64 -0
  80. data/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb +38 -0
  81. data/lib/puppet/parser/compiler/catalog_validator/site_validator.rb +20 -0
  82. data/lib/puppet/parser/environment_compiler.rb +165 -0
  83. data/lib/puppet/parser/functions/assert_type.rb +46 -16
  84. data/lib/puppet/parser/functions/defined.rb +105 -68
  85. data/lib/puppet/parser/functions/each.rb +85 -27
  86. data/lib/puppet/parser/functions/filter.rb +59 -23
  87. data/lib/puppet/parser/functions/hiera.rb +83 -27
  88. data/lib/puppet/parser/functions/hiera_array.rb +71 -28
  89. data/lib/puppet/parser/functions/hiera_hash.rb +81 -30
  90. data/lib/puppet/parser/functions/hiera_include.rb +81 -40
  91. data/lib/puppet/parser/functions/map.rb +55 -20
  92. data/lib/puppet/parser/functions/match.rb +27 -12
  93. data/lib/puppet/parser/functions/reduce.rb +97 -60
  94. data/lib/puppet/parser/functions/with.rb +16 -8
  95. data/lib/puppet/parser/resource.rb +98 -19
  96. data/lib/puppet/plugins/configuration.rb +3 -2
  97. data/lib/puppet/plugins/data_providers.rb +12 -60
  98. data/lib/puppet/plugins/data_providers/data_provider.rb +283 -0
  99. data/lib/puppet/plugins/data_providers/registry.rb +84 -0
  100. data/lib/puppet/pops.rb +19 -17
  101. data/lib/puppet/pops/adapters.rb +12 -0
  102. data/lib/puppet/pops/binder/binder.rb +2 -2
  103. data/lib/puppet/pops/binder/bindings_checker.rb +1 -1
  104. data/lib/puppet/pops/binder/bindings_label_provider.rb +3 -1
  105. data/lib/puppet/pops/binder/bindings_loader.rb +6 -2
  106. data/lib/puppet/pops/binder/bindings_model_meta.rb +2 -2
  107. data/lib/puppet/pops/binder/config/binder_config.rb +1 -1
  108. data/lib/puppet/pops/binder/injector.rb +4 -4
  109. data/lib/puppet/pops/binder/key_factory.rb +3 -9
  110. data/lib/puppet/pops/binder/scheme_handler/module_scheme.rb +68 -9
  111. data/lib/puppet/pops/evaluator/access_operator.rb +27 -60
  112. data/lib/puppet/pops/evaluator/closure.rb +8 -8
  113. data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +1 -1
  114. data/lib/puppet/pops/evaluator/evaluator_impl.rb +5 -5
  115. data/lib/puppet/pops/evaluator/literal_evaluator.rb +87 -0
  116. data/lib/puppet/pops/evaluator/relationship_operator.rb +7 -1
  117. data/lib/puppet/pops/functions/dispatcher.rb +3 -3
  118. data/lib/puppet/pops/issues.rb +1 -1
  119. data/lib/puppet/pops/label_provider.rb +1 -1
  120. data/lib/puppet/pops/lookup.rb +25 -47
  121. data/lib/puppet/pops/lookup/explainer.rb +402 -0
  122. data/lib/puppet/pops/lookup/invocation.rb +117 -0
  123. data/lib/puppet/pops/merge_strategy.rb +73 -5
  124. data/lib/puppet/pops/model/factory.rb +34 -0
  125. data/lib/puppet/pops/model/model_label_provider.rb +10 -1
  126. data/lib/puppet/pops/model/model_meta.rb +15 -0
  127. data/lib/puppet/pops/model/model_tree_dumper.rb +18 -0
  128. data/lib/puppet/pops/parser/code_merger.rb +13 -1
  129. data/lib/puppet/pops/parser/egrammar.ra +56 -3
  130. data/lib/puppet/pops/parser/eparser.rb +1549 -1352
  131. data/lib/puppet/pops/parser/lexer2.rb +31 -6
  132. data/lib/puppet/pops/parser/locator.rb +1 -1
  133. data/lib/puppet/pops/parser/parser_support.rb +25 -13
  134. data/lib/puppet/pops/types/enumeration.rb +1 -2
  135. data/lib/puppet/pops/types/type_asserter.rb +16 -15
  136. data/lib/puppet/pops/types/type_assertion_error.rb +1 -0
  137. data/lib/puppet/pops/types/type_calculator.rb +171 -1020
  138. data/lib/puppet/pops/types/type_factory.rb +87 -148
  139. data/lib/puppet/pops/types/type_mismatch_describer.rb +743 -0
  140. data/lib/puppet/pops/types/type_parser.rb +116 -127
  141. data/lib/puppet/pops/types/types.rb +1394 -255
  142. data/lib/puppet/pops/types/types_meta.rb +0 -234
  143. data/lib/puppet/pops/validation.rb +7 -2
  144. data/lib/puppet/pops/validation/checker4_0.rb +28 -0
  145. data/lib/puppet/provider/augeas/augeas.rb +50 -0
  146. data/lib/puppet/provider/group/directoryservice.rb +10 -0
  147. data/lib/puppet/provider/package/dnf.rb +41 -0
  148. data/lib/puppet/provider/package/gem.rb +7 -2
  149. data/lib/puppet/provider/package/rpm.rb +1 -0
  150. data/lib/puppet/provider/package/windows/exe_package.rb +10 -8
  151. data/lib/puppet/provider/package/windows/msi_package.rb +4 -3
  152. data/lib/puppet/provider/package/windows/package.rb +9 -1
  153. data/lib/puppet/provider/package/yum.rb +14 -9
  154. data/lib/puppet/provider/service/bsd.rb +1 -1
  155. data/lib/puppet/provider/service/debian.rb +21 -0
  156. data/lib/puppet/provider/service/init.rb +6 -0
  157. data/lib/puppet/provider/service/rcng.rb +51 -0
  158. data/lib/puppet/provider/service/redhat.rb +2 -1
  159. data/lib/puppet/provider/service/smf.rb +43 -2
  160. data/lib/puppet/provider/service/src.rb +27 -0
  161. data/lib/puppet/provider/service/systemd.rb +15 -3
  162. data/lib/puppet/provider/sshkey/parsed.rb +19 -9
  163. data/lib/puppet/reference/report.rb +9 -12
  164. data/lib/puppet/reports.rb +5 -1
  165. data/lib/puppet/resource.rb +50 -73
  166. data/lib/puppet/resource/capability_finder.rb +95 -0
  167. data/lib/puppet/resource/catalog.rb +47 -7
  168. data/lib/puppet/resource/status.rb +0 -2
  169. data/lib/puppet/resource/type.rb +238 -44
  170. data/lib/puppet/resource/type_collection.rb +60 -2
  171. data/lib/puppet/settings.rb +2 -2
  172. data/lib/puppet/ssl/certificate_authority/interface.rb +2 -2
  173. data/lib/puppet/ssl/oids.rb +9 -1
  174. data/lib/puppet/transaction.rb +4 -1
  175. data/lib/puppet/transaction/additional_resource_generator.rb +71 -8
  176. data/lib/puppet/transaction/resource_harness.rb +9 -4
  177. data/lib/puppet/type.rb +74 -3
  178. data/lib/puppet/type/augeas.rb +8 -0
  179. data/lib/puppet/type/file/source.rb +14 -12
  180. data/lib/puppet/type/user.rb +4 -2
  181. data/lib/puppet/util/windows/security.rb +4 -1
  182. data/lib/puppet/util/windows/taskscheduler.rb +1 -1
  183. data/lib/puppet/version.rb +1 -1
  184. data/spec/fixtures/unit/application/environments/production/data/common.yaml +3 -0
  185. data/spec/fixtures/unit/application/environments/production/environment.conf +1 -0
  186. data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/data/bad.json +3 -0
  187. data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/environment.conf +2 -0
  188. data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/hiera.yaml +5 -0
  189. data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/manifests/site.pp +5 -0
  190. data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/data/bad.yaml +3 -0
  191. data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/environment.conf +2 -0
  192. data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/hiera.yaml +5 -0
  193. data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/manifests/site.pp +5 -0
  194. data/spec/fixtures/unit/data_providers/environments/hiera_defaults/data/common.yaml +2 -0
  195. data/spec/fixtures/unit/data_providers/environments/hiera_defaults/environment.conf +2 -0
  196. data/spec/fixtures/unit/data_providers/environments/hiera_defaults/manifests/site.pp +1 -0
  197. data/spec/fixtures/unit/data_providers/environments/hiera_defaults/modules/one/data/common.yaml +2 -0
  198. data/spec/fixtures/unit/data_providers/environments/hiera_defaults/modules/one/manifests/init.pp +5 -0
  199. data/spec/fixtures/unit/data_providers/environments/hiera_defaults/modules/one/metadata.json +9 -0
  200. data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/first.json +3 -0
  201. data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/name.yaml +2 -0
  202. data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/second.json +3 -0
  203. data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/single.yaml +2 -0
  204. data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data2/single.yaml +2 -0
  205. data/spec/fixtures/unit/data_providers/environments/hiera_env_config/environment.conf +2 -0
  206. data/spec/fixtures/unit/data_providers/environments/hiera_env_config/hiera.yaml +18 -0
  207. data/spec/fixtures/unit/data_providers/environments/hiera_env_config/manifests/site.pp +5 -0
  208. data/spec/fixtures/unit/data_providers/environments/hiera_misc/data/common.yaml +46 -0
  209. data/spec/fixtures/unit/data_providers/environments/hiera_misc/environment.conf +2 -0
  210. data/spec/fixtures/unit/data_providers/environments/hiera_misc/manifests/site.pp +1 -0
  211. data/spec/fixtures/unit/data_providers/environments/hiera_misc/modules/one/data/common.yaml +30 -0
  212. data/spec/fixtures/unit/data_providers/environments/hiera_misc/modules/one/manifests/init.pp +13 -0
  213. data/spec/fixtures/unit/data_providers/environments/hiera_misc/modules/one/metadata.json +9 -0
  214. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/environment.conf +2 -0
  215. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/manifests/site.pp +1 -0
  216. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/first.json +3 -0
  217. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/name.yaml +1 -0
  218. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/second.json +3 -0
  219. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/single.yaml +2 -0
  220. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data2/single.yaml +2 -0
  221. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/hiera.yaml +18 -0
  222. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/manifests/init.pp +5 -0
  223. data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/metadata.json +9 -0
  224. data/spec/fixtures/unit/data_providers/environments/sample/modules/dataprovider/lib/puppet_x/helindbe/sample_env_data.rb +1 -0
  225. data/spec/fixtures/unit/data_providers/environments/sample/modules/dataprovider/lib/puppet_x/helindbe/sample_module_data.rb +1 -0
  226. data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/data/first.json +3 -0
  227. data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/hiera.yaml +8 -0
  228. data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/manifests/init.pp +5 -0
  229. data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/metadata.json +9 -0
  230. data/spec/fixtures/unit/functions/lookup/environments/production/modules/meta/lib/puppet/functions/meta/data.rb +9 -0
  231. data/spec/fixtures/unit/functions/lookup/environments/production/modules/meta/manifests/init.pp +3 -0
  232. data/spec/fixtures/unit/functions/lookup/environments/production/modules/meta/metadata.json +9 -0
  233. data/spec/fixtures/unit/functions/lookup/environments/production/modules/metawcp/lib/puppet/bindings/metawcp/default.rb +10 -0
  234. data/spec/fixtures/unit/functions/lookup/environments/production/modules/metawcp/lib/puppet_x/thallgren/sample_module_data.rb +23 -0
  235. data/spec/fixtures/unit/functions/lookup/environments/production/modules/metawcp/manifests/init.pp +3 -0
  236. data/spec/fixtures/unit/functions/lookup/environments/production/modules/metawcp/metadata.json +9 -0
  237. data/spec/fixtures/unit/provider/package/yum/yum-check-update-security.txt +184 -0
  238. data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_get/should_yield_to_the_block.yml +24 -0
  239. data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_head/should_yield_to_the_block.yml +24 -0
  240. data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_post/should_yield_to_the_block.yml +24 -0
  241. data/spec/integration/data_binding_spec.rb +229 -0
  242. data/spec/integration/file_bucket/file_spec.rb +2 -2
  243. data/spec/integration/parser/compiler_spec.rb +23 -19
  244. data/spec/integration/parser/resource_expressions_spec.rb +4 -4
  245. data/spec/integration/parser/undef_param_spec.rb +1 -1
  246. data/spec/integration/resource/catalog_spec.rb +1 -1
  247. data/spec/integration/type/package_spec.rb +2 -0
  248. data/spec/integration/util/windows/security_spec.rb +18 -0
  249. data/spec/lib/matchers/include_in_order.rb +2 -2
  250. data/spec/shared_behaviours/iterative_functions.rb +8 -8
  251. data/spec/spec_helper.rb +7 -0
  252. data/spec/unit/agent/locker_spec.rb +4 -4
  253. data/spec/unit/agent_spec.rb +0 -8
  254. data/spec/unit/application/agent_spec.rb +5 -0
  255. data/spec/unit/application/apply_spec.rb +8 -0
  256. data/spec/unit/application/filebucket_spec.rb +87 -1
  257. data/spec/unit/application/lookup_spec.rb +195 -0
  258. data/spec/unit/appmgmt_spec.rb +657 -0
  259. data/spec/unit/capability_spec.rb +414 -0
  260. data/spec/unit/configurer_spec.rb +7 -1
  261. data/spec/unit/context/trusted_information_spec.rb +24 -1
  262. data/spec/unit/daemon_spec.rb +18 -8
  263. data/spec/unit/data_providers/hiera_data_provider_spec.rb +201 -0
  264. data/spec/unit/file_bucket/dipper_spec.rb +210 -1
  265. data/spec/unit/functions/assert_type_spec.rb +5 -7
  266. data/spec/unit/functions/defined_spec.rb +2 -2
  267. data/spec/unit/functions/epp_spec.rb +2 -2
  268. data/spec/unit/functions/lookup_spec.rb +200 -9
  269. data/spec/unit/functions/regsubst_spec.rb +17 -8
  270. data/spec/unit/functions/scanf_spec.rb +1 -1
  271. data/spec/unit/functions/split_spec.rb +2 -2
  272. data/spec/unit/functions/versioncmp_spec.rb +36 -0
  273. data/spec/unit/functions4_spec.rb +58 -72
  274. data/spec/unit/indirector/catalog/compiler_spec.rb +28 -8
  275. data/spec/unit/indirector/catalog/static_compiler_spec.rb +38 -20
  276. data/spec/unit/indirector/data_binding/none_spec.rb +2 -2
  277. data/spec/unit/indirector/file_bucket_file/file_spec.rb +52 -1
  278. data/spec/unit/indirector/request_spec.rb +8 -8
  279. data/spec/unit/info_service_spec.rb +236 -0
  280. data/spec/unit/module_tool/metadata_spec.rb +31 -2
  281. data/spec/unit/network/authconfig_spec.rb +62 -32
  282. data/spec/unit/network/authorization_spec.rb +30 -2
  283. data/spec/unit/network/http/connection_spec.rb +14 -19
  284. data/spec/unit/parser/compiler_spec.rb +86 -2
  285. data/spec/unit/parser/functions/create_resources_spec.rb +1 -1
  286. data/spec/unit/parser/resource_spec.rb +2 -20
  287. data/spec/unit/pops/binder/config/binder_config_spec.rb +1 -1
  288. data/spec/unit/pops/binder/injector_spec.rb +3 -3
  289. data/spec/unit/pops/evaluator/access_ops_spec.rb +13 -11
  290. data/spec/unit/pops/evaluator/basic_expressions_spec.rb +1 -2
  291. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +19 -11
  292. data/spec/unit/pops/evaluator/literal_evaluator_spec.rb +43 -0
  293. data/spec/unit/pops/label_provider_spec.rb +5 -1
  294. data/spec/unit/pops/parser/lexer2_spec.rb +33 -7
  295. data/spec/unit/pops/parser/parse_application_spec.rb +40 -0
  296. data/spec/unit/pops/parser/parse_basic_expressions_spec.rb +4 -0
  297. data/spec/unit/pops/parser/parse_capabilities_spec.rb +47 -0
  298. data/spec/unit/pops/parser/parse_site_spec.rb +38 -0
  299. data/spec/unit/pops/parser/parser_rspec_helper.rb +5 -0
  300. data/spec/unit/pops/parser/parser_spec.rb +18 -0
  301. data/spec/unit/pops/types/type_calculator_spec.rb +427 -444
  302. data/spec/unit/pops/types/type_factory_spec.rb +12 -12
  303. data/spec/unit/pops/types/type_parser_spec.rb +7 -12
  304. data/spec/unit/pops/validator/validator_spec.rb +25 -0
  305. data/spec/unit/provider/augeas/augeas_spec.rb +50 -0
  306. data/spec/unit/provider/group/directoryservice_spec.rb +33 -0
  307. data/spec/unit/provider/group/windows_adsi_spec.rb +3 -0
  308. data/spec/unit/provider/package/dnf_spec.rb +92 -0
  309. data/spec/unit/provider/package/gem_spec.rb +7 -0
  310. data/spec/unit/provider/package/rpm_spec.rb +25 -2
  311. data/spec/unit/provider/package/windows/package_spec.rb +41 -0
  312. data/spec/unit/provider/package/yum_spec.rb +21 -13
  313. data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +10 -0
  314. data/spec/unit/provider/service/debian_spec.rb +27 -0
  315. data/spec/unit/provider/service/rcng_spec.rb +41 -0
  316. data/spec/unit/provider/service/redhat_spec.rb +8 -1
  317. data/spec/unit/provider/service/smf_spec.rb +30 -5
  318. data/spec/unit/provider/service/src_spec.rb +19 -4
  319. data/spec/unit/provider/service/systemd_spec.rb +78 -29
  320. data/spec/unit/provider/sshkey/parsed_spec.rb +23 -0
  321. data/spec/unit/reports_spec.rb +10 -0
  322. data/spec/unit/resource/capability_finder_spec.rb +56 -0
  323. data/spec/unit/resource/catalog_spec.rb +31 -8
  324. data/spec/unit/resource/type_collection_spec.rb +23 -2
  325. data/spec/unit/resource/type_spec.rb +1 -1
  326. data/spec/unit/resource_spec.rb +22 -4
  327. data/spec/unit/settings_spec.rb +90 -1
  328. data/spec/unit/ssl/certificate_authority/interface_spec.rb +4 -3
  329. data/spec/unit/ssl/oids_spec.rb +8 -0
  330. data/spec/unit/transaction/additional_resource_generator_spec.rb +78 -5
  331. data/spec/unit/transaction/report_spec.rb +24 -1
  332. data/spec/unit/type/package_spec.rb +1 -0
  333. data/spec/unit/type/user_spec.rb +14 -7
  334. data/spec/unit/type_spec.rb +1 -1
  335. metadata +169 -5
  336. data/lib/puppet/pops/evaluator/callable_mismatch_describer.rb +0 -175
  337. data/spec/integration/data_binding.rb +0 -104
@@ -4,49 +4,46 @@
4
4
  module Puppet::Pops::Types::TypeFactory
5
5
  Types = Puppet::Pops::Types
6
6
  @type_calculator = Types::TypeCalculator.singleton
7
- @undef_t = Types::PUndefType.new
8
7
 
9
8
  # Produces the Integer type
10
9
  # @api public
11
10
  #
12
- def self.integer()
13
- Types::PIntegerType.new()
11
+ def self.integer
12
+ Types::PIntegerType::DEFAULT
14
13
  end
15
14
 
16
15
  # Produces an Integer range type
17
16
  # @api public
18
17
  #
19
18
  def self.range(from, to)
20
- t = Types::PIntegerType.new()
21
19
  # optimize eq with symbol (faster when it is left)
22
- t.from = from unless (:default == from || from == 'default')
23
- t.to = to unless (:default == to || to == 'default')
24
- t
20
+ from = :default == from if from == 'default'
21
+ to = :default if to == 'default'
22
+ Types::PIntegerType.new(from, to)
25
23
  end
26
24
 
27
25
  # Produces a Float range type
28
26
  # @api public
29
27
  #
30
28
  def self.float_range(from, to)
31
- t = Types::PFloatType.new()
32
29
  # optimize eq with symbol (faster when it is left)
33
- t.from = Float(from) unless :default == from || from.nil?
34
- t.to = Float(to) unless :default == to || to.nil?
35
- t
30
+ from = Float(from) unless :default == from || from.nil?
31
+ to = Float(to) unless :default == to || to.nil?
32
+ Types::PFloatType.new(from, to)
36
33
  end
37
34
 
38
35
  # Produces the Float type
39
36
  # @api public
40
37
  #
41
- def self.float()
42
- Types::PFloatType.new()
38
+ def self.float
39
+ Types::PFloatType::DEFAULT
43
40
  end
44
41
 
45
42
  # Produces the Numeric type
46
43
  # @api public
47
44
  #
48
- def self.numeric()
49
- Types::PNumericType.new()
45
+ def self.numeric
46
+ Types::PNumericType::DEFAULT
50
47
  end
51
48
 
52
49
  # Produces a string representation of the type
@@ -59,10 +56,8 @@ module Puppet::Pops::Types::TypeFactory
59
56
  # Produces the String type, optionally with specific string values
60
57
  # @api public
61
58
  #
62
- def self.string(*values)
63
- t = Types::PStringType.new()
64
- values.each {|v| t.addValues(v) }
65
- t
59
+ def self.string(size_type = nil, *values)
60
+ Types::PStringType.new(size_type, values)
66
61
  end
67
62
 
68
63
  # Produces the Optional type, i.e. a short hand for Variant[T, Undef]
@@ -75,27 +70,21 @@ module Puppet::Pops::Types::TypeFactory
75
70
  # @api public
76
71
  #
77
72
  def self.optional(optional_type = nil)
78
- t = Types::POptionalType.new
79
- t.optional_type = optional_type.is_a?(String) ? string(optional_type) : type_of(optional_type)
80
- t
73
+ Types::POptionalType.new(type_of(optional_type.is_a?(String) ? string(nil, optional_type) : type_of(optional_type)))
81
74
  end
82
75
 
83
76
  # Produces the Enum type, optionally with specific string values
84
77
  # @api public
85
78
  #
86
79
  def self.enum(*values)
87
- t = Types::PEnumType.new()
88
- values.each {|v| t.addValues(v) }
89
- t
80
+ Types::PEnumType.new(values)
90
81
  end
91
82
 
92
83
  # Produces the Variant type, optionally with the "one of" types
93
84
  # @api public
94
85
  #
95
86
  def self.variant(*types)
96
- t = Types::PVariantType.new()
97
- t.types = types.map {|v| type_of(v) }
98
- t
87
+ Types::PVariantType.new(types.map {|v| type_of(v) })
99
88
  end
100
89
 
101
90
  # Produces the Struct type, either a non parameterized instance representing
@@ -111,17 +100,16 @@ module Puppet::Pops::Types::TypeFactory
111
100
  #
112
101
  def self.struct(hash = {})
113
102
  tc = @type_calculator
114
- t = Types::PStructType.new
115
- t.elements = hash.map do |key_type, value_type|
103
+ elements = hash.map do |key_type, value_type|
116
104
  value_type = type_of(value_type)
117
105
  raise ArgumentError, 'Struct element value_type must be a Type' unless value_type.is_a?(Types::PAnyType)
118
106
 
119
107
  # TODO: Should have stricter name rule
120
108
  if key_type.is_a?(String)
121
109
  raise ArgumentError, 'Struct element key cannot be an empty String' if key_type.empty?
122
- key_type = string(key_type)
110
+ key_type = string(nil, key_type)
123
111
  # Must make key optional if the value can be Undef
124
- key_type = optional(key_type) if tc.assignable?(value_type, @undef_t)
112
+ key_type = optional(key_type) if tc.assignable?(value_type, Types::PUndefType::DEFAULT)
125
113
  else
126
114
  # assert that the key type is one of String[1], NotUndef[String[1]] and Optional[String[1]]
127
115
  case key_type
@@ -131,39 +119,36 @@ module Puppet::Pops::Types::TypeFactory
131
119
  s = key_type
132
120
  when Types::POptionalType
133
121
  s = key_type.optional_type
134
- else
122
+ when Types::PStringType, Types::PEnumType
135
123
  s = key_type
124
+ else
125
+ raise ArgumentError, "Illegal Struct member key type. Expected NotUndef, Optional, String, or Enum. Got: #{key_type.class.name}"
136
126
  end
137
127
  unless (s.is_a?(Puppet::Pops::Types::PStringType) || s.is_a?(Puppet::Pops::Types::PEnumType)) && s.values.size == 1 && !s.values[0].empty?
138
- raise ArgumentError, 'Unable to extract a non-empty literal string from Struct member key type' if key_type.empty?
128
+ raise ArgumentError, "Unable to extract a non-empty literal string from Struct member key type #{tc.string(key_type)}"
139
129
  end
140
130
  end
141
- elem = Types::PStructElement.new
142
- elem.key_type = key_type
143
- elem.value_type = value_type
144
- elem
131
+ Types::PStructElement.new(key_type, value_type)
145
132
  end
146
- t
133
+ Types::PStructType.new(elements)
147
134
  end
148
135
 
149
- def self.tuple(*types)
150
- t = Types::PTupleType.new
151
- t.types = types.map {|elem| type_of(elem) }
152
- t
136
+ def self.tuple(types = [], size_type = nil)
137
+ Types::PTupleType.new(types.map {|elem| type_of(elem) }, size_type)
153
138
  end
154
139
 
155
140
  # Produces the Boolean type
156
141
  # @api public
157
142
  #
158
- def self.boolean()
159
- Types::PBooleanType.new()
143
+ def self.boolean
144
+ Types::PBooleanType::DEFAULT
160
145
  end
161
146
 
162
147
  # Produces the Any type
163
148
  # @api public
164
149
  #
165
- def self.any()
166
- Types::PAnyType.new()
150
+ def self.any
151
+ Types::PAnyType::DEFAULT
167
152
  end
168
153
 
169
154
  # Produces the Regexp type
@@ -172,59 +157,54 @@ module Puppet::Pops::Types::TypeFactory
172
157
  # @api public
173
158
  #
174
159
  def self.regexp(pattern = nil)
175
- t = Types::PRegexpType.new()
176
160
  if pattern
177
- t.pattern = pattern.is_a?(Regexp) ? pattern.inspect[1..-2] : pattern
161
+ t = Types::PRegexpType.new(pattern.is_a?(Regexp) ? pattern.inspect[1..-2] : pattern)
162
+ t.regexp unless pattern.nil? # compile pattern to catch errors
163
+ t
164
+ else
165
+ Types::PRegexpType::DEFAULT
178
166
  end
179
- t.regexp() unless pattern.nil? # compile pattern to catch errors
180
- t
181
167
  end
182
168
 
183
169
  def self.pattern(*regular_expressions)
184
- t = Types::PPatternType.new()
185
- regular_expressions.each do |re|
170
+ patterns = regular_expressions.map do |re|
186
171
  case re
187
172
  when String
188
- re_T = Types::PRegexpType.new()
189
- re_T.pattern = re
190
- re_T.regexp() # compile it to catch errors
191
- t.addPatterns(re_T)
173
+ re_t = Types::PRegexpType.new(re)
174
+ re_t.regexp # compile it to catch errors
175
+ re_t
192
176
 
193
177
  when Regexp
194
- re_T = Types::PRegexpType.new()
195
178
  # Regep.to_s includes options user did not enter and does not escape source
196
179
  # to work either as a string or as a // regexp. The inspect method does a better
197
180
  # job, but includes the //
198
- re_T.pattern = re.inspect[1..-2]
199
- t.addPatterns(re_T)
181
+ Types::PRegexpType.new(re.inspect[1..-2])
200
182
 
201
183
  when Types::PRegexpType
202
- t.addPatterns(re.copy)
184
+ re
203
185
 
204
186
  when Types::PPatternType
205
- re.patterns.each do |p|
206
- t.addPatterns(p.copy)
207
- end
187
+ re.patterns
208
188
 
209
189
  else
210
190
  raise ArgumentError, "Only String, Regexp, Pattern-Type, and Regexp-Type are allowed: got '#{re.class}"
211
191
  end
212
- end
213
- t
192
+ end.flatten.uniq
193
+ Types::PPatternType.new(patterns)
214
194
  end
215
195
 
216
196
  # Produces the Literal type
217
197
  # @api public
218
198
  #
219
- def self.scalar()
220
- Types::PScalarType.new()
199
+ def self.scalar
200
+ Types::PScalarType::DEFAULT
221
201
  end
222
202
 
223
203
  # Produces a CallableType matching all callables
224
204
  # @api public
225
205
  #
226
- def self.all_callables()
227
- return Puppet::Pops::Types::PCallableType.new
206
+ def self.all_callables
207
+ return Puppet::Pops::Types::PCallableType::DEFAULT
228
208
  end
229
209
 
230
210
  # Produces a Callable type with one signature without support for a block
@@ -244,9 +224,7 @@ module Puppet::Pops::Types::TypeFactory
244
224
  # Params are given as a sequence of arguments to {#type_of}.
245
225
  #
246
226
  def self.callable(*params)
247
- if Puppet::Pops::Types::TypeCalculator.is_kind_of_callable?(params.last)
248
- last_callable = true
249
- end
227
+ last_callable = Puppet::Pops::Types::TypeCalculator.is_kind_of_callable?(params.last)
250
228
  block_t = last_callable ? params.pop : nil
251
229
 
252
230
  # compute a size_type for the signature based on the two last parameters
@@ -256,63 +234,50 @@ module Puppet::Pops::Types::TypeFactory
256
234
  elsif is_range_parameter?(params[-1])
257
235
  size_type = range(params[-1], :default)
258
236
  params = params[0, params.size - 1]
237
+ else
238
+ size_type = nil
259
239
  end
260
240
 
261
241
  types = params.map {|p| type_of(p) }
262
242
 
263
243
  # If the specification requires types, and none were given, a Unit type is used
264
244
  if types.empty? && !size_type.nil? && size_type.range[1] > 0
265
- types << Types::PUnitType.new
245
+ types << Types::PUnitType::DEFAULT
266
246
  end
267
247
  # create a signature
268
- callable_t = Types::PCallableType.new()
269
- tuple_t = tuple(*types)
270
- tuple_t.size_type = size_type unless size_type.nil?
271
- callable_t.param_types = tuple_t
272
-
273
- callable_t.block_type = block_t
274
- callable_t
275
- end
276
-
277
- def self.with_block(callable, *block_params)
278
- callable.block_type = callable(*block_params)
279
- callable
280
- end
281
-
282
- def self.with_optional_block(callable, *block_params)
283
- callable.block_type = optional(callable(*block_params))
284
- callable
248
+ tuple_t = tuple(types, size_type)
249
+ Types::PCallableType.new(tuple_t, block_t)
285
250
  end
286
251
 
287
252
  # Produces the abstract type Collection
288
253
  # @api public
289
254
  #
290
- def self.collection()
291
- Types::PCollectionType.new()
255
+ def self.collection(size_type = nil)
256
+ size_type.nil? ? Types::PCollectionType::DEFAULT : Types::PCollectionType.new(nil, size_type)
292
257
  end
293
258
 
294
259
  # Produces the Data type
295
260
  # @api public
296
261
  #
297
- def self.data()
298
- Types::PDataType.new()
262
+ def self.data
263
+ Types::PDataType::DEFAULT
299
264
  end
300
265
 
301
266
  # Creates an instance of the Undef type
302
267
  # @api public
303
- def self.undef()
304
- Types::PUndefType.new()
268
+ def self.undef
269
+ Types::PUndefType::DEFAULT
305
270
  end
306
271
 
307
272
  # Creates an instance of the Default type
308
273
  # @api public
309
- def self.default()
310
- Types::PDefaultType.new()
274
+ def self.default
275
+ Types::PDefaultType::DEFAULT
311
276
  end
312
277
 
313
278
  # Produces an instance of the abstract type PCatalogEntryType
314
- def self.catalog_entry()
315
- Types::PCatalogEntryType.new()
279
+ def self.catalog_entry
280
+ Types::PCatalogEntryType::DEFAULT
316
281
  end
317
282
 
318
283
  # Produces a PResourceType with a String type_name A PResourceType with a nil
@@ -321,18 +286,15 @@ module Puppet::Pops::Types::TypeFactory
321
286
  # name. (There is no resource-type subtyping in Puppet (yet)).
322
287
  #
323
288
  def self.resource(type_name = nil, title = nil)
324
- type = Types::PResourceType.new()
325
289
  type_name = type_name.type_name if type_name.is_a?(Types::PResourceType)
326
290
  type_name = type_name.downcase unless type_name.nil?
327
- type.type_name = type_name
328
291
  unless type_name.nil? || type_name =~ Puppet::Pops::Patterns::CLASSREF
329
292
  raise ArgumentError, "Illegal type name '#{type.type_name}'"
330
293
  end
331
294
  if type_name.nil? && !title.nil?
332
- raise ArgumentError, "The type name cannot be nil, if title is given"
295
+ raise ArgumentError, 'The type name cannot be nil, if title is given'
333
296
  end
334
- type.title = title
335
- type
297
+ Types::PResourceType.new(type_name, title)
336
298
  end
337
299
 
338
300
  # Produces PHostClassType with a string class_name. A PHostClassType with
@@ -341,51 +303,41 @@ module Puppet::Pops::Types::TypeFactory
341
303
  # with the same name.
342
304
  #
343
305
  def self.host_class(class_name = nil)
344
- type = Types::PHostClassType.new()
345
- unless class_name.nil?
346
- type.class_name = class_name.sub(/^::/, '')
306
+ if class_name.nil?
307
+ Types::PHostClassType::DEFAULT
308
+ else
309
+ Types::PHostClassType.new(class_name.sub(/^::/, ''))
347
310
  end
348
- type
349
311
  end
350
312
 
351
313
  # Produces a type for Array[o] where o is either a type, or an instance for
352
314
  # which a type is inferred.
353
315
  # @api public
354
316
  #
355
- def self.array_of(o)
356
- type = Types::PArrayType.new()
357
- type.element_type = type_of(o)
358
- type
317
+ def self.array_of(o, size_type = nil)
318
+ Types::PArrayType.new(type_of(o), size_type)
359
319
  end
360
320
 
361
321
  # Produces a type for Hash[Scalar, o] where o is either a type, or an
362
322
  # instance for which a type is inferred.
363
323
  # @api public
364
324
  #
365
- def self.hash_of(value, key = scalar())
366
- type = Types::PHashType.new()
367
- type.key_type = type_of(key)
368
- type.element_type = type_of(value)
369
- type
325
+ def self.hash_of(value, key = scalar, size_type = nil)
326
+ Types::PHashType.new(type_of(key), type_of(value), size_type)
370
327
  end
371
328
 
372
329
  # Produces a type for Array[Data]
373
330
  # @api public
374
331
  #
375
- def self.array_of_data()
376
- type = Types::PArrayType.new()
377
- type.element_type = data()
378
- type
332
+ def self.array_of_data
333
+ Types::PArrayType::DATA
379
334
  end
380
335
 
381
336
  # Produces a type for Hash[Scalar, Data]
382
337
  # @api public
383
338
  #
384
- def self.hash_of_data()
385
- type = Types::PHashType.new()
386
- type.key_type = scalar()
387
- type.element_type = data()
388
- type
339
+ def self.hash_of_data
340
+ Types::PHashType::DATA
389
341
  end
390
342
 
391
343
  # Produces a type for NotUndef[T]
@@ -398,19 +350,15 @@ module Puppet::Pops::Types::TypeFactory
398
350
  # @api public
399
351
  #
400
352
  def self.not_undef(inst_type = nil)
401
- type = Types::PNotUndefType.new()
402
- inst_type = string(inst_type) if inst_type.is_a?(String)
403
- type.type = inst_type
404
- type
353
+ inst_type = string(nil, inst_type) if inst_type.is_a?(String)
354
+ Types::PNotUndefType.new(inst_type)
405
355
  end
406
356
 
407
357
  # Produces a type for Type[T]
408
358
  # @api public
409
359
  #
410
360
  def self.type_type(inst_type = nil)
411
- type = Types::PType.new()
412
- type.type = inst_type
413
- type
361
+ inst_type.nil? ? Types::PType::DEFAULT : Types::PType.new(inst_type)
414
362
  end
415
363
 
416
364
  # Produce a type corresponding to the class of given unless given is a
@@ -423,7 +371,7 @@ module Puppet::Pops::Types::TypeFactory
423
371
  elsif o.is_a?(Types::PAnyType)
424
372
  o
425
373
  elsif o.is_a?(String)
426
- Types::PRuntimeType.new(:runtime => :ruby, :runtime_type_name => o)
374
+ Types::PRuntimeType.new(:ruby, o)
427
375
  else
428
376
  @type_calculator.infer_generic(o)
429
377
  end
@@ -447,7 +395,7 @@ module Puppet::Pops::Types::TypeFactory
447
395
  if o.is_a?(Class)
448
396
  @type_calculator.type(o)
449
397
  else
450
- Types::PRuntimeType.new(:runtime => :ruby, :runtime_type_name => o.class.name)
398
+ Types::PRuntimeType.new(:ruby, o.class.name)
451
399
  end
452
400
  end
453
401
 
@@ -456,7 +404,7 @@ module Puppet::Pops::Types::TypeFactory
456
404
  # or mapps a Ruby Class to its name.
457
405
  #
458
406
  def self.ruby_type(class_name = nil)
459
- Types::PRuntimeType.new(:runtime => :ruby, :runtime_type_name => class_name)
407
+ Types::PRuntimeType.new(:ruby, class_name)
460
408
  end
461
409
 
462
410
  # Generic creator of a RuntimeType - allows creating the type with nil or
@@ -464,16 +412,7 @@ module Puppet::Pops::Types::TypeFactory
464
412
  #
465
413
  def self.runtime(runtime=nil, runtime_type_name = nil)
466
414
  runtime = runtime.to_sym if runtime.is_a?(String)
467
- Types::PRuntimeType.new(:runtime => runtime, :runtime_type_name => runtime_type_name)
468
- end
469
-
470
- # Sets the accepted size range of a collection if something other than the
471
- # default 0 to Infinity is wanted. The semantics for from/to are the same as
472
- # for #range
473
- #
474
- def self.constrain_size(collection_t, from, to)
475
- collection_t.size_type = range(from, to)
476
- collection_t
415
+ Types::PRuntimeType.new(runtime, runtime_type_name)
477
416
  end
478
417
 
479
418
  # Returns true if the given type t is of valid range parameter type (integer