puppet 3.5.1-x86-mingw32 → 3.6.0.rc1-x86-mingw32

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 (342) hide show
  1. data/CONTRIBUTING.md +5 -0
  2. data/Gemfile +17 -9
  3. data/README.md +1 -0
  4. data/conf/fileserver.conf +4 -3
  5. data/ext/README.environment +8 -0
  6. data/ext/build_defaults.yaml +1 -1
  7. data/ext/debian/control +2 -2
  8. data/ext/debian/puppet-common.dirs +4 -0
  9. data/ext/debian/rules +4 -0
  10. data/ext/emacs/puppet-mode-init.el +1 -1
  11. data/ext/emacs/puppet-mode.el +36 -17
  12. data/ext/redhat/client.init +3 -3
  13. data/ext/redhat/puppet.spec.erb +9 -0
  14. data/ext/systemd/puppet.service +3 -4
  15. data/ext/systemd/puppetmaster.service +1 -3
  16. data/install.rb +1 -1
  17. data/lib/puppet.rb +2 -1
  18. data/lib/puppet/agent.rb +1 -1
  19. data/lib/puppet/application.rb +17 -17
  20. data/lib/puppet/application/doc.rb +1 -1
  21. data/lib/puppet/configurer.rb +4 -1
  22. data/lib/puppet/configurer/downloader.rb +13 -12
  23. data/lib/puppet/configurer/plugin_handler.rb +3 -3
  24. data/lib/puppet/context.rb +6 -1
  25. data/lib/puppet/defaults.rb +82 -12
  26. data/lib/puppet/environments.rb +169 -13
  27. data/lib/puppet/external/nagios/grammar.ry +2 -0
  28. data/lib/puppet/external/nagios/parser.rb +28 -19
  29. data/lib/puppet/face/config.rb +19 -6
  30. data/lib/puppet/face/module/generate.rb +209 -7
  31. data/lib/puppet/face/module/install.rb +17 -16
  32. data/lib/puppet/face/module/list.rb +83 -82
  33. data/lib/puppet/face/module/search.rb +1 -1
  34. data/lib/puppet/face/module/upgrade.rb +10 -9
  35. data/lib/puppet/face/parser.rb +3 -2
  36. data/lib/puppet/face/plugin.rb +8 -4
  37. data/lib/puppet/file_bucket/dipper.rb +6 -3
  38. data/lib/puppet/file_bucket/file.rb +4 -2
  39. data/lib/puppet/file_serving/metadata.rb +1 -1
  40. data/lib/puppet/file_system/memory_file.rb +27 -1
  41. data/lib/puppet/file_system/memory_impl.rb +15 -1
  42. data/lib/puppet/forge.rb +148 -52
  43. data/lib/puppet/forge/cache.rb +5 -1
  44. data/lib/puppet/forge/errors.rb +10 -0
  45. data/lib/puppet/forge/repository.rb +61 -26
  46. data/lib/puppet/functions.rb +548 -0
  47. data/lib/puppet/functions/assert_type.rb +42 -0
  48. data/lib/puppet/functions/import.rb +7 -0
  49. data/lib/puppet/indirector/facts/facter.rb +1 -1
  50. data/lib/puppet/indirector/file_bucket_file/file.rb +3 -2
  51. data/lib/puppet/indirector/rest.rb +18 -0
  52. data/lib/puppet/loaders.rb +20 -0
  53. data/lib/puppet/module.rb +2 -2
  54. data/lib/puppet/module_tool.rb +40 -14
  55. data/lib/puppet/module_tool/applications.rb +0 -1
  56. data/lib/puppet/module_tool/applications/application.rb +35 -26
  57. data/lib/puppet/module_tool/applications/builder.rb +16 -6
  58. data/lib/puppet/module_tool/applications/checksummer.rb +25 -19
  59. data/lib/puppet/module_tool/applications/installer.rb +196 -35
  60. data/lib/puppet/module_tool/applications/searcher.rb +1 -0
  61. data/lib/puppet/module_tool/applications/uninstaller.rb +7 -1
  62. data/lib/puppet/module_tool/applications/unpacker.rb +57 -31
  63. data/lib/puppet/module_tool/applications/upgrader.rb +221 -65
  64. data/lib/puppet/module_tool/checksums.rb +5 -8
  65. data/lib/puppet/module_tool/errors/installer.rb +12 -44
  66. data/lib/puppet/module_tool/errors/shared.rb +84 -11
  67. data/lib/puppet/module_tool/errors/upgrader.rb +16 -45
  68. data/lib/puppet/module_tool/install_directory.rb +7 -6
  69. data/lib/puppet/module_tool/installed_modules.rb +92 -0
  70. data/lib/puppet/module_tool/local_tarball.rb +91 -0
  71. data/lib/puppet/module_tool/metadata.rb +119 -115
  72. data/lib/puppet/module_tool/modulefile.rb +9 -9
  73. data/lib/puppet/module_tool/shared_behaviors.rb +19 -7
  74. data/lib/puppet/module_tool/skeleton/templates/generator/README.md.erb +79 -0
  75. data/lib/puppet/module_tool/skeleton/templates/generator/Rakefile +18 -0
  76. data/lib/puppet/module_tool/skeleton/templates/generator/metadata.json.erb +1 -0
  77. data/lib/puppet/module_tool/skeleton/templates/generator/spec/classes/init_spec.rb.erb +7 -0
  78. data/lib/puppet/module_tool/tar.rb +3 -7
  79. data/lib/puppet/module_tool/tar/gnu.rb +21 -9
  80. data/lib/puppet/module_tool/tar/mini.rb +2 -8
  81. data/lib/puppet/network/http/api/v1.rb +1 -1
  82. data/lib/puppet/network/http/api/v2/authorization.rb +4 -2
  83. data/lib/puppet/network/http/issues.rb +1 -0
  84. data/lib/puppet/network/http_pool.rb +15 -6
  85. data/lib/puppet/node/environment.rb +91 -20
  86. data/lib/puppet/parser/ast/pops_bridge.rb +44 -3
  87. data/lib/puppet/parser/collector.rb +1 -1
  88. data/lib/puppet/parser/compiler.rb +50 -7
  89. data/lib/puppet/parser/functions.rb +6 -0
  90. data/lib/puppet/parser/functions/generate.rb +1 -1
  91. data/lib/puppet/parser/resource.rb +1 -1
  92. data/lib/puppet/pops.rb +22 -1
  93. data/lib/puppet/pops/adapters.rb +8 -1
  94. data/lib/puppet/pops/binder/bindings_composer.rb +1 -1
  95. data/lib/puppet/pops/binder/bindings_factory.rb +1 -1
  96. data/lib/puppet/pops/binder/config/binder_config_checker.rb +1 -1
  97. data/lib/puppet/pops/binder/producers.rb +2 -2
  98. data/lib/puppet/pops/evaluator/access_operator.rb +65 -25
  99. data/lib/puppet/pops/evaluator/callable_signature.rb +101 -0
  100. data/lib/puppet/pops/evaluator/closure.rb +57 -2
  101. data/lib/puppet/pops/evaluator/compare_operator.rb +1 -1
  102. data/lib/puppet/pops/evaluator/evaluator_impl.rb +9 -11
  103. data/lib/puppet/pops/evaluator/runtime3_support.rb +72 -21
  104. data/lib/puppet/pops/functions/dispatch.rb +71 -0
  105. data/lib/puppet/pops/functions/dispatcher.rb +237 -0
  106. data/lib/puppet/pops/functions/function.rb +77 -0
  107. data/lib/puppet/pops/issues.rb +12 -0
  108. data/lib/puppet/pops/loader/base_loader.rb +102 -0
  109. data/lib/puppet/pops/loader/dependency_loader.rb +60 -0
  110. data/lib/puppet/pops/loader/gem_support.rb +49 -0
  111. data/lib/puppet/pops/loader/loader.rb +180 -0
  112. data/lib/puppet/pops/loader/loader_paths.rb +137 -0
  113. data/lib/puppet/pops/loader/module_loaders.rb +242 -0
  114. data/lib/puppet/pops/loader/null_loader.rb +44 -0
  115. data/lib/puppet/pops/loader/ruby_function_instantiator.rb +34 -0
  116. data/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +109 -0
  117. data/lib/puppet/pops/loader/simple_environment_loader.rb +20 -0
  118. data/lib/puppet/pops/loader/static_loader.rb +69 -0
  119. data/lib/puppet/pops/loader/uri_helper.rb +22 -0
  120. data/lib/puppet/pops/loaders.rb +240 -0
  121. data/lib/puppet/pops/model/factory.rb +13 -5
  122. data/lib/puppet/pops/model/model_tree_dumper.rb +12 -4
  123. data/lib/puppet/pops/parser/egrammar.ra +31 -18
  124. data/lib/puppet/pops/parser/eparser.rb +1137 -1106
  125. data/lib/puppet/pops/parser/lexer2.rb +17 -16
  126. data/lib/puppet/pops/semantic_error.rb +17 -0
  127. data/lib/puppet/pops/types/type_calculator.rb +150 -15
  128. data/lib/puppet/pops/types/type_factory.rb +69 -0
  129. data/lib/puppet/pops/types/type_parser.rb +9 -0
  130. data/lib/puppet/pops/types/types.rb +65 -4
  131. data/lib/puppet/pops/validation/checker4_0.rb +1 -1
  132. data/lib/puppet/pops/validation/validator_factory_4_0.rb +1 -1
  133. data/lib/puppet/property/list.rb +1 -1
  134. data/lib/puppet/provider/augeas/augeas.rb +2 -2
  135. data/lib/puppet/provider/cron/crontab.rb +13 -2
  136. data/lib/puppet/provider/package.rb +24 -0
  137. data/lib/puppet/provider/package/apt.rb +6 -1
  138. data/lib/puppet/provider/package/gem.rb +8 -2
  139. data/lib/puppet/provider/package/msi.rb +0 -15
  140. data/lib/puppet/provider/package/openbsd.rb +0 -24
  141. data/lib/puppet/provider/package/rpm.rb +3 -29
  142. data/lib/puppet/provider/package/windows.rb +0 -15
  143. data/lib/puppet/provider/package/yum.rb +101 -24
  144. data/lib/puppet/provider/package/yumhelper.py +31 -1
  145. data/lib/puppet/provider/package/zypper.rb +10 -28
  146. data/lib/puppet/provider/service/debian.rb +1 -1
  147. data/lib/puppet/provider/service/init.rb +3 -0
  148. data/lib/puppet/provider/service/openbsd.rb +318 -0
  149. data/lib/puppet/provider/service/redhat.rb +6 -3
  150. data/lib/puppet/provider/service/systemd.rb +2 -2
  151. data/lib/puppet/provider/yumrepo/inifile.rb +115 -42
  152. data/lib/puppet/resource.rb +13 -9
  153. data/lib/puppet/resource/catalog.rb +12 -6
  154. data/lib/puppet/resource/type_collection.rb +3 -3
  155. data/lib/puppet/settings.rb +57 -36
  156. data/lib/puppet/settings/config_file.rb +5 -0
  157. data/lib/puppet/settings/environment_conf.rb +147 -0
  158. data/lib/puppet/settings/ttl_setting.rb +48 -0
  159. data/lib/puppet/ssl/certificate_authority.rb +2 -3
  160. data/lib/puppet/ssl/certificate_authority/autosign_command.rb +1 -1
  161. data/lib/puppet/ssl/certificate_request.rb +4 -4
  162. data/lib/puppet/ssl/validator/default_validator.rb +2 -2
  163. data/lib/puppet/status.rb +1 -1
  164. data/lib/puppet/test/test_helper.rb +1 -0
  165. data/lib/puppet/type/augeas.rb +13 -1
  166. data/lib/puppet/type/cron.rb +32 -18
  167. data/lib/puppet/type/file.rb +4 -2
  168. data/lib/puppet/type/file/checksum.rb +15 -5
  169. data/lib/puppet/type/file/content.rb +3 -1
  170. data/lib/puppet/type/file/source.rb +5 -5
  171. data/lib/puppet/type/package.rb +12 -17
  172. data/lib/puppet/type/resources.rb +3 -1
  173. data/lib/puppet/type/scheduled_task.rb +4 -5
  174. data/lib/puppet/type/service.rb +12 -2
  175. data/lib/puppet/type/user.rb +106 -0
  176. data/lib/puppet/type/yumrepo.rb +9 -1
  177. data/lib/puppet/util/checksums.rb +60 -1
  178. data/lib/puppet/util/diff.rb +3 -1
  179. data/lib/puppet/util/execution.rb +20 -16
  180. data/lib/puppet/util/feature.rb +3 -0
  181. data/lib/puppet/util/logging.rb +19 -12
  182. data/lib/puppet/util/rubygems.rb +10 -0
  183. data/lib/puppet/util/watched_file.rb +1 -1
  184. data/lib/puppet/util/windows/security.rb +5 -3
  185. data/lib/puppet/vendor/load_semantic.rb +1 -0
  186. data/lib/puppet/vendor/require_vendored.rb +2 -0
  187. data/lib/puppet/vendor/semantic/Gemfile +20 -0
  188. data/lib/puppet/vendor/semantic/Rakefile +69 -0
  189. data/lib/puppet/vendor/semantic/lib/semantic.rb +7 -0
  190. data/lib/puppet/vendor/semantic/lib/semantic/dependency.rb +181 -0
  191. data/lib/puppet/vendor/semantic/lib/semantic/dependency/graph.rb +60 -0
  192. data/lib/puppet/vendor/semantic/lib/semantic/dependency/graph_node.rb +117 -0
  193. data/lib/puppet/vendor/semantic/lib/semantic/dependency/module_release.rb +46 -0
  194. data/lib/puppet/vendor/semantic/lib/semantic/dependency/source.rb +25 -0
  195. data/lib/puppet/vendor/semantic/lib/semantic/dependency/unsatisfiable_graph.rb +31 -0
  196. data/lib/puppet/vendor/semantic/lib/semantic/version.rb +168 -0
  197. data/lib/puppet/vendor/semantic/lib/semantic/version_range.rb +424 -0
  198. data/lib/puppet/vendor/semantic/spec/spec_helper.rb +24 -0
  199. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/graph_node_spec.rb +141 -0
  200. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/graph_spec.rb +162 -0
  201. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/module_release_spec.rb +143 -0
  202. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/source_spec.rb +5 -0
  203. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/unsatisfiable_graph_spec.rb +44 -0
  204. data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency_spec.rb +383 -0
  205. data/lib/puppet/vendor/semantic/spec/unit/semantic/version_range_spec.rb +307 -0
  206. data/lib/puppet/vendor/semantic/spec/unit/semantic/version_spec.rb +608 -0
  207. data/lib/puppet/version.rb +1 -1
  208. data/spec/fixtures/java.tgz +0 -0
  209. data/spec/fixtures/stdlib.tgz +0 -0
  210. data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/usee/lib/puppet/functions/usee/callee.rb +5 -0
  211. data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/user/lib/puppet/functions/user/caller.rb +5 -0
  212. data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/user/metadata.json +9 -0
  213. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/lib/puppet/functions/modulea/rb_func_a.rb +5 -0
  214. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/lib/puppet/functions/rb_func_a.rb +5 -0
  215. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/manifests/init.pp +3 -0
  216. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/metadata.json +19 -0
  217. data/spec/fixtures/unit/pops/loaders/loaders/wo_metadata_module/modules/moduleb/lib/puppet/functions/moduleb/rb_func_b.rb +6 -0
  218. data/spec/fixtures/unit/pops/loaders/loaders/wo_metadata_module/modules/moduleb/manifests/init.pp +3 -0
  219. data/spec/fixtures/unit/provider/naginator/define_empty_param +6 -0
  220. data/spec/fixtures/unit/provider/service/systemd/list_unit_files_services +7 -0
  221. data/spec/fixtures/unit/type/user/authorized_keys +5 -0
  222. data/spec/integration/application/apply_spec.rb +1 -2
  223. data/spec/integration/configurer_spec.rb +2 -2
  224. data/spec/integration/faces/plugin_spec.rb +62 -0
  225. data/spec/integration/indirector/catalog/compiler_spec.rb +1 -1
  226. data/spec/integration/indirector/catalog/queue_spec.rb +1 -1
  227. data/spec/integration/node/environment_spec.rb +2 -2
  228. data/spec/integration/parser/future_compiler_spec.rb +96 -142
  229. data/spec/integration/parser/ruby_manifest_spec.rb +0 -5
  230. data/spec/integration/provider/cron/crontab_spec.rb +35 -0
  231. data/spec/integration/type/file_spec.rb +74 -72
  232. data/spec/integration/util/windows/security_spec.rb +17 -0
  233. data/spec/lib/matchers/resource.rb +45 -13
  234. data/spec/lib/puppet_spec/files.rb +18 -0
  235. data/spec/lib/puppet_spec/module_tool/shared_functions.rb +56 -0
  236. data/spec/lib/puppet_spec/module_tool/stub_source.rb +133 -0
  237. data/spec/shared_contexts/checksums.rb +55 -0
  238. data/spec/unit/application/apply_spec.rb +10 -7
  239. data/spec/unit/application/doc_spec.rb +17 -10
  240. data/spec/unit/application/indirection_base_spec.rb +18 -10
  241. data/spec/unit/application/inspect_spec.rb +22 -20
  242. data/spec/unit/configurer/downloader_spec.rb +7 -6
  243. data/spec/unit/configurer/plugin_handler_spec.rb +5 -8
  244. data/spec/unit/configurer_spec.rb +1 -1
  245. data/spec/unit/context_spec.rb +23 -0
  246. data/spec/unit/environments_spec.rb +274 -16
  247. data/spec/unit/face/config_spec.rb +111 -11
  248. data/spec/unit/face/module/install_spec.rb +14 -85
  249. data/spec/unit/face/module/list_spec.rb +108 -62
  250. data/spec/unit/face/module/search_spec.rb +1 -1
  251. data/spec/unit/face/module/uninstall_spec.rb +21 -42
  252. data/spec/unit/face/parser_spec.rb +5 -2
  253. data/spec/unit/file_bucket/dipper_spec.rb +92 -86
  254. data/spec/unit/file_bucket/file_spec.rb +23 -75
  255. data/spec/unit/file_serving/metadata_spec.rb +74 -74
  256. data/spec/unit/forge/module_release_spec.rb +131 -0
  257. data/spec/unit/forge/repository_spec.rb +21 -20
  258. data/spec/unit/forge_spec.rb +99 -23
  259. data/spec/unit/functions/assert_type_spec.rb +59 -0
  260. data/spec/unit/functions4_spec.rb +671 -0
  261. data/spec/unit/indirector/catalog/static_compiler_spec.rb +2 -2
  262. data/spec/unit/indirector/facts/facter_spec.rb +9 -3
  263. data/spec/unit/indirector/file_bucket_file/file_spec.rb +156 -155
  264. data/spec/unit/indirector/rest_spec.rb +8 -0
  265. data/spec/unit/interface/face_collection_spec.rb +35 -23
  266. data/spec/unit/module_spec.rb +20 -8
  267. data/spec/unit/module_tool/applications/builder_spec.rb +40 -12
  268. data/spec/unit/module_tool/applications/checksummer_spec.rb +86 -105
  269. data/spec/unit/module_tool/applications/installer_spec.rb +293 -261
  270. data/spec/unit/module_tool/applications/searcher_spec.rb +1 -1
  271. data/spec/unit/module_tool/applications/uninstaller_spec.rb +90 -154
  272. data/spec/unit/module_tool/applications/unpacker_spec.rb +12 -12
  273. data/spec/unit/module_tool/applications/upgrader_spec.rb +286 -18
  274. data/spec/unit/module_tool/metadata_spec.rb +223 -14
  275. data/spec/unit/module_tool/tar/gnu_spec.rb +12 -9
  276. data/spec/unit/module_tool/tar/mini_spec.rb +1 -1
  277. data/spec/unit/module_tool/tar_spec.rb +4 -18
  278. data/spec/unit/module_tool_spec.rb +123 -27
  279. data/spec/unit/network/formats_spec.rb +2 -2
  280. data/spec/unit/network/http_pool_spec.rb +21 -0
  281. data/spec/unit/network/rights_spec.rb +10 -8
  282. data/spec/unit/node/environment_spec.rb +27 -2
  283. data/spec/unit/parser/collector_spec.rb +1 -1
  284. data/spec/unit/parser/compiler_spec.rb +1 -1
  285. data/spec/unit/parser/functions/generate_spec.rb +4 -0
  286. data/spec/unit/pops/evaluator/access_ops_spec.rb +50 -11
  287. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +25 -0
  288. data/spec/unit/pops/loaders/dependency_loader_spec.rb +44 -0
  289. data/spec/unit/pops/loaders/loader_paths_spec.rb +66 -0
  290. data/spec/unit/pops/loaders/loaders_spec.rb +105 -0
  291. data/spec/unit/pops/loaders/module_loaders_spec.rb +119 -0
  292. data/spec/unit/pops/loaders/static_loader_spec.rb +46 -0
  293. data/spec/unit/pops/types/type_calculator_spec.rb +145 -10
  294. data/spec/unit/pops/types/type_factory_spec.rb +101 -0
  295. data/spec/unit/pops/types/type_parser_spec.rb +22 -0
  296. data/spec/unit/property/list_spec.rb +9 -1
  297. data/spec/unit/provider/augeas/augeas_spec.rb +58 -11
  298. data/spec/unit/provider/cron/crontab_spec.rb +1 -0
  299. data/spec/unit/provider/cron/parsed_spec.rb +15 -0
  300. data/spec/unit/provider/naginator_spec.rb +14 -0
  301. data/spec/unit/provider/package/apt_spec.rb +78 -64
  302. data/spec/unit/provider/package/gem_spec.rb +15 -0
  303. data/spec/unit/provider/package/rpm_spec.rb +6 -6
  304. data/spec/unit/provider/package/windows_spec.rb +1 -1
  305. data/spec/unit/provider/package/yum_spec.rb +199 -104
  306. data/spec/unit/provider/package/zypper_spec.rb +41 -15
  307. data/spec/unit/provider/service/openbsd_spec.rb +129 -22
  308. data/spec/unit/provider/service/redhat_spec.rb +18 -4
  309. data/spec/unit/provider/service/systemd_spec.rb +5 -9
  310. data/spec/unit/provider/service/upstart_spec.rb +1 -1
  311. data/spec/unit/provider/user/directoryservice_spec.rb +10 -0
  312. data/spec/unit/provider/yumrepo/inifile_spec.rb +171 -15
  313. data/spec/unit/resource/catalog_spec.rb +20 -104
  314. data/spec/unit/resource/type_collection_spec.rb +10 -9
  315. data/spec/unit/settings/config_file_spec.rb +29 -6
  316. data/spec/unit/settings/environment_conf_spec.rb +51 -0
  317. data/spec/unit/settings_spec.rb +97 -12
  318. data/spec/unit/ssl/certificate_authority_spec.rb +2 -0
  319. data/spec/unit/type/augeas_spec.rb +1 -1
  320. data/spec/unit/type/cron_spec.rb +6 -7
  321. data/spec/unit/type/file/checksum_spec.rb +6 -0
  322. data/spec/unit/type/file/content_spec.rb +277 -207
  323. data/spec/unit/type/file_spec.rb +9 -7
  324. data/spec/unit/type/user_spec.rb +106 -18
  325. data/spec/unit/type/yumrepo_spec.rb +8 -0
  326. data/spec/unit/util/checksums_spec.rb +12 -5
  327. data/spec/unit/util/diff_spec.rb +8 -0
  328. data/spec/unit/util/execution_spec.rb +4 -4
  329. data/spec/unit/util/feature_spec.rb +2 -0
  330. data/spec/unit/util/logging_spec.rb +14 -4
  331. data/spec/unit/util/rdoc/parser_spec.rb +5 -4
  332. data/spec/unit/util/rubygems_spec.rb +14 -0
  333. data/tasks/parallel.rake +2 -2
  334. metadata +154 -21
  335. checksums.yaml +0 -7
  336. data/lib/puppet/module_tool/applications/generator.rb +0 -142
  337. data/lib/puppet/module_tool/skeleton.rb +0 -37
  338. data/lib/puppet/module_tool/skeleton/templates/generator/Modulefile.erb +0 -11
  339. data/lib/puppet/module_tool/skeleton/templates/generator/README.erb +0 -16
  340. data/lib/puppet/module_tool/tar/solaris.rb +0 -5
  341. data/spec/fixtures/unit/provider/service/systemd/list_units_services +0 -17
  342. data/spec/unit/module_tool/tar/solaris_spec.rb +0 -22
