puppet 4.2.0 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +5 -7
- data/README.md +1 -1
- data/Rakefile +20 -0
- data/ext/debian/puppet.init +0 -1
- data/ext/debian/puppet.logrotate +14 -5
- data/ext/osx/puppet.plist +2 -4
- data/ext/project_data.yaml +1 -1
- data/ext/redhat/client.init +65 -12
- data/ext/redhat/logrotate +15 -3
- data/ext/redhat/puppet.spec.erb +5 -1
- data/ext/redhat/server.init +1 -1
- data/ext/solaris/smf/puppet +44 -0
- data/ext/solaris/smf/puppet.xml +44 -0
- data/ext/suse/client.init +27 -27
- data/ext/suse/server.init +2 -2
- data/ext/systemd/puppet.service +1 -0
- data/install.rb +21 -39
- data/lib/hiera/puppet_function.rb +5 -5
- data/lib/puppet/agent/locker.rb +11 -2
- data/lib/puppet/agent.rb +4 -4
- data/lib/puppet/application/agent.rb +28 -14
- data/lib/puppet/application/apply.rb +17 -4
- data/lib/puppet/application/cert.rb +16 -0
- data/lib/puppet/application/filebucket.rb +78 -4
- data/lib/puppet/application/lookup.rb +356 -0
- data/lib/puppet/application/master.rb +5 -1
- data/lib/puppet/configurer.rb +9 -5
- data/lib/puppet/context/trusted_information.rb +21 -1
- data/lib/puppet/context.rb +16 -1
- data/lib/puppet/daemon.rb +17 -13
- data/lib/puppet/data_binding.rb +4 -2
- 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/data_providers.rb +12 -13
- data/lib/puppet/defaults.rb +14 -3
- data/lib/puppet/environments.rb +94 -6
- 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/file_system/windows.rb +3 -1
- 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/epp.rb +29 -37
- data/lib/puppet/functions/filter.rb +60 -25
- 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 +77 -4
- data/lib/puppet/functions/inline_epp.rb +44 -71
- 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/functions.rb +2 -4
- 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/indirection.rb +6 -1
- 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/class_information_service.rb +111 -0
- data/lib/puppet/info_service.rb +7 -0
- data/lib/puppet/module_tool/applications/unpacker.rb +1 -1
- 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/module_tool/skeleton/templates/generator/manifests/init.pp.erb +25 -18
- data/lib/puppet/network/authconfig.rb +21 -1
- data/lib/puppet/network/authorization.rb +8 -1
- data/lib/puppet/network/http/api/master/v3/environment.rb +59 -0
- data/lib/puppet/network/http/api/master/v3.rb +7 -1
- data/lib/puppet/node/environment.rb +9 -2
- data/lib/puppet/node.rb +11 -5
- data/lib/puppet/parser/ast/pops_bridge.rb +39 -1
- 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/compiler/catalog_validator.rb +33 -0
- data/lib/puppet/parser/compiler.rb +300 -12
- 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/epp.rb +29 -37
- 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/inline_epp.rb +35 -60
- data/lib/puppet/parser/functions/inline_template.rb +2 -2
- 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 +103 -21
- data/lib/puppet/parser.rb +3 -0
- data/lib/puppet/plugins/configuration.rb +3 -2
- data/lib/puppet/plugins/data_providers/data_provider.rb +283 -0
- data/lib/puppet/plugins/data_providers/registry.rb +84 -0
- data/lib/puppet/plugins/data_providers.rb +12 -60
- 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 +10 -6
- 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 +11 -3
- data/lib/puppet/pops/label_provider.rb +1 -1
- data/lib/puppet/pops/lookup/explainer.rb +402 -0
- data/lib/puppet/pops/lookup/invocation.rb +117 -0
- data/lib/puppet/pops/lookup.rb +25 -47
- data/lib/puppet/pops/merge_strategy.rb +73 -5
- data/lib/puppet/pops/model/factory.rb +38 -3
- data/lib/puppet/pops/model/model_label_provider.rb +10 -1
- data/lib/puppet/pops/model/model_meta.rb +19 -1
- 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 +65 -2
- data/lib/puppet/pops/parser/eparser.rb +1569 -1241
- data/lib/puppet/pops/parser/lexer2.rb +32 -1
- data/lib/puppet/pops/parser/locator.rb +1 -1
- data/lib/puppet/pops/parser/parser_support.rb +25 -13
- data/lib/puppet/pops/patterns.rb +3 -0
- 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 +118 -129
- data/lib/puppet/pops/types/types.rb +1394 -255
- data/lib/puppet/pops/types/types_meta.rb +0 -234
- data/lib/puppet/pops/validation/checker4_0.rb +49 -1
- data/lib/puppet/pops/validation/validator_factory_4_0.rb +3 -1
- data/lib/puppet/pops/validation.rb +7 -2
- data/lib/puppet/pops.rb +19 -17
- data/lib/puppet/provider/augeas/augeas.rb +50 -0
- data/lib/puppet/provider/exec.rb +6 -1
- 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/nim.rb +1 -1
- 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 +20 -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/launchd.rb +36 -7
- 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 +25 -5
- data/lib/puppet/provider/sshkey/parsed.rb +19 -9
- data/lib/puppet/provider/zone/solaris.rb +2 -2
- data/lib/puppet/reference/configuration.rb +10 -4
- data/lib/puppet/reference/report.rb +9 -12
- data/lib/puppet/reports.rb +5 -1
- 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/resource.rb +50 -73
- data/lib/puppet/settings/file_setting.rb +10 -9
- 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/additional_resource_generator.rb +71 -8
- data/lib/puppet/transaction/resource_harness.rb +9 -4
- data/lib/puppet/transaction.rb +8 -1
- data/lib/puppet/type/augeas.rb +8 -0
- data/lib/puppet/type/file/source.rb +14 -12
- data/lib/puppet/type/package.rb +9 -6
- data/lib/puppet/type/user.rb +4 -2
- data/lib/puppet/type.rb +78 -7
- data/lib/puppet/util/command_line.rb +4 -0
- data/lib/puppet/util/execution.rb +18 -2
- data/lib/puppet/util/tagging.rb +7 -1
- data/lib/puppet/util/windows/adsi.rb +5 -2
- data/lib/puppet/util/windows/security.rb +4 -1
- data/lib/puppet/util/windows/taskscheduler.rb +1 -1
- data/lib/puppet/util.rb +9 -1
- data/lib/puppet/version.rb +1 -1
- data/lib/puppet.rb +12 -0
- 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 +30 -24
- data/spec/integration/parser/resource_expressions_spec.rb +4 -4
- data/spec/integration/parser/undef_param_spec.rb +1 -1
- data/spec/integration/provider/package_spec.rb +3 -1
- data/spec/integration/resource/catalog_spec.rb +1 -1
- data/spec/integration/ssl/certificate_authority_spec.rb +0 -1
- data/spec/integration/ssl/certificate_request_spec.rb +0 -1
- data/spec/integration/ssl/certificate_revocation_list_spec.rb +0 -1
- data/spec/integration/ssl/host_spec.rb +0 -1
- data/spec/integration/type/package_spec.rb +2 -0
- data/spec/integration/util/rdoc/parser_spec.rb +1 -1
- 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 +9 -1
- data/spec/unit/application/filebucket_spec.rb +88 -2
- data/spec/unit/application/lookup_spec.rb +195 -0
- data/spec/unit/application/master_spec.rb +2 -2
- data/spec/unit/application_spec.rb +3 -3
- 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/environments_spec.rb +2 -0
- data/spec/unit/face/node_spec.rb +1 -1
- data/spec/unit/file_bucket/dipper_spec.rb +210 -1
- data/spec/unit/file_serving/configuration_spec.rb +1 -1
- data/spec/unit/file_system_spec.rb +20 -0
- 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/filter_spec.rb +18 -0
- data/spec/unit/functions/hiera_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/graph/sequential_prioritizer_spec.rb +1 -1
- 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/indirection_spec.rb +13 -2
- data/spec/unit/indirector/request_spec.rb +8 -8
- data/spec/unit/indirector/ssl_file_spec.rb +1 -1
- data/spec/unit/indirector/yaml_spec.rb +1 -1
- data/spec/unit/info_service_spec.rb +236 -0
- data/spec/unit/module_tool/application_spec.rb +1 -1
- data/spec/unit/module_tool/applications/builder_spec.rb +1 -1
- 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/authstore_spec.rb +1 -1
- data/spec/unit/network/http/compression_spec.rb +1 -1
- data/spec/unit/network/http/connection_spec.rb +14 -19
- data/spec/unit/network/http/handler_spec.rb +0 -5
- data/spec/unit/network/rights_spec.rb +3 -3
- data/spec/unit/node_spec.rb +27 -0
- data/spec/unit/parser/ast/leaf_spec.rb +1 -1
- 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 +20 -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 +39 -0
- 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 +15 -12
- data/spec/unit/pops/validator/validator_spec.rb +68 -0
- data/spec/unit/property_spec.rb +1 -1
- 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/nim_spec.rb +6 -6
- 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 +35 -12
- data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +10 -0
- data/spec/unit/provider/service/debian_spec.rb +28 -0
- data/spec/unit/provider/service/gentoo_spec.rb +1 -0
- data/spec/unit/provider/service/init_spec.rb +6 -0
- data/spec/unit/provider/service/launchd_spec.rb +85 -10
- data/spec/unit/provider/service/openrc_spec.rb +1 -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 +20 -4
- data/spec/unit/provider/service/systemd_spec.rb +79 -29
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +1 -1
- data/spec/unit/provider/sshkey/parsed_spec.rb +23 -0
- data/spec/unit/provider/user/windows_adsi_spec.rb +2 -1
- data/spec/unit/provider/zone/solaris_spec.rb +19 -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 +23 -5
- data/spec/unit/settings/file_setting_spec.rb +31 -0
- data/spec/unit/settings_spec.rb +91 -2
- data/spec/unit/ssl/certificate_authority/interface_spec.rb +4 -3
- data/spec/unit/ssl/certificate_authority_spec.rb +5 -3
- data/spec/unit/ssl/host_spec.rb +2 -2
- 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/transaction_spec.rb +7 -0
- data/spec/unit/type/exec_spec.rb +16 -8
- data/spec/unit/type/host_spec.rb +4 -4
- data/spec/unit/type/package_spec.rb +1 -0
- data/spec/unit/type/tidy_spec.rb +4 -4
- data/spec/unit/type/user_spec.rb +14 -7
- data/spec/unit/type/vlan_spec.rb +1 -1
- data/spec/unit/type_spec.rb +1 -1
- data/spec/unit/util/ldap/generator_spec.rb +1 -1
- data/spec/unit/util/network_device/cisco/device_spec.rb +1 -1
- data/spec/unit/util/network_device/transport/ssh_spec.rb +1 -1
- data/spec/unit/util/network_device_spec.rb +1 -1
- data/spec/unit/util/storage_spec.rb +5 -1
- data/spec/unit/util/windows/adsi_spec.rb +13 -0
- data/spec/unit/util_spec.rb +21 -2
- metadata +173 -7
- data/lib/puppet/pops/evaluator/callable_mismatch_describer.rb +0 -175
- data/spec/integration/data_binding.rb +0 -104
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
module Puppet::Plugins::DataProviders
|
|
2
|
+
module DataProvider
|
|
3
|
+
# Performs a lookup with an endless recursion check.
|
|
4
|
+
#
|
|
5
|
+
# @param key [String] The key to lookup
|
|
6
|
+
# @param lookup_invocation [Puppet::Pops::Lookup::Invocation] The current lookup invocation
|
|
7
|
+
# @param merge [String|Hash<String,Object>|nil] Merge strategy or hash with strategy and options
|
|
8
|
+
#
|
|
9
|
+
# @api public
|
|
10
|
+
def lookup(name, lookup_invocation, merge)
|
|
11
|
+
lookup_invocation.check(name) { unchecked_lookup(name, lookup_invocation, merge) }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Performs a lookup with the assumption that a recursive check has been made.
|
|
15
|
+
#
|
|
16
|
+
# @param key [String] The key to lookup
|
|
17
|
+
# @param lookup_invocation [Puppet::Pops::Lookup::Invocation] The current lookup invocation
|
|
18
|
+
# @param merge [String|Hash<String,Object>|nil] Merge strategy or hash with strategy and options
|
|
19
|
+
#
|
|
20
|
+
# @api public
|
|
21
|
+
def unchecked_lookup(key, lookup_invocation, merge)
|
|
22
|
+
lookup_invocation.with(:data_provider, self) do
|
|
23
|
+
hash = data(data_key(key, lookup_invocation), lookup_invocation)
|
|
24
|
+
value = hash[key]
|
|
25
|
+
if value || hash.include?(key)
|
|
26
|
+
lookup_invocation.report_found(key, post_process(value, lookup_invocation))
|
|
27
|
+
else
|
|
28
|
+
lookup_invocation.report_not_found(key)
|
|
29
|
+
throw :no_such_key
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Perform optional post processing of found value. This hook is used by the hiera style
|
|
35
|
+
# providers to perform interpolation. The default method simply returns the given _value_.
|
|
36
|
+
#
|
|
37
|
+
# @param value [Object] The value to perform post processing on
|
|
38
|
+
# @param lookup_invocation [Puppet::Pops::Lookup::Invocation] The current lookup invocation
|
|
39
|
+
# @return [Object] The result of post processing the value.
|
|
40
|
+
#
|
|
41
|
+
# @api public
|
|
42
|
+
def post_process(value, lookup_invocation)
|
|
43
|
+
value
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Gets the data from the compiler, or initializes it by calling #initialize_data if not present in the compiler.
|
|
47
|
+
# This means, that data is initialized once per compilation, and the data is cached for as long as the compiler
|
|
48
|
+
# lives (which is for one catalog production). This makes it possible to return data that is tailored for the
|
|
49
|
+
# request.
|
|
50
|
+
#
|
|
51
|
+
# If data is obtained using the #initialize_data method it will be sent to the #validate_data for validation
|
|
52
|
+
#
|
|
53
|
+
# @param data_key [String] The data key such as the name of a module or the constant 'environment'
|
|
54
|
+
# @param lookup_invocation [Puppet::Pops::Lookup::Invocation] The current lookup invocation
|
|
55
|
+
# @param merge [String|Hash<String,Object>|nil] Merge strategy or hash with strategy and options
|
|
56
|
+
# @return [Hash] The data hash for the given _key_
|
|
57
|
+
#
|
|
58
|
+
# @api public
|
|
59
|
+
def data(data_key, lookup_invocation)
|
|
60
|
+
compiler = lookup_invocation.scope.compiler
|
|
61
|
+
adapter = Puppet::DataProviders::DataAdapter.get(compiler) || Puppet::DataProviders::DataAdapter.adapt(compiler)
|
|
62
|
+
adapter.data[data_key] ||= validate_data(initialize_data(data_key, lookup_invocation), data_key)
|
|
63
|
+
end
|
|
64
|
+
protected :data
|
|
65
|
+
|
|
66
|
+
# Obtain an optional key to use when retrieving the data.
|
|
67
|
+
#
|
|
68
|
+
# @param key [String] The key to lookup
|
|
69
|
+
# @return [String,nil] The data key or nil if not applicable
|
|
70
|
+
#
|
|
71
|
+
# @api public
|
|
72
|
+
def data_key(key, lookup_invocation)
|
|
73
|
+
nil
|
|
74
|
+
end
|
|
75
|
+
protected :data_key
|
|
76
|
+
|
|
77
|
+
# Should be reimplemented by subclass to provide the hash that corresponds to the given name.
|
|
78
|
+
#
|
|
79
|
+
# @param data_key [String] The data key such as the name of a module or the constant 'environment'
|
|
80
|
+
# @param lookup_invocation [Puppet::Pops::Lookup::Invocation] The current lookup invocation
|
|
81
|
+
# @return [Hash] The hash of values
|
|
82
|
+
#
|
|
83
|
+
# @api public
|
|
84
|
+
def initialize_data(data_key, lookup_invocation)
|
|
85
|
+
{}
|
|
86
|
+
end
|
|
87
|
+
protected :initialize_data
|
|
88
|
+
|
|
89
|
+
def name
|
|
90
|
+
cname = self.class.name
|
|
91
|
+
cname[cname.rindex(':')+1..-1]
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def validate_data(data, data_key)
|
|
95
|
+
data
|
|
96
|
+
end
|
|
97
|
+
protected :validate_data
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
class ModuleDataProvider
|
|
101
|
+
include DataProvider
|
|
102
|
+
|
|
103
|
+
# Retrieve the first segment of the qualified name _key_. This method will throw
|
|
104
|
+
# :no_such_key unless the segment can be extracted.
|
|
105
|
+
#
|
|
106
|
+
# @param key [String] The key
|
|
107
|
+
# @return [String] The first segment of the given key
|
|
108
|
+
def data_key(key, lookup_invocation)
|
|
109
|
+
return lookup_invocation.module_name if key == 'lookup_options'
|
|
110
|
+
qual_index = key.index('::')
|
|
111
|
+
throw :no_such_key if qual_index.nil?
|
|
112
|
+
key[0..qual_index-1]
|
|
113
|
+
end
|
|
114
|
+
protected :data_key
|
|
115
|
+
|
|
116
|
+
# Assert that all keys in the given _data_ are prefixed with the given _module_name_.
|
|
117
|
+
#
|
|
118
|
+
# @param data [Hash] The data hash
|
|
119
|
+
# @param module_name [String] The name of the module where the data was found
|
|
120
|
+
# @return [Hash] The data_hash unaltered
|
|
121
|
+
def validate_data(data, module_name)
|
|
122
|
+
module_prefix = "#{module_name}::"
|
|
123
|
+
data.each_key do |k|
|
|
124
|
+
unless k.is_a?(String) && (k == 'lookup_options' || k.start_with?(module_prefix))
|
|
125
|
+
raise Puppet::DataBinding::LookupError, "Module data for module '#{module_name}' must use keys qualified with the name of the module"
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
protected :validate_data
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
class EnvironmentDataProvider
|
|
133
|
+
include DataProvider
|
|
134
|
+
|
|
135
|
+
def data_key(key, lookup_invocation)
|
|
136
|
+
'environment'
|
|
137
|
+
end
|
|
138
|
+
protected :data_key
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
# Class that keeps track of the original path (as it appears in the declaration, before interpolation),
|
|
142
|
+
# the fully resolved path, and whether or the resolved path exists.
|
|
143
|
+
#
|
|
144
|
+
# @api public
|
|
145
|
+
class ResolvedPath
|
|
146
|
+
attr_reader :original_path, :path
|
|
147
|
+
|
|
148
|
+
# @param original_path [String] path as found in declaration. May contain interpolation expressions
|
|
149
|
+
# @param path [Pathname] the expanded absolue path
|
|
150
|
+
# @api public
|
|
151
|
+
def initialize(original_path, path)
|
|
152
|
+
@original_path = original_path
|
|
153
|
+
@path = path
|
|
154
|
+
@exists = nil
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# @return [Boolean] cached info if the path exists or not
|
|
158
|
+
# @api public
|
|
159
|
+
def exists?
|
|
160
|
+
@exists = @path.exist? if @exists.nil?
|
|
161
|
+
@exists
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
# A data provider that is initialized with a set of _paths_. When performing lookup, each
|
|
166
|
+
# path is search in the order they appear. If a value is found in more than one location it
|
|
167
|
+
# will be merged according to a given (optional) merge strategy.
|
|
168
|
+
#
|
|
169
|
+
# @abstract
|
|
170
|
+
# @api public
|
|
171
|
+
class PathBasedDataProvider
|
|
172
|
+
include DataProvider
|
|
173
|
+
|
|
174
|
+
attr_reader :name
|
|
175
|
+
|
|
176
|
+
# @param name [String] The name of the data provider
|
|
177
|
+
# @param paths [Array<ResolvedPath>] Paths used by this provider
|
|
178
|
+
#
|
|
179
|
+
# @api public
|
|
180
|
+
def initialize(name, paths)
|
|
181
|
+
@name = name
|
|
182
|
+
@paths = paths
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
# Performs a lookup by searching all given paths for the given _key_. A merge will be performed if
|
|
186
|
+
# the value is found in more than one location and _merge_ is not nil.
|
|
187
|
+
#
|
|
188
|
+
# @param key [String] The key to lookup
|
|
189
|
+
# @param lookup_invocation [Puppet::Pops::Lookup::Invocation] The current lookup invocation
|
|
190
|
+
# @param merge [Puppet::Pops::MergeStrategy,String,Hash<String,Object>,nil] Merge strategy or hash with strategy and options
|
|
191
|
+
#
|
|
192
|
+
# @api public
|
|
193
|
+
def unchecked_lookup(key, lookup_invocation, merge)
|
|
194
|
+
lookup_invocation.with(:data_provider, self) do
|
|
195
|
+
merge_strategy = Puppet::Pops::MergeStrategy.strategy(merge)
|
|
196
|
+
lookup_invocation.with(:merge, merge_strategy) do
|
|
197
|
+
merged_result = merge_strategy.merge_lookup(@paths) do |path|
|
|
198
|
+
lookup_invocation.with(:path, path) do
|
|
199
|
+
if path.exists?
|
|
200
|
+
hash = data(path.path, lookup_invocation)
|
|
201
|
+
value = hash[key]
|
|
202
|
+
if value || hash.include?(key)
|
|
203
|
+
lookup_invocation.report_found(key, post_process(value, lookup_invocation))
|
|
204
|
+
else
|
|
205
|
+
lookup_invocation.report_not_found(key)
|
|
206
|
+
throw :no_such_key
|
|
207
|
+
end
|
|
208
|
+
else
|
|
209
|
+
lookup_invocation.report_path_not_found
|
|
210
|
+
throw :no_such_key
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
lookup_invocation.report_result(merged_result)
|
|
215
|
+
end
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# Factory for creating path based data providers
|
|
221
|
+
#
|
|
222
|
+
# @abstract
|
|
223
|
+
# @api public
|
|
224
|
+
class PathBasedDataProviderFactory
|
|
225
|
+
# Create a path based data provider with the given _name_ and _paths_
|
|
226
|
+
#
|
|
227
|
+
# @param name [String] the name of the created provider (for logging and debugging)
|
|
228
|
+
# @param paths [Array<String>] array of resolved paths
|
|
229
|
+
# @return [DataProvider] The created data provider
|
|
230
|
+
#
|
|
231
|
+
# @api public
|
|
232
|
+
def create(name, paths)
|
|
233
|
+
raise NotImplementedError, "Subclass of PathBasedDataProviderFactory must implement 'create' method"
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
# Resolve the given _paths_ to something that is meaningful as a _paths_ argument when creating
|
|
237
|
+
# a provider using the #create call.
|
|
238
|
+
#
|
|
239
|
+
# In order to increase efficiency, the implementors of this method should ensure that resolved
|
|
240
|
+
# paths that exists are included in the result.
|
|
241
|
+
#
|
|
242
|
+
# @param datadir [Pathname] The base when creating absolute paths
|
|
243
|
+
# @param declared_paths [Array<String>] paths as found in declaration. May contain interpolation expressions
|
|
244
|
+
# @param paths [Array<String>] paths that have been preprocessed (interpolations resolved)
|
|
245
|
+
# @param lookup_invocation [Puppet::Pops::Lookup::Invocation] The current lookup invocation
|
|
246
|
+
# @return [Array<ResolvedPath>] Array of resolved paths
|
|
247
|
+
#
|
|
248
|
+
# @api public
|
|
249
|
+
def resolve_paths(datadir, declared_paths, paths, lookup_invocation)
|
|
250
|
+
[]
|
|
251
|
+
end
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
# Factory for creating file based data providers. This is an extension of the path based
|
|
255
|
+
# factory where it is required that each resolved path appoints an existing file in the local
|
|
256
|
+
# file system.
|
|
257
|
+
#
|
|
258
|
+
# @abstract
|
|
259
|
+
# @api public
|
|
260
|
+
class FileBasedDataProviderFactory < PathBasedDataProviderFactory
|
|
261
|
+
# @param datadir [Pathname] The base when creating absolute paths
|
|
262
|
+
# @param declared_paths [Array<String>] paths as found in declaration. May contain interpolation expressions
|
|
263
|
+
# @param paths [Array<String>] paths that have been preprocessed (interpolations resolved)
|
|
264
|
+
# @param lookup_invocation [Puppet::Pops::Lookup::Invocation] The current lookup invocation
|
|
265
|
+
# @return [Array<ResolvedPath>] Array of resolved paths
|
|
266
|
+
def resolve_paths(datadir, declared_paths, paths, lookup_invocation)
|
|
267
|
+
resolved_paths = []
|
|
268
|
+
unless paths.nil? || datadir.nil?
|
|
269
|
+
ext = path_extension
|
|
270
|
+
paths.each_with_index do |path, idx|
|
|
271
|
+
path = path + ext unless path.end_with?(ext)
|
|
272
|
+
resolved_paths << ResolvedPath.new(declared_paths[idx], datadir + path)
|
|
273
|
+
end
|
|
274
|
+
end
|
|
275
|
+
resolved_paths
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
def path_extension
|
|
279
|
+
raise NotImplementedError, "Subclass of FileBasedProviderFactory must implement 'path_extension' method"
|
|
280
|
+
end
|
|
281
|
+
protected :path_extension
|
|
282
|
+
end
|
|
283
|
+
end
|
|
@@ -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
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module Puppet::Plugins; end
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
module Puppet::Plugins::DataProviders
|
|
4
4
|
|
|
5
5
|
# The lookup **key** for the multibind containing data provider name per module
|
|
6
6
|
# @api public
|
|
@@ -26,65 +26,17 @@ class Puppet::Plugins::DataProviders
|
|
|
26
26
|
# @api public
|
|
27
27
|
MODULE_DATA_PROVIDERS_TYPE = 'Puppet::Plugins::DataProviders::ModuleDataProvider'
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def self.hash_of_per_module_data_provider
|
|
36
|
-
@@HASH_OF_PER_MODULE_DATA_PROVIDERS ||= Puppet::Pops::Types::TypeFactory.hash_of(PER_MODULE_DATA_PROVIDER_TYPE)
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def self.hash_of_module_data_providers
|
|
40
|
-
@@HASH_OF_MODULE_DATA_PROVIDERS ||= Puppet::Pops::Types::TypeFactory.hash_of(
|
|
41
|
-
Puppet::Pops::Types::TypeFactory.type_of(MODULE_DATA_PROVIDERS_TYPE))
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def self.hash_of_environment_data_providers
|
|
45
|
-
@@HASH_OF_ENV_DATA_PROVIDERS ||= Puppet::Pops::Types::TypeFactory.hash_of(
|
|
46
|
-
Puppet::Pops::Types::TypeFactory.type_of(ENV_DATA_PROVIDERS_TYPE))
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
# Registers a 'none' environment data provider, and a 'none' module data provider as the defaults.
|
|
50
|
-
# This is only done to allow that something binds to 'none' rather than removing the entire binding (which
|
|
51
|
-
# has the same effect).
|
|
52
|
-
#
|
|
53
|
-
def self.register_defaults(default_bindings)
|
|
54
|
-
default_bindings.bind do
|
|
55
|
-
name('none')
|
|
56
|
-
in_multibind(ENV_DATA_PROVIDERS_KEY)
|
|
57
|
-
to_instance(ENV_DATA_PROVIDERS_TYPE)
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
default_bindings.bind do
|
|
61
|
-
name('function')
|
|
62
|
-
in_multibind(ENV_DATA_PROVIDERS_KEY)
|
|
63
|
-
to_instance('Puppet::DataProviders::FunctionEnvDataProvider')
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
default_bindings.bind do
|
|
67
|
-
name('none')
|
|
68
|
-
in_multibind(MODULE_DATA_PROVIDERS_KEY)
|
|
69
|
-
to_instance(MODULE_DATA_PROVIDERS_TYPE)
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
default_bindings.bind do
|
|
73
|
-
name('function')
|
|
74
|
-
in_multibind(MODULE_DATA_PROVIDERS_KEY)
|
|
75
|
-
to_instance('Puppet::DataProviders::FunctionModuleDataProvider')
|
|
76
|
-
end
|
|
77
|
-
end
|
|
29
|
+
# The lookup **key** for the multibind containing map of provider name to path based data provider factory
|
|
30
|
+
# implementation.
|
|
31
|
+
# @api public
|
|
32
|
+
PATH_BASED_DATA_PROVIDER_FACTORIES_KEY = 'puppet::path_based_data_provider_factories'
|
|
78
33
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
end
|
|
34
|
+
# The lookup **type** for the multibind containing map of provider name to path based data provider factory
|
|
35
|
+
# implementation.
|
|
36
|
+
# @api public
|
|
37
|
+
PATH_BASED_DATA_PROVIDER_FACTORIES_TYPE = 'Puppet::Plugins::DataProviders::PathBasedDataProviderFactory'
|
|
84
38
|
|
|
85
|
-
class EnvironmentDataProvider
|
|
86
|
-
def lookup(name, scope, merge)
|
|
87
|
-
throw :no_such_key
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
39
|
end
|
|
40
|
+
|
|
41
|
+
require_relative 'data_providers/data_provider'
|
|
42
|
+
require_relative 'data_providers/registry'
|
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
|