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,44 @@
1
+ # The null loader is empty and delegates everything to its parent if it has one.
2
+ #
3
+ class Puppet::Pops::Loader::NullLoader < Puppet::Pops::Loader::Loader
4
+ attr_reader :loader_name
5
+
6
+ # Construct a NullLoader, optionally with a parent loader
7
+ #
8
+ def initialize(parent_loader=nil, loader_name = "null-loader")
9
+ @loader_name = loader_name
10
+ @parent = parent_loader
11
+ end
12
+
13
+ # Has parent if one was set when constructed
14
+ def parent
15
+ @parent
16
+ end
17
+
18
+ def load_typed(typed_name)
19
+ if @parent.nil?
20
+ nil
21
+ else
22
+ @parent.load_typed(typed_name)
23
+ end
24
+ end
25
+
26
+ # Has no entries on its own - always nil
27
+ def get_entry(typed_name)
28
+ nil
29
+ end
30
+
31
+ # Finds nothing, there are no entries
32
+ def find(name)
33
+ nil
34
+ end
35
+
36
+ # Cannot store anything
37
+ def set_entry(typed_name, value, origin = nil)
38
+ nil
39
+ end
40
+
41
+ def to_s()
42
+ "(NullLoader '#{loader_name}')"
43
+ end
44
+ end
@@ -0,0 +1,34 @@
1
+ # The RubyFunctionInstantiator instantiates a Puppet::Functions::Function given the ruby source
2
+ # that calls Puppet::Functions.create_function.
3
+ #
4
+ class Puppet::Pops::Loader::RubyFunctionInstantiator
5
+ # Produces an instance of the Function class with the given typed_name, or fails with an error if the
6
+ # given ruby source does not produce this instance when evaluated.
7
+ #
8
+ # @param loader [Puppet::Pops::Loader::Loader] The loader the function is associated with
9
+ # @param typed_name [Puppet::Pops::Loader::TypedName] the type / name of the function to load
10
+ # @param source_ref [URI, String] a reference to the source / origin of the ruby code to evaluate
11
+ # @param ruby_code_string [String] ruby code in a string
12
+ #
13
+ # @return [Puppet::Pops::Functions.Function] - an instantiated function with global scope closure associated with the given loader
14
+ #
15
+ def self.create(loader, typed_name, source_ref, ruby_code_string)
16
+ unless ruby_code_string.is_a?(String) && ruby_code_string =~ /Puppet\:\:Functions\.create_function/
17
+ raise ArgumentError, "The code loaded from #{source_ref} does not seem to be a Puppet 4x API function - no create_function call."
18
+ end
19
+ created = eval(ruby_code_string)
20
+ unless created.is_a?(Class)
21
+ raise ArgumentError, "The code loaded from #{source_ref} did not produce a Function class when evaluated. Got '#{created.class}'"
22
+ end
23
+ unless created.name.to_s == typed_name.name()
24
+ raise ArgumentError, "The code loaded from #{source_ref} produced mis-matched name, expected '#{typed_name.name}', got #{created.name}"
25
+ end
26
+ # create the function instance - it needs closure (scope), and loader (i.e. where it should start searching for things
27
+ # when calling functions etc.
28
+ # It should be bound to global scope
29
+
30
+ # TODO: Cheating wrt. scope - assuming it is found in the context
31
+ closure_scope = Puppet.lookup(:global_scope) { {} }
32
+ created.new(closure_scope, loader.private_loader)
33
+ end
34
+ end
@@ -0,0 +1,109 @@
1
+ # The RubyLegacyFunctionInstantiator loads a 3x function and turns it into a 4x function
2
+ # that is called with 3x semantics (values are transformed to be 3x compliant).
3
+ #
4
+ # The code is loaded from a string obtained by reading the 3x function ruby code into a string
5
+ # and then passing it to the loaders class method `create`. When Puppet[:biff] == true, the
6
+ # 3x Puppet::Parser::Function.newfunction method relays back to this function loader's
7
+ # class method legacy_newfunction which creates a Puppet::Functions class wrapping the
8
+ # 3x function's block into a method in a function class derived from Puppet::Function.
9
+ # This class is then returned, and the Legacy loader continues the same way as it does
10
+ # for a 4x function.
11
+ #
12
+ # TODO: Wrapping of Scope
13
+ # The 3x function expects itself to be Scope. It passes itself as scope to other parts of the runtime,
14
+ # it expects to find all sorts of information in itself, get/set variables, get compiler, get environment
15
+ # etc.
16
+ # TODO: Transformation of arguments to 3x compliant objects
17
+ #
18
+ class Puppet::Pops::Loader::RubyLegacyFunctionInstantiator
19
+
20
+ # Produces an instance of the Function class with the given typed_name, or fails with an error if the
21
+ # given ruby source does not produce this instance when evaluated.
22
+ #
23
+ # @param loader [Puppet::Pops::Loader::Loader] The loader the function is associated with
24
+ # @param typed_name [Puppet::Pops::Loader::TypedName] the type / name of the function to load
25
+ # @param source_ref [URI, String] a reference to the source / origin of the ruby code to evaluate
26
+ # @param ruby_code_string [String] ruby code in a string
27
+ #
28
+ # @return [Puppet::Pops::Functions.Function] - an instantiated function with global scope closure associated with the given loader
29
+ #
30
+ def self.create(loader, typed_name, source_ref, ruby_code_string)
31
+ # Old Ruby API supports calling a method via ::
32
+ # this must also be checked as well as call with '.'
33
+ #
34
+ unless ruby_code_string.is_a?(String) && ruby_code_string =~ /Puppet\:\:Parser\:\:Functions(?:\.|\:\:)newfunction/
35
+ raise ArgumentError, "The code loaded from #{source_ref} does not seem to be a Puppet 3x API function - no newfunction call."
36
+ end
37
+
38
+ # The evaluation of the 3x function creation source should result in a call to the legacy_newfunction
39
+ #
40
+ created = eval(ruby_code_string)
41
+ unless created.is_a?(Class)
42
+ raise ArgumentError, "The code loaded from #{source_ref} did not produce a Function class when evaluated. Got '#{created.class}'"
43
+ end
44
+ unless created.name.to_s == typed_name.name()
45
+ raise ArgumentError, "The code loaded from #{source_ref} produced mis-matched name, expected '#{typed_name.name}', got #{created.name}"
46
+ end
47
+ # create the function instance - it needs closure (scope), and loader (i.e. where it should start searching for things
48
+ # when calling functions etc.
49
+ # It should be bound to global scope
50
+
51
+ # TODO: Cheating wrt. scope - assuming it is found in the context
52
+ closure_scope = Puppet.lookup(:global_scope) { {} }
53
+ created.new(closure_scope, loader)
54
+ end
55
+
56
+ # This is a new implementation of the method that is used in 3x to create a function.
57
+ # The arguments are the same as those passed to Puppet::Parser::Functions.newfunction, hence its
58
+ # deviation from regular method naming practice.
59
+ #
60
+ def self.legacy_newfunction(name, options, &block)
61
+
62
+ # 3x api allows arity to be specified, if unspecified it is 0 or more arguments
63
+ # arity >= 0, is an exact count
64
+ # airty < 0 is the number of required arguments -1 (i.e. -1 is 0 or more)
65
+ # (there is no upper cap, there is no support for optional values, or defaults)
66
+ #
67
+ arity = options[:arity] || -1
68
+ if arity >= 0
69
+ min_arg_count = arity
70
+ max_arg_count = arity
71
+ else
72
+ min_arg_count = (arity + 1).abs
73
+ # infinity
74
+ max_arg_count = :default
75
+ end
76
+
77
+ # Create a 4x function wrapper around the 3x Function
78
+ created_function_class = Puppet::Functions.create_function(name) do
79
+ # define a method on the new Function class with the same name as the function, but
80
+ # padded with __ because the function may represent a ruby method with the same name that
81
+ # expects to have inherited from Kernel, and then Object.
82
+ # (This can otherwise lead to infinite recursion, or that an ArgumentError is raised).
83
+ #
84
+ __name__ = :"__#{name}__"
85
+ define_method(__name__, &block)
86
+
87
+ # Define the method that is called from dispatch - this method just changes a call
88
+ # with multiple unknown arguments to passing all in an array (since this is expected in the 3x API).
89
+ # We want the call to be checked for type and number of arguments so cannot call the function
90
+ # defined by the block directly since it is defined to take a single argument.
91
+ #
92
+ define_method(:__relay__call__) do |*args|
93
+ # dup the args since the function may destroy them
94
+ # TODO: Should convert arguments to 3x, now :undef is send to the function
95
+ send(__name__, args.dup)
96
+ end
97
+
98
+ # Define a dispatch that performs argument type/count checking
99
+ #
100
+ dispatch :__relay__call__ do
101
+ # Use Puppet Type Object (not Optional[Object] since the 3x API passes undef as empty string).
102
+ param 'Object', 'args'
103
+ # Specify arg count (transformed from 3x function arity specification).
104
+ arg_count(min_arg_count, max_arg_count)
105
+ end
106
+ end
107
+ created_function_class
108
+ end
109
+ end
@@ -0,0 +1,20 @@
1
+ # SimpleEnvironmentLoader
2
+ # ===
3
+ # This loader does not load anything and it is populated by the bootstrapping logic that loads
4
+ # the site.pp or equivalent for an environment. It does not restrict the names of what it may contain,
5
+ # and what is loaded here overrides any child loaders (modules).
6
+ #
7
+ class Puppet::Pops::Loader::SimpleEnvironmentLoader < Puppet::Pops::Loader::BaseLoader
8
+
9
+ attr_accessor :private_loader
10
+
11
+ # Never finds anything, everything "loaded" is set externally
12
+ def find(typed_name)
13
+ nil
14
+ end
15
+
16
+ def to_s()
17
+ "(SimpleEnvironmentLoader '#{loader_name}')"
18
+ end
19
+
20
+ end
@@ -0,0 +1,69 @@
1
+ # Static Loader contains constants, basic data types and other types required for the system
2
+ # to boot.
3
+ #
4
+ class Puppet::Pops::Loader::StaticLoader < Puppet::Pops::Loader::Loader
5
+
6
+ attr_reader :loaded
7
+ def initialize
8
+ @loaded = {}
9
+ create_logging_functions()
10
+ end
11
+
12
+ def load_typed(typed_name)
13
+ load_constant(typed_name)
14
+ end
15
+
16
+ def get_entry(typed_name)
17
+ load_constant(typed_name)
18
+ end
19
+
20
+ def find(name)
21
+ # There is nothing to search for, everything this loader knows about is already available
22
+ nil
23
+ end
24
+
25
+ def parent
26
+ nil # at top of the hierarchy
27
+ end
28
+
29
+ def to_s()
30
+ "(StaticLoader)"
31
+ end
32
+ private
33
+
34
+ def load_constant(typed_name)
35
+ @loaded[typed_name]
36
+ end
37
+
38
+ private
39
+
40
+ # Creates a function for each of the specified log levels
41
+ #
42
+ def create_logging_functions()
43
+ Puppet::Util::Log.levels.each do |level|
44
+
45
+ fc = Puppet::Functions.create_function(level) do
46
+ # create empty dispatcher to stop it from complaining about missing method since
47
+ # an override of :call is made instead of using dispatch.
48
+ dispatch(:log) { }
49
+
50
+ # Logs per the specified level, outputs formatted information for arrays, hashes etc.
51
+ # Overrides the implementation in Function that uses dispatching. This is not needed here
52
+ # since it accepts 0-n Optional[Object]
53
+ #
54
+ define_method(:call) do |scope, *vals|
55
+ # NOTE: 3x, does this: vals.join(" ")
56
+ # New implementation uses the evaluator to get proper formatting per type
57
+ # TODO: uses a fake scope (nil) - fix when :scopes are available via settings
58
+ mapped = vals.map {|v| Puppet::Pops::Evaluator::EvaluatorImpl.new.string(v, nil) }
59
+ Puppet.send(level, mapped.join(" "))
60
+ end
61
+ end
62
+
63
+ typed_name = Puppet::Pops::Loader::Loader::TypedName.new(:function, level)
64
+ # TODO:closure scope is fake (an empty hash) - waiting for new global scope to be available via lookup of :scopes
65
+ func = fc.new({},self)
66
+ @loaded[ typed_name ] = Puppet::Pops::Loader::Loader::NamedEntry.new(typed_name, func, __FILE__)
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,22 @@
1
+ module Puppet::Pops::Loader::UriHelper
2
+ # Raises an exception if specified gem can not be located
3
+ #
4
+ def path_for_uri(uri, subdir='lib')
5
+ case uri.scheme
6
+ when "gem"
7
+ begin
8
+ spec = Gem::Specification.find_by_name(uri.hostname)
9
+ # if path given append that, else append given subdir
10
+ File.join(spec.gem_dir, uri.path.empty?() ? subdir : uri.path)
11
+ rescue StandardError => e
12
+ raise "TODO TYPE: Failed to located gem #{uri}. #{e.message}"
13
+ end
14
+ when "file"
15
+ File.join(uri.path, subdir)
16
+ when nil
17
+ File.join(uri.path, subdir)
18
+ else
19
+ raise "Not a valid scheme for a loader: #{uri.scheme}. Use a 'file:' (or just a path), or 'gem://gemname[/path]"
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,240 @@
1
+ class Puppet::Pops::Loaders
2
+ class LoaderError < Puppet::Error; end
3
+
4
+ attr_reader :static_loader
5
+ attr_reader :puppet_system_loader
6
+ attr_reader :public_environment_loader
7
+ attr_reader :private_environment_loader
8
+
9
+ def initialize(environment)
10
+ # The static loader can only be changed after a reboot
11
+ @@static_loader ||= Puppet::Pops::Loader::StaticLoader.new()
12
+
13
+ # Create the set of loaders
14
+ # 1. Puppet, loads from the "running" puppet - i.e. bundled functions, types, extension points and extensions
15
+ # Does not change without rebooting the service running puppet.
16
+ #
17
+ @@puppet_system_loader ||= create_puppet_system_loader()
18
+
19
+ # 2. Environment loader - i.e. what is bound across the environment, may change for each setup
20
+ # TODO: loaders need to work when also running in an agent doing catalog application. There is no
21
+ # concept of environment the same way as when running as a master (except when doing apply).
22
+ # The creation mechanisms should probably differ between the two.
23
+ #
24
+ @private_environment_loader = create_environment_loader(environment)
25
+
26
+ # 3. module loaders are set up from the create_environment_loader, they register themselves
27
+ end
28
+
29
+ # Clears the cached static and puppet_system loaders (to enable testing)
30
+ #
31
+ def self.clear
32
+ @@static_loader = nil
33
+ @@puppet_system_loader = nil
34
+ end
35
+
36
+ def static_loader
37
+ @@static_loader
38
+ end
39
+
40
+ def puppet_system_loader
41
+ @@puppet_system_loader
42
+ end
43
+
44
+ def public_loader_for_module(module_name)
45
+ md = @module_resolver[module_name] || (return nil)
46
+ # Note, this loader is not resolved until there is interest in the visibility of entities from the
47
+ # perspective of something contained in the module. (Many request may pass through a module loader
48
+ # without it loading anything.
49
+ # See {#private_loader_for_module}, and not in {#configure_loaders_for_modules}
50
+ md.public_loader
51
+ end
52
+
53
+ def private_loader_for_module(module_name)
54
+ md = @module_resolver[module_name] || (return nil)
55
+ # Since there is interest in the visibility from the perspective of entities contained in the
56
+ # module, it must be resolved (to provide this visibility).
57
+ # See {#configure_loaders_for_modules}
58
+ unless md.resolved?
59
+ @module_resolver.resolve(md)
60
+ end
61
+ md.private_loader
62
+ end
63
+
64
+ private
65
+
66
+ def create_puppet_system_loader()
67
+ module_name = nil
68
+ loader_name = 'puppet_system'
69
+
70
+ # Puppet system may be installed in a fixed location via RPM, installed as a Gem, via source etc.
71
+ # The only way to find this across the different ways puppet can be installed is
72
+ # to search up the path from this source file's __FILE__ location until it finds the parent of
73
+ # lib/puppet... e.g.. dirname(__FILE__)/../../.. (i.e. <somewhere>/lib/puppet/pops/loaders.rb).
74
+ #
75
+ puppet_lib = File.join(File.dirname(__FILE__), '../../..')
76
+ Puppet::Pops::Loader::ModuleLoaders::FileBased.new(static_loader, self, module_name, puppet_lib, loader_name)
77
+ end
78
+
79
+ def create_environment_loader(environment)
80
+ # This defines where to start parsing/evaluating - the "initial import" (to use 3x terminology)
81
+ # Is either a reference to a single .pp file, or a directory of manifests. If the environment becomes
82
+ # a module and can hold functions, types etc. then these are available across all other modules without
83
+ # them declaring this dependency - it is however valuable to be able to treat it the same way
84
+ # bindings and other such system related configuration.
85
+
86
+ # This is further complicated by the many options available:
87
+ # - The environment may not have a directory, the code comes from one appointed 'manifest' (site.pp)
88
+ # - The environment may have a directory and also point to a 'manifest'
89
+ # - The code to run may be set in settings (code)
90
+
91
+ # Further complication is that there is nothing specifying what the visibility is into
92
+ # available modules. (3x is everyone sees everything).
93
+ # Puppet binder currently reads confdir/bindings - that is bad, it should be using the new environment support.
94
+
95
+ # The environment is not a namespace, so give it a nil "module_name"
96
+ module_name = nil
97
+ loader_name = "environment:#{environment.name}"
98
+ loader = Puppet::Pops::Loader::SimpleEnvironmentLoader.new(puppet_system_loader, loader_name)
99
+
100
+ # An environment has a module path even if it has a null loader
101
+ configure_loaders_for_modules(loader, environment)
102
+ # modules should see this loader
103
+ @public_environment_loader = loader
104
+
105
+ # Code in the environment gets to see all modules (since there is no metadata for the environment)
106
+ # but since this is not given to the module loaders, they can not load global code (since they can not
107
+ # have prior knowledge about this
108
+ loader = Puppet::Pops::Loader::DependencyLoader.new(loader, "environment", @module_resolver.all_module_loaders())
109
+
110
+ # The module loader gets the private loader via a lazy operation to look up the module's private loader.
111
+ # This does not work for an environment since it is not resolved the same way.
112
+ # TODO: The EnvironmentLoader could be a specialized loader instead of using a ModuleLoader to do the work.
113
+ # This is subject to future design - an Environment may move more in the direction of a Module.
114
+ @public_environment_loader.private_loader = loader
115
+ loader
116
+ end
117
+
118
+ def configure_loaders_for_modules(parent_loader, environment)
119
+ @module_resolver = mr = ModuleResolver.new()
120
+ environment.modules.each do |puppet_module|
121
+ # Create data about this module
122
+ md = LoaderModuleData.new(puppet_module)
123
+ mr[puppet_module.name] = md
124
+ md.public_loader = Puppet::Pops::Loader::ModuleLoaders::FileBased.new(parent_loader, self, md.name, md.path, md.name)
125
+ end
126
+ # NOTE: Do not resolve all modules here - this is wasteful if only a subset of modules / functions are used
127
+ # The resolution is triggered by asking for a module's private loader, since this means there is interest
128
+ # in the visibility from that perspective.
129
+ # If later, it is wanted that all resolutions should be made up-front (to capture errors eagerly, this
130
+ # can be introduced (better for production), but may be irritating in development mode.
131
+ end
132
+
133
+ # =LoaderModuleData
134
+ # Information about a Module and its loaders.
135
+ # TODO: should have reference to real model element containing all module data; this is faking it
136
+ # TODO: Should use Puppet::Module to get the metadata (as a hash) - a somewhat blunt instrument, but that is
137
+ # what is available with a reasonable API.
138
+ #
139
+ class LoaderModuleData
140
+
141
+ attr_accessor :state
142
+ attr_accessor :public_loader
143
+ attr_accessor :private_loader
144
+ attr_accessor :resolutions
145
+
146
+ # The Puppet::Module this LoaderModuleData represents in the loader configuration
147
+ attr_reader :puppet_module
148
+
149
+ # @param puppet_module [Puppet::Module] the module instance for the module being represented
150
+ #
151
+ def initialize(puppet_module)
152
+ @state = :initial
153
+ @puppet_module = puppet_module
154
+ @resolutions = []
155
+ @public_loader = nil
156
+ @private_loader = nil
157
+ end
158
+
159
+ def name
160
+ @puppet_module.name
161
+ end
162
+
163
+ def version
164
+ @puppet_module.version
165
+ end
166
+
167
+ def path
168
+ @puppet_module.path
169
+ end
170
+
171
+ def resolved?
172
+ @state == :resolved
173
+ end
174
+
175
+ def restrict_to_dependencies?
176
+ @puppet_module.has_metadata?
177
+ end
178
+
179
+ def unmet_dependencies?
180
+ @puppet_module.unmet_dependencies.any?
181
+ end
182
+
183
+ def dependency_names
184
+ @puppet_module.dependencies_as_modules.collect(&:name)
185
+ end
186
+ end
187
+
188
+ # Resolves module loaders - resolution of model dependencies is done by Puppet::Module
189
+ #
190
+ class ModuleResolver
191
+
192
+ def initialize()
193
+ @index = {}
194
+ @all_module_loaders = nil
195
+ end
196
+
197
+ def [](name)
198
+ @index[name]
199
+ end
200
+
201
+ def []=(name, module_data)
202
+ @index[name] = module_data
203
+ end
204
+
205
+ def all_module_loaders
206
+ @all_module_loaders ||= @index.values.map {|md| md.public_loader }
207
+ end
208
+
209
+ def resolve(module_data)
210
+ if module_data.resolved?
211
+ return
212
+ else
213
+ module_data.private_loader =
214
+ if module_data.restrict_to_dependencies?
215
+ create_loader_with_only_dependencies_visible(module_data)
216
+ else
217
+ create_loader_with_all_modules_visible(module_data)
218
+ end
219
+ end
220
+ end
221
+
222
+ private
223
+
224
+ def create_loader_with_all_modules_visible(from_module_data)
225
+ Puppet.debug("ModuleLoader: module '#{from_module_data.name}' has unknown dependencies - it will have all other modules visible")
226
+
227
+ Puppet::Pops::Loader::DependencyLoader.new(from_module_data.public_loader, from_module_data.name, all_module_loaders())
228
+ end
229
+
230
+ def create_loader_with_only_dependencies_visible(from_module_data)
231
+ if from_module_data.unmet_dependencies?
232
+ Puppet.warning("ModuleLoader: module '#{from_module_data.name}' has unresolved dependencies"+
233
+ " - it will only see those that are resolved."+
234
+ " Use 'puppet module list --tree' to see information about modules")
235
+ end
236
+ dependency_loaders = from_module_data.dependency_names.collect { |name| @index[name].public_loader }
237
+ Puppet::Pops::Loader::DependencyLoader.new(from_module_data.public_loader, from_module_data.name, dependency_loaders)
238
+ end
239
+ end
240
+ end