@@ -0,0 +1,101 @@
1
+ # CallableSignature
2
+ # ===
3
+ # A CallableSignature describes how something callable expects to be called.
4
+ # Different implementation of this class are used for different types of callables.
5
+ #
6
+ # @api public
7
+ #
8
+ class Puppet::Pops::Evaluator::CallableSignature
9
+
10
+ # Returns the names of the parameters as an array of strings. This does not include the name
11
+ # of an optional block parameter.
12
+ #
13
+ # All implementations are not required to supply names for parameters. They may be used if present,
14
+ # to provide user feedback in errors etc. but they are not authoritative about the number of
15
+ # required arguments, optional arguments, etc.
16
+ #
17
+ # A derived class must implement this method.
18
+ #
19
+ # @return [Array<String>] - an array of names (that may be empty if names are unavailable)
20
+ #
21
+ # @api public
22
+ #
23
+ def parameter_names
24
+ raise NotImplementedError.new
25
+ end
26
+
27
+ # Returns a PCallableType with the type information, required and optional count, and type information about
28
+ # an optional block.
29
+ #
30
+ # A derived class must implement this method.
31
+ #
32
+ # @return [Puppet::Pops::Types::PCallableType]
33
+ # @api public
34
+ #
35
+ def type
36
+ raise NotImplementedError.new
37
+ end
38
+
39
+ # Returns the expected type for an optional block. The type may be nil, which means that the callable does
40
+ # not accept a block. If a type is returned it is one of Callable, Optional[Callable], Variant[Callable,...],
41
+ # or Optional[Variant[Callable, ...]]. The Variant type is used when multiple signatures are acceptable.
42
+ # The Optional type is used when the block is optional.
43
+ #
44
+ # @return [Puppet::Pops::Types::PAbstractType, nil] the expected type of a block given as the last parameter in a call.
45
+ #
46
+ # @api public
47
+ #
48
+ def block_type
49
+ type.block_type
50
+ end
51
+
52
+ # Returns the name of the block parameter if the callable accepts a block.
53
+ # @return [String] the name of the block parameter
54
+ # A derived class must implement this method.
55
+ # @api public
56
+ #
57
+ def block_name
58
+ raise NotImplementedError.new
59
+ end
60
+
61
+ # Returns a range indicating the optionality of a block. One of [0,0] (does not accept block), [0,1] (optional
62
+ # block), and [1,1] (block required)
63
+ #
64
+ # @return [Array(Integer, Integer)] the range of the block parameter
65
+ #
66
+ def block_range
67
+ type.block_range
68
+ end
69
+
70
+ # Returns the range of required/optional argument values as an array of [min, max], where an infinite
71
+ # end is given as INFINITY. To test against infinity, use the infinity? method.
72
+ #
73
+ # @return [Array[Integer, Numeric]] - an Array with [min, max]
74
+ #
75
+ # @api public
76
+ #
77
+ def args_range
78
+ type.size_range
79
+ end
80
+
81
+ # Returns true if the last parameter captures the rest of the arguments, with a possible cap, as indicated
82
+ # by the `args_range` method.
83
+ # A derived class must implement this method.
84
+ #
85
+ # @return [Boolean] true if last parameter captures the rest of the given arguments (up to a possible cap)
86
+ # @api public
87
+ #
88
+ def last_captures_rest?
89
+ raise NotImplementedError.new
90
+ end
91
+
92
+ # Returns true if the given x is infinity
93
+ # @return [Boolean] true, if given value represents infinity
94
+ #
95
+ # @api public
96
+ #
97
+ def infinity?(x)
98
+ x == Puppet::Pops::Types::INFINITY
99
+ end
100
+
101
+ end
@@ -2,11 +2,14 @@
2
2
  # A Closure represents logic bound to a particular scope.
