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.
- data/CONTRIBUTING.md +5 -0
- data/Gemfile +17 -9
- data/README.md +1 -0
- data/conf/fileserver.conf +4 -3
- data/ext/README.environment +8 -0
- data/ext/build_defaults.yaml +1 -1
- data/ext/debian/control +2 -2
- data/ext/debian/puppet-common.dirs +4 -0
- data/ext/debian/rules +4 -0
- data/ext/emacs/puppet-mode-init.el +1 -1
- data/ext/emacs/puppet-mode.el +36 -17
- data/ext/redhat/client.init +3 -3
- data/ext/redhat/puppet.spec.erb +9 -0
- data/ext/systemd/puppet.service +3 -4
- data/ext/systemd/puppetmaster.service +1 -3
- data/install.rb +1 -1
- data/lib/puppet.rb +2 -1
- data/lib/puppet/agent.rb +1 -1
- data/lib/puppet/application.rb +17 -17
- data/lib/puppet/application/doc.rb +1 -1
- data/lib/puppet/configurer.rb +4 -1
- data/lib/puppet/configurer/downloader.rb +13 -12
- data/lib/puppet/configurer/plugin_handler.rb +3 -3
- data/lib/puppet/context.rb +6 -1
- data/lib/puppet/defaults.rb +82 -12
- data/lib/puppet/environments.rb +169 -13
- data/lib/puppet/external/nagios/grammar.ry +2 -0
- data/lib/puppet/external/nagios/parser.rb +28 -19
- data/lib/puppet/face/config.rb +19 -6
- data/lib/puppet/face/module/generate.rb +209 -7
- data/lib/puppet/face/module/install.rb +17 -16
- data/lib/puppet/face/module/list.rb +83 -82
- data/lib/puppet/face/module/search.rb +1 -1
- data/lib/puppet/face/module/upgrade.rb +10 -9
- data/lib/puppet/face/parser.rb +3 -2
- data/lib/puppet/face/plugin.rb +8 -4
- data/lib/puppet/file_bucket/dipper.rb +6 -3
- data/lib/puppet/file_bucket/file.rb +4 -2
- data/lib/puppet/file_serving/metadata.rb +1 -1
- data/lib/puppet/file_system/memory_file.rb +27 -1
- data/lib/puppet/file_system/memory_impl.rb +15 -1
- data/lib/puppet/forge.rb +148 -52
- data/lib/puppet/forge/cache.rb +5 -1
- data/lib/puppet/forge/errors.rb +10 -0
- data/lib/puppet/forge/repository.rb +61 -26
- data/lib/puppet/functions.rb +548 -0
- data/lib/puppet/functions/assert_type.rb +42 -0
- data/lib/puppet/functions/import.rb +7 -0
- data/lib/puppet/indirector/facts/facter.rb +1 -1
- data/lib/puppet/indirector/file_bucket_file/file.rb +3 -2
- data/lib/puppet/indirector/rest.rb +18 -0
- data/lib/puppet/loaders.rb +20 -0
- data/lib/puppet/module.rb +2 -2
- data/lib/puppet/module_tool.rb +40 -14
- data/lib/puppet/module_tool/applications.rb +0 -1
- data/lib/puppet/module_tool/applications/application.rb +35 -26
- data/lib/puppet/module_tool/applications/builder.rb +16 -6
- data/lib/puppet/module_tool/applications/checksummer.rb +25 -19
- data/lib/puppet/module_tool/applications/installer.rb +196 -35
- data/lib/puppet/module_tool/applications/searcher.rb +1 -0
- data/lib/puppet/module_tool/applications/uninstaller.rb +7 -1
- data/lib/puppet/module_tool/applications/unpacker.rb +57 -31
- data/lib/puppet/module_tool/applications/upgrader.rb +221 -65
- data/lib/puppet/module_tool/checksums.rb +5 -8
- data/lib/puppet/module_tool/errors/installer.rb +12 -44
- data/lib/puppet/module_tool/errors/shared.rb +84 -11
- data/lib/puppet/module_tool/errors/upgrader.rb +16 -45
- data/lib/puppet/module_tool/install_directory.rb +7 -6
- data/lib/puppet/module_tool/installed_modules.rb +92 -0
- data/lib/puppet/module_tool/local_tarball.rb +91 -0
- data/lib/puppet/module_tool/metadata.rb +119 -115
- data/lib/puppet/module_tool/modulefile.rb +9 -9
- data/lib/puppet/module_tool/shared_behaviors.rb +19 -7
- data/lib/puppet/module_tool/skeleton/templates/generator/README.md.erb +79 -0
- data/lib/puppet/module_tool/skeleton/templates/generator/Rakefile +18 -0
- data/lib/puppet/module_tool/skeleton/templates/generator/metadata.json.erb +1 -0
- data/lib/puppet/module_tool/skeleton/templates/generator/spec/classes/init_spec.rb.erb +7 -0
- data/lib/puppet/module_tool/tar.rb +3 -7
- data/lib/puppet/module_tool/tar/gnu.rb +21 -9
- data/lib/puppet/module_tool/tar/mini.rb +2 -8
- data/lib/puppet/network/http/api/v1.rb +1 -1
- data/lib/puppet/network/http/api/v2/authorization.rb +4 -2
- data/lib/puppet/network/http/issues.rb +1 -0
- data/lib/puppet/network/http_pool.rb +15 -6
- data/lib/puppet/node/environment.rb +91 -20
- data/lib/puppet/parser/ast/pops_bridge.rb +44 -3
- data/lib/puppet/parser/collector.rb +1 -1
- data/lib/puppet/parser/compiler.rb +50 -7
- data/lib/puppet/parser/functions.rb +6 -0
- data/lib/puppet/parser/functions/generate.rb +1 -1
- data/lib/puppet/parser/resource.rb +1 -1
- data/lib/puppet/pops.rb +22 -1
- data/lib/puppet/pops/adapters.rb +8 -1
- data/lib/puppet/pops/binder/bindings_composer.rb +1 -1
- data/lib/puppet/pops/binder/bindings_factory.rb +1 -1
- data/lib/puppet/pops/binder/config/binder_config_checker.rb +1 -1
- data/lib/puppet/pops/binder/producers.rb +2 -2
- data/lib/puppet/pops/evaluator/access_operator.rb +65 -25
- data/lib/puppet/pops/evaluator/callable_signature.rb +101 -0
- data/lib/puppet/pops/evaluator/closure.rb +57 -2
- data/lib/puppet/pops/evaluator/compare_operator.rb +1 -1
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +9 -11
- data/lib/puppet/pops/evaluator/runtime3_support.rb +72 -21
- data/lib/puppet/pops/functions/dispatch.rb +71 -0
- data/lib/puppet/pops/functions/dispatcher.rb +237 -0
- data/lib/puppet/pops/functions/function.rb +77 -0
- data/lib/puppet/pops/issues.rb +12 -0
- data/lib/puppet/pops/loader/base_loader.rb +102 -0
- data/lib/puppet/pops/loader/dependency_loader.rb +60 -0
- data/lib/puppet/pops/loader/gem_support.rb +49 -0
- data/lib/puppet/pops/loader/loader.rb +180 -0
- data/lib/puppet/pops/loader/loader_paths.rb +137 -0
- data/lib/puppet/pops/loader/module_loaders.rb +242 -0
- data/lib/puppet/pops/loader/null_loader.rb +44 -0
- data/lib/puppet/pops/loader/ruby_function_instantiator.rb +34 -0
- data/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +109 -0
- data/lib/puppet/pops/loader/simple_environment_loader.rb +20 -0
- data/lib/puppet/pops/loader/static_loader.rb +69 -0
- data/lib/puppet/pops/loader/uri_helper.rb +22 -0
- data/lib/puppet/pops/loaders.rb +240 -0
- data/lib/puppet/pops/model/factory.rb +13 -5
- data/lib/puppet/pops/model/model_tree_dumper.rb +12 -4
- data/lib/puppet/pops/parser/egrammar.ra +31 -18
- data/lib/puppet/pops/parser/eparser.rb +1137 -1106
- data/lib/puppet/pops/parser/lexer2.rb +17 -16
- data/lib/puppet/pops/semantic_error.rb +17 -0
- data/lib/puppet/pops/types/type_calculator.rb +150 -15
- data/lib/puppet/pops/types/type_factory.rb +69 -0
- data/lib/puppet/pops/types/type_parser.rb +9 -0
- data/lib/puppet/pops/types/types.rb +65 -4
- data/lib/puppet/pops/validation/checker4_0.rb +1 -1
- data/lib/puppet/pops/validation/validator_factory_4_0.rb +1 -1
- data/lib/puppet/property/list.rb +1 -1
- data/lib/puppet/provider/augeas/augeas.rb +2 -2
- data/lib/puppet/provider/cron/crontab.rb +13 -2
- data/lib/puppet/provider/package.rb +24 -0
- data/lib/puppet/provider/package/apt.rb +6 -1
- data/lib/puppet/provider/package/gem.rb +8 -2
- data/lib/puppet/provider/package/msi.rb +0 -15
- data/lib/puppet/provider/package/openbsd.rb +0 -24
- data/lib/puppet/provider/package/rpm.rb +3 -29
- data/lib/puppet/provider/package/windows.rb +0 -15
- data/lib/puppet/provider/package/yum.rb +101 -24
- data/lib/puppet/provider/package/yumhelper.py +31 -1
- data/lib/puppet/provider/package/zypper.rb +10 -28
- data/lib/puppet/provider/service/debian.rb +1 -1
- data/lib/puppet/provider/service/init.rb +3 -0
- data/lib/puppet/provider/service/openbsd.rb +318 -0
- data/lib/puppet/provider/service/redhat.rb +6 -3
- data/lib/puppet/provider/service/systemd.rb +2 -2
- data/lib/puppet/provider/yumrepo/inifile.rb +115 -42
- data/lib/puppet/resource.rb +13 -9
- data/lib/puppet/resource/catalog.rb +12 -6
- data/lib/puppet/resource/type_collection.rb +3 -3
- data/lib/puppet/settings.rb +57 -36
- data/lib/puppet/settings/config_file.rb +5 -0
- data/lib/puppet/settings/environment_conf.rb +147 -0
- data/lib/puppet/settings/ttl_setting.rb +48 -0
- data/lib/puppet/ssl/certificate_authority.rb +2 -3
- data/lib/puppet/ssl/certificate_authority/autosign_command.rb +1 -1
- data/lib/puppet/ssl/certificate_request.rb +4 -4
- data/lib/puppet/ssl/validator/default_validator.rb +2 -2
- data/lib/puppet/status.rb +1 -1
- data/lib/puppet/test/test_helper.rb +1 -0
- data/lib/puppet/type/augeas.rb +13 -1
- data/lib/puppet/type/cron.rb +32 -18
- data/lib/puppet/type/file.rb +4 -2
- data/lib/puppet/type/file/checksum.rb +15 -5
- data/lib/puppet/type/file/content.rb +3 -1
- data/lib/puppet/type/file/source.rb +5 -5
- data/lib/puppet/type/package.rb +12 -17
- data/lib/puppet/type/resources.rb +3 -1
- data/lib/puppet/type/scheduled_task.rb +4 -5
- data/lib/puppet/type/service.rb +12 -2
- data/lib/puppet/type/user.rb +106 -0
- data/lib/puppet/type/yumrepo.rb +9 -1
- data/lib/puppet/util/checksums.rb +60 -1
- data/lib/puppet/util/diff.rb +3 -1
- data/lib/puppet/util/execution.rb +20 -16
- data/lib/puppet/util/feature.rb +3 -0
- data/lib/puppet/util/logging.rb +19 -12
- data/lib/puppet/util/rubygems.rb +10 -0
- data/lib/puppet/util/watched_file.rb +1 -1
- data/lib/puppet/util/windows/security.rb +5 -3
- data/lib/puppet/vendor/load_semantic.rb +1 -0
- data/lib/puppet/vendor/require_vendored.rb +2 -0
- data/lib/puppet/vendor/semantic/Gemfile +20 -0
- data/lib/puppet/vendor/semantic/Rakefile +69 -0
- data/lib/puppet/vendor/semantic/lib/semantic.rb +7 -0
- data/lib/puppet/vendor/semantic/lib/semantic/dependency.rb +181 -0
- data/lib/puppet/vendor/semantic/lib/semantic/dependency/graph.rb +60 -0
- data/lib/puppet/vendor/semantic/lib/semantic/dependency/graph_node.rb +117 -0
- data/lib/puppet/vendor/semantic/lib/semantic/dependency/module_release.rb +46 -0
- data/lib/puppet/vendor/semantic/lib/semantic/dependency/source.rb +25 -0
- data/lib/puppet/vendor/semantic/lib/semantic/dependency/unsatisfiable_graph.rb +31 -0
- data/lib/puppet/vendor/semantic/lib/semantic/version.rb +168 -0
- data/lib/puppet/vendor/semantic/lib/semantic/version_range.rb +424 -0
- data/lib/puppet/vendor/semantic/spec/spec_helper.rb +24 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/graph_node_spec.rb +141 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/graph_spec.rb +162 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/module_release_spec.rb +143 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/source_spec.rb +5 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/unsatisfiable_graph_spec.rb +44 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency_spec.rb +383 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/version_range_spec.rb +307 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/version_spec.rb +608 -0
- data/lib/puppet/version.rb +1 -1
- data/spec/fixtures/java.tgz +0 -0
- data/spec/fixtures/stdlib.tgz +0 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/usee/lib/puppet/functions/usee/callee.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/user/lib/puppet/functions/user/caller.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/user/metadata.json +9 -0
- data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/lib/puppet/functions/modulea/rb_func_a.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/lib/puppet/functions/rb_func_a.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/manifests/init.pp +3 -0
- data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/metadata.json +19 -0
- data/spec/fixtures/unit/pops/loaders/loaders/wo_metadata_module/modules/moduleb/lib/puppet/functions/moduleb/rb_func_b.rb +6 -0
- data/spec/fixtures/unit/pops/loaders/loaders/wo_metadata_module/modules/moduleb/manifests/init.pp +3 -0
- data/spec/fixtures/unit/provider/naginator/define_empty_param +6 -0
- data/spec/fixtures/unit/provider/service/systemd/list_unit_files_services +7 -0
- data/spec/fixtures/unit/type/user/authorized_keys +5 -0
- data/spec/integration/application/apply_spec.rb +1 -2
- data/spec/integration/configurer_spec.rb +2 -2
- data/spec/integration/faces/plugin_spec.rb +62 -0
- data/spec/integration/indirector/catalog/compiler_spec.rb +1 -1
- data/spec/integration/indirector/catalog/queue_spec.rb +1 -1
- data/spec/integration/node/environment_spec.rb +2 -2
- data/spec/integration/parser/future_compiler_spec.rb +96 -142
- data/spec/integration/parser/ruby_manifest_spec.rb +0 -5
- data/spec/integration/provider/cron/crontab_spec.rb +35 -0
- data/spec/integration/type/file_spec.rb +74 -72
- data/spec/integration/util/windows/security_spec.rb +17 -0
- data/spec/lib/matchers/resource.rb +45 -13
- data/spec/lib/puppet_spec/files.rb +18 -0
- data/spec/lib/puppet_spec/module_tool/shared_functions.rb +56 -0
- data/spec/lib/puppet_spec/module_tool/stub_source.rb +133 -0
- data/spec/shared_contexts/checksums.rb +55 -0
- data/spec/unit/application/apply_spec.rb +10 -7
- data/spec/unit/application/doc_spec.rb +17 -10
- data/spec/unit/application/indirection_base_spec.rb +18 -10
- data/spec/unit/application/inspect_spec.rb +22 -20
- data/spec/unit/configurer/downloader_spec.rb +7 -6
- data/spec/unit/configurer/plugin_handler_spec.rb +5 -8
- data/spec/unit/configurer_spec.rb +1 -1
- data/spec/unit/context_spec.rb +23 -0
- data/spec/unit/environments_spec.rb +274 -16
- data/spec/unit/face/config_spec.rb +111 -11
- data/spec/unit/face/module/install_spec.rb +14 -85
- data/spec/unit/face/module/list_spec.rb +108 -62
- data/spec/unit/face/module/search_spec.rb +1 -1
- data/spec/unit/face/module/uninstall_spec.rb +21 -42
- data/spec/unit/face/parser_spec.rb +5 -2
- data/spec/unit/file_bucket/dipper_spec.rb +92 -86
- data/spec/unit/file_bucket/file_spec.rb +23 -75
- data/spec/unit/file_serving/metadata_spec.rb +74 -74
- data/spec/unit/forge/module_release_spec.rb +131 -0
- data/spec/unit/forge/repository_spec.rb +21 -20
- data/spec/unit/forge_spec.rb +99 -23
- data/spec/unit/functions/assert_type_spec.rb +59 -0
- data/spec/unit/functions4_spec.rb +671 -0
- data/spec/unit/indirector/catalog/static_compiler_spec.rb +2 -2
- data/spec/unit/indirector/facts/facter_spec.rb +9 -3
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +156 -155
- data/spec/unit/indirector/rest_spec.rb +8 -0
- data/spec/unit/interface/face_collection_spec.rb +35 -23
- data/spec/unit/module_spec.rb +20 -8
- data/spec/unit/module_tool/applications/builder_spec.rb +40 -12
- data/spec/unit/module_tool/applications/checksummer_spec.rb +86 -105
- data/spec/unit/module_tool/applications/installer_spec.rb +293 -261
- data/spec/unit/module_tool/applications/searcher_spec.rb +1 -1
- data/spec/unit/module_tool/applications/uninstaller_spec.rb +90 -154
- data/spec/unit/module_tool/applications/unpacker_spec.rb +12 -12
- data/spec/unit/module_tool/applications/upgrader_spec.rb +286 -18
- data/spec/unit/module_tool/metadata_spec.rb +223 -14
- data/spec/unit/module_tool/tar/gnu_spec.rb +12 -9
- data/spec/unit/module_tool/tar/mini_spec.rb +1 -1
- data/spec/unit/module_tool/tar_spec.rb +4 -18
- data/spec/unit/module_tool_spec.rb +123 -27
- data/spec/unit/network/formats_spec.rb +2 -2
- data/spec/unit/network/http_pool_spec.rb +21 -0
- data/spec/unit/network/rights_spec.rb +10 -8
- data/spec/unit/node/environment_spec.rb +27 -2
- data/spec/unit/parser/collector_spec.rb +1 -1
- data/spec/unit/parser/compiler_spec.rb +1 -1
- data/spec/unit/parser/functions/generate_spec.rb +4 -0
- data/spec/unit/pops/evaluator/access_ops_spec.rb +50 -11
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +25 -0
- data/spec/unit/pops/loaders/dependency_loader_spec.rb +44 -0
- data/spec/unit/pops/loaders/loader_paths_spec.rb +66 -0
- data/spec/unit/pops/loaders/loaders_spec.rb +105 -0
- data/spec/unit/pops/loaders/module_loaders_spec.rb +119 -0
- data/spec/unit/pops/loaders/static_loader_spec.rb +46 -0
- data/spec/unit/pops/types/type_calculator_spec.rb +145 -10
- data/spec/unit/pops/types/type_factory_spec.rb +101 -0
- data/spec/unit/pops/types/type_parser_spec.rb +22 -0
- data/spec/unit/property/list_spec.rb +9 -1
- data/spec/unit/provider/augeas/augeas_spec.rb +58 -11
- data/spec/unit/provider/cron/crontab_spec.rb +1 -0
- data/spec/unit/provider/cron/parsed_spec.rb +15 -0
- data/spec/unit/provider/naginator_spec.rb +14 -0
- data/spec/unit/provider/package/apt_spec.rb +78 -64
- data/spec/unit/provider/package/gem_spec.rb +15 -0
- data/spec/unit/provider/package/rpm_spec.rb +6 -6
- data/spec/unit/provider/package/windows_spec.rb +1 -1
- data/spec/unit/provider/package/yum_spec.rb +199 -104
- data/spec/unit/provider/package/zypper_spec.rb +41 -15
- data/spec/unit/provider/service/openbsd_spec.rb +129 -22
- data/spec/unit/provider/service/redhat_spec.rb +18 -4
- data/spec/unit/provider/service/systemd_spec.rb +5 -9
- data/spec/unit/provider/service/upstart_spec.rb +1 -1
- data/spec/unit/provider/user/directoryservice_spec.rb +10 -0
- data/spec/unit/provider/yumrepo/inifile_spec.rb +171 -15
- data/spec/unit/resource/catalog_spec.rb +20 -104
- data/spec/unit/resource/type_collection_spec.rb +10 -9
- data/spec/unit/settings/config_file_spec.rb +29 -6
- data/spec/unit/settings/environment_conf_spec.rb +51 -0
- data/spec/unit/settings_spec.rb +97 -12
- data/spec/unit/ssl/certificate_authority_spec.rb +2 -0
- data/spec/unit/type/augeas_spec.rb +1 -1
- data/spec/unit/type/cron_spec.rb +6 -7
- data/spec/unit/type/file/checksum_spec.rb +6 -0
- data/spec/unit/type/file/content_spec.rb +277 -207
- data/spec/unit/type/file_spec.rb +9 -7
- data/spec/unit/type/user_spec.rb +106 -18
- data/spec/unit/type/yumrepo_spec.rb +8 -0
- data/spec/unit/util/checksums_spec.rb +12 -5
- data/spec/unit/util/diff_spec.rb +8 -0
- data/spec/unit/util/execution_spec.rb +4 -4
- data/spec/unit/util/feature_spec.rb +2 -0
- data/spec/unit/util/logging_spec.rb +14 -4
- data/spec/unit/util/rdoc/parser_spec.rb +5 -4
- data/spec/unit/util/rubygems_spec.rb +14 -0
- data/tasks/parallel.rake +2 -2
- metadata +154 -21
- checksums.yaml +0 -7
- data/lib/puppet/module_tool/applications/generator.rb +0 -142
- data/lib/puppet/module_tool/skeleton.rb +0 -37
- data/lib/puppet/module_tool/skeleton/templates/generator/Modulefile.erb +0 -11
- data/lib/puppet/module_tool/skeleton/templates/generator/README.erb +0 -16
- data/lib/puppet/module_tool/tar/solaris.rb +0 -5
- data/spec/fixtures/unit/provider/service/systemd/list_units_services +0 -17
- data/spec/unit/module_tool/tar/solaris_spec.rb +0 -22
@@ -0,0 +1,237 @@
|
|
1
|
+
# Evaluate the dispatches defined as {Puppet::Pops::Functions::Dispatch}
|
2
|
+
# instances to call the appropriate method on the
|
3
|
+
# {Puppet::Pops::Functions::Function} instance.
|
4
|
+
#
|
5
|
+
# @api private
|
6
|
+
class Puppet::Pops::Functions::Dispatcher
|
7
|
+
attr_reader :dispatchers
|
8
|
+
|
9
|
+
# @api private
|
10
|
+
def initialize()
|
11
|
+
@dispatchers = [ ]
|
12
|
+
end
|
13
|
+
|
14
|
+
# Answers if dispatching has been defined
|
15
|
+
# @return [Boolean] true if dispatching has been defined
|
16
|
+
#
|
17
|
+
# @api private
|
18
|
+
def empty?
|
19
|
+
@dispatchers.empty?
|
20
|
+
end
|
21
|
+
|
22
|
+
# Dispatches the call to the first found signature (entry with matching type).
|
23
|
+
#
|
24
|
+
# @param instance [Puppet::Functions::Function] - the function to call
|
25
|
+
# @param calling_scope [T.B.D::Scope] - the scope of the caller
|
26
|
+
# @param args [Array<Object>] - the given arguments in the form of an Array
|
27
|
+
# @return [Object] - what the called function produced
|
28
|
+
#
|
29
|
+
# @api private
|
30
|
+
def dispatch(instance, calling_scope, args)
|
31
|
+
tc = Puppet::Pops::Types::TypeCalculator
|
32
|
+
actual = tc.infer_set(args)
|
33
|
+
found = @dispatchers.find { |d| tc.callable?(d.type, actual) }
|
34
|
+
if found
|
35
|
+
found.invoke(instance, calling_scope, args)
|
36
|
+
else
|
37
|
+
raise ArgumentError, "function '#{instance.class.name}' called with mis-matched arguments\n#{diff_string(instance.class.name, actual)}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# Adds a regular dispatch for one method name
|
42
|
+
#
|
43
|
+
# @param type [Puppet::Pops::Types::PArrayType, Puppet::Pops::Types::PTupleType] - type describing signature
|
44
|
+
# @param method_name [String] - the name of the method that will be called when type matches given arguments
|
45
|
+
# @param names [Array<String>] - array with names matching the number of parameters specified by type (or empty array)
|
46
|
+
#
|
47
|
+
# @api private
|
48
|
+
def add_dispatch(type, method_name, param_names, block_name, injections, weaving, last_captures)
|
49
|
+
@dispatchers << Puppet::Pops::Functions::Dispatch.new(type, method_name, param_names, block_name, injections, weaving, last_captures)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Produces a CallableType for a single signature, and a Variant[<callables>] otherwise
|
53
|
+
#
|
54
|
+
# @api private
|
55
|
+
def to_type()
|
56
|
+
# make a copy to make sure it can be contained by someone else (even if it is not contained here, it
|
57
|
+
# should be treated as immutable).
|
58
|
+
#
|
59
|
+
callables = dispatchers.map { | dispatch | dispatch.type.copy }
|
60
|
+
|
61
|
+
# multiple signatures, produce a Variant type of Callable1-n (must copy them)
|
62
|
+
# single signature, produce single Callable
|
63
|
+
callables.size > 1 ? Puppet::Pops::Types::TypeFactory.variant(*callables) : callables.pop
|
64
|
+
end
|
65
|
+
|
66
|
+
# @api private
|
67
|
+
def signatures
|
68
|
+
@dispatchers
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
# Produces a string with the difference between the given arguments and support signature(s).
|
74
|
+
#
|
75
|
+
# @api private
|
76
|
+
def diff_string(name, args_type)
|
77
|
+
result = [ ]
|
78
|
+
if @dispatchers.size < 2
|
79
|
+
dispatch = @dispatchers[ 0 ]
|
80
|
+
params_type = dispatch.type.param_types
|
81
|
+
block_type = dispatch.type.block_type
|
82
|
+
params_names = dispatch.param_names
|
83
|
+
result << "expected:\n #{name}(#{signature_string(dispatch)}) - #{arg_count_string(dispatch.type)}"
|
84
|
+
else
|
85
|
+
result << "expected one of:\n"
|
86
|
+
result << (@dispatchers.map do |d|
|
87
|
+
params_type = d.type.param_types
|
88
|
+
" #{name}(#{signature_string(d)}) - #{arg_count_string(d.type)}"
|
89
|
+
end.join("\n"))
|
90
|
+
end
|
91
|
+
result << "\nactual:\n #{name}(#{arg_types_string(args_type)}) - #{arg_count_string(args_type)}"
|
92
|
+
result.join('')
|
93
|
+
end
|
94
|
+
|
95
|
+
# Produces a string for the signature(s)
|
96
|
+
#
|
97
|
+
# @api private
|
98
|
+
def signature_string(dispatch) # args_type, param_names
|
99
|
+
param_types = dispatch.type.param_types
|
100
|
+
block_type = dispatch.type.block_type
|
101
|
+
param_names = dispatch.param_names
|
102
|
+
|
103
|
+
from, to = param_types.size_range
|
104
|
+
if from == 0 && to == 0
|
105
|
+
# No parameters function
|
106
|
+
return ''
|
107
|
+
end
|
108
|
+
|
109
|
+
required_count = from
|
110
|
+
# there may be more names than there are types, and count needs to be subtracted from the count
|
111
|
+
# to make it correct for the last named element
|
112
|
+
adjust = max(0, param_names.size() -1)
|
113
|
+
last_range = [max(0, (from - adjust)), (to - adjust)]
|
114
|
+
|
115
|
+
types =
|
116
|
+
case param_types
|
117
|
+
when Puppet::Pops::Types::PTupleType
|
118
|
+
param_types.types
|
119
|
+
when Puppet::Pops::Types::PArrayType
|
120
|
+
[ param_types.element_type ]
|
121
|
+
end
|
122
|
+
tc = Puppet::Pops::Types::TypeCalculator
|
123
|
+
|
124
|
+
# join type with names (types are always present, names are optional)
|
125
|
+
# separate entries with comma
|
126
|
+
#
|
127
|
+
result =
|
128
|
+
if param_names.empty?
|
129
|
+
types.each_with_index.map {|t, index| tc.string(t) + opt_value_indicator(index, required_count, 0) }
|
130
|
+
else
|
131
|
+
limit = param_names.size
|
132
|
+
result = param_names.each_with_index.map do |name, index|
|
133
|
+
[tc.string(types[index] || types[-1]), name].join(' ') + opt_value_indicator(index, required_count, limit)
|
134
|
+
end
|
135
|
+
end.join(', ')
|
136
|
+
|
137
|
+
# Add {from, to} for the last type
|
138
|
+
# This works for both Array and Tuple since it describes the allowed count of the "last" type element
|
139
|
+
# for both. It does not show anything when the range is {1,1}.
|
140
|
+
#
|
141
|
+
result += range_string(last_range)
|
142
|
+
|
143
|
+
# If there is a block, include it with its own optional count {0,1}
|
144
|
+
case dispatch.type.block_type
|
145
|
+
when Puppet::Pops::Types::POptionalType
|
146
|
+
result << ', ' unless result == ''
|
147
|
+
result << "#{tc.string(dispatch.type.block_type.optional_type)} #{dispatch.block_name} {0,1}"
|
148
|
+
when Puppet::Pops::Types::PCallableType
|
149
|
+
result << ', ' unless result == ''
|
150
|
+
result << "#{tc.string(dispatch.type.block_type)} #{dispatch.block_name}"
|
151
|
+
when NilClass
|
152
|
+
# nothing
|
153
|
+
end
|
154
|
+
result
|
155
|
+
end
|
156
|
+
|
157
|
+
# Why oh why Ruby do you not have a standard Math.max ?
|
158
|
+
# @api private
|
159
|
+
def max(a, b)
|
160
|
+
a >= b ? a : b
|
161
|
+
end
|
162
|
+
|
163
|
+
# @api private
|
164
|
+
def opt_value_indicator(index, required_count, limit)
|
165
|
+
count = index + 1
|
166
|
+
(count > required_count && count < limit) ? '?' : ''
|
167
|
+
end
|
168
|
+
|
169
|
+
# @api private
|
170
|
+
def arg_count_string(args_type)
|
171
|
+
if args_type.is_a?(Puppet::Pops::Types::PCallableType)
|
172
|
+
size_range = args_type.param_types.size_range # regular parameters
|
173
|
+
adjust_range=
|
174
|
+
case args_type.block_type
|
175
|
+
when Puppet::Pops::Types::POptionalType
|
176
|
+
size_range[1] += 1
|
177
|
+
when Puppet::Pops::Types::PCallableType
|
178
|
+
size_range[0] += 1
|
179
|
+
size_range[1] += 1
|
180
|
+
when NilClass
|
181
|
+
# nothing
|
182
|
+
else
|
183
|
+
raise ArgumentError, "Internal Error, only nil, Callable, and Optional[Callable] supported by Callable block type"
|
184
|
+
end
|
185
|
+
else
|
186
|
+
size_range = args_type.size_range
|
187
|
+
end
|
188
|
+
"arg count #{range_string(size_range, false)}"
|
189
|
+
end
|
190
|
+
|
191
|
+
# @api private
|
192
|
+
def arg_types_string(args_type)
|
193
|
+
types =
|
194
|
+
case args_type
|
195
|
+
when Puppet::Pops::Types::PTupleType
|
196
|
+
last_range = args_type.repeat_last_range
|
197
|
+
args_type.types
|
198
|
+
when Puppet::Pops::Types::PArrayType
|
199
|
+
last_range = args_type.size_range
|
200
|
+
[ args_type.element_type ]
|
201
|
+
end
|
202
|
+
# stringify generalized versions or it will display Integer[10,10] for "10", String['the content'] etc.
|
203
|
+
# note that type must be copied since generalize is a mutating operation
|
204
|
+
tc = Puppet::Pops::Types::TypeCalculator
|
205
|
+
result = types.map { |t| tc.string(tc.generalize!(t.copy)) }.join(', ')
|
206
|
+
|
207
|
+
# Add {from, to} for the last type
|
208
|
+
# This works for both Array and Tuple since it describes the allowed count of the "last" type element
|
209
|
+
# for both. It does not show anything when the range is {1,1}.
|
210
|
+
#
|
211
|
+
result += range_string(last_range)
|
212
|
+
result
|
213
|
+
end
|
214
|
+
|
215
|
+
# Formats a range into a string of the form: `{from, to}`
|
216
|
+
#
|
217
|
+
# The following cases are optimized:
|
218
|
+
#
|
219
|
+
# * from and to are equal => `{from}`
|
220
|
+
# * from and to are both and 1 and squelch_one == true => `''`
|
221
|
+
# * from is 0 and to is 1 => `'?'`
|
222
|
+
# * to is INFINITY => `{from, }`
|
223
|
+
#
|
224
|
+
# @api private
|
225
|
+
def range_string(size_range, squelch_one = true)
|
226
|
+
from, to = size_range
|
227
|
+
if from == to
|
228
|
+
(squelch_one && from == 1) ? '' : "{#{from}}"
|
229
|
+
elsif to == Puppet::Pops::Types::INFINITY
|
230
|
+
"{#{from},}"
|
231
|
+
elsif from == 0 && to == 1
|
232
|
+
'?'
|
233
|
+
else
|
234
|
+
"{#{from},#{to}}"
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# @note WARNING: This new function API is still under development and may change at
|
2
|
+
# any time
|
3
|
+
#
|
4
|
+
# A function in the puppet evaluator.
|
5
|
+
#
|
6
|
+
# Functions are normally defined by another system, which produces subclasses
|
7
|
+
# of this class as well as constructing delegations to call the appropriate methods.
|
8
|
+
#
|
9
|
+
# This class should rarely be used directly. Instead functions should be
|
10
|
+
# constructed using {Puppet::Functions.create_function}.
|
11
|
+
#
|
12
|
+
# @api public
|
13
|
+
class Puppet::Pops::Functions::Function
|
14
|
+
# The scope where the function was defined
|
15
|
+
attr_reader :closure_scope
|
16
|
+
|
17
|
+
# The loader that loaded this function.
|
18
|
+
# Should be used if function wants to load other things.
|
19
|
+
#
|
20
|
+
attr_reader :loader
|
21
|
+
|
22
|
+
def initialize(closure_scope, loader)
|
23
|
+
@closure_scope = closure_scope
|
24
|
+
@loader = loader
|
25
|
+
end
|
26
|
+
|
27
|
+
# Invokes the function via the dispatching logic that performs type check and weaving.
|
28
|
+
# A specialized function may override this method to do its own dispatching and checking of
|
29
|
+
# the raw arguments. A specialized implementation can rearrange arguments, add or remove
|
30
|
+
# arguments and then delegate to the dispatching logic by calling:
|
31
|
+
#
|
32
|
+
# @example Delegating to the dispatcher
|
33
|
+
# def call(scope, *args)
|
34
|
+
# manipulated_args = args + ['easter_egg']
|
35
|
+
# self.class.dispatcher.dispatch(self, scope, manipulated_args)
|
36
|
+
# end
|
37
|
+
#
|
38
|
+
# System functions that must have access to the calling scope can use this technique. Functions
|
39
|
+
# in general should not need the calling scope. (The closure scope; what is visible where the function
|
40
|
+
# is defined) is available via the method `closure_scope`).
|
41
|
+
#
|
42
|
+
# @api public
|
43
|
+
def call(scope, *args)
|
44
|
+
self.class.dispatcher.dispatch(self, scope, args)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Allows the implementation of a function to call other functions by name. The callable functions
|
48
|
+
# are those visible to the same loader that loaded this function (the calling function).
|
49
|
+
#
|
50
|
+
# @api public
|
51
|
+
def call_function(function_name, *args)
|
52
|
+
if the_loader = loader
|
53
|
+
func = the_loader.load(:function, function_name)
|
54
|
+
if func
|
55
|
+
return func.call(closure_scope, *args)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
# Raise a generic error to allow upper layers to fill in the details about where in a puppet manifest this
|
59
|
+
# error originates. (Such information is not available here).
|
60
|
+
#
|
61
|
+
raise ArgumentError, "Function #{self.class.name}(): cannot call function '#{function_name}' - not found"
|
62
|
+
end
|
63
|
+
|
64
|
+
# The dispatcher for the function
|
65
|
+
#
|
66
|
+
# @api private
|
67
|
+
def self.dispatcher
|
68
|
+
@dispatcher ||= Puppet::Pops::Functions::Dispatcher.new
|
69
|
+
end
|
70
|
+
|
71
|
+
# Produces information about parameters in a way that is compatible with Closure
|
72
|
+
#
|
73
|
+
# @api private
|
74
|
+
def self.signatures
|
75
|
+
@dispatcher.signatures
|
76
|
+
end
|
77
|
+
end
|
data/lib/puppet/pops/issues.rb
CHANGED
@@ -403,6 +403,10 @@ module Puppet::Pops::Issues
|
|
403
403
|
"First argument to Resource[] must be a resource type or a String. Got #{actual}."
|
404
404
|
end
|
405
405
|
|
406
|
+
EMPTY_RESOURCE_SPECIALIZATION = issue :EMPTY_RESOURCE_SPECIALIZATION do
|
407
|
+
"Arguments to Resource[] are all empty/undefined"
|
408
|
+
end
|
409
|
+
|
406
410
|
ILLEGAL_HOSTCLASS_NAME = hard_issue :ILLEGAL_HOSTCLASS_NAME, :name do
|
407
411
|
"Illegal Class name in class reference. #{label.a_an_uc(name)} cannot be used where a String is expected"
|
408
412
|
end
|
@@ -414,6 +418,10 @@ module Puppet::Pops::Issues
|
|
414
418
|
"Unacceptable name. The name '#{name}' is unacceptable as the name of #{label.a_an(semantic)}"
|
415
419
|
end
|
416
420
|
|
421
|
+
NON_NAMESPACED_FUNCTION = hard_issue :NON_NAMESPACED_FUNCTION, :name do
|
422
|
+
"A Puppet Function must be defined within a module name-space. The name '#{name}' is unacceptable."
|
423
|
+
end
|
424
|
+
|
417
425
|
NOT_NUMERIC = issue :NOT_NUMERIC, :value do
|
418
426
|
"The value '#{value}' cannot be converted to Numeric."
|
419
427
|
end
|
@@ -458,4 +466,8 @@ module Puppet::Pops::Issues
|
|
458
466
|
ILLEGAL_EPP_PARAMETERS = issue :ILLEGAL_EPP_PARAMETERS do
|
459
467
|
"Ambiguous EPP parameter expression. Probably missing '<%-' before parameters to remove leading whitespace"
|
460
468
|
end
|
469
|
+
|
470
|
+
DISCONTINUED_IMPORT = hard_issue :DISCONTINUED_IMPORT do
|
471
|
+
"Use of 'import' has been discontinued in favor of a manifest directory. See http://links.puppetlabs.com/puppet-import-deprecation"
|
472
|
+
end
|
461
473
|
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
# BaseLoader
|
2
|
+
# ===
|
3
|
+
# An abstract implementation of Puppet::Pops::Loader::Loader
|
4
|
+
#
|
5
|
+
# A derived class should implement `find(typed_name)` and set entries, and possible handle "miss caching".
|
6
|
+
#
|
7
|
+
# @api private
|
8
|
+
#
|
9
|
+
class Puppet::Pops::Loader::BaseLoader < Puppet::Pops::Loader::Loader
|
10
|
+
|
11
|
+
# The parent loader
|
12
|
+
attr_reader :parent
|
13
|
+
|
14
|
+
# An internal name used for debugging and error message purposes
|
15
|
+
attr_reader :loader_name
|
16
|
+
|
17
|
+
def initialize(parent_loader, loader_name)
|
18
|
+
@parent = parent_loader # the higher priority loader to consult
|
19
|
+
@named_values = {} # hash name => NamedEntry
|
20
|
+
@last_name = nil # the last name asked for (optimization)
|
21
|
+
@last_result = nil # the value of the last name (optimization)
|
22
|
+
@loader_name = loader_name # the name of the loader (not the name-space it is a loader for)
|
23
|
+
end
|
24
|
+
|
25
|
+
# @api public
|
26
|
+
#
|
27
|
+
def load_typed(typed_name)
|
28
|
+
# The check for "last queried name" is an optimization when a module searches. First it checks up its parent
|
29
|
+
# chain, then itself, and then delegates to modules it depends on.
|
30
|
+
# These modules are typically parented by the same
|
31
|
+
# loader as the one initiating the search. It is inefficient to again try to search the same loader for
|
32
|
+
# the same name.
|
33
|
+
if typed_name == @last_name
|
34
|
+
@last_result
|
35
|
+
else
|
36
|
+
@last_name = typed_name
|
37
|
+
@last_result = internal_load(typed_name)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# This method is final (subclasses should not override it)
|
42
|
+
#
|
43
|
+
# @api private
|
44
|
+
#
|
45
|
+
def get_entry(typed_name)
|
46
|
+
@named_values[typed_name]
|
47
|
+
end
|
48
|
+
|
49
|
+
# @api private
|
50
|
+
#
|
51
|
+
def set_entry(typed_name, value, origin = nil)
|
52
|
+
if entry = @named_values[typed_name] then fail_redefined(entry); end
|
53
|
+
@named_values[typed_name] = Puppet::Pops::Loader::Loader::NamedEntry.new(typed_name, value, origin)
|
54
|
+
end
|
55
|
+
|
56
|
+
# @api private
|
57
|
+
#
|
58
|
+
def add_entry(type, name, value, origin)
|
59
|
+
set_entry(Puppet::Pops::Loader::Loader::TypedName.new(type, name), value, origin)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Promotes an already created entry (typically from another loader) to this loader
|
63
|
+
#
|
64
|
+
# @api private
|
65
|
+
#
|
66
|
+
def promote_entry(named_entry)
|
67
|
+
typed_name = named_entry.typed_name
|
68
|
+
if entry = @named_values[typed_name] then fail_redefined(entry); end
|
69
|
+
@named_values[typed_name] = named_entry
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
def fail_redefine(entry)
|
75
|
+
origin_info = entry.origin ? " Originally set at #{origin_label(entry.origin)}." : "unknown location"
|
76
|
+
raise ArgumentError, "Attempt to redefine entity '#{entry.typed_name}' originally set at #{origin_label(origin)}.#{origin_info}"
|
77
|
+
end
|
78
|
+
|
79
|
+
# TODO: Should not really be here?? - TODO: A Label provider ? semantics for the URI?
|
80
|
+
#
|
81
|
+
def origin_label(origin)
|
82
|
+
if origin && origin.is_a?(URI)
|
83
|
+
origin.to_s
|
84
|
+
elsif origin.respond_to?(:uri)
|
85
|
+
origin.uri.to_s
|
86
|
+
else
|
87
|
+
nil
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# loads in priority order:
|
92
|
+
# 1. already loaded here
|
93
|
+
# 2. load from parent
|
94
|
+
# 3. find it here
|
95
|
+
# 4. give up
|
96
|
+
#
|
97
|
+
def internal_load(typed_name)
|
98
|
+
# avoid calling get_entry, by looking it up
|
99
|
+
@named_values[typed_name] || parent.load_typed(typed_name) || find(typed_name)
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# =DependencyLoader
|
2
|
+
# This loader provides visibility into a set of other loaders. It is used as a child of a ModuleLoader (or other
|
3
|
+
# loader) to make its direct dependencies visible for loading from contexts that have access to this dependency loader.
|
4
|
+
# Access is typically given to logic that resides inside of the module, but not to those that just depend on the module.
|
5
|
+
#
|
6
|
+
# It is instantiated with a name, and with a set of dependency_loaders.
|
7
|
+
#
|
8
|
+
# @api private
|
9
|
+
#
|
10
|
+
class Puppet::Pops::Loader::DependencyLoader < Puppet::Pops::Loader::BaseLoader
|
11
|
+
|
12
|
+
# An index of module_name to module loader used to speed up lookup of qualified names
|
13
|
+
attr_reader :index
|
14
|
+
|
15
|
+
# Creates a DependencyLoader for one parent loader
|
16
|
+
#
|
17
|
+
# @param parent_loader [Puppet::Pops::Loader] typically a module loader for the root
|
18
|
+
# @param name [String] the name of the dependency-loader (used for debugging and tracing only)
|
19
|
+
# @param dependency_loaders [Array<Puppet::Pops::Loader>] array of loaders for modules this module depends on
|
20
|
+
#
|
21
|
+
def initialize(parent_loader, name, dependency_loaders)
|
22
|
+
super parent_loader, name
|
23
|
+
@dependency_loaders = dependency_loaders
|
24
|
+
end
|
25
|
+
|
26
|
+
# Finds name in a loader this loader depends on / can see
|
27
|
+
#
|
28
|
+
def find(typed_name)
|
29
|
+
if typed_name.qualified
|
30
|
+
if loader = index()[typed_name.name_parts[0]]
|
31
|
+
loader.load_typed(typed_name)
|
32
|
+
else
|
33
|
+
# no module entered as dependency with name matching first segment of wanted name
|
34
|
+
nil
|
35
|
+
end
|
36
|
+
else
|
37
|
+
# a non name-spaced name, have to search since it can be anywhere.
|
38
|
+
# (Note: superclass caches the result in this loader as it would have to repeat this search for every
|
39
|
+
# lookup otherwise).
|
40
|
+
loaded = @dependency_loaders.reduce(nil) do |previous, loader|
|
41
|
+
break previous if !previous.nil?
|
42
|
+
loader.load_typed(typed_name)
|
43
|
+
end
|
44
|
+
if loaded
|
45
|
+
promote_entry(loaded)
|
46
|
+
end
|
47
|
+
loaded
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def to_s()
|
52
|
+
"(DependencyLoader '#{@loader_name}' [" + @dependency_loaders.map {|loader| loader.to_s }.join(' ,') + "])"
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def index()
|
58
|
+
@index ||= @dependency_loaders.reduce({}) { |index, loader| index[loader.module_name] = loader; index }
|
59
|
+
end
|
60
|
+
end
|