puppet 4.3.2-x64-mingw32 → 4.4.0-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/COMMITTERS.md +2 -2
- data/CONTRIBUTING.md +6 -6
- data/LICENSE +1 -1
- data/README.md +8 -9
- data/conf/auth.conf +2 -2
- data/ext/README.environment +1 -1
- data/ext/debian/README.source +1 -1
- data/ext/debian/control +1 -1
- data/ext/debian/copyright +4 -4
- data/ext/debian/puppetmaster.README.debian +11 -9
- data/ext/emacs/puppet-mode.el +1 -1
- data/ext/envpuppet +2 -2
- data/ext/ips/puppetagent.xml +1 -1
- data/ext/ips/puppetmaster.xml +1 -1
- data/ext/project_data.yaml +8 -0
- data/ext/puppet-test +3 -3
- data/ext/rack/example-passenger-vhost.conf +1 -1
- data/ext/redhat/puppet.spec.erb +2 -2
- data/ext/regexp_nodes/regexp_nodes.rb +1 -1
- data/ext/solaris/pkginfo +1 -1
- data/ext/solaris/smf/puppet.xml +1 -1
- data/ext/suse/puppet.spec +2 -2
- data/ext/upload_facts.rb +1 -1
- data/ext/windows/puppet_interactive.bat +6 -0
- data/ext/windows/puppet_shell.bat +9 -0
- data/ext/windows/run_puppet_interactive.bat +9 -0
- data/ext/yaml_nodes.rb +1 -1
- data/install.rb +30 -20
- data/lib/puppet/agent.rb +1 -1
- data/lib/puppet/application/agent.rb +4 -2
- data/lib/puppet/application/apply.rb +7 -4
- data/lib/puppet/application/cert.rb +1 -1
- data/lib/puppet/application/device.rb +1 -1
- data/lib/puppet/application/filebucket.rb +1 -1
- data/lib/puppet/application/inspect.rb +1 -1
- data/lib/puppet/application/lookup.rb +4 -4
- data/lib/puppet/application/master.rb +2 -2
- data/lib/puppet/application/resource.rb +1 -1
- data/lib/puppet/configurer.rb +100 -22
- data/lib/puppet/data_providers/hiera_config.rb +28 -3
- data/lib/puppet/data_providers/hiera_interpolate.rb +30 -15
- data/lib/puppet/data_providers/hiera_support.rb +1 -1
- data/lib/puppet/data_providers/json_data_provider_factory.rb +2 -2
- data/lib/puppet/data_providers/yaml_data_provider_factory.rb +2 -2
- data/lib/puppet/defaults.rb +65 -19
- data/lib/puppet/environments.rb +3 -1
- data/lib/puppet/face/config.rb +1 -1
- data/lib/puppet/face/epp.rb +1 -1
- data/lib/puppet/face/help/man.erb +1 -1
- data/lib/puppet/face/module/install.rb +6 -6
- data/lib/puppet/face/parser.rb +12 -9
- data/lib/puppet/face/status.rb +2 -1
- data/lib/puppet/feature/cfpropertylist.rb +3 -0
- data/lib/puppet/feature/telnet.rb +9 -0
- data/lib/puppet/file_serving/http_metadata.rb +46 -0
- data/lib/puppet/file_serving/metadata.rb +18 -2
- data/lib/puppet/file_serving/terminus_selector.rb +2 -0
- data/lib/puppet/file_system.rb +2 -2
- data/lib/puppet/file_system/file_impl.rb +2 -2
- data/lib/puppet/file_system/memory_impl.rb +1 -1
- data/lib/puppet/file_system/uniquefile.rb +1 -1
- data/lib/puppet/forge.rb +1 -1
- data/lib/puppet/forge/repository.rb +1 -31
- data/lib/puppet/functions.rb +45 -6
- data/lib/puppet/functions/assert_type.rb +9 -9
- data/lib/puppet/functions/each.rb +5 -13
- data/lib/puppet/functions/filter.rb +5 -14
- data/lib/puppet/functions/map.rb +6 -14
- data/lib/puppet/functions/reduce.rb +5 -13
- data/lib/puppet/functions/reverse_each.rb +82 -0
- data/lib/puppet/functions/scanf.rb +15 -18
- data/lib/puppet/functions/slice.rb +22 -36
- data/lib/puppet/functions/split.rb +2 -2
- data/lib/puppet/functions/step.rb +88 -0
- data/lib/puppet/functions/type.rb +70 -0
- data/lib/puppet/graph/rb_tree_map.rb +1 -1
- data/lib/puppet/indirector/catalog/compiler.rb +188 -5
- data/lib/puppet/indirector/file_content/http.rb +15 -0
- data/lib/puppet/indirector/file_metadata/http.rb +27 -0
- data/lib/puppet/indirector/generic_http.rb +16 -0
- data/lib/puppet/indirector/node/exec.rb +1 -1
- data/lib/puppet/indirector/node/ldap.rb +1 -1
- data/lib/puppet/indirector/rest.rb +2 -1
- data/lib/puppet/info_service/class_information_service.rb +13 -12
- data/lib/puppet/loaders.rb +1 -0
- data/lib/puppet/module.rb +3 -0
- data/lib/puppet/module_tool/skeleton/templates/generator/Gemfile +9 -2
- data/lib/puppet/module_tool/skeleton/templates/generator/spec/classes/init_spec.rb.erb +1 -1
- data/lib/puppet/module_tool/skeleton/templates/generator/tests/init.pp.erb +2 -2
- data/lib/puppet/module_tool/tar/mini.rb +3 -3
- data/lib/puppet/network/http/pool.rb +9 -0
- data/lib/puppet/node.rb +1 -1
- data/lib/puppet/node/environment.rb +11 -2
- data/lib/puppet/parser/ast/pops_bridge.rb +19 -22
- data/lib/puppet/parser/compiler.rb +3 -3
- data/lib/puppet/parser/environment_compiler.rb +0 -1
- data/lib/puppet/parser/functions.rb +28 -16
- data/lib/puppet/parser/functions/fqdn_rand.rb +1 -1
- data/lib/puppet/parser/functions/inline_template.rb +1 -1
- data/lib/puppet/parser/functions/map.rb +1 -1
- data/lib/puppet/parser/functions/scanf.rb +15 -26
- data/lib/puppet/parser/functions/slice.rb +17 -24
- data/lib/puppet/parser/functions/split.rb +1 -1
- data/lib/puppet/parser/resource.rb +19 -17
- data/lib/puppet/parser/scope.rb +176 -5
- data/lib/puppet/plugins/data_providers/data_provider.rb +54 -13
- data/lib/puppet/pops.rb +0 -8
- data/lib/puppet/pops/adaptable.rb +4 -1
- data/lib/puppet/pops/adapters.rb +38 -13
- data/lib/puppet/pops/binder/binder.rb +21 -17
- data/lib/puppet/pops/binder/binder_issues.rb +8 -6
- data/lib/puppet/pops/binder/bindings_checker.rb +12 -8
- data/lib/puppet/pops/binder/bindings_composer.rb +16 -12
- data/lib/puppet/pops/binder/bindings_factory.rb +108 -104
- data/lib/puppet/pops/binder/bindings_model.rb +49 -47
- data/lib/puppet/pops/binder/config/diagnostic_producer.rb +10 -6
- data/lib/puppet/pops/binder/injector.rb +53 -48
- data/lib/puppet/pops/binder/key_factory.rb +10 -6
- data/lib/puppet/pops/binder/producers.rb +67 -62
- data/lib/puppet/pops/evaluator/access_operator.rb +95 -93
- data/lib/puppet/pops/evaluator/closure.rb +84 -68
- data/lib/puppet/pops/evaluator/collector_transformer.rb +18 -14
- data/lib/puppet/pops/evaluator/collectors/exported_collector.rb +0 -1
- data/lib/puppet/pops/evaluator/compare_operator.rb +13 -9
- data/lib/puppet/pops/evaluator/epp_evaluator.rb +9 -8
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +78 -76
- data/lib/puppet/pops/evaluator/json_strict_literal_evaluator.rb +85 -0
- data/lib/puppet/pops/evaluator/relationship_operator.rb +13 -11
- data/lib/puppet/pops/evaluator/runtime3_converter.rb +5 -0
- data/lib/puppet/pops/evaluator/runtime3_support.rb +41 -45
- data/lib/puppet/pops/issue_reporter.rb +6 -4
- data/lib/puppet/pops/issues.rb +34 -11
- data/lib/puppet/pops/loader/base_loader.rb +1 -1
- data/lib/puppet/pops/loader/loader.rb +1 -1
- data/lib/puppet/pops/loader/loader_paths.rb +15 -0
- data/lib/puppet/pops/loader/module_loaders.rb +17 -13
- data/lib/puppet/pops/loader/puppet_function_instantiator.rb +16 -12
- data/lib/puppet/pops/loader/ruby_function_instantiator.rb +16 -3
- data/lib/puppet/pops/loader/type_definition_instantiator.rb +55 -0
- data/lib/puppet/pops/loaders.rb +51 -9
- data/lib/puppet/pops/lookup.rb +14 -12
- data/lib/puppet/pops/merge_strategy.rb +16 -19
- data/lib/puppet/pops/model/factory.rb +26 -2
- data/lib/puppet/pops/model/model.rb +8 -8
- data/lib/puppet/pops/model/model_label_provider.rb +13 -7
- data/lib/puppet/pops/model/model_meta.rb +17 -0
- data/lib/puppet/pops/model/model_tree_dumper.rb +8 -0
- data/lib/puppet/pops/parser/egrammar.ra +38 -14
- data/lib/puppet/pops/parser/eparser.rb +1353 -1276
- data/lib/puppet/pops/parser/epp_support.rb +11 -7
- data/lib/puppet/pops/parser/evaluating_parser.rb +14 -10
- data/lib/puppet/pops/parser/heredoc_support.rb +15 -11
- data/lib/puppet/pops/parser/lexer2.rb +26 -19
- data/lib/puppet/pops/parser/lexer_support.rb +85 -7
- data/lib/puppet/pops/parser/locator.rb +21 -0
- data/lib/puppet/pops/parser/parser_support.rb +19 -16
- data/lib/puppet/pops/parser/slurp_support.rb +11 -7
- data/lib/puppet/pops/types/class_loader.rb +23 -19
- data/lib/puppet/pops/types/enumeration.rb +9 -26
- data/lib/puppet/pops/types/iterable.rb +308 -0
- data/lib/puppet/pops/types/recursion_guard.rb +82 -0
- data/lib/puppet/pops/types/type_acceptor.rb +25 -0
- data/lib/puppet/pops/types/type_asserter.rb +10 -9
- data/lib/puppet/pops/types/type_calculator.rb +138 -381
- data/lib/puppet/pops/types/type_factory.rb +91 -57
- data/lib/puppet/pops/types/type_formatter.rb +334 -0
- data/lib/puppet/pops/types/type_mismatch_describer.rb +226 -59
- data/lib/puppet/pops/types/type_parser.rb +159 -112
- data/lib/puppet/pops/types/types.rb +2057 -1247
- data/lib/puppet/pops/utils.rb +11 -10
- data/lib/puppet/pops/validation.rb +11 -9
- data/lib/puppet/pops/validation/checker4_0.rb +83 -55
- data/lib/puppet/pops/validation/validator_factory_4_0.rb +8 -4
- data/lib/puppet/provider/aixobject.rb +1 -1
- data/lib/puppet/provider/augeas/augeas.rb +1 -1
- data/lib/puppet/provider/cron/crontab.rb +1 -1
- data/lib/puppet/provider/exec/windows.rb +1 -1
- data/lib/puppet/provider/macauthorization/macauthorization.rb +10 -9
- data/lib/puppet/provider/nameservice/directoryservice.rb +35 -50
- data/lib/puppet/provider/package/appdmg.rb +3 -2
- data/lib/puppet/provider/package/dnf.rb +1 -1
- data/lib/puppet/provider/package/pip.rb +5 -8
- data/lib/puppet/provider/package/pip3.rb +1 -1
- data/lib/puppet/provider/package/pkg.rb +1 -1
- data/lib/puppet/provider/package/pkgdmg.rb +3 -2
- data/lib/puppet/provider/package/pkgng.rb +13 -4
- data/lib/puppet/provider/package/windows.rb +1 -1
- data/lib/puppet/provider/package/yum.rb +1 -1
- data/lib/puppet/provider/package/zypper.rb +19 -0
- data/lib/puppet/provider/service/debian.rb +2 -2
- data/lib/puppet/provider/service/launchd.rb +6 -18
- data/lib/puppet/provider/service/systemd.rb +9 -2
- data/lib/puppet/provider/sshkey/parsed.rb +1 -1
- data/lib/puppet/provider/user/aix.rb +1 -1
- data/lib/puppet/provider/user/directoryservice.rb +33 -58
- data/lib/puppet/provider/zfs/zfs.rb +1 -1
- data/lib/puppet/provider/zpool/zpool.rb +1 -1
- data/lib/puppet/reference/configuration.rb +1 -1
- data/lib/puppet/reference/providers.rb +1 -1
- data/lib/puppet/resource.rb +15 -12
- data/lib/puppet/resource/capability_finder.rb +20 -13
- data/lib/puppet/resource/catalog.rb +60 -3
- data/lib/puppet/resource/status.rb +11 -2
- data/lib/puppet/resource/type.rb +28 -38
- data/lib/puppet/settings.rb +1 -1
- data/lib/puppet/settings/config_file.rb +1 -1
- data/lib/puppet/settings/environment_conf.rb +13 -5
- data/lib/puppet/ssl/certificate_factory.rb +3 -3
- data/lib/puppet/ssl/certificate_request.rb +4 -4
- data/lib/puppet/ssl/certificate_signer.rb +1 -1
- data/lib/puppet/ssl/validator/default_validator.rb +1 -1
- data/lib/puppet/test/test_helper.rb +16 -4
- data/lib/puppet/transaction.rb +15 -2
- data/lib/puppet/transaction/additional_resource_generator.rb +6 -2
- data/lib/puppet/transaction/report.rb +31 -1
- data/lib/puppet/transaction/resource_harness.rb +0 -25
- data/lib/puppet/type.rb +11 -11
- data/lib/puppet/type/augeas.rb +1 -1
- data/lib/puppet/type/cron.rb +12 -12
- data/lib/puppet/type/file.rb +91 -39
- data/lib/puppet/type/file/checksum_value.rb +53 -0
- data/lib/puppet/type/file/content.rb +26 -111
- data/lib/puppet/type/file/data_sync.rb +84 -0
- data/lib/puppet/type/file/ensure.rb +17 -14
- data/lib/puppet/type/file/selcontext.rb +1 -1
- data/lib/puppet/type/file/source.rb +103 -18
- data/lib/puppet/type/filebucket.rb +1 -1
- data/lib/puppet/type/interface.rb +8 -3
- data/lib/puppet/type/macauthorization.rb +1 -1
- data/lib/puppet/type/package.rb +6 -0
- data/lib/puppet/type/schedule.rb +1 -1
- data/lib/puppet/type/stage.rb +1 -1
- data/lib/puppet/type/user.rb +19 -17
- data/lib/puppet/type/yumrepo.rb +20 -0
- data/lib/puppet/util.rb +109 -22
- data/lib/puppet/util/autoload.rb +16 -11
- data/lib/puppet/util/checksums.rb +74 -31
- data/lib/puppet/util/execution.rb +1 -1
- data/lib/puppet/util/http_proxy.rb +72 -0
- data/lib/puppet/util/log.rb +2 -0
- data/lib/puppet/util/logging.rb +43 -1
- data/lib/puppet/util/monkey_patches.rb +2 -2
- data/lib/puppet/util/multi_match.rb +51 -0
- data/lib/puppet/util/network_device/cisco/device.rb +10 -2
- data/lib/puppet/util/network_device/cisco/interface.rb +21 -8
- data/lib/puppet/util/network_device/transport/ssh.rb +7 -3
- data/lib/puppet/util/network_device/transport/telnet.rb +39 -36
- data/lib/puppet/util/plist.rb +130 -0
- data/lib/puppet/util/resource_template.rb +1 -1
- data/lib/puppet/util/run_mode.rb +2 -2
- data/lib/puppet/util/skip_tags.rb +9 -0
- data/lib/puppet/util/windows/access_control_entry.rb +1 -1
- data/lib/puppet/util/windows/access_control_list.rb +3 -3
- data/lib/puppet/util/windows/adsi.rb +4 -4
- data/lib/puppet/util/windows/api_types.rb +24 -18
- data/lib/puppet/util/windows/com.rb +3 -3
- data/lib/puppet/util/windows/error.rb +1 -1
- data/lib/puppet/util/windows/file.rb +8 -8
- data/lib/puppet/util/windows/principal.rb +23 -14
- data/lib/puppet/util/windows/process.rb +78 -11
- data/lib/puppet/util/windows/registry.rb +1 -1
- data/lib/puppet/util/windows/root_certs.rb +5 -5
- data/lib/puppet/util/windows/security.rb +33 -35
- data/lib/puppet/util/windows/security_descriptor.rb +1 -1
- data/lib/puppet/util/windows/sid.rb +42 -4
- data/lib/puppet/util/windows/taskscheduler.rb +15 -15
- data/lib/puppet/util/windows/user.rb +10 -10
- data/lib/puppet/vendor/deep_merge/deep_merge.gemspec +1 -1
- data/lib/puppet/vendor/pathspec/LICENSE +2 -2
- data/lib/puppet/vendor/pathspec/README.md +1 -1
- data/lib/puppet/vendor/rgen/README.rdoc +1 -1
- data/lib/puppet/vendor/semantic/lib/semantic/dependency/module_release.rb +14 -0
- data/lib/puppet/version.rb +1 -1
- data/lib/semver.rb +17 -1
- data/man/man5/puppet.conf.5 +12 -12
- data/man/man8/extlookup2hiera.8 +1 -1
- data/man/man8/puppet-agent.8 +2 -2
- data/man/man8/puppet-apply.8 +2 -2
- data/man/man8/puppet-ca.8 +2 -2
- data/man/man8/puppet-catalog.8 +2 -2
- data/man/man8/puppet-cert.8 +2 -2
- data/man/man8/puppet-certificate.8 +2 -2
- data/man/man8/puppet-certificate_request.8 +2 -2
- data/man/man8/puppet-certificate_revocation_list.8 +2 -2
- data/man/man8/puppet-config.8 +3 -3
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +1 -1
- data/man/man8/puppet-doc.8 +1 -1
- data/man/man8/puppet-epp.8 +2 -2
- data/man/man8/puppet-facts.8 +2 -2
- data/man/man8/puppet-file.8 +2 -2
- data/man/man8/puppet-filebucket.8 +2 -2
- data/man/man8/puppet-help.8 +2 -2
- data/man/man8/puppet-inspect.8 +2 -2
- data/man/man8/puppet-key.8 +2 -2
- data/man/man8/puppet-man.8 +2 -2
- data/man/man8/puppet-master.8 +2 -2
- data/man/man8/puppet-module.8 +9 -9
- data/man/man8/puppet-node.8 +2 -2
- data/man/man8/puppet-parser.8 +2 -2
- data/man/man8/puppet-plugin.8 +2 -2
- data/man/man8/puppet-report.8 +2 -2
- data/man/man8/puppet-resource.8 +2 -2
- data/man/man8/puppet-resource_type.8 +2 -2
- data/man/man8/puppet-status.8 +3 -3
- data/man/man8/puppet.8 +1 -1
- data/spec/fixtures/module.tar.gz +0 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/bad_data/lib/puppet/functions/bad_data/data.rb +1 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/bad_data/manifests/init.pp +0 -1
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_json/data/empty.json +0 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_json/hiera.yaml +5 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_json/manifests/init.pp +2 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_json/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_yaml/data/empty.yaml +1 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_yaml/hiera.yaml +5 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_yaml/manifests/init.pp +2 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/empty_yaml/metadata.json +9 -0
- data/spec/fixtures/unit/functions/lookup/environments/production/modules/hieraprovider/data/first.json +2 -1
- data/spec/fixtures/unit/module/trailing-comma.json +1 -1
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee/manifests/init.pp +3 -1
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/usee/types/zero.pp +1 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/types/withuseeone.pp +1 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/modules/user/types/withuseezero.pp +1 -0
- data/spec/fixtures/unit/provider/package/yum/yum-check-update-broken-notices.txt +187 -0
- data/spec/fixtures/unit/provider/sshkey/parsed/sample_with_blank_lines +8 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_md5/should_fetch_if_not_on_the_local_disk.yml +205 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_md5/should_not_update_if_content_on_disk_is_up-to-date.yml +213 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_md5/should_update_if_content_differs_on_disk.yml +213 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_mtime/should_fetch_if_mtime_is_older_on_disk.yml +205 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_mtime/should_fetch_if_no_header_specified.yml +197 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_mtime/should_fetch_if_not_on_the_local_disk.yml +205 -0
- data/spec/fixtures/vcr/cassettes/Puppet_Type_File/when_sourcing/from_http/using_mtime/should_not_update_if_mtime_is_newer_on_disk.yml +205 -0
- data/spec/integration/defaults_spec.rb +14 -2
- data/spec/integration/file_system/uniquefile_spec.rb +29 -0
- data/spec/integration/module_tool/tar/mini_spec.rb +28 -0
- data/spec/integration/node/environment_spec.rb +13 -0
- data/spec/integration/parser/dynamic_scoping_spec.rb +67 -0
- data/spec/integration/parser/parameter_defaults_spec.rb +336 -0
- data/spec/integration/parser/undef_param_spec.rb +8 -0
- data/spec/integration/provider/yumrepo_spec.rb +1 -1
- data/spec/integration/test/test_helper_spec.rb +28 -0
- data/spec/integration/transaction/report_spec.rb +16 -0
- data/spec/integration/transaction_spec.rb +11 -0
- data/spec/integration/type/file_spec.rb +194 -4
- data/spec/integration/type/package_spec.rb +5 -1
- data/spec/integration/type/tidy_spec.rb +21 -9
- data/spec/integration/util/execution_spec.rb +22 -0
- data/spec/integration/util/windows/principal_spec.rb +90 -4
- data/spec/integration/util/windows/process_spec.rb +31 -0
- data/spec/integration/util/windows/security_spec.rb +6 -6
- data/spec/integration/util/windows/user_spec.rb +1 -1
- data/spec/integration/util_spec.rb +49 -27
- data/spec/lib/puppet_spec/compiler.rb +17 -0
- data/spec/lib/puppet_spec/files.rb +2 -2
- data/spec/lib/puppet_spec/pops.rb +13 -0
- data/spec/shared_behaviours/iterative_functions.rb +1 -1
- data/spec/shared_contexts/types_setup.rb +96 -0
- data/spec/unit/agent_spec.rb +1 -0
- data/spec/unit/application/agent_spec.rb +10 -0
- data/spec/unit/application/apply_spec.rb +9 -0
- data/spec/unit/configurer/downloader_spec.rb +5 -5
- data/spec/unit/configurer_spec.rb +271 -39
- data/spec/unit/data_providers/hiera_interpolation_spec.rb +57 -0
- data/spec/unit/defaults_spec.rb +15 -0
- data/spec/unit/environments_spec.rb +24 -4
- data/spec/unit/face/parser_spec.rb +43 -2
- data/spec/unit/file_serving/http_metadata_spec.rb +85 -0
- data/spec/unit/file_serving/metadata_spec.rb +50 -0
- data/spec/unit/file_serving/terminus_selector_spec.rb +12 -2
- data/spec/unit/file_system_spec.rb +26 -0
- data/spec/unit/functions/assert_type_spec.rb +36 -2
- data/spec/unit/functions/defined_spec.rb +2 -2
- data/spec/unit/functions/epp_spec.rb +11 -3
- data/spec/unit/functions/lookup_spec.rb +58 -13
- data/spec/unit/functions/regsubst_spec.rb +1 -1
- data/spec/unit/functions/reverse_each_spec.rb +108 -0
- data/spec/unit/functions/step_spec.rb +113 -0
- data/spec/unit/functions/type_spec.rb +35 -0
- data/spec/unit/functions4_spec.rb +61 -5
- data/spec/unit/indirector/catalog/compiler_spec.rb +705 -4
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +1 -1
- data/spec/unit/indirector/indirection_spec.rb +1 -1
- data/spec/unit/info_service_spec.rb +94 -32
- data/spec/unit/module_spec.rb +14 -0
- data/spec/unit/module_tool/applications/builder_spec.rb +4 -4
- data/spec/unit/network/authstore_spec.rb +1 -1
- data/spec/unit/network/http/connection_spec.rb +1 -0
- data/spec/unit/network/http/pool_spec.rb +30 -0
- data/spec/unit/node_spec.rb +1 -1
- data/spec/unit/parser/compiler_spec.rb +16 -0
- data/spec/unit/parser/scope_spec.rb +28 -11
- data/spec/unit/pops/evaluator/access_ops_spec.rb +3 -3
- data/spec/unit/pops/evaluator/comparison_ops_spec.rb +3 -0
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +7 -1
- data/spec/unit/pops/evaluator/evaluator_rspec_helper.rb +4 -4
- data/spec/unit/pops/evaluator/json_strict_literal_evaluator_spec.rb +63 -0
- data/spec/unit/pops/evaluator/runtime3_converter_spec.rb +6 -0
- data/spec/unit/pops/loaders/dependency_loader_spec.rb +53 -0
- data/spec/unit/pops/loaders/loaders_spec.rb +44 -1
- data/spec/unit/pops/parser/lexer2_spec.rb +112 -3
- data/spec/unit/pops/parser/parse_calls_spec.rb +8 -0
- data/spec/unit/pops/parser/parser_spec.rb +10 -0
- data/spec/unit/pops/parser/source_pos_adapter_spec.rb +26 -0
- data/spec/unit/pops/types/iterable_spec.rb +262 -0
- data/spec/unit/pops/types/recursion_guard_spec.rb +91 -0
- data/spec/unit/pops/types/type_acceptor_spec.rb +105 -0
- data/spec/unit/pops/types/type_asserter_spec.rb +43 -0
- data/spec/unit/pops/types/type_calculator_spec.rb +275 -373
- data/spec/unit/pops/types/type_formatter_spec.rb +280 -0
- data/spec/unit/pops/types/type_mismatch_describer_spec.rb +152 -0
- data/spec/unit/pops/types/type_parser_spec.rb +58 -13
- data/spec/unit/pops/types/types_spec.rb +241 -0
- data/spec/unit/pops/validator/validator_spec.rb +100 -43
- data/spec/unit/provider/cron/parsed_spec.rb +1 -0
- data/spec/unit/provider/macauthorization_spec.rb +5 -2
- data/spec/unit/provider/nameservice/directoryservice_spec.rb +14 -19
- data/spec/unit/provider/package/appdmg_spec.rb +3 -3
- data/spec/unit/provider/package/dnf_spec.rb +16 -0
- data/spec/unit/provider/package/pip3_spec.rb +60 -42
- data/spec/unit/provider/package/pip_spec.rb +47 -34
- data/spec/unit/provider/package/pkgdmg_spec.rb +18 -9
- data/spec/unit/provider/package/pkgng_spec.rb +4 -2
- data/spec/unit/provider/package/yum_spec.rb +11 -0
- data/spec/unit/provider/package/zypper_spec.rb +14 -0
- data/spec/unit/provider/service/launchd_spec.rb +17 -35
- data/spec/unit/provider/service/systemd_spec.rb +7 -0
- data/spec/unit/provider/sshkey/parsed_spec.rb +20 -19
- data/spec/unit/provider/user/directoryservice_spec.rb +40 -59
- data/spec/unit/resource/capability_finder_spec.rb +28 -15
- data/spec/unit/resource/catalog_spec.rb +33 -1
- data/spec/unit/resource/type_spec.rb +149 -7
- data/spec/unit/resource_spec.rb +96 -57
- data/spec/unit/settings/environment_conf_spec.rb +18 -1
- data/spec/unit/ssl/certificate_revocation_list_spec.rb +3 -3
- data/spec/unit/transaction/report_spec.rb +27 -0
- data/spec/unit/transaction/resource_harness_spec.rb +0 -47
- data/spec/unit/transaction_spec.rb +5 -0
- data/spec/unit/type/file/checksum_spec.rb +6 -0
- data/spec/unit/type/file/checksum_value_spec.rb +286 -0
- data/spec/unit/type/file/content_spec.rb +12 -193
- data/spec/unit/type/file/source_spec.rb +211 -119
- data/spec/unit/type/file_spec.rb +133 -34
- data/spec/unit/type/interface_spec.rb +32 -0
- data/spec/unit/type/macauthorization_spec.rb +4 -1
- data/spec/unit/type/yumrepo_spec.rb +2 -2
- data/spec/unit/util/filetype_spec.rb +1 -1
- data/spec/unit/util/http_proxy_spec.rb +2 -2
- data/spec/unit/util/log/destinations_spec.rb +0 -2
- data/spec/unit/util/logging_spec.rb +69 -0
- data/spec/unit/util/multi_match_spec.rb +39 -0
- data/spec/unit/util/network_device/cisco/device_spec.rb +253 -216
- data/spec/unit/util/network_device/transport/telnet_spec.rb +60 -58
- data/spec/unit/util/plist_spec.rb +110 -0
- data/spec/unit/util/resource_template_spec.rb +2 -2
- data/spec/unit/util/run_mode_spec.rb +27 -3
- data/spec/unit/util/windows/adsi_spec.rb +4 -4
- data/spec/unit/util/windows/api_types_spec.rb +42 -0
- data/spec/unit/util/windows/security_descriptor_spec.rb +3 -3
- data/spec/unit/util/windows/sid_spec.rb +1 -1
- data/spec/unit/util_spec.rb +123 -13
- data/tasks/cfpropertylist.rake +15 -0
- metadata +114 -26
- data/lib/puppet/vendor/load_plist.rb +0 -1
- data/lib/puppet/vendor/plist/CHANGELOG +0 -82
- data/lib/puppet/vendor/plist/MIT-LICENSE +0 -21
- data/lib/puppet/vendor/plist/PUPPET_README.md +0 -6
- data/lib/puppet/vendor/plist/README +0 -36
- data/lib/puppet/vendor/plist/Rakefile +0 -144
- data/lib/puppet/vendor/plist/docs/USAGE +0 -104
- data/lib/puppet/vendor/plist/docs/jamis-template.rb +0 -591
- data/lib/puppet/vendor/plist/lib/plist.rb +0 -22
- data/lib/puppet/vendor/plist/lib/plist/generator.rb +0 -224
- data/lib/puppet/vendor/plist/lib/plist/parser.rb +0 -225
- data/lib/puppet/vendor/plist/test/assets/AlbumData.xml +0 -203
- data/lib/puppet/vendor/plist/test/assets/Cookies.plist +0 -104
- data/lib/puppet/vendor/plist/test/assets/commented.plist +0 -9
- data/lib/puppet/vendor/plist/test/assets/example_data.bin +0 -0
- data/lib/puppet/vendor/plist/test/assets/example_data.jpg +0 -0
- data/lib/puppet/vendor/plist/test/assets/example_data.plist +0 -259
- data/lib/puppet/vendor/plist/test/assets/test_data_elements.plist +0 -24
- data/lib/puppet/vendor/plist/test/assets/test_empty_key.plist +0 -13
- data/lib/puppet/vendor/plist/test/test_data_elements.rb +0 -115
- data/lib/puppet/vendor/plist/test/test_generator.rb +0 -59
- data/lib/puppet/vendor/plist/test/test_generator_basic_types.rb +0 -58
- data/lib/puppet/vendor/plist/test/test_generator_collections.rb +0 -82
- data/lib/puppet/vendor/plist/test/test_parser.rb +0 -90
@@ -1,15 +1,16 @@
|
|
1
|
+
module Puppet::Pops
|
2
|
+
module Types
|
1
3
|
# Helper module that makes creation of type objects simpler.
|
2
4
|
# @api public
|
3
5
|
#
|
4
|
-
module
|
5
|
-
|
6
|
-
@type_calculator = Types::TypeCalculator.singleton
|
6
|
+
module TypeFactory
|
7
|
+
@type_calculator = TypeCalculator.singleton
|
7
8
|
|
8
9
|
# Produces the Integer type
|
9
10
|
# @api public
|
10
11
|
#
|
11
12
|
def self.integer
|
12
|
-
|
13
|
+
PIntegerType::DEFAULT
|
13
14
|
end
|
14
15
|
|
15
16
|
# Produces an Integer range type
|
@@ -19,7 +20,7 @@ module Puppet::Pops::Types::TypeFactory
|
|
19
20
|
# optimize eq with symbol (faster when it is left)
|
20
21
|
from = :default == from if from == 'default'
|
21
22
|
to = :default if to == 'default'
|
22
|
-
|
23
|
+
PIntegerType.new(from, to)
|
23
24
|
end
|
24
25
|
|
25
26
|
# Produces a Float range type
|
@@ -29,21 +30,35 @@ module Puppet::Pops::Types::TypeFactory
|
|
29
30
|
# optimize eq with symbol (faster when it is left)
|
30
31
|
from = Float(from) unless :default == from || from.nil?
|
31
32
|
to = Float(to) unless :default == to || to.nil?
|
32
|
-
|
33
|
+
PFloatType.new(from, to)
|
33
34
|
end
|
34
35
|
|
35
36
|
# Produces the Float type
|
36
37
|
# @api public
|
37
38
|
#
|
38
39
|
def self.float
|
39
|
-
|
40
|
+
PFloatType::DEFAULT
|
40
41
|
end
|
41
42
|
|
42
43
|
# Produces the Numeric type
|
43
44
|
# @api public
|
44
45
|
#
|
45
46
|
def self.numeric
|
46
|
-
|
47
|
+
PNumericType::DEFAULT
|
48
|
+
end
|
49
|
+
|
50
|
+
# Produces the Iterable type
|
51
|
+
# @api public
|
52
|
+
#
|
53
|
+
def self.iterable(elem_type = nil)
|
54
|
+
elem_type.nil? ? PIterableType::DEFAULT : PIterableType.new(elem_type)
|
55
|
+
end
|
56
|
+
|
57
|
+
# Produces the Iterator type
|
58
|
+
# @api public
|
59
|
+
#
|
60
|
+
def self.iterator(elem_type = nil)
|
61
|
+
elem_type.nil? ? PIteratorType::DEFAULT : PIteratorType.new(elem_type)
|
47
62
|
end
|
48
63
|
|
49
64
|
# Produces a string representation of the type
|
@@ -57,7 +72,7 @@ module Puppet::Pops::Types::TypeFactory
|
|
57
72
|
# @api public
|
58
73
|
#
|
59
74
|
def self.string(size_type = nil, *values)
|
60
|
-
|
75
|
+
PStringType.new(size_type, values)
|
61
76
|
end
|
62
77
|
|
63
78
|
# Produces the Optional type, i.e. a short hand for Variant[T, Undef]
|
@@ -70,21 +85,21 @@ module Puppet::Pops::Types::TypeFactory
|
|
70
85
|
# @api public
|
71
86
|
#
|
72
87
|
def self.optional(optional_type = nil)
|
73
|
-
|
88
|
+
POptionalType.new(type_of(optional_type.is_a?(String) ? string(nil, optional_type) : type_of(optional_type)))
|
74
89
|
end
|
75
90
|
|
76
91
|
# Produces the Enum type, optionally with specific string values
|
77
92
|
# @api public
|
78
93
|
#
|
79
94
|
def self.enum(*values)
|
80
|
-
|
95
|
+
PEnumType.new(values)
|
81
96
|
end
|
82
97
|
|
83
98
|
# Produces the Variant type, optionally with the "one of" types
|
84
99
|
# @api public
|
85
100
|
#
|
86
101
|
def self.variant(*types)
|
87
|
-
|
102
|
+
PVariantType.new(types.map {|v| type_of(v) })
|
88
103
|
end
|
89
104
|
|
90
105
|
# Produces the Struct type, either a non parameterized instance representing
|
@@ -102,53 +117,53 @@ module Puppet::Pops::Types::TypeFactory
|
|
102
117
|
tc = @type_calculator
|
103
118
|
elements = hash.map do |key_type, value_type|
|
104
119
|
value_type = type_of(value_type)
|
105
|
-
raise ArgumentError, 'Struct element value_type must be a Type' unless value_type.is_a?(
|
120
|
+
raise ArgumentError, 'Struct element value_type must be a Type' unless value_type.is_a?(PAnyType)
|
106
121
|
|
107
122
|
# TODO: Should have stricter name rule
|
108
123
|
if key_type.is_a?(String)
|
109
124
|
raise ArgumentError, 'Struct element key cannot be an empty String' if key_type.empty?
|
110
125
|
key_type = string(nil, key_type)
|
111
126
|
# Must make key optional if the value can be Undef
|
112
|
-
key_type = optional(key_type) if tc.assignable?(value_type,
|
127
|
+
key_type = optional(key_type) if tc.assignable?(value_type, PUndefType::DEFAULT)
|
113
128
|
else
|
114
129
|
# assert that the key type is one of String[1], NotUndef[String[1]] and Optional[String[1]]
|
115
130
|
case key_type
|
116
|
-
when
|
131
|
+
when PNotUndefType
|
117
132
|
# We can loose the NotUndef wrapper here since String[1] isn't optional anyway
|
118
133
|
key_type = key_type.type
|
119
134
|
s = key_type
|
120
|
-
when
|
135
|
+
when POptionalType
|
121
136
|
s = key_type.optional_type
|
122
|
-
when
|
137
|
+
when PStringType, PEnumType
|
123
138
|
s = key_type
|
124
139
|
else
|
125
140
|
raise ArgumentError, "Illegal Struct member key type. Expected NotUndef, Optional, String, or Enum. Got: #{key_type.class.name}"
|
126
141
|
end
|
127
|
-
unless (s.is_a?(
|
142
|
+
unless (s.is_a?(PStringType) || s.is_a?(PEnumType)) && s.values.size == 1 && !s.values[0].empty?
|
128
143
|
raise ArgumentError, "Unable to extract a non-empty literal string from Struct member key type #{tc.string(key_type)}"
|
129
144
|
end
|
130
145
|
end
|
131
|
-
|
146
|
+
PStructElement.new(key_type, value_type)
|
132
147
|
end
|
133
|
-
|
148
|
+
PStructType.new(elements)
|
134
149
|
end
|
135
150
|
|
136
151
|
def self.tuple(types = [], size_type = nil)
|
137
|
-
|
152
|
+
PTupleType.new(types.map {|elem| type_of(elem) }, size_type)
|
138
153
|
end
|
139
154
|
|
140
155
|
# Produces the Boolean type
|
141
156
|
# @api public
|
142
157
|
#
|
143
158
|
def self.boolean
|
144
|
-
|
159
|
+
PBooleanType::DEFAULT
|
145
160
|
end
|
146
161
|
|
147
162
|
# Produces the Any type
|
148
163
|
# @api public
|
149
164
|
#
|
150
165
|
def self.any
|
151
|
-
|
166
|
+
PAnyType::DEFAULT
|
152
167
|
end
|
153
168
|
|
154
169
|
# Produces the Regexp type
|
@@ -158,11 +173,11 @@ module Puppet::Pops::Types::TypeFactory
|
|
158
173
|
#
|
159
174
|
def self.regexp(pattern = nil)
|
160
175
|
if pattern
|
161
|
-
t =
|
176
|
+
t = PRegexpType.new(pattern.is_a?(Regexp) ? pattern.inspect[1..-2] : pattern)
|
162
177
|
t.regexp unless pattern.nil? # compile pattern to catch errors
|
163
178
|
t
|
164
179
|
else
|
165
|
-
|
180
|
+
PRegexpType::DEFAULT
|
166
181
|
end
|
167
182
|
end
|
168
183
|
|
@@ -170,7 +185,7 @@ module Puppet::Pops::Types::TypeFactory
|
|
170
185
|
patterns = regular_expressions.map do |re|
|
171
186
|
case re
|
172
187
|
when String
|
173
|
-
re_t =
|
188
|
+
re_t = PRegexpType.new(re)
|
174
189
|
re_t.regexp # compile it to catch errors
|
175
190
|
re_t
|
176
191
|
|
@@ -178,33 +193,33 @@ module Puppet::Pops::Types::TypeFactory
|
|
178
193
|
# Regep.to_s includes options user did not enter and does not escape source
|
179
194
|
# to work either as a string or as a // regexp. The inspect method does a better
|
180
195
|
# job, but includes the //
|
181
|
-
|
196
|
+
PRegexpType.new(re.inspect[1..-2])
|
182
197
|
|
183
|
-
when
|
198
|
+
when PRegexpType
|
184
199
|
re
|
185
200
|
|
186
|
-
when
|
201
|
+
when PPatternType
|
187
202
|
re.patterns
|
188
203
|
|
189
204
|
else
|
190
205
|
raise ArgumentError, "Only String, Regexp, Pattern-Type, and Regexp-Type are allowed: got '#{re.class}"
|
191
206
|
end
|
192
207
|
end.flatten.uniq
|
193
|
-
|
208
|
+
PPatternType.new(patterns)
|
194
209
|
end
|
195
210
|
|
196
211
|
# Produces the Literal type
|
197
212
|
# @api public
|
198
213
|
#
|
199
214
|
def self.scalar
|
200
|
-
|
215
|
+
PScalarType::DEFAULT
|
201
216
|
end
|
202
217
|
|
203
218
|
# Produces a CallableType matching all callables
|
204
219
|
# @api public
|
205
220
|
#
|
206
221
|
def self.all_callables
|
207
|
-
return
|
222
|
+
return PCallableType::DEFAULT
|
208
223
|
end
|
209
224
|
|
210
225
|
# Produces a Callable type with one signature without support for a block
|
@@ -224,7 +239,7 @@ module Puppet::Pops::Types::TypeFactory
|
|
224
239
|
# Params are given as a sequence of arguments to {#type_of}.
|
225
240
|
#
|
226
241
|
def self.callable(*params)
|
227
|
-
last_callable =
|
242
|
+
last_callable = TypeCalculator.is_kind_of_callable?(params.last)
|
228
243
|
block_t = last_callable ? params.pop : nil
|
229
244
|
|
230
245
|
# compute a size_type for the signature based on the two last parameters
|
@@ -242,42 +257,42 @@ module Puppet::Pops::Types::TypeFactory
|
|
242
257
|
|
243
258
|
# If the specification requires types, and none were given, a Unit type is used
|
244
259
|
if types.empty? && !size_type.nil? && size_type.range[1] > 0
|
245
|
-
types <<
|
260
|
+
types << PUnitType::DEFAULT
|
246
261
|
end
|
247
262
|
# create a signature
|
248
263
|
tuple_t = tuple(types, size_type)
|
249
|
-
|
264
|
+
PCallableType.new(tuple_t, block_t)
|
250
265
|
end
|
251
266
|
|
252
267
|
# Produces the abstract type Collection
|
253
268
|
# @api public
|
254
269
|
#
|
255
270
|
def self.collection(size_type = nil)
|
256
|
-
size_type.nil? ?
|
271
|
+
size_type.nil? ? PCollectionType::DEFAULT : PCollectionType.new(nil, size_type)
|
257
272
|
end
|
258
273
|
|
259
274
|
# Produces the Data type
|
260
275
|
# @api public
|
261
276
|
#
|
262
277
|
def self.data
|
263
|
-
|
278
|
+
PDataType::DEFAULT
|
264
279
|
end
|
265
280
|
|
266
281
|
# Creates an instance of the Undef type
|
267
282
|
# @api public
|
268
283
|
def self.undef
|
269
|
-
|
284
|
+
PUndefType::DEFAULT
|
270
285
|
end
|
271
286
|
|
272
287
|
# Creates an instance of the Default type
|
273
288
|
# @api public
|
274
289
|
def self.default
|
275
|
-
|
290
|
+
PDefaultType::DEFAULT
|
276
291
|
end
|
277
292
|
|
278
293
|
# Produces an instance of the abstract type PCatalogEntryType
|
279
294
|
def self.catalog_entry
|
280
|
-
|
295
|
+
PCatalogEntryType::DEFAULT
|
281
296
|
end
|
282
297
|
|
283
298
|
# Produces a PResourceType with a String type_name A PResourceType with a nil
|
@@ -286,15 +301,15 @@ module Puppet::Pops::Types::TypeFactory
|
|
286
301
|
# name. (There is no resource-type subtyping in Puppet (yet)).
|
287
302
|
#
|
288
303
|
def self.resource(type_name = nil, title = nil)
|
289
|
-
type_name = type_name.type_name if type_name.is_a?(
|
304
|
+
type_name = type_name.type_name if type_name.is_a?(PResourceType)
|
290
305
|
type_name = type_name.downcase unless type_name.nil?
|
291
|
-
unless type_name.nil? || type_name =~
|
306
|
+
unless type_name.nil? || type_name =~ Patterns::CLASSREF
|
292
307
|
raise ArgumentError, "Illegal type name '#{type.type_name}'"
|
293
308
|
end
|
294
309
|
if type_name.nil? && !title.nil?
|
295
310
|
raise ArgumentError, 'The type name cannot be nil, if title is given'
|
296
311
|
end
|
297
|
-
|
312
|
+
PResourceType.new(type_name, title)
|
298
313
|
end
|
299
314
|
|
300
315
|
# Produces PHostClassType with a string class_name. A PHostClassType with
|
@@ -304,9 +319,9 @@ module Puppet::Pops::Types::TypeFactory
|
|
304
319
|
#
|
305
320
|
def self.host_class(class_name = nil)
|
306
321
|
if class_name.nil?
|
307
|
-
|
322
|
+
PHostClassType::DEFAULT
|
308
323
|
else
|
309
|
-
|
324
|
+
PHostClassType.new(class_name.sub(/^::/, ''))
|
310
325
|
end
|
311
326
|
end
|
312
327
|
|
@@ -315,7 +330,7 @@ module Puppet::Pops::Types::TypeFactory
|
|
315
330
|
# @api public
|
316
331
|
#
|
317
332
|
def self.array_of(o, size_type = nil)
|
318
|
-
|
333
|
+
PArrayType.new(type_of(o), size_type)
|
319
334
|
end
|
320
335
|
|
321
336
|
# Produces a type for Hash[Scalar, o] where o is either a type, or an
|
@@ -323,21 +338,21 @@ module Puppet::Pops::Types::TypeFactory
|
|
323
338
|
# @api public
|
324
339
|
#
|
325
340
|
def self.hash_of(value, key = scalar, size_type = nil)
|
326
|
-
|
341
|
+
PHashType.new(type_of(key), type_of(value), size_type)
|
327
342
|
end
|
328
343
|
|
329
344
|
# Produces a type for Array[Data]
|
330
345
|
# @api public
|
331
346
|
#
|
332
347
|
def self.array_of_data
|
333
|
-
|
348
|
+
PArrayType::DATA
|
334
349
|
end
|
335
350
|
|
336
351
|
# Produces a type for Hash[Scalar, Data]
|
337
352
|
# @api public
|
338
353
|
#
|
339
354
|
def self.hash_of_data
|
340
|
-
|
355
|
+
PHashType::DATA
|
341
356
|
end
|
342
357
|
|
343
358
|
# Produces a type for NotUndef[T]
|
@@ -345,20 +360,20 @@ module Puppet::Pops::Types::TypeFactory
|
|
345
360
|
# the type String[inst_type].
|
346
361
|
#
|
347
362
|
# @param inst_type [Type,String] the type to qualify
|
348
|
-
# @return [
|
363
|
+
# @return [PNotUndefType] the NotUndef type
|
349
364
|
#
|
350
365
|
# @api public
|
351
366
|
#
|
352
367
|
def self.not_undef(inst_type = nil)
|
353
368
|
inst_type = string(nil, inst_type) if inst_type.is_a?(String)
|
354
|
-
|
369
|
+
PNotUndefType.new(inst_type)
|
355
370
|
end
|
356
371
|
|
357
372
|
# Produces a type for Type[T]
|
358
373
|
# @api public
|
359
374
|
#
|
360
375
|
def self.type_type(inst_type = nil)
|
361
|
-
inst_type.nil? ?
|
376
|
+
inst_type.nil? ? PType::DEFAULT : PType.new(inst_type)
|
362
377
|
end
|
363
378
|
|
364
379
|
# Produce a type corresponding to the class of given unless given is a
|
@@ -368,10 +383,10 @@ module Puppet::Pops::Types::TypeFactory
|
|
368
383
|
def self.type_of(o)
|
369
384
|
if o.is_a?(Class)
|
370
385
|
@type_calculator.type(o)
|
371
|
-
elsif o.is_a?(
|
386
|
+
elsif o.is_a?(PAnyType)
|
372
387
|
o
|
373
388
|
elsif o.is_a?(String)
|
374
|
-
|
389
|
+
PRuntimeType.new(:ruby, o)
|
375
390
|
else
|
376
391
|
@type_calculator.infer_generic(o)
|
377
392
|
end
|
@@ -395,7 +410,7 @@ module Puppet::Pops::Types::TypeFactory
|
|
395
410
|
if o.is_a?(Class)
|
396
411
|
@type_calculator.type(o)
|
397
412
|
else
|
398
|
-
|
413
|
+
PRuntimeType.new(:ruby, o.class.name)
|
399
414
|
end
|
400
415
|
end
|
401
416
|
|
@@ -404,7 +419,7 @@ module Puppet::Pops::Types::TypeFactory
|
|
404
419
|
# or mapps a Ruby Class to its name.
|
405
420
|
#
|
406
421
|
def self.ruby_type(class_name = nil)
|
407
|
-
|
422
|
+
PRuntimeType.new(:ruby, class_name)
|
408
423
|
end
|
409
424
|
|
410
425
|
# Generic creator of a RuntimeType - allows creating the type with nil or
|
@@ -412,7 +427,24 @@ module Puppet::Pops::Types::TypeFactory
|
|
412
427
|
#
|
413
428
|
def self.runtime(runtime=nil, runtime_type_name = nil)
|
414
429
|
runtime = runtime.to_sym if runtime.is_a?(String)
|
415
|
-
|
430
|
+
PRuntimeType.new(runtime, runtime_type_name)
|
431
|
+
end
|
432
|
+
|
433
|
+
# Returns the type alias for the given expression
|
434
|
+
# @param name [String] the name of the unresolved type
|
435
|
+
# @param expression [Model::Expression] an expression that will evaluate to a type
|
436
|
+
# @return [PTypeAliasType] the type alias
|
437
|
+
def self.type_alias(name, expression)
|
438
|
+
PTypeAliasType.new(name, expression)
|
439
|
+
end
|
440
|
+
|
441
|
+
# Returns the type that represents a type reference with a given name and optional
|
442
|
+
# parameters.
|
443
|
+
# @param name [String] the name of the type
|
444
|
+
# @param parameters [Array] the parameters
|
445
|
+
# @return [PTypeReferenceType] the type reference
|
446
|
+
def self.type_reference(name, parameters = nil)
|
447
|
+
PTypeReferenceType.new(name, parameters)
|
416
448
|
end
|
417
449
|
|
418
450
|
# Returns true if the given type t is of valid range parameter type (integer
|
@@ -422,3 +454,5 @@ module Puppet::Pops::Types::TypeFactory
|
|
422
454
|
end
|
423
455
|
|
424
456
|
end
|
457
|
+
end
|
458
|
+
end
|
@@ -0,0 +1,334 @@
|
|
1
|
+
module Puppet::Pops
|
2
|
+
module Types
|
3
|
+
# String
|
4
|
+
# ------
|
5
|
+
# Creates a string representation of a type.
|
6
|
+
#
|
7
|
+
# @api public
|
8
|
+
#
|
9
|
+
class TypeFormatter
|
10
|
+
# Produces a String representation of the given type.
|
11
|
+
# @param t [PAnyType] the type to produce a string form
|
12
|
+
# @return [String] the type in string form
|
13
|
+
#
|
14
|
+
# @api public
|
15
|
+
#
|
16
|
+
def self.string(t)
|
17
|
+
@singleton.string(t)
|
18
|
+
end
|
19
|
+
|
20
|
+
# @return [TypeCalculator] the singleton instance
|
21
|
+
#
|
22
|
+
# @api private
|
23
|
+
def self.singleton
|
24
|
+
@singleton
|
25
|
+
end
|
26
|
+
|
27
|
+
# Produces a string representing the type
|
28
|
+
# @api public
|
29
|
+
#
|
30
|
+
def string(t)
|
31
|
+
@@string_visitor.visit_this_0(self, t)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Produces a string representing the type where type aliases have been expanded
|
35
|
+
# @api public
|
36
|
+
#
|
37
|
+
def alias_expanded_string(t)
|
38
|
+
@expand_aliases = true
|
39
|
+
begin
|
40
|
+
string(t)
|
41
|
+
ensure
|
42
|
+
@expand_aliases = false
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Produces a debug string representing the type (possibly with more information that the regular string format)
|
47
|
+
# @api public
|
48
|
+
#
|
49
|
+
def debug_string(t)
|
50
|
+
@debug = true
|
51
|
+
begin
|
52
|
+
string(t)
|
53
|
+
ensure
|
54
|
+
@debug = false
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# @api private
|
59
|
+
def string_Module(t)
|
60
|
+
string(TypeCalculator.singleton.type(t))
|
61
|
+
end
|
62
|
+
|
63
|
+
# @api private
|
64
|
+
def string_NilClass(t) ; '?' ; end
|
65
|
+
|
66
|
+
# @api private
|
67
|
+
def string_String(t) ; t.inspect ; end
|
68
|
+
|
69
|
+
# @api private
|
70
|
+
def string_Symbol(t) ; t.to_s ; end
|
71
|
+
|
72
|
+
# @api private
|
73
|
+
def string_PAnyType(t) ; 'Any' ; end
|
74
|
+
|
75
|
+
# @api private
|
76
|
+
def string_PUndefType(t) ; 'Undef' ; end
|
77
|
+
|
78
|
+
# @api private
|
79
|
+
def string_PDefaultType(t) ; 'Default' ; end
|
80
|
+
|
81
|
+
# @api private
|
82
|
+
def string_PBooleanType(t) ; 'Boolean' ; end
|
83
|
+
|
84
|
+
# @api private
|
85
|
+
def string_PScalarType(t) ; 'Scalar' ; end
|
86
|
+
|
87
|
+
# @api private
|
88
|
+
def string_PDataType(t) ; 'Data' ; end
|
89
|
+
|
90
|
+
# @api private
|
91
|
+
def string_PNumericType(t) ; 'Numeric' ; end
|
92
|
+
|
93
|
+
# @api private
|
94
|
+
def string_PIntegerType(t)
|
95
|
+
append_array('Integer', range_array_part(t))
|
96
|
+
end
|
97
|
+
|
98
|
+
# @api private
|
99
|
+
def string_PType(t)
|
100
|
+
append_array('Type', t.type.nil? ? EMPTY_ARRAY : [string(t.type)])
|
101
|
+
end
|
102
|
+
|
103
|
+
# @api private
|
104
|
+
def string_PIterableType(t)
|
105
|
+
append_array('Iterable', t.element_type.nil? ? EMPTY_ARRAY : [string(t.element_type)])
|
106
|
+
end
|
107
|
+
|
108
|
+
# @api private
|
109
|
+
def string_PIteratorType(t)
|
110
|
+
append_array('Iterator', t.element_type.nil? ? EMPTY_ARRAY : [string(t.element_type)])
|
111
|
+
end
|
112
|
+
|
113
|
+
# @api private
|
114
|
+
def string_PFloatType(t)
|
115
|
+
append_array('Float', range_array_part(t))
|
116
|
+
end
|
117
|
+
|
118
|
+
# @api private
|
119
|
+
def string_PRegexpType(t)
|
120
|
+
append_array('Regexp', t.pattern.nil? ? EMPTY_ARRAY : [t.regexp.inspect])
|
121
|
+
end
|
122
|
+
|
123
|
+
# @api private
|
124
|
+
def string_PStringType(t)
|
125
|
+
elements = range_array_part(t.size_type)
|
126
|
+
elements += t.values.map {|s| "'#{s}'" } if @debug
|
127
|
+
append_array('String', elements)
|
128
|
+
end
|
129
|
+
|
130
|
+
# @api private
|
131
|
+
def string_PEnumType(t)
|
132
|
+
append_array('Enum', t.values.map {|s| "'#{s}'" })
|
133
|
+
end
|
134
|
+
|
135
|
+
# @api private
|
136
|
+
def string_PVariantType(t)
|
137
|
+
append_array('Variant', t.types.map {|t2| string(t2) })
|
138
|
+
end
|
139
|
+
|
140
|
+
# @api private
|
141
|
+
def string_PTupleType(t)
|
142
|
+
type_strings = t.types.map {|t2| string(t2) }
|
143
|
+
type_strings += range_array_part(t.size_type) unless type_strings.empty?
|
144
|
+
append_array('Tuple', type_strings)
|
145
|
+
end
|
146
|
+
|
147
|
+
# @api private
|
148
|
+
def string_PCallableType(t)
|
149
|
+
elements = EMPTY_ARRAY
|
150
|
+
unless t.param_types.nil?
|
151
|
+
# translate to string, and skip Unit types
|
152
|
+
elements = t.param_types.types.map {|t2| string(t2) unless t2.class == PUnitType }.compact
|
153
|
+
|
154
|
+
if t.param_types.types.empty?
|
155
|
+
elements += ['0', '0']
|
156
|
+
else
|
157
|
+
elements += range_array_part(t.param_types.size_type)
|
158
|
+
end
|
159
|
+
|
160
|
+
# Add block T last (after min, max) if present)
|
161
|
+
#
|
162
|
+
unless t.block_type.nil?
|
163
|
+
elements << string(t.block_type)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
append_array('Callable', elements)
|
167
|
+
end
|
168
|
+
|
169
|
+
# @api private
|
170
|
+
def string_PStructType(t)
|
171
|
+
args = t.elements.empty? ? EMPTY_ARRAY : [append_hash('', t.elements.map {|e| hash_entry_PStructElement(e)})]
|
172
|
+
append_array('Struct', args)
|
173
|
+
end
|
174
|
+
|
175
|
+
# @api private
|
176
|
+
def hash_entry_PStructElement(t)
|
177
|
+
k = t.key_type
|
178
|
+
value_optional = t.value_type.assignable?(PUndefType::DEFAULT)
|
179
|
+
key_string =
|
180
|
+
if k.is_a?(POptionalType)
|
181
|
+
# Output as literal String
|
182
|
+
value_optional ? "'#{t.name}'" : string(k)
|
183
|
+
else
|
184
|
+
value_optional ? "NotUndef['#{t.name}']" : "'#{t.name}'"
|
185
|
+
end
|
186
|
+
[key_string, string(t.value_type)]
|
187
|
+
end
|
188
|
+
|
189
|
+
# @api private
|
190
|
+
def string_PPatternType(t)
|
191
|
+
append_array('Pattern', t.patterns.map {|s| "#{s.regexp.inspect}" })
|
192
|
+
end
|
193
|
+
|
194
|
+
# @api private
|
195
|
+
def string_PCollectionType(t)
|
196
|
+
append_array('Collection', range_array_part(t.size_type))
|
197
|
+
end
|
198
|
+
|
199
|
+
# @api private
|
200
|
+
def string_PUnitType(t)
|
201
|
+
'Unit'
|
202
|
+
end
|
203
|
+
|
204
|
+
# @api private
|
205
|
+
def string_PRuntimeType(t)
|
206
|
+
append_array('Runtime', [string(t.runtime), string(t.runtime_type_name)])
|
207
|
+
end
|
208
|
+
|
209
|
+
# @api private
|
210
|
+
def string_PArrayType(t)
|
211
|
+
append_array('Array', t == PArrayType::DATA ? EMPTY_ARRAY : [string(t.element_type)] + range_array_part(t.size_type))
|
212
|
+
end
|
213
|
+
|
214
|
+
# @api private
|
215
|
+
def string_PHashType(t)
|
216
|
+
append_array('Hash', t == PHashType::DATA ? EMPTY_ARRAY : [string(t.key_type), string(t.element_type)] + range_array_part(t.size_type))
|
217
|
+
end
|
218
|
+
|
219
|
+
# @api private
|
220
|
+
def string_PCatalogEntryType(t)
|
221
|
+
'CatalogEntry'
|
222
|
+
end
|
223
|
+
|
224
|
+
# @api private
|
225
|
+
def string_PHostClassType(t)
|
226
|
+
append_array('Class', t.class_name.nil? ? EMPTY_ARRAY : [t.class_name])
|
227
|
+
end
|
228
|
+
|
229
|
+
# @api private
|
230
|
+
def string_PResourceType(t)
|
231
|
+
if t.type_name
|
232
|
+
append_array(capitalize_segments(t.type_name), t.title.nil? ? EMPTY_ARRAY : ["'#{t.title}'"])
|
233
|
+
else
|
234
|
+
'Resource'
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
# @api private
|
239
|
+
def string_PNotUndefType(t)
|
240
|
+
contained_type = t.type
|
241
|
+
if contained_type.nil? || contained_type.class == PAnyType
|
242
|
+
args = EMPTY_ARRAY
|
243
|
+
else
|
244
|
+
if contained_type.is_a?(PStringType) && contained_type.values.size == 1
|
245
|
+
args = [ "'#{contained_type.values[0]}'" ]
|
246
|
+
else
|
247
|
+
args = [ string(contained_type) ]
|
248
|
+
end
|
249
|
+
end
|
250
|
+
append_array('NotUndef', args)
|
251
|
+
end
|
252
|
+
|
253
|
+
# @api private
|
254
|
+
def string_POptionalType(t)
|
255
|
+
optional_type = t.optional_type
|
256
|
+
if optional_type.nil?
|
257
|
+
args = EMPTY_ARRAY
|
258
|
+
else
|
259
|
+
if optional_type.is_a?(PStringType) && optional_type.values.size == 1
|
260
|
+
args = [ "'#{optional_type.values[0]}'" ]
|
261
|
+
else
|
262
|
+
args = [ string(optional_type) ]
|
263
|
+
end
|
264
|
+
end
|
265
|
+
append_array('Optional', args)
|
266
|
+
end
|
267
|
+
|
268
|
+
# @api private
|
269
|
+
def string_PTypeAliasType(t)
|
270
|
+
expand = @expand_aliases
|
271
|
+
if expand && t.self_recursion?
|
272
|
+
@guard ||= RecursionGuard.new
|
273
|
+
expand = (@guard.add_this(t) & RecursionGuard::SELF_RECURSION_IN_THIS) == 0
|
274
|
+
end
|
275
|
+
expand ? "#{t.name} = #{string(t.resolved_type)}" : t.name
|
276
|
+
end
|
277
|
+
|
278
|
+
# @api private
|
279
|
+
def string_PTypeReferenceType(t)
|
280
|
+
if t.parameters.empty?
|
281
|
+
t.name
|
282
|
+
else
|
283
|
+
append_array(t.name.clone, t.parameters.map {|p| string(p) })
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
# Debugging to_s to reduce the amount of output
|
288
|
+
def to_s
|
289
|
+
'[a TypeFormatter]'
|
290
|
+
end
|
291
|
+
|
292
|
+
private
|
293
|
+
|
294
|
+
NAME_SEGMENT_SEPARATOR = '::'.freeze
|
295
|
+
|
296
|
+
COMMA_SEP = ', '.freeze
|
297
|
+
|
298
|
+
HASH_ENTRY_OP = ' => '.freeze
|
299
|
+
|
300
|
+
def range_array_part(t)
|
301
|
+
t.nil? || t.unbounded? ? EMPTY_ARRAY : [t.from.nil? ? 'default' : t.from.to_s , t.to.nil? ? 'default' : t.to.to_s ]
|
302
|
+
end
|
303
|
+
|
304
|
+
def append_array(bld, array)
|
305
|
+
case array.size
|
306
|
+
when 0
|
307
|
+
when 1
|
308
|
+
bld << '[' << array[0] << ']'
|
309
|
+
else
|
310
|
+
bld << '['
|
311
|
+
array.each { |elem| bld << elem << COMMA_SEP }
|
312
|
+
bld.chomp!(COMMA_SEP)
|
313
|
+
bld << ']'
|
314
|
+
end
|
315
|
+
bld
|
316
|
+
end
|
317
|
+
|
318
|
+
def append_hash(bld, hash_entries)
|
319
|
+
bld << '{'
|
320
|
+
hash_entries.each { |k, v| bld << k << HASH_ENTRY_OP << v << COMMA_SEP }
|
321
|
+
bld.chomp!(COMMA_SEP)
|
322
|
+
bld << '}'
|
323
|
+
bld
|
324
|
+
end
|
325
|
+
|
326
|
+
def capitalize_segments(s)
|
327
|
+
s.split(NAME_SEGMENT_SEPARATOR).map(&:capitalize).join(NAME_SEGMENT_SEPARATOR)
|
328
|
+
end
|
329
|
+
|
330
|
+
@singleton = new
|
331
|
+
@@string_visitor = Visitor.new(nil, 'string',0,0)
|
332
|
+
end
|
333
|
+
end
|
334
|
+
end
|