3
3
  # As long as the runtime (basically the scope implementation) has the behaviour of Puppet 3x it is not
4
4
  # safe to use this closure when the scope given to it when initialized goes "out of scope".
5
- #
5
+ #
6
6
  # Note that the implementation is backwards compatible in that the call method accepts a scope, but this
7
7
  # scope is not used.
8
8
  #
9
- class Puppet::Pops::Evaluator::Closure
9
+ # Note that this class is a CallableSignature, and the methods defined there should be used
10
+ # as the API for obtaining information in a callable implementation agnostic way.
11
+ #
12
+ class Puppet::Pops::Evaluator::Closure < Puppet::Pops::Evaluator::CallableSignature
10
13
  attr_reader :evaluator
11
14
  attr_reader :model
12
15
  attr_reader :enclosing_scope
@@ -18,11 +21,14 @@ class Puppet::Pops::Evaluator::Closure
18
21
  end
19
22
 
20
23
  # marker method checked with respond_to :puppet_lambda
24
+ # @api private
25
+ # @deprecated Use the type system to query if an object is of Callable type, then use its signatures method for info
21
26
  def puppet_lambda()
22
27
  true
23
28
  end
24
29
 
25
30
  # compatible with 3x AST::Lambda
31
+ # @api public
26
32
  def call(scope, *args)
