puppet 4.2.3 → 4.3.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- data/Gemfile +3 -0
- data/README.md +1 -1
- data/ext/debian/puppet.init +0 -1
- data/ext/debian/puppet.logrotate +14 -5
- data/ext/osx/puppet.plist +0 -2
- data/ext/redhat/client.init +13 -5
- data/ext/redhat/logrotate +15 -3
- data/ext/redhat/puppet.spec.erb +5 -1
- data/ext/redhat/server.init +1 -1
- data/ext/systemd/puppet.service +1 -0
- data/lib/puppet.rb +12 -0
- data/lib/puppet/agent.rb +4 -4
- data/lib/puppet/agent/locker.rb +11 -2
- data/lib/puppet/application/agent.rb +5 -1
- data/lib/puppet/application/apply.rb +4 -0
- data/lib/puppet/application/filebucket.rb +78 -4
- data/lib/puppet/application/lookup.rb +356 -0
- data/lib/puppet/application/master.rb +3 -0
- data/lib/puppet/configurer.rb +9 -5
- data/lib/puppet/context.rb +16 -1
- data/lib/puppet/context/trusted_information.rb +21 -1
- data/lib/puppet/daemon.rb +17 -13
- data/lib/puppet/data_binding.rb +4 -2
- data/lib/puppet/data_providers.rb +12 -13
- data/lib/puppet/data_providers/data_adapter.rb +7 -68
- data/lib/puppet/data_providers/data_function_support.rb +5 -26
- data/lib/puppet/data_providers/function_env_data_provider.rb +0 -10
- data/lib/puppet/data_providers/function_module_data_provider.rb +0 -22
- data/lib/puppet/data_providers/hiera_config.rb +106 -0
- data/lib/puppet/data_providers/hiera_env_data_provider.rb +18 -0
- data/lib/puppet/data_providers/hiera_interpolate.rb +97 -0
- data/lib/puppet/data_providers/hiera_module_data_provider.rb +23 -0
- data/lib/puppet/data_providers/hiera_support.rb +37 -0
- data/lib/puppet/data_providers/json_data_provider_factory.rb +31 -0
- data/lib/puppet/data_providers/lookup_adapter.rb +200 -0
- data/lib/puppet/data_providers/yaml_data_provider_factory.rb +32 -0
- data/lib/puppet/defaults.rb +12 -2
- data/lib/puppet/error.rb +4 -0
- data/lib/puppet/face/module/changes.rb +2 -1
- data/lib/puppet/feature/cfacter.rb +1 -0
- data/lib/puppet/file_bucket/dipper.rb +58 -2
- data/lib/puppet/functions.rb +2 -4
- data/lib/puppet/functions/assert_type.rb +48 -12
- data/lib/puppet/functions/defined.rb +79 -48
- data/lib/puppet/functions/each.rb +85 -27
- data/lib/puppet/functions/filter.rb +58 -23
- data/lib/puppet/functions/hiera.rb +76 -3
- data/lib/puppet/functions/hiera_array.rb +65 -3
- data/lib/puppet/functions/hiera_hash.rb +74 -2
- data/lib/puppet/functions/hiera_include.rb +75 -2
- data/lib/puppet/functions/lookup.rb +19 -17
- data/lib/puppet/functions/map.rb +56 -21
- data/lib/puppet/functions/match.rb +29 -12
- data/lib/puppet/functions/reduce.rb +95 -58
- data/lib/puppet/functions/versioncmp.rb +36 -0
- data/lib/puppet/functions/with.rb +15 -7
- data/lib/puppet/indirector/catalog/compiler.rb +3 -3
- data/lib/puppet/indirector/catalog/static_compiler.rb +46 -30
- data/lib/puppet/indirector/data_binding/none.rb +4 -1
- data/lib/puppet/indirector/file_bucket_file/file.rb +58 -1
- data/lib/puppet/indirector/hiera.rb +4 -0
- data/lib/puppet/indirector/json.rb +1 -1
- data/lib/puppet/indirector/msgpack.rb +1 -1
- data/lib/puppet/indirector/request.rb +7 -8
- data/lib/puppet/indirector/resource_type/parser.rb +5 -3
- data/lib/puppet/info_service.rb +7 -0
- data/lib/puppet/info_service/class_information_service.rb +111 -0
- data/lib/puppet/module_tool/metadata.rb +32 -9
- data/lib/puppet/module_tool/skeleton/templates/generator/README.md.erb +42 -38
- data/lib/puppet/network/authconfig.rb +21 -1
- data/lib/puppet/network/authorization.rb +8 -1
- data/lib/puppet/network/http/api/master/v3.rb +7 -1
- data/lib/puppet/network/http/api/master/v3/environment.rb +59 -0
- data/lib/puppet/node/environment.rb +9 -2
- data/lib/puppet/parser.rb +3 -0
- data/lib/puppet/parser/ast/pops_bridge.rb +39 -1
- data/lib/puppet/parser/compiler.rb +302 -12
- data/lib/puppet/parser/compiler/catalog_validator.rb +33 -0
- data/lib/puppet/parser/compiler/catalog_validator/env_relationship_validator.rb +64 -0
- data/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb +38 -0
- data/lib/puppet/parser/compiler/catalog_validator/site_validator.rb +20 -0
- data/lib/puppet/parser/environment_compiler.rb +165 -0
- data/lib/puppet/parser/functions/assert_type.rb +46 -16
- data/lib/puppet/parser/functions/defined.rb +105 -68
- data/lib/puppet/parser/functions/each.rb +85 -27
- data/lib/puppet/parser/functions/filter.rb +59 -23
- data/lib/puppet/parser/functions/hiera.rb +83 -27
- data/lib/puppet/parser/functions/hiera_array.rb +71 -28
- data/lib/puppet/parser/functions/hiera_hash.rb +81 -30
- data/lib/puppet/parser/functions/hiera_include.rb +81 -40
- data/lib/puppet/parser/functions/map.rb +55 -20
- data/lib/puppet/parser/functions/match.rb +27 -12
- data/lib/puppet/parser/functions/reduce.rb +97 -60
- data/lib/puppet/parser/functions/with.rb +16 -8
- data/lib/puppet/parser/resource.rb +98 -19
- data/lib/puppet/plugins/configuration.rb +3 -2
- data/lib/puppet/plugins/data_providers.rb +12 -60
- data/lib/puppet/plugins/data_providers/data_provider.rb +283 -0
- data/lib/puppet/plugins/data_providers/registry.rb +84 -0
- data/lib/puppet/pops.rb +19 -17
- data/lib/puppet/pops/adapters.rb +12 -0
- data/lib/puppet/pops/binder/binder.rb +2 -2
- data/lib/puppet/pops/binder/bindings_checker.rb +1 -1
- data/lib/puppet/pops/binder/bindings_label_provider.rb +3 -1
- data/lib/puppet/pops/binder/bindings_loader.rb +6 -2
- data/lib/puppet/pops/binder/bindings_model_meta.rb +2 -2
- data/lib/puppet/pops/binder/config/binder_config.rb +1 -1
- data/lib/puppet/pops/binder/injector.rb +4 -4
- data/lib/puppet/pops/binder/key_factory.rb +3 -9
- data/lib/puppet/pops/binder/scheme_handler/module_scheme.rb +68 -9
- data/lib/puppet/pops/evaluator/access_operator.rb +27 -60
- data/lib/puppet/pops/evaluator/closure.rb +8 -8
- data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +1 -1
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +5 -5
- data/lib/puppet/pops/evaluator/literal_evaluator.rb +87 -0
- data/lib/puppet/pops/evaluator/relationship_operator.rb +7 -1
- data/lib/puppet/pops/functions/dispatcher.rb +3 -3
- data/lib/puppet/pops/issues.rb +1 -1
- data/lib/puppet/pops/label_provider.rb +1 -1
- data/lib/puppet/pops/lookup.rb +25 -47
- data/lib/puppet/pops/lookup/explainer.rb +402 -0
- data/lib/puppet/pops/lookup/invocation.rb +117 -0
- data/lib/puppet/pops/merge_strategy.rb +73 -5
- data/lib/puppet/pops/model/factory.rb +34 -0
- data/lib/puppet/pops/model/model_label_provider.rb +10 -1
- data/lib/puppet/pops/model/model_meta.rb +15 -0
- data/lib/puppet/pops/model/model_tree_dumper.rb +18 -0
- data/lib/puppet/pops/parser/code_merger.rb +13 -1
- data/lib/puppet/pops/parser/egrammar.ra +56 -3
- data/lib/puppet/pops/parser/eparser.rb +1549 -1352
- data/lib/puppet/pops/parser/lexer2.rb +31 -6
- data/lib/puppet/pops/parser/locator.rb +1 -1
- data/lib/puppet/pops/parser/parser_support.rb +25 -13
- data/lib/puppet/pops/types/enumeration.rb +1 -2
- data/lib/puppet/pops/types/type_asserter.rb +16 -15
- data/lib/puppet/pops/types/type_assertion_error.rb +1 -0
- data/lib/puppet/pops/types/type_calculator.rb +171 -1020
- data/lib/puppet/pops/types/type_factory.rb +87 -148
- data/lib/puppet/pops/types/type_mismatch_describer.rb +743 -0
- data/lib/puppet/pops/types/type_parser.rb +116 -127
- data/lib/puppet/pops/types/types.rb +1394 -255
- data/lib/puppet/pops/types/types_meta.rb +0 -234
- data/lib/puppet/pops/validation.rb +7 -2
- data/lib/puppet/pops/validation/checker4_0.rb +28 -0
- data/lib/puppet/provider/augeas/augeas.rb +50 -0
- data/lib/puppet/provider/group/directoryservice.rb +10 -0
- data/lib/puppet/provider/package/dnf.rb +41 -0
- data/lib/puppet/provider/package/gem.rb +7 -2
- data/lib/puppet/provider/package/rpm.rb +1 -0
- data/lib/puppet/provider/package/windows/exe_package.rb +10 -8
- data/lib/puppet/provider/package/windows/msi_package.rb +4 -3
- data/lib/puppet/provider/package/windows/package.rb +9 -1
- data/lib/puppet/provider/package/yum.rb +14 -9
- data/lib/puppet/provider/service/bsd.rb +1 -1
- data/lib/puppet/provider/service/debian.rb +21 -0
- data/lib/puppet/provider/service/init.rb +6 -0
- data/lib/puppet/provider/service/rcng.rb +51 -0
- data/lib/puppet/provider/service/redhat.rb +2 -1
- data/lib/puppet/provider/service/smf.rb +43 -2
- data/lib/puppet/provider/service/src.rb +27 -0
- data/lib/puppet/provider/service/systemd.rb +15 -3
- data/lib/puppet/provider/sshkey/parsed.rb +19 -9
- data/lib/puppet/reference/report.rb +9 -12
- data/lib/puppet/reports.rb +5 -1
- data/lib/puppet/resource.rb +50 -73
- data/lib/puppet/resource/capability_finder.rb +95 -0
- data/lib/puppet/resource/catalog.rb +47 -7
- data/lib/puppet/resource/status.rb +0 -2
- data/lib/puppet/resource/type.rb +238 -44
- data/lib/puppet/resource/type_collection.rb +60 -2
- data/lib/puppet/settings.rb +2 -2
- data/lib/puppet/ssl/certificate_authority/interface.rb +2 -2
- data/lib/puppet/ssl/oids.rb +9 -1
- data/lib/puppet/transaction.rb +4 -1
- data/lib/puppet/transaction/additional_resource_generator.rb +71 -8
- data/lib/puppet/transaction/resource_harness.rb +9 -4
- data/lib/puppet/type.rb +74 -3
- data/lib/puppet/type/augeas.rb +8 -0
- data/lib/puppet/type/file/source.rb +14 -12
- data/lib/puppet/type/user.rb +4 -2
- data/lib/puppet/util/windows/security.rb +4 -1
- data/lib/puppet/util/windows/taskscheduler.rb +1 -1
- data/lib/puppet/version.rb +1 -1
- data/spec/fixtures/unit/application/environments/production/data/common.yaml +3 -0
- data/spec/fixtures/unit/application/environments/production/environment.conf +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/data/bad.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/hiera.yaml +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_json/manifests/site.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/data/bad.yaml +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/hiera.yaml +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_bad_syntax_yaml/manifests/site.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/data/common.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/manifests/site.pp +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/modules/one/data/common.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/modules/one/manifests/init.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_defaults/modules/one/metadata.json +9 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/first.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/name.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/second.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data1/single.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/data2/single.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/hiera.yaml +18 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_env_config/manifests/site.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/data/common.yaml +46 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/manifests/site.pp +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/modules/one/data/common.yaml +30 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/modules/one/manifests/init.pp +13 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_misc/modules/one/metadata.json +9 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/environment.conf +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/manifests/site.pp +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/first.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/name.yaml +1 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/second.json +3 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/single.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data2/single.yaml +2 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/hiera.yaml +18 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/manifests/init.pp +5 -0
- data/spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/metadata.json +9 -0
- data/spec/fixtures/unit/data_providers/environments/sample/modules/dataprovider/lib/puppet_x/helindbe/sample_env_data.rb +1 -0
- data/spec/fixtures/unit/data_providers/environments/sample/modules/dataprovider/lib/puppet_x/helindbe/sample_module_data.rb +1 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/data/first.json +3 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/hiera.yaml +8 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/manifests/init.pp +5 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/meta/lib/puppet/functions/meta/data.rb +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/meta/manifests/init.pp +3 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/meta/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/metawcp/lib/puppet/bindings/metawcp/default.rb +10 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/metawcp/lib/puppet_x/thallgren/sample_module_data.rb +23 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/metawcp/manifests/init.pp +3 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/metawcp/metadata.json +9 -0
- data/spec/fixtures/unit/provider/package/yum/yum-check-update-security.txt +184 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_get/should_yield_to_the_block.yml +24 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_head/should_yield_to_the_block.yml +24 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Network_HTTP_Connection/when_handling_requests/_request_post/should_yield_to_the_block.yml +24 -0
- data/spec/integration/data_binding_spec.rb +229 -0
- data/spec/integration/file_bucket/file_spec.rb +2 -2
- data/spec/integration/parser/compiler_spec.rb +23 -19
- data/spec/integration/parser/resource_expressions_spec.rb +4 -4
- data/spec/integration/parser/undef_param_spec.rb +1 -1
- data/spec/integration/resource/catalog_spec.rb +1 -1
- data/spec/integration/type/package_spec.rb +2 -0
- data/spec/integration/util/windows/security_spec.rb +18 -0
- data/spec/lib/matchers/include_in_order.rb +2 -2
- data/spec/shared_behaviours/iterative_functions.rb +8 -8
- data/spec/spec_helper.rb +7 -0
- data/spec/unit/agent/locker_spec.rb +4 -4
- data/spec/unit/agent_spec.rb +0 -8
- data/spec/unit/application/agent_spec.rb +5 -0
- data/spec/unit/application/apply_spec.rb +8 -0
- data/spec/unit/application/filebucket_spec.rb +87 -1
- data/spec/unit/application/lookup_spec.rb +195 -0
- data/spec/unit/appmgmt_spec.rb +657 -0
- data/spec/unit/capability_spec.rb +414 -0
- data/spec/unit/configurer_spec.rb +7 -1
- data/spec/unit/context/trusted_information_spec.rb +24 -1
- data/spec/unit/daemon_spec.rb +18 -8
- data/spec/unit/data_providers/hiera_data_provider_spec.rb +201 -0
- data/spec/unit/file_bucket/dipper_spec.rb +210 -1
- data/spec/unit/functions/assert_type_spec.rb +5 -7
- data/spec/unit/functions/defined_spec.rb +2 -2
- data/spec/unit/functions/epp_spec.rb +2 -2
- data/spec/unit/functions/lookup_spec.rb +200 -9
- data/spec/unit/functions/regsubst_spec.rb +17 -8
- data/spec/unit/functions/scanf_spec.rb +1 -1
- data/spec/unit/functions/split_spec.rb +2 -2
- data/spec/unit/functions/versioncmp_spec.rb +36 -0
- data/spec/unit/functions4_spec.rb +58 -72
- data/spec/unit/indirector/catalog/compiler_spec.rb +28 -8
- data/spec/unit/indirector/catalog/static_compiler_spec.rb +38 -20
- data/spec/unit/indirector/data_binding/none_spec.rb +2 -2
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +52 -1
- data/spec/unit/indirector/request_spec.rb +8 -8
- data/spec/unit/info_service_spec.rb +236 -0
- data/spec/unit/module_tool/metadata_spec.rb +31 -2
- data/spec/unit/network/authconfig_spec.rb +62 -32
- data/spec/unit/network/authorization_spec.rb +30 -2
- data/spec/unit/network/http/connection_spec.rb +14 -19
- data/spec/unit/parser/compiler_spec.rb +86 -2
- data/spec/unit/parser/functions/create_resources_spec.rb +1 -1
- data/spec/unit/parser/resource_spec.rb +2 -20
- data/spec/unit/pops/binder/config/binder_config_spec.rb +1 -1
- data/spec/unit/pops/binder/injector_spec.rb +3 -3
- data/spec/unit/pops/evaluator/access_ops_spec.rb +13 -11
- data/spec/unit/pops/evaluator/basic_expressions_spec.rb +1 -2
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +19 -11
- data/spec/unit/pops/evaluator/literal_evaluator_spec.rb +43 -0
- data/spec/unit/pops/label_provider_spec.rb +5 -1
- data/spec/unit/pops/parser/lexer2_spec.rb +33 -7
- data/spec/unit/pops/parser/parse_application_spec.rb +40 -0
- data/spec/unit/pops/parser/parse_basic_expressions_spec.rb +4 -0
- data/spec/unit/pops/parser/parse_capabilities_spec.rb +47 -0
- data/spec/unit/pops/parser/parse_site_spec.rb +38 -0
- data/spec/unit/pops/parser/parser_rspec_helper.rb +5 -0
- data/spec/unit/pops/parser/parser_spec.rb +18 -0
- data/spec/unit/pops/types/type_calculator_spec.rb +427 -444
- data/spec/unit/pops/types/type_factory_spec.rb +12 -12
- data/spec/unit/pops/types/type_parser_spec.rb +7 -12
- data/spec/unit/pops/validator/validator_spec.rb +25 -0
- data/spec/unit/provider/augeas/augeas_spec.rb +50 -0
- data/spec/unit/provider/group/directoryservice_spec.rb +33 -0
- data/spec/unit/provider/group/windows_adsi_spec.rb +3 -0
- data/spec/unit/provider/package/dnf_spec.rb +92 -0
- data/spec/unit/provider/package/gem_spec.rb +7 -0
- data/spec/unit/provider/package/rpm_spec.rb +25 -2
- data/spec/unit/provider/package/windows/package_spec.rb +41 -0
- data/spec/unit/provider/package/yum_spec.rb +21 -13
- data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +10 -0
- data/spec/unit/provider/service/debian_spec.rb +27 -0
- data/spec/unit/provider/service/rcng_spec.rb +41 -0
- data/spec/unit/provider/service/redhat_spec.rb +8 -1
- data/spec/unit/provider/service/smf_spec.rb +30 -5
- data/spec/unit/provider/service/src_spec.rb +19 -4
- data/spec/unit/provider/service/systemd_spec.rb +78 -29
- data/spec/unit/provider/sshkey/parsed_spec.rb +23 -0
- data/spec/unit/reports_spec.rb +10 -0
- data/spec/unit/resource/capability_finder_spec.rb +56 -0
- data/spec/unit/resource/catalog_spec.rb +31 -8
- data/spec/unit/resource/type_collection_spec.rb +23 -2
- data/spec/unit/resource/type_spec.rb +1 -1
- data/spec/unit/resource_spec.rb +22 -4
- data/spec/unit/settings_spec.rb +90 -1
- data/spec/unit/ssl/certificate_authority/interface_spec.rb +4 -3
- data/spec/unit/ssl/oids_spec.rb +8 -0
- data/spec/unit/transaction/additional_resource_generator_spec.rb +78 -5
- data/spec/unit/transaction/report_spec.rb +24 -1
- data/spec/unit/type/package_spec.rb +1 -0
- data/spec/unit/type/user_spec.rb +14 -7
- data/spec/unit/type_spec.rb +1 -1
- metadata +169 -5
- data/lib/puppet/pops/evaluator/callable_mismatch_describer.rb +0 -175
- data/spec/integration/data_binding.rb +0 -104
@@ -0,0 +1,84 @@
|
|
1
|
+
module Puppet::Plugins::DataProviders
|
2
|
+
class Registry
|
3
|
+
def self.register_extensions(extensions)
|
4
|
+
extensions.multibind(PER_MODULE_DATA_PROVIDER_KEY).name(PER_MODULE_DATA_PROVIDER_KEY).hash_of(PER_MODULE_DATA_PROVIDER_TYPE)
|
5
|
+
extensions.multibind(ENV_DATA_PROVIDERS_KEY).name(ENV_DATA_PROVIDERS_KEY).hash_of(ENV_DATA_PROVIDERS_TYPE)
|
6
|
+
extensions.multibind(MODULE_DATA_PROVIDERS_KEY).name(MODULE_DATA_PROVIDERS_KEY).hash_of(MODULE_DATA_PROVIDERS_TYPE)
|
7
|
+
extensions.multibind(PATH_BASED_DATA_PROVIDER_FACTORIES_KEY).name(PATH_BASED_DATA_PROVIDER_FACTORIES_KEY).hash_of(PATH_BASED_DATA_PROVIDER_FACTORIES_TYPE)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.hash_of_per_module_data_provider
|
11
|
+
@@HASH_OF_PER_MODULE_DATA_PROVIDERS ||= Puppet::Pops::Types::TypeFactory.hash_of(PER_MODULE_DATA_PROVIDER_TYPE)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.hash_of_module_data_providers
|
15
|
+
@@HASH_OF_MODULE_DATA_PROVIDERS ||= Puppet::Pops::Types::TypeFactory.hash_of(
|
16
|
+
Puppet::Pops::Types::TypeFactory.type_of(MODULE_DATA_PROVIDERS_TYPE))
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.hash_of_environment_data_providers
|
20
|
+
@@HASH_OF_ENV_DATA_PROVIDERS ||= Puppet::Pops::Types::TypeFactory.hash_of(
|
21
|
+
Puppet::Pops::Types::TypeFactory.type_of(ENV_DATA_PROVIDERS_TYPE))
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.hash_of_path_based_data_provider_factories
|
25
|
+
@@HASH_OF_PATH_BASED_DATA_PROVIDER_FACTORIES ||= Puppet::Pops::Types::TypeFactory.hash_of(
|
26
|
+
Puppet::Pops::Types::TypeFactory.type_of(PATH_BASED_DATA_PROVIDER_FACTORIES_TYPE))
|
27
|
+
end
|
28
|
+
|
29
|
+
# Registers a 'none' environment data provider, and a 'none' module data provider as the defaults.
|
30
|
+
# This is only done to allow that something binds to 'none' rather than removing the entire binding (which
|
31
|
+
# has the same effect).
|
32
|
+
#
|
33
|
+
def self.register_defaults(default_bindings)
|
34
|
+
default_bindings.bind do
|
35
|
+
name('none')
|
36
|
+
in_multibind(ENV_DATA_PROVIDERS_KEY)
|
37
|
+
to_instance(ENV_DATA_PROVIDERS_TYPE)
|
38
|
+
end
|
39
|
+
|
40
|
+
default_bindings.bind do
|
41
|
+
name('function')
|
42
|
+
in_multibind(ENV_DATA_PROVIDERS_KEY)
|
43
|
+
to_instance('Puppet::DataProviders::FunctionEnvDataProvider')
|
44
|
+
end
|
45
|
+
|
46
|
+
default_bindings.bind do
|
47
|
+
name('hiera')
|
48
|
+
in_multibind(ENV_DATA_PROVIDERS_KEY)
|
49
|
+
to_instance('Puppet::DataProviders::HieraEnvDataProvider')
|
50
|
+
end
|
51
|
+
|
52
|
+
default_bindings.bind do
|
53
|
+
name('none')
|
54
|
+
in_multibind(MODULE_DATA_PROVIDERS_KEY)
|
55
|
+
to_instance(MODULE_DATA_PROVIDERS_TYPE)
|
56
|
+
end
|
57
|
+
|
58
|
+
default_bindings.bind do
|
59
|
+
name('function')
|
60
|
+
in_multibind(MODULE_DATA_PROVIDERS_KEY)
|
61
|
+
to_instance('Puppet::DataProviders::FunctionModuleDataProvider')
|
62
|
+
end
|
63
|
+
|
64
|
+
default_bindings.bind do
|
65
|
+
name('hiera')
|
66
|
+
in_multibind(MODULE_DATA_PROVIDERS_KEY)
|
67
|
+
to_instance('Puppet::DataProviders::HieraModuleDataProvider')
|
68
|
+
end
|
69
|
+
|
70
|
+
default_bindings.bind do
|
71
|
+
name('json')
|
72
|
+
in_multibind(PATH_BASED_DATA_PROVIDER_FACTORIES_KEY)
|
73
|
+
to_instance('Puppet::DataProviders::JsonDataProviderFactory')
|
74
|
+
end
|
75
|
+
|
76
|
+
default_bindings.bind do
|
77
|
+
name('yaml')
|
78
|
+
in_multibind(PATH_BASED_DATA_PROVIDER_FACTORIES_KEY)
|
79
|
+
to_instance('Puppet::DataProviders::YamlDataProviderFactory')
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
data/lib/puppet/pops.rb
CHANGED
@@ -27,6 +27,8 @@ module Puppet
|
|
27
27
|
require 'puppet/pops/validation'
|
28
28
|
require 'puppet/pops/issue_reporter'
|
29
29
|
require 'puppet/pops/lookup'
|
30
|
+
require 'puppet/pops/lookup/invocation'
|
31
|
+
require 'puppet/pops/lookup/explainer'
|
30
32
|
|
31
33
|
require 'puppet/pops/model/model'
|
32
34
|
|
@@ -39,6 +41,7 @@ module Puppet
|
|
39
41
|
require 'puppet/pops/types/type_parser'
|
40
42
|
require 'puppet/pops/types/class_loader'
|
41
43
|
require 'puppet/pops/types/enumeration'
|
44
|
+
require 'puppet/pops/types/type_mismatch_describer'
|
42
45
|
|
43
46
|
require 'puppet/pops/merge_strategy'
|
44
47
|
|
@@ -81,29 +84,12 @@ module Puppet
|
|
81
84
|
end
|
82
85
|
end
|
83
86
|
|
84
|
-
module Parser
|
85
|
-
require 'puppet/pops/parser/eparser'
|
86
|
-
require 'puppet/pops/parser/parser_support'
|
87
|
-
require 'puppet/pops/parser/locator'
|
88
|
-
require 'puppet/pops/parser/locatable'
|
89
|
-
require 'puppet/pops/parser/lexer2'
|
90
|
-
require 'puppet/pops/parser/evaluating_parser'
|
91
|
-
require 'puppet/pops/parser/epp_parser'
|
92
|
-
require 'puppet/pops/parser/code_merger'
|
93
|
-
end
|
94
|
-
|
95
|
-
module Validation
|
96
|
-
require 'puppet/pops/validation/checker4_0'
|
97
|
-
require 'puppet/pops/validation/validator_factory_4_0'
|
98
|
-
end
|
99
|
-
|
100
87
|
module Evaluator
|
101
88
|
require 'puppet/pops/evaluator/callable_signature'
|
102
89
|
require 'puppet/pops/evaluator/runtime3_converter'
|
103
90
|
require 'puppet/pops/evaluator/runtime3_support'
|
104
91
|
require 'puppet/pops/evaluator/evaluator_impl'
|
105
92
|
require 'puppet/pops/evaluator/epp_evaluator'
|
106
|
-
require 'puppet/pops/evaluator/callable_mismatch_describer'
|
107
93
|
require 'puppet/pops/evaluator/collector_transformer'
|
108
94
|
require 'puppet/pops/evaluator/puppet_proc'
|
109
95
|
module Collectors
|
@@ -114,6 +100,22 @@ module Puppet
|
|
114
100
|
end
|
115
101
|
end
|
116
102
|
|
103
|
+
module Parser
|
104
|
+
require 'puppet/pops/parser/eparser'
|
105
|
+
require 'puppet/pops/parser/parser_support'
|
106
|
+
require 'puppet/pops/parser/locator'
|
107
|
+
require 'puppet/pops/parser/locatable'
|
108
|
+
require 'puppet/pops/parser/lexer2'
|
109
|
+
require 'puppet/pops/parser/evaluating_parser'
|
110
|
+
require 'puppet/pops/parser/epp_parser'
|
111
|
+
require 'puppet/pops/parser/code_merger'
|
112
|
+
end
|
113
|
+
|
114
|
+
module Validation
|
115
|
+
require 'puppet/pops/validation/checker4_0'
|
116
|
+
require 'puppet/pops/validation/validator_factory_4_0'
|
117
|
+
end
|
118
|
+
|
117
119
|
# Subsystem for puppet functions defined in ruby.
|
118
120
|
#
|
119
121
|
# @api public
|
data/lib/puppet/pops/adapters.rb
CHANGED
@@ -85,6 +85,18 @@ module Puppet::Pops::Adapters
|
|
85
85
|
locator.string.slice(offset, length)
|
86
86
|
end
|
87
87
|
|
88
|
+
def extract_tree_text
|
89
|
+
first = @adapted.offset
|
90
|
+
last = first + @adapted.length
|
91
|
+
@adapted.eAllContents.each do |m|
|
92
|
+
m_offset = m.offset
|
93
|
+
first = m_offset if m_offset < first
|
94
|
+
m_last = m_offset + m.length
|
95
|
+
last = m_last if m_last > last
|
96
|
+
end
|
97
|
+
locator.string.slice(first, last-first)
|
98
|
+
end
|
99
|
+
|
88
100
|
# Produces an URI with path?line=n&pos=n. If origin is unknown the URI is string:?line=n&pos=n
|
89
101
|
def to_uri
|
90
102
|
f = locator.file
|
@@ -138,7 +138,7 @@ class Puppet::Pops::Binder::Binder
|
|
138
138
|
|
139
139
|
# @api private
|
140
140
|
def self.format_binding(b)
|
141
|
-
type_name = Puppet::Pops::Types::TypeCalculator.
|
141
|
+
type_name = Puppet::Pops::Types::TypeCalculator.singleton.string(b.type)
|
142
142
|
layer_name, bindings_name = get_named_binding_layer_and_name(b)
|
143
143
|
"binding: '#{type_name}/#{b.name}' in: '#{bindings_name}' in layer: '#{layer_name}'"
|
144
144
|
end
|
@@ -319,7 +319,7 @@ class Puppet::Pops::Binder::Binder
|
|
319
319
|
unless key_factory.is_contributions_key?(k)
|
320
320
|
if v.is_abstract?()
|
321
321
|
layer_name, bindings_name = Puppet::Pops::Binder::Binder.get_named_binding_layer_and_name(v.binding)
|
322
|
-
type_name =
|
322
|
+
type_name = Puppet::Pops::Types::TypeCalculator.singleton.string(v.binding.type)
|
323
323
|
raise ArgumentError, "The abstract binding '#{type_name}/#{v.binding.name}' in '#{bindings_name}' in layer '#{layer_name}' was not overridden"
|
324
324
|
end
|
325
325
|
raise ArgumentError, "Internal Error - redefinition of key: #{k}, (should never happen)" if entry
|
@@ -12,7 +12,7 @@ class Puppet::Pops::Binder::BindingsChecker
|
|
12
12
|
# @api public
|
13
13
|
def initialize(diagnostics_producer)
|
14
14
|
@@check_visitor ||= Puppet::Pops::Visitor.new(nil, "check", 0, 0)
|
15
|
-
@type_calculator = Puppet::Pops::Types::TypeCalculator.
|
15
|
+
@type_calculator = Puppet::Pops::Types::TypeCalculator.singleton
|
16
16
|
@expression_validator = Puppet::Pops::Validation::ValidatorFactory_4_0.new().checker(diagnostics_producer)
|
17
17
|
@acceptor = diagnostics_producer
|
18
18
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# A provider of labels for bindings model object, producing a human name for the model object.
|
2
2
|
# @api private
|
3
3
|
#
|
4
|
-
class Puppet::Pops::Binder::BindingsLabelProvider
|
4
|
+
class Puppet::Pops::Binder::BindingsLabelProvider
|
5
|
+
include Puppet::Pops::LabelProvider
|
6
|
+
|
5
7
|
def initialize
|
6
8
|
@@label_visitor ||= Puppet::Pops::Visitor.new(self,"label",0,0)
|
7
9
|
end
|
@@ -38,11 +38,10 @@ class Puppet::Pops::Binder::BindingsLoader
|
|
38
38
|
paths_for_name(name).find {|p| Puppet::FileSystem.exist?(File.join(basedir, "lib/puppet/bindings", p)+'.rb') }
|
39
39
|
end
|
40
40
|
|
41
|
-
private
|
42
|
-
|
43
41
|
def self.loader()
|
44
42
|
@autoloader ||= Puppet::Util::Autoload.new("BindingsLoader", "puppet/bindings")
|
45
43
|
end
|
44
|
+
private_class_method :loader
|
46
45
|
|
47
46
|
def self.provide_from_string(scope, name)
|
48
47
|
name_path = name.split('::')
|
@@ -52,6 +51,7 @@ class Puppet::Pops::Binder::BindingsLoader
|
|
52
51
|
end
|
53
52
|
provide_from_name_path(scope, name, name_path)
|
54
53
|
end
|
54
|
+
private_class_method :provide_from_string
|
55
55
|
|
56
56
|
def self.provide_from_name_path(scope, name, name_path)
|
57
57
|
# If bindings is already loaded, try this first
|
@@ -64,14 +64,17 @@ class Puppet::Pops::Binder::BindingsLoader
|
|
64
64
|
end
|
65
65
|
result
|
66
66
|
end
|
67
|
+
private_class_method :provide_from_name_path
|
67
68
|
|
68
69
|
def self.paths_for_name(fq_name)
|
69
70
|
[de_camel(fq_name), downcased_path(fq_name)].uniq
|
70
71
|
end
|
72
|
+
private_class_method :paths_for_name
|
71
73
|
|
72
74
|
def self.downcased_path(fq_name)
|
73
75
|
fq_name.to_s.gsub(/::/, '/').downcase
|
74
76
|
end
|
77
|
+
private_class_method :downcased_path
|
75
78
|
|
76
79
|
def self.de_camel(fq_name)
|
77
80
|
fq_name.to_s.gsub(/::/, '/').
|
@@ -80,4 +83,5 @@ class Puppet::Pops::Binder::BindingsLoader
|
|
80
83
|
tr("-", "_").
|
81
84
|
downcase
|
82
85
|
end
|
86
|
+
private_class_method :de_camel
|
83
87
|
end
|
@@ -94,7 +94,7 @@ module Puppet::Pops::Binder::Bindings
|
|
94
94
|
# @api public
|
95
95
|
#
|
96
96
|
class LookupProducerDescriptor < ProducerDescriptor
|
97
|
-
|
97
|
+
has_attr 'type', Object
|
98
98
|
has_attr 'name', String
|
99
99
|
end
|
100
100
|
|
@@ -147,7 +147,7 @@ module Puppet::Pops::Binder::Bindings
|
|
147
147
|
#
|
148
148
|
# @api public
|
149
149
|
class Binding < AbstractBinding
|
150
|
-
|
150
|
+
has_attr 'type', Object
|
151
151
|
has_attr 'name', String
|
152
152
|
has_attr 'override', Boolean
|
153
153
|
has_attr 'abstract', Boolean
|
@@ -23,7 +23,7 @@ module Puppet::Pops::Binder::Config
|
|
23
23
|
|
24
24
|
DEFAULT_LAYERS = [
|
25
25
|
{ 'name' => 'site', 'include' => [ 'confdir:/default?optional'] },
|
26
|
-
{ 'name' => 'modules', 'include' => [ 'module:/*::default'] },
|
26
|
+
{ 'name' => 'modules', 'include' => [ 'module:/*::default', 'module:/*::metadata'] },
|
27
27
|
]
|
28
28
|
|
29
29
|
DEFAULT_SCHEME_EXTENSIONS = {}
|
@@ -354,7 +354,7 @@ module Private
|
|
354
354
|
def initialize
|
355
355
|
@entries = []
|
356
356
|
@key_factory = Puppet::Pops::Binder::KeyFactory.new()
|
357
|
-
@type_calculator =
|
357
|
+
@type_calculator = Puppet::Pops::Types::TypeCalculator.singleton
|
358
358
|
end
|
359
359
|
|
360
360
|
def lookup(scope, *args, &block)
|
@@ -430,7 +430,7 @@ module Private
|
|
430
430
|
# represented the same (but still opaque) way.
|
431
431
|
#
|
432
432
|
@key_factory = configured_binder.key_factory()
|
433
|
-
@type_calculator =
|
433
|
+
@type_calculator = Puppet::Pops::Types::TypeCalculator.singleton
|
434
434
|
@@transform_visitor ||= Puppet::Pops::Visitor.new(nil,"transform", 2, 2)
|
435
435
|
@recursion_lock = [ ]
|
436
436
|
end
|
@@ -484,7 +484,7 @@ module Private
|
|
484
484
|
def lookup_type(scope, type, name='')
|
485
485
|
val = lookup_key(scope, named_key(type, name))
|
486
486
|
return nil if val.nil?
|
487
|
-
unless
|
487
|
+
unless type_calculator.instance?(type, val)
|
488
488
|
raise ArgumentError, "Type error: incompatible type, #{type_error_detail(type, val)}"
|
489
489
|
end
|
490
490
|
val
|
@@ -510,7 +510,7 @@ module Private
|
|
510
510
|
when Puppet::Pops::Binder::InjectorEntry
|
511
511
|
val = produce(scope, entry)
|
512
512
|
return nil if val.nil?
|
513
|
-
unless
|
513
|
+
unless type_calculator.instance?(entry.binding.type, val)
|
514
514
|
raise "Type error: incompatible type returned by producer, #{type_error_detail(entry.binding.type, val)}"
|
515
515
|
end
|
516
516
|
val
|
@@ -3,12 +3,6 @@
|
|
3
3
|
#
|
4
4
|
class Puppet::Pops::Binder::KeyFactory
|
5
5
|
|
6
|
-
attr_reader :type_calculator
|
7
|
-
# @api public
|
8
|
-
def initialize(type_calculator = Puppet::Pops::Types::TypeCalculator.new())
|
9
|
-
@type_calculator = type_calculator
|
10
|
-
end
|
11
|
-
|
12
6
|
# @api public
|
13
7
|
def binding_key(binding)
|
14
8
|
named_key(binding.type, binding.name)
|
@@ -16,12 +10,12 @@ class Puppet::Pops::Binder::KeyFactory
|
|
16
10
|
|
17
11
|
# @api public
|
18
12
|
def named_key(type, name)
|
19
|
-
[(
|
13
|
+
[(Puppet::Pops::Types::PDataType::DEFAULT.assignable?(type) ? Puppet::Pops::Types::PDataType::DEFAULT : type), name]
|
20
14
|
end
|
21
15
|
|
22
16
|
# @api public
|
23
17
|
def data_key(name)
|
24
|
-
[
|
18
|
+
[Puppet::Pops::Types::PDataType::DEFAULT, name]
|
25
19
|
end
|
26
20
|
|
27
21
|
# @api public
|
@@ -49,7 +43,7 @@ class Puppet::Pops::Binder::KeyFactory
|
|
49
43
|
# @api public
|
50
44
|
def is_data?(key)
|
51
45
|
return false unless key.is_a?(Array) && key[0].is_a?(Puppet::Pops::Types::PAnyType)
|
52
|
-
|
46
|
+
Puppet::Pops::Types::PDataType::DEFAULT.assignable?(key[0])
|
53
47
|
end
|
54
48
|
|
55
49
|
# @api public
|
@@ -15,7 +15,18 @@ require 'puppet/pops/binder/scheme_handler/symbolic_scheme'
|
|
15
15
|
# Does currently only support checking of optionality against files under a module. If the result should be loaded
|
16
16
|
# from any other location it can not be marked as optional as it will be ignored.
|
17
17
|
#
|
18
|
-
|
18
|
+
module Puppet::Pops::Binder
|
19
|
+
class SchemeHandler::ModuleScheme < SchemeHandler::SymbolicScheme
|
20
|
+
|
21
|
+
METADATA_DATA_PROVIDER = 'data_provider'.freeze
|
22
|
+
|
23
|
+
def contributed_bindings(uri, scope, composer)
|
24
|
+
split_name, fqn = fqn_from_path(uri)
|
25
|
+
bindings = Puppet::Bindings.resolve(scope, split_name[0]) || load_bindings(uri, scope, composer, split_name, fqn)
|
26
|
+
|
27
|
+
# Must clone as the rest mutates the model
|
28
|
+
BindingsFactory.contributed_bindings(fqn, Marshal.load(Marshal.dump(bindings)))
|
29
|
+
end
|
19
30
|
|
20
31
|
# Expands URIs with wildcards and checks optionality.
|
21
32
|
# @param uri [URI] the uri to possibly expand
|
@@ -29,13 +40,18 @@ class Puppet::Pops::Binder::SchemeHandler::ModuleScheme < Puppet::Pops::Binder::
|
|
29
40
|
# supports wild card in the module name
|
30
41
|
case split_name[0]
|
31
42
|
when '*'
|
32
|
-
# create new URIs, one per module name that has a corresponding
|
33
|
-
# '<root>/lib/puppet/bindings/'
|
43
|
+
# create new URIs, one per module name that has a corresponding data_provider entry in metadata.json
|
44
|
+
# or an .rb file relative to its '<root>/lib/puppet/bindings/'
|
34
45
|
#
|
35
|
-
composer.name_to_module.each_pair do |
|
36
|
-
expanded_name_parts = [
|
46
|
+
composer.name_to_module.each_pair do | module_name, mod |
|
47
|
+
expanded_name_parts = [module_name] + split_name[1..-1]
|
37
48
|
expanded_name = expanded_name_parts.join('::')
|
38
|
-
|
49
|
+
|
50
|
+
if is_metadata?(split_name)
|
51
|
+
if mod.metadata && mod.metadata[METADATA_DATA_PROVIDER]
|
52
|
+
result << URI.parse('module:/' + expanded_name)
|
53
|
+
end
|
54
|
+
elsif BindingsLoader.loadable?(mod.path, expanded_name)
|
39
55
|
result << URI.parse('module:/' + expanded_name)
|
40
56
|
end
|
41
57
|
end
|
@@ -43,11 +59,18 @@ class Puppet::Pops::Binder::SchemeHandler::ModuleScheme < Puppet::Pops::Binder::
|
|
43
59
|
raise ArgumentError, "Bad bindings uri, the #{uri} has neither module name or wildcard '*' in its first path position"
|
44
60
|
else
|
45
61
|
joined_name = split_name.join('::')
|
62
|
+
module_name = split_name[0]
|
46
63
|
# skip optional uri if it does not exist
|
47
64
|
if is_optional?(uri)
|
48
|
-
mod = composer.name_to_module[
|
49
|
-
|
50
|
-
|
65
|
+
mod = composer.name_to_module[module_name]
|
66
|
+
unless mod.nil?
|
67
|
+
if is_metadata?(split_name)
|
68
|
+
if mod.metadata && mod.metadata[METADATA_DATA_PROVIDER]
|
69
|
+
result << URI.parse('module:/' + joined_name)
|
70
|
+
end
|
71
|
+
elsif BindingsLoader.loadable?(mod.path, joined_name)
|
72
|
+
result << URI.parse('module:/' + joined_name)
|
73
|
+
end
|
51
74
|
end
|
52
75
|
else
|
53
76
|
# assume it exists (do not give error if not, since it may be excluded later)
|
@@ -81,4 +104,40 @@ class Puppet::Pops::Binder::SchemeHandler::ModuleScheme < Puppet::Pops::Binder::
|
|
81
104
|
end
|
82
105
|
result
|
83
106
|
end
|
107
|
+
|
108
|
+
def load_bindings(uri, scope, composer, split_name, fqn)
|
109
|
+
module_name = split_name[0]
|
110
|
+
mod = composer.name_to_module[module_name]
|
111
|
+
# given module name must exist
|
112
|
+
raise ArgumentError, "Cannot load bindings '#{uri}' - module not found." if mod.nil?
|
113
|
+
|
114
|
+
if is_metadata?(split_name)
|
115
|
+
metadata = mod.metadata
|
116
|
+
data_provider = metadata.nil? ? nil : metadata[METADATA_DATA_PROVIDER]
|
117
|
+
unless data_provider.nil?
|
118
|
+
# bind the data provider in a binding named after the module
|
119
|
+
# loader.load('thallgren/sample_module_data', Puppet.lookup(:current_environment))
|
120
|
+
Puppet::Bindings.newbindings(module_name) do
|
121
|
+
bind {
|
122
|
+
name(module_name)
|
123
|
+
to(data_provider)
|
124
|
+
in_multibind(Puppet::Plugins::DataProviders::PER_MODULE_DATA_PROVIDER_KEY)
|
125
|
+
}
|
126
|
+
end
|
127
|
+
# pick up and return the just created and registered bindings
|
128
|
+
bindings = Puppet::Bindings.resolve(scope, module_name)
|
129
|
+
end
|
130
|
+
else
|
131
|
+
bindings = BindingsLoader.provide(scope, fqn)
|
132
|
+
end
|
133
|
+
raise ArgumentError, "Cannot load bindings '#{uri}' - no bindings found." unless bindings
|
134
|
+
bindings
|
135
|
+
end
|
136
|
+
private :load_bindings
|
137
|
+
|
138
|
+
def is_metadata?(split_name)
|
139
|
+
split_name.size > 1 && split_name[1] == 'metadata'
|
140
|
+
end
|
141
|
+
private :is_metadata?
|
142
|
+
end
|
84
143
|
end
|