27
33
  @evaluator.call(self, args, @enclosing_scope)
28
34
  end
@@ -50,8 +56,57 @@ class Puppet::Pops::Evaluator::Closure
50
56
  @model.parameters.count { |p| !p.value.nil? }
51
57
  end
52
58
 
59
+ # @api public
53
60
  def parameter_names
54
61
  @model.parameters.collect {|p| p.name }
55
62
  end
56
63
 
64
+ # @api public
65
+ def type
66
+ @callable || create_callable_type
67
+ end
68
+
69
+ # @api public
70
+ def last_captures_rest?
71
+ # TODO: No support for this yet
72
+ false
73
+ end
74
+
75
+ # @api public
76
+ def block_name
77
+ # TODO: Lambda's does not support blocks yet. This is a placeholder
78
+ 'unsupported_block'
79
+ end
80
+
81
+ private
82
+
83
+ def create_callable_type()
84
+ t = Puppet::Pops::Types::PCallableType.new()
85
+ tuple_t = Puppet::Pops::Types::PTupleType.new()
86
+ # since closure lambdas are currently untyped, each parameter becomes Optional[Object]
87
+ parameter_names.each do |name|
88
+ # TODO: Change when Closure supports typed parameters
89
+ tuple_t.addTypes(Puppet::Pops::Types::TypeFactory.optional_object())
90
+ end
91
+
92
+ # TODO: A Lambda can not currently declare varargs
93
+ to = parameter_count
94
+ from = to - optional_parameter_count
95
+ if from != to
96
+ size_t = Puppet::Pops::Types::PIntegerType.new()
97
+ size_t.from = size
98
+ size_t.to = size
99
+ tuple_t.size_type = size_t
100
+ end
101
+ t.param_types = tuple_t
102
+ # TODO: A Lambda can not currently declare that it accepts a lambda, except as an explicit parameter
103
+ # being a Callable
104
+ t
105
+ end
106
+
107
+ # Produces information about parameters compatible with a 4x Function (which can have multiple signatures)
108
+ def signatures
109
+ [ self ]
110
+ end
111
+
57
112
  end
@@ -64,7 +64,7 @@ class Puppet::Pops::Evaluator::CompareOperator
64
64
  def cmp_Numeric(a, b)
65
65
  if n2 = Puppet::Pops::Utils.to_n(b)
66
66
  a <=> n2
67
- elsif b.kind_of(String)
67
+ elsif b.kind_of?(String)
68
68
  # Numeric is always lexiographically smaller than a string, even if the string is empty.
69
69
  -1
70
70
  else
@@ -82,8 +82,14 @@ class Puppet::Pops::Evaluator::EvaluatorImpl
82
82
  def evaluate(target, scope)
83
83
  begin
84
84
  @@eval_visitor.visit_this_1(self, target, scope)
85
+
86
+ rescue Puppet::Pops::SemanticError => e
87
+ # a raised issue may not know the semantic target
88
+ fail(e.issue, e.semantic || target, e.options, e)
89
+
85
90
  rescue StandardError => e
86
91
  if e.is_a? Puppet::ParseError
92
+ # ParseError's are supposed to be fully configured with location information
87
93
  raise e
88
94
  end
89
95
  fail(Issues::RUNTIME_ERROR, target, {:detail => e.message}, e)
@@ -205,7 +211,7 @@ class Puppet::Pops::Evaluator::EvaluatorImpl
205
211
  #
206
212
  # "given" is always an optional entry. If a parameter was provided then
207
213
  # the entry will be in the array, otherwise the m array will be a
208
- # single element.a = []
214
+ # single element.
209
215
  given_argument = m[1]
210
216
  argument_name = m[0].name
211
217
  default_expression = m[0].value
@@ -756,14 +762,10 @@ class Puppet::Pops::Evaluator::EvaluatorImpl
756
762
  fail(Issues::ILLEGAL_EXPRESSION, o.functor_expr, {:feature=>'function name', :container => o})
757
763
  end
758
764
  name = o.functor_expr.value
759
- assert_function_available(name, o, scope)
760
765
  evaluated_arguments = o.arguments.collect {|arg| evaluate(arg, scope) }
761
766
  # wrap lambda in a callable block if it is present
762
767
  evaluated_arguments << Puppet::Pops::Evaluator::Closure.new(self, o.lambda, scope) if o.lambda
763
- call_function(name, evaluated_arguments, o, scope) do |result|
764
- # prevent functions that are not r-value from leaking its return value
765
- rvalue_function?(name, o, scope) ? result : nil
766
- end
768
+ call_function(name, evaluated_arguments, o, scope)
767
769
  end
768
770
 
769
771
  # Evaluation of CallMethodExpression handles a NamedAccessExpression functor (receiver.function_name)
@@ -778,13 +780,9 @@ class Puppet::Pops::Evaluator::EvaluatorImpl
778
780
  fail(Issues::ILLEGAL_EXPRESSION, o.functor_expr, {:feature=>'function name', :container => o})
779
781
  end
780
782
  name = name.value # the string function name
781
- assert_function_available(name, o, scope)
782
783
  evaluated_arguments = [receiver] + (o.arguments || []).collect {|arg| evaluate(arg, scope) }
783
784
  evaluated_arguments << Puppet::Pops::Evaluator::Closure.new(self, o.lambda, scope) if o.lambda
784
- call_function(name, evaluated_arguments, o, scope) do |result|
785
- # prevent functions that are not r-value from leaking its return value
786
- rvalue_function?(name, o, scope) ? result : nil
787
- end
785
+ call_function(name, evaluated_arguments, o, scope)
788
786
  end
789
787
 
790
788
  # @example
@@ -4,6 +4,7 @@
4
4
  #
5
5
  # @api private
6
6
  module Puppet::Pops::Evaluator::Runtime3Support
7
+
7
8
  # Fails the evaluation of _semantic_ with a given issue.
8
9
  #
9
10
  # @param issue [Puppet::Pops::Issue] the issue to report
@@ -13,6 +14,21 @@ module Puppet::Pops::Evaluator::Runtime3Support
13
14
  # @raise [Puppet::ParseError] an evaluation error initialized from the arguments (TODO: Change to EvaluationError?)
14
15
  #
15
16
  def fail(issue, semantic, options={}, except=nil)
17
+ optionally_fail(issue, semantic, options, except)
18
+ # an error should have been raised since fail always fails
19
+ raise ArgumentError, "Internal Error: Configuration of runtime error handling wrong: should have raised exception"
20
+ end
21
+
22
+ # Optionally (based on severity) Fails the evaluation of _semantic_ with a given issue
23
+ # If the given issue is configured to be of severity < :error it is only reported, and the function returns.
24
+ #
25
+ # @param issue [Puppet::Pops::Issue] the issue to report
26
+ # @param semantic [Puppet::Pops::ModelPopsObject] the object for which evaluation failed in some way. Used to determine origin.
27
+ # @param options [Hash] hash of optional named data elements for the given issue
28
+ # @return [!] this method does not return
29
+ # @raise [Puppet::ParseError] an evaluation error initialized from the arguments (TODO: Change to EvaluationError?)
30
+ #
31
+ def optionally_fail(issue, semantic, options={}, except=nil)
16
32
  if except.nil?
17
33
  # Want a stacktrace, and it must be passed as an exception
18
34
  begin
@@ -212,23 +228,27 @@ module Puppet::Pops::Evaluator::Runtime3Support
212
228
  n
213
229
  end
214
230
 
215
- # Asserts that the given function name resolves to an available function. The function is loaded
216
- # as a side effect. Fails if the function does not exist.
217
- #
218
- def assert_function_available(name, o, scope)
231
+ def call_function(name, args, o, scope)
232
+ # Call via 4x API if it is available, and the function exists
233
+ #
234
+ if loaders = Puppet.lookup(:loaders) {nil}
235
+ # find the loader that loaded the code, or use the private_environment_loader (sees env + all modules)
236
+ adapter = Puppet::Pops::Utils.find_adapter(o, Puppet::Pops::Adapters::LoaderAdapter)
237
+ loader = adapter.nil? ? loaders.private_environment_loader : adapter.loader
238
+ if loader && func = loader.load(:function, name)
239
+ return func.call(scope, *args)
240
+ end
241
+ end
242
+
219
243
  fail(Puppet::Pops::Issues::UNKNOWN_FUNCTION, o, {:name => name}) unless Puppet::Parser::Functions.function(name)
220
- end
221
244
 
222
- def call_function(name, args, o, scope)
245
+ # TODO: if Puppet[:biff] == true, then 3x functions should be called via loaders above
223
246
  # Arguments must be mapped since functions are unaware of the new and magical creatures in 4x.
224
247
  # NOTE: Passing an empty string last converts :undef to empty string
225
248
  mapped_args = args.map {|a| convert(a, scope, '') }
226
- scope.send("function_#{name}", mapped_args)
227
- end
228
-
229
- # Returns true if the function produces a value
230
- def rvalue_function?(name, o, scope)
231
- Puppet::Parser::Functions.rvalue?(name)
249
+ result = scope.send("function_#{name}", mapped_args)
250
+ # Prevent non r-value functions from leaking their result (they are not written to care about this)
251
+ Puppet::Parser::Functions.rvalue?(name) ? result : nil
232
252
  end
233
253
 
234
254
  # The o is used for source reference
@@ -257,7 +277,6 @@ module Puppet::Pops::Evaluator::Runtime3Support
257
277
  # TODO: Revisit and possible improve the accuracy.
258
278
  #
259
279
  file, line = extract_file_line(o)
260
-
261
280
  # Build a resource for each title
262
281
  resource_titles.map do |resource_title|
263
282
  resource = Puppet::Parser::Resource.new(
@@ -292,7 +311,13 @@ module Puppet::Pops::Evaluator::Runtime3Support
292
311
  # for the type of the name.
293
312
  # Note, locations are available per parameter.
294
313
  #
295
- scope.define_settings(type_name.capitalize, evaluated_parameters)
314
+ scope.define_settings(capitalize_qualified_name(type_name), evaluated_parameters)
315
+ end
316
+
317
+ # Capitalizes each segment of a qualified name
318
+ #
319
+ def capitalize_qualified_name(name)
320
+ name.split(/::/).map(&:capitalize).join('::')
296
321
  end
297
322
 
298
323
  # Creates resource overrides for all resource type objects in evaluated_resources. The same set of
@@ -330,15 +355,20 @@ module Puppet::Pops::Evaluator::Runtime3Support
330
355
  # Returns the value of a resource's parameter by first looking up the parameter in the resource
331
356
  # and then in the defaults for the resource. Since the resource exists (it must in order to look up its
332
357
  # parameters, any overrides have already been applied). Defaults are not applied to a resource until it
333
- # has been finished (which typically has not taked place when this is evaluated; hence the dual lookup).
358
+ # has been finished (which typically has not taken place when this is evaluated; hence the dual lookup).
334
359
  #
335
360
  def get_resource_parameter_value(scope, resource, parameter_name)
361
+ # This gets the parameter value, or nil (for both valid parameters and parameters that do not exist).
336
362
  val = resource[parameter_name]
337
363
  if val.nil? && defaults = scope.lookupdefaults(resource.type)
338
364
  # NOTE: 3x resource keeps defaults as hash using symbol for name as key to Parameter which (again) holds
339
365
  # name and value.
366
+ # NOTE: meta parameters that are unset ends up here, and there are no defaults for those encoded
367
+ # in the defaults, they may receive hardcoded defaults later (e.g. 'tag').
340
368
  param = defaults[parameter_name.to_sym]
341
- val = param.value
369
+ # Some parameters (meta parameters like 'tag') does not return a param from which the value can be obtained
370
+ # at all times. Instead, they return a nil param until a value has been set.
371
+ val = param.nil? ? nil : param.value
342
372
  end
343
373
  val
344
374
  end
@@ -430,14 +460,16 @@ module Puppet::Pops::Evaluator::Runtime3Support
430
460
  # Needs conversion by calling scope to resolve the name and possibly return a different name
431
461
  # Resolution can only be called with an array, and returns an array. Here there is only one name
432
462
  type, titles = scope.resolve_type_and_titles(o.type_name, [o.title])
433
- Puppet::Resource.new(type, titles[0])
463
+ # Note: a title of nil makes Resource class throw error with information that is wrong
464
+ Puppet::Resource.new(type, titles[0].nil? ? '' : titles[0] )
434
465
  end
435
466
 
436
467
  def convert_PHostClassType(o, scope, undef_value)
437
468
  # Needs conversion by calling scope to resolve the name and possibly return a different name
438
469
  # Resolution can only be called with an array, and returns an array. Here there is only one name
439
470
  type, titles = scope.resolve_type_and_titles('class', [o.class_name])
440
- Puppet::Resource.new(type, titles[0])
471
+ # Note: a title of nil makes Resource class throw error with information that is wrong
472
+ Puppet::Resource.new(type, titles[0].nil? ? '' : titles[0] )
441
473
  end
442
474
 
443
475
  private
@@ -471,16 +503,35 @@ module Puppet::Pops::Evaluator::Runtime3Support
471
503
  def diagnostic_producer
472
504
  Puppet::Pops::Validation::DiagnosticProducer.new(
473
505
  ExceptionRaisingAcceptor.new(), # Raises exception on all issues
474
- Puppet::Pops::Validation::SeverityProducer.new(), # All issues are errors
506
+ SeverityProducer.new(), # All issues are errors
507
+ # Puppet::Pops::Validation::SeverityProducer.new(), # All issues are errors
475
508
  Puppet::Pops::Model::ModelLabelProvider.new())
476
509
  end
477
510
 
511
+ # Configure the severity of failures
512
+ class SeverityProducer < Puppet::Pops::Validation::SeverityProducer
513
+ Issues = Puppet::Pops::Issues
514
+
515
+ def initialize
516
+ super
517
+ p = self
518
+ # Issues triggering warning only if --debug is on
519
+ if Puppet[:debug]
520
+ p[Issues::EMPTY_RESOURCE_SPECIALIZATION] = :warning
521
+ else
522
+ p[Issues::EMPTY_RESOURCE_SPECIALIZATION] = :ignore
523
+ end
524
+ end
525
+ end
526
+
478
527
  # An acceptor of diagnostics that immediately raises an exception.
479
528
  class ExceptionRaisingAcceptor < Puppet::Pops::Validation::Acceptor
480
529
  def accept(diagnostic)
481
530
  super
482
- Puppet::Pops::IssueReporter.assert_and_report(self, {:message => "Evaluation Error:" })
483
- raise ArgumentError, "Internal Error: Configuration of runtime error handling wrong: should have raised exception"
531
+ Puppet::Pops::IssueReporter.assert_and_report(self, {:message => "Evaluation Error:", :emit_warnings => true })
532
+ if errors?
533
+ raise ArgumentError, "Internal Error: Configuration of runtime error handling wrong: should have raised exception"
534
+ end
484
535
  end
485
536
  end
486
537
 
@@ -0,0 +1,71 @@
1
+ # Defines a connection between a implementation method and the signature that
2
+ # the method will handle.
3
+ #
4
+ # This interface should not be used directly. Instead dispatches should be
5
+ # constructed using the DSL defined in {Puppet::Functions}.
6
+ #
7
+ # @api private
8
+ class Puppet::Pops::Functions::Dispatch < Puppet::Pops::Evaluator::CallableSignature
9
+ # @api public
10
+ attr_reader :type
11
+ # TODO: refactor to parameter_names since that makes it API
12
+ attr_reader :param_names
13
+ attr_reader :injections
14
+
15
+ # Describes how arguments are woven if there are injections, a regular argument is a given arg index, an array
16
+ # an injection description.
17
+ #
18
+ attr_reader :weaving
19
+ # @api public
20
+ attr_reader :block_name
21
+
22
+ # @api private
23
+ def initialize(type, method_name, param_names, block_name, injections, weaving, last_captures)
24
+ @type = type
25
+ @method_name = method_name
26
+ @param_names = param_names || []
27
+ @block_name = block_name
28
+ @injections = injections || []
29
+ @weaving = weaving
30
+ @last_captures = last_captures
31
+ end
32
+
33
+ # @api private
34
+ def parameter_names
35
+ @param_names
36
+ end
37
+
38
+ # @api private
39
+ def last_captures_rest?
40
+ !! @last_captures
41
+ end
42
+
43
+ # @api private
44
+ def invoke(instance, calling_scope, args)
45
+ instance.send(@method_name, *weave(calling_scope, args))
46
+ end
47
+
48
+ # @api private
49
+ def weave(scope, args)
50
+ # no need to weave if there are no injections
51
+ if injections.empty?
52
+ args
53
+ else
54
+ injector = Puppet.lookup(:injector)
55
+ weaving.map do |knit|
56
+ if knit.is_a?(Array)
57
+ injection_data = @injections[knit[0]]
58
+ # inject
59
+ if injection_data[3] == :producer
60
+ injector.lookup_producer(scope, injection_data[0], injection_data[2])
61
+ else
62
+ injector.lookup(scope, injection_data[0], injection_data[2])
63
+ end
64
+ else
65
+ # pick that argument
66
+ args[knit]
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end