puppet 5.3.7-x64-mingw32 → 5.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/CONTRIBUTING.md +42 -29
- data/README.md +8 -6
- data/ext/cert_inspector +2 -2
- data/ext/envpuppet +1 -1
- data/ext/gentoo/init.d/puppetmaster +4 -4
- data/ext/ips/puppet-agent +11 -11
- data/ext/ips/puppet-master +11 -11
- data/ext/puppet-test +1 -2
- data/ext/redhat/client.init +2 -2
- data/ext/redhat/logrotate +1 -1
- data/ext/solaris/smf/puppet +11 -11
- data/ext/solaris/smf/svc-puppetd +5 -5
- data/ext/solaris/smf/svc-puppetmasterd +5 -5
- data/ext/windows/service/daemon.rb +1 -1
- data/install.rb +2 -3
- data/lib/puppet/agent.rb +1 -1
- data/lib/puppet/application/cert.rb +1 -3
- data/lib/puppet/application/describe.rb +0 -1
- data/lib/puppet/application/device.rb +12 -99
- data/lib/puppet/application/filebucket.rb +32 -11
- data/lib/puppet/application/lookup.rb +1 -11
- data/lib/puppet/application/script.rb +261 -0
- data/lib/puppet/configurer.rb +3 -4
- data/lib/puppet/configurer/plugin_handler.rb +26 -9
- data/lib/puppet/context.rb +1 -1
- data/lib/puppet/datatypes.rb +213 -0
- data/lib/puppet/datatypes/error.rb +21 -0
- data/lib/puppet/datatypes/impl/error.rb +40 -0
- data/lib/puppet/defaults.rb +51 -20
- data/lib/puppet/environments.rb +17 -0
- data/lib/puppet/error.rb +17 -0
- data/lib/puppet/etc.rb +2 -2
- data/lib/puppet/external/pson/pure/generator.rb +1 -1
- data/lib/puppet/external/pson/pure/parser.rb +1 -1
- data/lib/puppet/face/config.rb +45 -0
- data/lib/puppet/face/epp.rb +3 -3
- data/lib/puppet/face/help/action.erb +3 -0
- data/lib/puppet/face/module/build.rb +1 -0
- data/lib/puppet/face/module/generate.rb +5 -0
- data/lib/puppet/face/module/install.rb +1 -0
- data/lib/puppet/face/module/search.rb +6 -2
- data/lib/puppet/face/module/uninstall.rb +1 -0
- data/lib/puppet/face/module/upgrade.rb +1 -0
- data/lib/puppet/face/parser.rb +0 -1
- data/lib/puppet/face/plugin.rb +1 -3
- data/lib/puppet/feature/base.rb +1 -1
- data/lib/puppet/feature/bolt.rb +3 -0
- data/lib/puppet/file_bucket/dipper.rb +1 -2
- data/lib/puppet/file_serving/http_metadata.rb +1 -1
- data/lib/puppet/file_system/uniquefile.rb +2 -2
- data/lib/puppet/forge.rb +6 -0
- data/lib/puppet/functions.rb +70 -88
- data/lib/puppet/functions/all.rb +6 -2
- data/lib/puppet/functions/annotate.rb +1 -1
- data/lib/puppet/functions/any.rb +7 -3
- data/lib/puppet/functions/contain.rb +6 -0
- data/lib/puppet/functions/convert_to.rb +32 -0
- data/lib/puppet/functions/defined.rb +0 -3
- data/lib/puppet/functions/each.rb +10 -6
- data/lib/puppet/functions/filter.rb +16 -10
- data/lib/puppet/functions/find_file.rb +0 -1
- data/lib/puppet/functions/include.rb +6 -0
- data/lib/puppet/functions/map.rb +12 -9
- data/lib/puppet/functions/module_directory.rb +41 -0
- data/lib/puppet/functions/new.rb +1 -4
- data/lib/puppet/functions/regsubst.rb +1 -1
- data/lib/puppet/functions/require.rb +6 -0
- data/lib/puppet/generate/type.rb +1 -1
- data/lib/puppet/gettext/config.rb +2 -2
- data/lib/puppet/gettext/stubs.rb +1 -1
- data/lib/puppet/indirector/catalog/compiler.rb +0 -1
- data/lib/puppet/indirector/file_bucket_file/file.rb +6 -2
- data/lib/puppet/indirector/file_server.rb +1 -1
- data/lib/puppet/indirector/node/ldap.rb +19 -3
- data/lib/puppet/indirector/request.rb +10 -6
- data/lib/puppet/indirector/rest.rb +11 -12
- data/lib/puppet/info_service/class_information_service.rb +1 -1
- data/lib/puppet/interface/action.rb +11 -0
- data/lib/puppet/interface/action_builder.rb +8 -0
- data/lib/puppet/interface/option_manager.rb +1 -1
- data/lib/puppet/loaders.rb +2 -0
- data/lib/puppet/module.rb +6 -2
- data/lib/puppet/module_tool/applications/builder.rb +4 -0
- data/lib/puppet/module_tool/applications/installer.rb +3 -0
- data/lib/puppet/module_tool/applications/uninstaller.rb +3 -0
- data/lib/puppet/module_tool/applications/unpacker.rb +1 -1
- data/lib/puppet/module_tool/applications/upgrader.rb +3 -0
- data/lib/puppet/module_tool/installed_modules.rb +1 -1
- data/lib/puppet/module_tool/metadata.rb +0 -1
- data/lib/puppet/network/authstore.rb +1 -1
- data/lib/puppet/network/http/api/indirected_routes.rb +1 -1
- data/lib/puppet/network/http/connection.rb +1 -9
- data/lib/puppet/network/http/factory.rb +0 -3
- data/lib/puppet/network/http/webrick.rb +1 -0
- data/lib/puppet/network/rights.rb +1 -1
- data/lib/puppet/node.rb +53 -0
- data/lib/puppet/node/environment.rb +1 -1
- data/lib/puppet/parameter/boolean.rb +1 -1
- data/lib/puppet/parser.rb +1 -0
- data/lib/puppet/parser/abstract_compiler.rb +36 -0
- data/lib/puppet/parser/ast/branch.rb +1 -1
- data/lib/puppet/parser/ast/pops_bridge.rb +8 -52
- data/lib/puppet/parser/compiler.rb +4 -54
- data/lib/puppet/parser/functions.rb +0 -1
- data/lib/puppet/parser/functions/create_resources.rb +6 -0
- data/lib/puppet/parser/functions/fqdn_rand.rb +6 -2
- data/lib/puppet/parser/functions/inline_template.rb +6 -0
- data/lib/puppet/parser/functions/new.rb +47 -32
- data/lib/puppet/parser/functions/realize.rb +6 -0
- data/lib/puppet/parser/functions/return.rb +1 -22
- data/lib/puppet/parser/functions/reverse_each.rb +1 -1
- data/lib/puppet/parser/functions/scanf.rb +1 -1
- data/lib/puppet/parser/functions/sha256.rb +5 -0
- data/lib/puppet/parser/functions/tag.rb +6 -0
- data/lib/puppet/parser/functions/tagged.rb +6 -0
- data/lib/puppet/parser/functions/template.rb +5 -0
- data/lib/puppet/parser/scope.rb +28 -4
- data/lib/puppet/parser/script_compiler.rb +118 -0
- data/lib/puppet/parser/type_loader.rb +1 -1
- data/lib/puppet/pops.rb +1 -1
- data/lib/puppet/pops/evaluator/access_operator.rb +38 -4
- data/lib/puppet/pops/evaluator/closure.rb +12 -4
- data/lib/puppet/pops/evaluator/compare_operator.rb +4 -4
- data/lib/puppet/pops/evaluator/epp_evaluator.rb +13 -0
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +38 -10
- data/lib/puppet/pops/evaluator/literal_evaluator.rb +1 -1
- data/lib/puppet/pops/evaluator/runtime3_converter.rb +1 -1
- data/lib/puppet/pops/evaluator/runtime3_support.rb +2 -3
- data/lib/puppet/pops/functions/dispatch.rb +6 -5
- data/lib/puppet/pops/functions/function.rb +2 -2
- data/lib/puppet/pops/issues.rb +34 -2
- data/lib/puppet/pops/loader/base_loader.rb +10 -0
- data/lib/puppet/pops/loader/dependency_loader.rb +7 -0
- data/lib/puppet/pops/loader/loader.rb +21 -2
- data/lib/puppet/pops/loader/loader_paths.rb +180 -30
- data/lib/puppet/pops/loader/module_loaders.rb +202 -33
- data/lib/puppet/pops/loader/puppet_plan_instantiator.rb +84 -0
- data/lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb +9 -9
- data/lib/puppet/pops/loader/ruby_data_type_instantiator.rb +40 -0
- data/lib/puppet/pops/loader/runtime3_type_loader.rb +6 -1
- data/lib/puppet/pops/loader/static_loader.rb +23 -8
- data/lib/puppet/pops/loader/task_instantiator.rb +69 -0
- data/lib/puppet/pops/loader/type_definition_instantiator.rb +4 -0
- data/lib/puppet/pops/loaders.rb +122 -11
- data/lib/puppet/pops/lookup/data_dig_function_provider.rb +1 -1
- data/lib/puppet/pops/lookup/interpolation.rb +1 -1
- data/lib/puppet/pops/lookup/lookup_adapter.rb +0 -1
- data/lib/puppet/pops/model/ast.pp +3 -0
- data/lib/puppet/pops/model/ast.rb +34 -1
- data/lib/puppet/pops/model/factory.rb +30 -3
- data/lib/puppet/pops/model/model_label_provider.rb +1 -0
- data/lib/puppet/pops/model/model_tree_dumper.rb +12 -1
- data/lib/puppet/pops/model/tree_dumper.rb +1 -1
- data/lib/puppet/pops/parser/code_merger.rb +2 -2
- data/lib/puppet/pops/parser/egrammar.ra +44 -15
- data/lib/puppet/pops/parser/eparser.rb +1687 -1571
- data/lib/puppet/pops/parser/epp_support.rb +1 -3
- data/lib/puppet/pops/parser/evaluating_parser.rb +1 -1
- data/lib/puppet/pops/parser/interpolation_support.rb +2 -2
- data/lib/puppet/pops/parser/lexer2.rb +4 -4
- data/lib/puppet/pops/parser/lexer_support.rb +2 -2
- data/lib/puppet/pops/parser/locatable.rb +1 -1
- data/lib/puppet/pops/parser/locator.rb +7 -13
- data/lib/puppet/pops/parser/parser_support.rb +3 -3
- data/lib/puppet/pops/parser/slurp_support.rb +0 -3
- data/lib/puppet/pops/pcore.rb +45 -0
- data/lib/puppet/pops/resource/param.rb +1 -1
- data/lib/puppet/pops/resource/resource_type_impl.rb +1 -1
- data/lib/puppet/pops/serialization/abstract_reader.rb +4 -0
- data/lib/puppet/pops/serialization/abstract_writer.rb +6 -0
- data/lib/puppet/pops/serialization/extension.rb +1 -0
- data/lib/puppet/pops/serialization/from_data_converter.rb +64 -10
- data/lib/puppet/pops/serialization/json_path.rb +2 -1
- data/lib/puppet/pops/serialization/object.rb +3 -4
- data/lib/puppet/pops/serialization/serializer.rb +2 -1
- data/lib/puppet/pops/serialization/to_data_converter.rb +7 -3
- data/lib/puppet/pops/time/timespan.rb +1 -1
- data/lib/puppet/pops/types/iterable.rb +38 -9
- data/lib/puppet/pops/types/p_init_type.rb +1 -1
- data/lib/puppet/pops/types/p_meta_type.rb +4 -0
- data/lib/puppet/pops/types/p_object_type.rb +146 -14
- data/lib/puppet/pops/types/p_object_type_extension.rb +218 -0
- data/lib/puppet/pops/types/p_sem_ver_range_type.rb +0 -1
- data/lib/puppet/pops/types/p_sem_ver_type.rb +10 -2
- data/lib/puppet/pops/types/p_type_set_type.rb +0 -1
- data/lib/puppet/pops/types/p_uri_type.rb +190 -0
- data/lib/puppet/pops/types/puppet_object.rb +15 -1
- data/lib/puppet/pops/types/ruby_generator.rb +46 -54
- data/lib/puppet/pops/types/string_converter.rb +22 -1
- data/lib/puppet/pops/types/type_acceptor.rb +1 -1
- data/lib/puppet/pops/types/type_calculator.rb +13 -4
- data/lib/puppet/pops/types/type_factory.rb +29 -5
- data/lib/puppet/pops/types/type_formatter.rb +67 -4
- data/lib/puppet/pops/types/type_parser.rb +92 -4
- data/lib/puppet/pops/types/type_with_members.rb +43 -0
- data/lib/puppet/pops/types/types.rb +212 -80
- data/lib/puppet/pops/validation/checker4_0.rb +10 -6
- data/lib/puppet/pops/validation/tasks_checker.rb +60 -0
- data/lib/puppet/pops/validation/validator_factory_4_0.rb +6 -1
- data/lib/puppet/property.rb +1 -1
- data/lib/puppet/provider.rb +18 -8
- data/lib/puppet/provider/augeas/augeas.rb +3 -4
- data/lib/puppet/provider/exec.rb +0 -2
- data/lib/puppet/provider/group/groupadd.rb +25 -1
- data/lib/puppet/provider/group/windows_adsi.rb +7 -4
- data/lib/puppet/provider/mount.rb +25 -8
- data/lib/puppet/provider/nameservice.rb +9 -4
- data/lib/puppet/provider/nameservice/directoryservice.rb +3 -3
- data/lib/puppet/provider/nameservice/objectadd.rb +13 -24
- data/lib/puppet/provider/nameservice/pw.rb +14 -14
- data/lib/puppet/provider/package/appdmg.rb +0 -1
- data/lib/puppet/provider/package/apple.rb +0 -1
- data/lib/puppet/provider/package/gem.rb +2 -2
- data/lib/puppet/provider/package/macports.rb +2 -2
- data/lib/puppet/provider/package/pkg.rb +3 -0
- data/lib/puppet/provider/package/pkgdmg.rb +0 -1
- data/lib/puppet/provider/package/portage.rb +0 -1
- data/lib/puppet/provider/package/yum.rb +23 -8
- data/lib/puppet/provider/package/zypper.rb +2 -2
- data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +2 -2
- data/lib/puppet/provider/service/init.rb +1 -0
- data/lib/puppet/provider/service/launchd.rb +6 -7
- data/lib/puppet/provider/service/redhat.rb +3 -2
- data/lib/puppet/provider/service/systemd.rb +2 -2
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +1 -1
- data/lib/puppet/provider/user/aix.rb +3 -2
- data/lib/puppet/provider/user/openbsd.rb +1 -1
- data/lib/puppet/provider/user/pw.rb +1 -1
- data/lib/puppet/provider/user/user_role_add.rb +7 -1
- data/lib/puppet/provider/user/useradd.rb +36 -6
- data/lib/puppet/provider/user/windows_adsi.rb +1 -1
- data/lib/puppet/provider/yumrepo/inifile.rb +2 -4
- data/lib/puppet/provider/zfs/zfs.rb +23 -3
- data/lib/puppet/provider/zpool/zpool.rb +1 -1
- data/lib/puppet/reference/configuration.rb +0 -2
- data/lib/puppet/reference/type.rb +0 -1
- data/lib/puppet/resource.rb +1 -2
- data/lib/puppet/resource/catalog.rb +1 -1
- data/lib/puppet/resource/status.rb +0 -1
- data/lib/puppet/resource/type.rb +4 -4
- data/lib/puppet/resource/type_collection.rb +1 -1
- data/lib/puppet/settings/base_setting.rb +1 -1
- data/lib/puppet/settings/environment_conf.rb +0 -1
- data/lib/puppet/settings/ini_file.rb +66 -12
- data/lib/puppet/ssl/certificate_authority.rb +1 -1
- data/lib/puppet/ssl/certificate_request.rb +2 -2
- data/lib/puppet/ssl/certificate_revocation_list.rb +2 -1
- data/lib/puppet/ssl/certificate_signer.rb +11 -0
- data/lib/puppet/ssl/host.rb +2 -2
- data/lib/puppet/syntax_checkers/base64.rb +1 -1
- data/lib/puppet/transaction.rb +37 -14
- data/lib/puppet/transaction/report.rb +3 -1
- data/lib/puppet/type.rb +17 -4
- data/lib/puppet/type/cron.rb +1 -1
- data/lib/puppet/type/exec.rb +5 -4
- data/lib/puppet/type/file.rb +3 -3
- data/lib/puppet/type/file/checksum.rb +7 -1
- data/lib/puppet/type/file/checksum_value.rb +4 -3
- data/lib/puppet/type/group.rb +3 -0
- data/lib/puppet/type/k5login.rb +101 -0
- data/lib/puppet/type/macauthorization.rb +1 -1
- data/lib/puppet/type/mount.rb +6 -2
- data/lib/puppet/type/tidy.rb +6 -4
- data/lib/puppet/type/user.rb +26 -39
- data/lib/puppet/type/yumrepo.rb +9 -0
- data/lib/puppet/type/zfs.rb +4 -0
- data/lib/puppet/util.rb +8 -15
- data/lib/puppet/util/character_encoding.rb +2 -2
- data/lib/puppet/util/checksums.rb +82 -1
- data/lib/puppet/util/errors.rb +0 -2
- data/lib/puppet/util/filetype.rb +2 -2
- data/lib/puppet/util/json_lockfile.rb +1 -1
- data/lib/puppet/util/log.rb +1 -1
- data/lib/puppet/util/log/destinations.rb +10 -1
- data/lib/puppet/util/monkey_patches.rb +1 -1
- data/lib/puppet/util/network_device/cisco/device.rb +5 -5
- data/lib/puppet/util/network_device/config.rb +2 -3
- data/lib/puppet/util/platform.rb +13 -0
- data/lib/puppet/util/plist.rb +4 -4
- data/lib/puppet/util/rdoc/generators/puppet_generator.rb +2 -2
- data/lib/puppet/util/rdoc/parser/puppet_parser_rdoc2.rb +1 -1
- data/lib/puppet/util/reference.rb +8 -1
- data/lib/puppet/util/windows/adsi.rb +18 -15
- data/lib/puppet/util/windows/principal.rb +6 -7
- data/lib/puppet/util/windows/process.rb +1 -1
- data/lib/puppet/util/windows/registry.rb +2 -2
- data/lib/puppet/util/windows/sid.rb +7 -62
- data/lib/puppet/vendor/deep_merge/README.md +2 -2
- data/lib/puppet/vendor/pathspec/lib/pathspec/gitignorespec.rb +18 -18
- data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/version.rb +2 -2
- data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet/version_range.rb +5 -5
- data/lib/puppet/vendor/semantic_puppet/locales/config.yaml +1 -1
- data/lib/puppet/version.rb +1 -1
- data/lib/puppet_pal.rb +874 -0
- data/locales/ja/puppet.po +140 -163
- data/locales/puppet.pot +940 -597
- data/man/man5/puppet.conf.5 +16 -91
- data/man/man8/puppet-agent.8 +2 -6
- data/man/man8/puppet-apply.8 +2 -2
- data/man/man8/puppet-ca.8 +1 -1
- data/man/man8/puppet-catalog.8 +1 -1
- data/man/man8/puppet-cert.8 +1 -1
- data/man/man8/puppet-certificate.8 +1 -1
- data/man/man8/puppet-certificate_request.8 +1 -1
- data/man/man8/puppet-certificate_revocation_list.8 +1 -1
- data/man/man8/puppet-config.8 +1 -1
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +11 -33
- data/man/man8/puppet-doc.8 +1 -1
- data/man/man8/puppet-epp.8 +1 -1
- data/man/man8/puppet-facts.8 +1 -1
- data/man/man8/puppet-filebucket.8 +4 -22
- data/man/man8/puppet-generate.8 +1 -1
- data/man/man8/puppet-help.8 +1 -1
- data/man/man8/puppet-key.8 +1 -1
- data/man/man8/puppet-lookup.8 +1 -1
- data/man/man8/puppet-man.8 +1 -1
- data/man/man8/puppet-master.8 +1 -1
- data/man/man8/puppet-module.8 +2 -11
- data/man/man8/puppet-node.8 +1 -1
- data/man/man8/puppet-parser.8 +1 -1
- data/man/man8/puppet-plugin.8 +1 -1
- data/man/man8/puppet-report.8 +1 -1
- data/man/man8/puppet-resource.8 +1 -1
- data/man/man8/puppet-status.8 +1 -1
- data/man/man8/puppet.8 +2 -2
- data/spec/integration/application/lookup_spec.rb +0 -21
- data/spec/integration/parser/compiler_spec.rb +18 -0
- data/spec/integration/parser/script_compiler_spec.rb +113 -0
- data/spec/integration/provider/mount_spec.rb +2 -0
- data/spec/integration/type/file_spec.rb +11 -3
- data/spec/integration/util/windows/adsi_spec.rb +1 -86
- data/spec/integration/util/windows/principal_spec.rb +1 -10
- data/spec/shared_contexts/checksum.rb +4 -1
- data/spec/shared_contexts/digests.rb +46 -1
- data/spec/shared_contexts/types_setup.rb +8 -3
- data/spec/unit/agent_spec.rb +2 -2
- data/spec/unit/application/cert_spec.rb +5 -17
- data/spec/unit/application/device_spec.rb +2 -96
- data/spec/unit/application/filebucket_spec.rb +18 -4
- data/spec/unit/configurer/plugin_handler_spec.rb +5 -32
- data/spec/unit/configurer_spec.rb +3 -3
- data/spec/unit/datatypes_spec.rb +304 -0
- data/spec/unit/defaults_spec.rb +41 -20
- data/spec/unit/face/config_spec.rb +46 -1
- data/spec/unit/face/epp_face_spec.rb +7 -3
- data/spec/unit/face/module/search_spec.rb +11 -0
- data/spec/unit/face/parser_spec.rb +2 -2
- data/spec/unit/file_bucket/dipper_spec.rb +12 -1
- data/spec/unit/forge/module_release_spec.rb +70 -0
- data/spec/unit/functions/break_spec.rb +34 -2
- data/spec/unit/functions/contain_spec.rb +1 -0
- data/spec/unit/functions/convert_to_spec.rb +22 -0
- data/spec/unit/functions/epp_spec.rb +5 -0
- data/spec/unit/functions/include_spec.rb +15 -0
- data/spec/unit/functions/module_directory_spec.rb +43 -0
- data/spec/unit/functions/new_spec.rb +14 -14
- data/spec/unit/functions/require_spec.rb +2 -0
- data/spec/unit/functions/shared.rb +12 -0
- data/spec/unit/functions/step_spec.rb +1 -1
- data/spec/unit/functions4_spec.rb +49 -4
- data/spec/unit/indirector/catalog/compiler_spec.rb +3 -3
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +148 -94
- data/spec/unit/indirector/node/ldap_spec.rb +15 -12
- data/spec/unit/indirector/rest_spec.rb +0 -43
- data/spec/unit/interface/action_spec.rb +33 -0
- data/spec/unit/module_tool/applications/builder_spec.rb +7 -0
- data/spec/unit/module_tool/applications/installer_spec.rb +8 -0
- data/spec/unit/module_tool/applications/uninstaller_spec.rb +8 -0
- data/spec/unit/module_tool/applications/upgrader_spec.rb +6 -0
- data/spec/unit/network/http/connection_spec.rb +1 -1
- data/spec/unit/network/http/factory_spec.rb +28 -35
- data/spec/unit/parser/compiler_spec.rb +0 -8
- data/spec/unit/parser/environment_compiler_spec.rb +36 -0
- data/spec/unit/parser/functions/create_resources_spec.rb +9 -0
- data/spec/unit/parser/functions/inline_template_spec.rb +7 -0
- data/spec/unit/parser/functions/realize_spec.rb +9 -0
- data/spec/unit/parser/functions/tag_spec.rb +7 -0
- data/spec/unit/parser/functions/tagged_spec.rb +25 -0
- data/spec/unit/parser/functions/template_spec.rb +8 -0
- data/spec/unit/parser/scope_spec.rb +19 -0
- data/spec/unit/pops/evaluator/conditionals_spec.rb +1 -1
- data/spec/unit/pops/loaders/loader_spec.rb +516 -0
- data/spec/unit/pops/loaders/loaders_spec.rb +11 -0
- data/spec/unit/pops/loaders/module_loaders_spec.rb +43 -0
- data/spec/unit/pops/loaders/static_loader_spec.rb +15 -7
- data/spec/unit/pops/model/model_spec.rb +5 -0
- data/spec/unit/pops/parser/lexer2_spec.rb +15 -0
- data/spec/unit/pops/parser/locator_spec.rb +20 -0
- data/spec/unit/pops/parser/parse_basic_expressions_spec.rb +33 -0
- data/spec/unit/pops/parser/parse_calls_spec.rb +28 -0
- data/spec/unit/pops/parser/parse_conditionals_spec.rb +12 -0
- data/spec/unit/pops/parser/parse_plan_spec.rb +48 -0
- data/spec/unit/pops/serialization/packer_spec.rb +8 -0
- data/spec/unit/pops/serialization/serialization_spec.rb +30 -0
- data/spec/unit/pops/serialization/to_from_hr_spec.rb +31 -0
- data/spec/unit/pops/types/error_spec.rb +207 -0
- data/spec/unit/pops/types/p_init_type_spec.rb +98 -0
- data/spec/unit/pops/types/p_object_type_spec.rb +275 -10
- data/spec/unit/pops/types/p_uri_type_spec.rb +191 -0
- data/spec/unit/pops/types/ruby_generator_spec.rb +82 -44
- data/spec/unit/pops/types/task_spec.rb +353 -0
- data/spec/unit/pops/types/type_calculator_spec.rb +76 -5
- data/spec/unit/pops/types/type_formatter_spec.rb +31 -13
- data/spec/unit/pops/types/type_parser_spec.rb +13 -1
- data/spec/unit/pops/types/types_spec.rb +60 -0
- data/spec/unit/pops/validator/validator_spec.rb +76 -0
- data/spec/unit/provider/group/groupadd_spec.rb +77 -1
- data/spec/unit/provider/group/pw_spec.rb +4 -4
- data/spec/unit/provider/group/windows_adsi_spec.rb +22 -79
- data/spec/unit/provider/mount_spec.rb +18 -5
- data/spec/unit/provider/nameservice_spec.rb +5 -5
- data/spec/unit/provider/package/dnf_spec.rb +2 -2
- data/spec/unit/provider/package/gem_spec.rb +1 -1
- data/spec/unit/provider/package/pkg_spec.rb +3 -0
- data/spec/unit/provider/package/yum_spec.rb +40 -0
- data/spec/unit/provider/service/launchd_spec.rb +2 -1
- data/spec/unit/provider/service/redhat_spec.rb +5 -0
- data/spec/unit/provider/service/systemd_spec.rb +1 -1
- data/spec/unit/provider/user/hpux_spec.rb +2 -2
- data/spec/unit/provider/user/openbsd_spec.rb +2 -2
- data/spec/unit/provider/user/pw_spec.rb +14 -14
- data/spec/unit/provider/user/user_role_add_spec.rb +19 -2
- data/spec/unit/provider/user/useradd_spec.rb +188 -22
- data/spec/unit/provider/user/windows_adsi_spec.rb +4 -4
- data/spec/unit/provider/zfs/zfs_spec.rb +55 -1
- data/spec/unit/provider_spec.rb +48 -0
- data/spec/unit/puppet_pal_2pec.rb +1005 -0
- data/spec/unit/puppet_pal_spec.rb +11 -0
- data/spec/unit/settings/ini_file_spec.rb +313 -2
- data/spec/unit/ssl/certificate_request_spec.rb +42 -1
- data/spec/unit/ssl/certificate_revocation_list_spec.rb +2 -1
- data/spec/unit/transaction/report_spec.rb +1 -0
- data/spec/unit/transaction_spec.rb +112 -21
- data/spec/unit/type/file/checksum_spec.rb +20 -0
- data/spec/unit/type/file_spec.rb +8 -0
- data/spec/unit/type/group_spec.rb +8 -0
- data/spec/unit/type/k5login_spec.rb +22 -1
- data/spec/unit/type/scheduled_task_spec.rb +15 -0
- data/spec/unit/type/user_spec.rb +11 -1
- data/spec/unit/type/yumrepo_spec.rb +5 -0
- data/spec/unit/util/checksums_spec.rb +3 -3
- data/spec/unit/util/log/destinations_spec.rb +14 -0
- data/spec/unit/util/network_device/cisco/device_spec.rb +1 -1
- data/spec/unit/util/plist_spec.rb +3 -3
- data/spec/unit/util/windows/adsi_spec.rb +27 -31
- data/spec/unit/util/windows/sid_spec.rb +15 -86
- data/spec/unit/util_spec.rb +17 -3
- data/tasks/manpages.rake +1 -1
- metadata +220 -182
- data/lib/puppet/bindings.rb +0 -148
- data/lib/puppet/configurer/downloader_factory.rb +0 -44
- data/spec/unit/configurer/downloader_factory_spec.rb +0 -129
@@ -0,0 +1,43 @@
|
|
1
|
+
module Puppet::Pops
|
2
|
+
module Types
|
3
|
+
|
4
|
+
# Interface implemented by a type that has InvocableMembers
|
5
|
+
module TypeWithMembers
|
6
|
+
# @return [InvocableMember,nil] An invocable member if it exists, or `nil`
|
7
|
+
def [](member_name)
|
8
|
+
raise NotImplementedError, "'#{self.class.name}' should implement #[]"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# Interface implemented by attribute and function members
|
13
|
+
module InvocableMember
|
14
|
+
# Performs type checking of arguments and invokes the method that corresponds to this
|
15
|
+
# method. The result of the invocation is returned
|
16
|
+
#
|
17
|
+
# @param receiver [Object] The receiver of the call
|
18
|
+
# @param scope [Puppet::Parser::Scope] The caller scope
|
19
|
+
# @param args [Array] Array of arguments.
|
20
|
+
# @return [Object] The result returned by the member function or attribute
|
21
|
+
#
|
22
|
+
# @api private
|
23
|
+
def invoke(receiver, scope, args, &block)
|
24
|
+
raise NotImplementedError, "'#{self.class.name}' should implement #invoke"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Plays the same role as an PAttribute in the PObjectType. Provides
|
29
|
+
# access to known attr_readers and plain reader methods.
|
30
|
+
class AttrReader
|
31
|
+
include InvocableMember
|
32
|
+
|
33
|
+
def initialize(message)
|
34
|
+
@message = message.to_sym
|
35
|
+
end
|
36
|
+
|
37
|
+
def invoke(receiver, scope, args, &block)
|
38
|
+
receiver.send(@message)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
@@ -57,7 +57,7 @@ class TypedModelObject < Object
|
|
57
57
|
def self.register_ptypes(loader, ir)
|
58
58
|
types = [
|
59
59
|
Annotation.register_ptype(loader, ir),
|
60
|
-
RubyMethod.register_ptype(loader, ir)
|
60
|
+
RubyMethod.register_ptype(loader, ir),
|
61
61
|
]
|
62
62
|
Types.constants.each do |c|
|
63
63
|
next if c == :PType || c == :PHostClassType
|
@@ -129,8 +129,11 @@ class PAnyType < TypedModelObject
|
|
129
129
|
assignable?(o.resolved_type, guard)
|
130
130
|
end
|
131
131
|
when PVariantType
|
132
|
-
# Assignable if all contained types are assignable
|
133
|
-
|
132
|
+
# Assignable if all contained types are assignable, or if this is exactly Any
|
133
|
+
return true if self.class == PAnyType
|
134
|
+
# An empty variant may be assignable to NotUndef[T] if T is assignable to empty variant
|
135
|
+
return _assignable?(o, guard) if is_a?(PNotUndefType) && o.types.empty?
|
136
|
+
!o.types.empty? && o.types.all? { |vt| assignable?(vt, guard) }
|
134
137
|
when POptionalType
|
135
138
|
# Assignable if undef and contained type is assignable
|
136
139
|
assignable?(PUndefType::DEFAULT) && (o.type.nil? || assignable?(o.type))
|
@@ -343,7 +346,7 @@ class PAnyType < TypedModelObject
|
|
343
346
|
# Answers the question if instances of this type can represent themselves as a string that
|
344
347
|
# can then be passed to the create method
|
345
348
|
#
|
346
|
-
# @return [Boolean]
|
349
|
+
# @return [Boolean] whether or not the instance has a canonical string representation
|
347
350
|
def roundtrip_with_string?
|
348
351
|
false
|
349
352
|
end
|
@@ -476,7 +479,7 @@ class PTypeType < PTypeWithContainedType
|
|
476
479
|
def self.new_function(type)
|
477
480
|
@new_function ||= Puppet::Functions.create_loaded_function(:new_type, type.loader) do
|
478
481
|
dispatch :from_string do
|
479
|
-
param 'String', :type_string
|
482
|
+
param 'String[1]', :type_string
|
480
483
|
end
|
481
484
|
|
482
485
|
def from_string(type_string)
|
@@ -649,7 +652,12 @@ class PUnitType < PAnyType
|
|
649
652
|
|
650
653
|
DEFAULT = PUnitType.new
|
651
654
|
|
655
|
+
def assignable?(o, guard=nil)
|
656
|
+
true
|
657
|
+
end
|
658
|
+
|
652
659
|
protected
|
660
|
+
|
653
661
|
# @api private
|
654
662
|
def _assignable?(o, guard)
|
655
663
|
true
|
@@ -750,13 +758,20 @@ end
|
|
750
758
|
#
|
751
759
|
class PEnumType < PScalarDataType
|
752
760
|
def self.register_ptype(loader, ir)
|
753
|
-
create_ptype(loader, ir, 'ScalarDataType',
|
761
|
+
create_ptype(loader, ir, 'ScalarDataType',
|
762
|
+
'values' => PArrayType.new(PStringType::NON_EMPTY),
|
763
|
+
'case_insensitive' => { 'type' => PBooleanType::DEFAULT, 'value' => false })
|
754
764
|
end
|
755
765
|
|
756
|
-
attr_reader :values
|
766
|
+
attr_reader :values, :case_insensitive
|
757
767
|
|
758
|
-
def initialize(values)
|
768
|
+
def initialize(values, case_insensitive = false)
|
759
769
|
@values = values.uniq.sort.freeze
|
770
|
+
@case_insensitive = case_insensitive
|
771
|
+
end
|
772
|
+
|
773
|
+
def case_insensitive?
|
774
|
+
@case_insensitive
|
760
775
|
end
|
761
776
|
|
762
777
|
# Returns Enumerator if no block is given, otherwise, calls the given
|
@@ -786,15 +801,19 @@ class PEnumType < PScalarDataType
|
|
786
801
|
end
|
787
802
|
|
788
803
|
def hash
|
789
|
-
@values.hash
|
804
|
+
@values.hash ^ @case_insensitive.hash
|
790
805
|
end
|
791
806
|
|
792
807
|
def eql?(o)
|
793
|
-
self.class == o.class && @values == o.values
|
808
|
+
self.class == o.class && @values == o.values && @case_insensitive == o.case_insensitive?
|
794
809
|
end
|
795
810
|
|
796
811
|
def instance?(o, guard = nil)
|
797
|
-
o.is_a?(String)
|
812
|
+
if o.is_a?(String)
|
813
|
+
@case_insensitive ? @values.any? { |p| p.casecmp(o) == 0 } : @values.any? { |p| p == o }
|
814
|
+
else
|
815
|
+
false
|
816
|
+
end
|
798
817
|
end
|
799
818
|
|
800
819
|
DEFAULT = PEnumType.new(EMPTY_ARRAY)
|
@@ -813,13 +832,26 @@ class PEnumType < PScalarDataType
|
|
813
832
|
# if the contained string is found in the set of enums
|
814
833
|
instance?(o.value, guard)
|
815
834
|
when PEnumType
|
816
|
-
!o.values.empty? && o.values.all? { |s| instance?(s, guard) }
|
835
|
+
!o.values.empty? && (case_insensitive? || !o.case_insensitive?) && o.values.all? { |s| instance?(s, guard) }
|
817
836
|
else
|
818
837
|
false
|
819
838
|
end
|
820
839
|
end
|
821
840
|
end
|
822
841
|
|
842
|
+
INTEGER_HEX = '(?:0[xX][0-9A-Fa-f]+)'
|
843
|
+
INTEGER_OCT = '(?:0[0-7]+)'
|
844
|
+
INTEGER_BIN = '(?:0[bB][01]+)'
|
845
|
+
INTEGER_DEC = '(?:0|[1-9]\d*)'
|
846
|
+
SIGN_PREFIX = '[+-]?\s*'
|
847
|
+
|
848
|
+
OPTIONAL_FRACTION = '(?:\.\d+)?'
|
849
|
+
OPTIONAL_EXPONENT = '(?:[eE]-?\d+)?'
|
850
|
+
FLOAT_DEC = '(?:' + INTEGER_DEC + OPTIONAL_FRACTION + OPTIONAL_EXPONENT + ')'
|
851
|
+
|
852
|
+
INTEGER_PATTERN = '\A' + SIGN_PREFIX + '(?:' + INTEGER_DEC + '|' + INTEGER_HEX + '|' + INTEGER_OCT + '|' + INTEGER_BIN + ')\z'
|
853
|
+
FLOAT_PATTERN = '\A' + SIGN_PREFIX + '(?:' + FLOAT_DEC + '|' + INTEGER_HEX + '|' + INTEGER_OCT + '|' + INTEGER_BIN + ')\z'
|
854
|
+
|
823
855
|
# @api public
|
824
856
|
#
|
825
857
|
class PNumericType < PScalarDataType
|
@@ -833,7 +865,7 @@ class PNumericType < PScalarDataType
|
|
833
865
|
def self.new_function(type)
|
834
866
|
@new_function ||= Puppet::Functions.create_loaded_function(:new_numeric, type.loader) do
|
835
867
|
local_types do
|
836
|
-
type
|
868
|
+
type "Convertible = Variant[Integer, Float, Boolean, Pattern[/#{FLOAT_PATTERN}/], Timespan, Timestamp]"
|
837
869
|
type 'NamedArgs = Struct[{from => Convertible, Optional[abs] => Boolean}]'
|
838
870
|
end
|
839
871
|
|
@@ -846,6 +878,11 @@ class PNumericType < PScalarDataType
|
|
846
878
|
param 'NamedArgs', :hash_args
|
847
879
|
end
|
848
880
|
|
881
|
+
argument_mismatch :on_error do
|
882
|
+
param 'Any', :from
|
883
|
+
optional_param 'Boolean', :abs
|
884
|
+
end
|
885
|
+
|
849
886
|
def from_args(from, abs = false)
|
850
887
|
result = from_convertible(from)
|
851
888
|
abs ? result.abs : result
|
@@ -857,8 +894,6 @@ class PNumericType < PScalarDataType
|
|
857
894
|
|
858
895
|
def from_convertible(from)
|
859
896
|
case from
|
860
|
-
when NilClass
|
861
|
-
throw :undefined_value
|
862
897
|
when Float
|
863
898
|
from
|
864
899
|
when Integer
|
@@ -869,7 +904,7 @@ class PNumericType < PScalarDataType
|
|
869
904
|
1
|
870
905
|
when FalseClass
|
871
906
|
0
|
872
|
-
|
907
|
+
else
|
873
908
|
begin
|
874
909
|
if from[0] == '0' && (from[1].downcase == 'b' || from[1].downcase == 'x')
|
875
910
|
Integer(from)
|
@@ -881,9 +916,15 @@ class PNumericType < PScalarDataType
|
|
881
916
|
rescue ArgumentError => e
|
882
917
|
raise TypeConversionError.new(e.message)
|
883
918
|
end
|
919
|
+
end
|
920
|
+
end
|
921
|
+
|
922
|
+
def on_error(from, abs = false)
|
923
|
+
if from.is_a?(String)
|
924
|
+
_("The string '%{str}' cannot be converted to Numeric") % { str: from }
|
884
925
|
else
|
885
|
-
t =
|
886
|
-
|
926
|
+
t = TypeCalculator.singleton.infer(from).generalize
|
927
|
+
_("Value of type %{type} cannot be converted to Numeric") % { type: t }
|
887
928
|
end
|
888
929
|
end
|
889
930
|
end
|
@@ -1044,7 +1085,7 @@ class PIntegerType < PNumericType
|
|
1044
1085
|
@@new_function ||= Puppet::Functions.create_loaded_function(:new, loader) do
|
1045
1086
|
local_types do
|
1046
1087
|
type 'Radix = Variant[Default, Integer[2,2], Integer[8,8], Integer[10,10], Integer[16,16]]'
|
1047
|
-
type
|
1088
|
+
type "Convertible = Variant[Numeric, Boolean, Pattern[/#{INTEGER_PATTERN}/], Timespan, Timestamp]"
|
1048
1089
|
type 'NamedArgs = Struct[{from => Convertible, Optional[radix] => Radix, Optional[abs] => Boolean}]'
|
1049
1090
|
end
|
1050
1091
|
|
@@ -1058,6 +1099,16 @@ class PIntegerType < PNumericType
|
|
1058
1099
|
param 'NamedArgs', :hash_args
|
1059
1100
|
end
|
1060
1101
|
|
1102
|
+
argument_mismatch :on_error_hash do
|
1103
|
+
param 'Hash', :hash_args
|
1104
|
+
end
|
1105
|
+
|
1106
|
+
argument_mismatch :on_error do
|
1107
|
+
param 'Any', :from
|
1108
|
+
optional_param 'Integer', :radix
|
1109
|
+
optional_param 'Boolean', :abs
|
1110
|
+
end
|
1111
|
+
|
1061
1112
|
def from_args(from, radix = :default, abs = false)
|
1062
1113
|
result = from_convertible(from, radix)
|
1063
1114
|
abs ? result.abs : result
|
@@ -1069,8 +1120,6 @@ class PIntegerType < PNumericType
|
|
1069
1120
|
|
1070
1121
|
def from_convertible(from, radix)
|
1071
1122
|
case from
|
1072
|
-
when NilClass
|
1073
|
-
throw :undefined_value
|
1074
1123
|
when Float, Time::TimeData
|
1075
1124
|
from.to_i
|
1076
1125
|
when Integer
|
@@ -1079,9 +1128,9 @@ class PIntegerType < PNumericType
|
|
1079
1128
|
1
|
1080
1129
|
when FalseClass
|
1081
1130
|
0
|
1082
|
-
|
1131
|
+
else
|
1083
1132
|
begin
|
1084
|
-
radix == :default ? Integer(from) : Integer(from,
|
1133
|
+
radix == :default ? Integer(from) : Integer(from, radix)
|
1085
1134
|
rescue TypeError => e
|
1086
1135
|
raise TypeConversionError.new(e.message)
|
1087
1136
|
rescue ArgumentError => e
|
@@ -1097,17 +1146,34 @@ class PIntegerType < PNumericType
|
|
1097
1146
|
end
|
1098
1147
|
raise TypeConversionError.new(e.message)
|
1099
1148
|
end
|
1149
|
+
end
|
1150
|
+
end
|
1151
|
+
|
1152
|
+
def on_error_hash(args_hash)
|
1153
|
+
if args_hash.include?('from')
|
1154
|
+
from = args_hash['from']
|
1155
|
+
return on_error(from) unless loader.load(:type, 'convertible').instance?(from)
|
1156
|
+
end
|
1157
|
+
radix = args_hash['radix']
|
1158
|
+
assert_radix(radix) unless radix.nil? || radix == :default
|
1159
|
+
TypeAsserter.assert_instance_of('Integer.new', loader.load(:type, 'namedargs'), args_hash)
|
1160
|
+
end
|
1161
|
+
|
1162
|
+
def on_error(from, radix = :default, abs = nil)
|
1163
|
+
assert_radix(radix) unless radix == :default
|
1164
|
+
if from.is_a?(String)
|
1165
|
+
_("The string '%{str}' cannot be converted to Integer") % { str: from }
|
1100
1166
|
else
|
1101
|
-
t =
|
1102
|
-
|
1167
|
+
t = TypeCalculator.singleton.infer(from).generalize
|
1168
|
+
_("Value of type %{type} cannot be converted to Integer") % { type: t }
|
1103
1169
|
end
|
1104
1170
|
end
|
1105
1171
|
|
1106
1172
|
def assert_radix(radix)
|
1107
1173
|
case radix
|
1108
|
-
when 2, 8, 10, 16
|
1174
|
+
when 2, 8, 10, 16
|
1109
1175
|
else
|
1110
|
-
raise ArgumentError.new("Illegal radix:
|
1176
|
+
raise ArgumentError.new(_("Illegal radix: %{radix}, expected 2, 8, 10, 16, or default") % { radix: radix })
|
1111
1177
|
end
|
1112
1178
|
radix
|
1113
1179
|
end
|
@@ -1154,7 +1220,7 @@ class PFloatType < PNumericType
|
|
1154
1220
|
def self.new_function(type)
|
1155
1221
|
@new_function ||= Puppet::Functions.create_loaded_function(:new_float, type.loader) do
|
1156
1222
|
local_types do
|
1157
|
-
type
|
1223
|
+
type "Convertible = Variant[Numeric, Boolean, Pattern[/#{FLOAT_PATTERN}/], Timespan, Timestamp]"
|
1158
1224
|
type 'NamedArgs = Struct[{from => Convertible, Optional[abs] => Boolean}]'
|
1159
1225
|
end
|
1160
1226
|
|
@@ -1167,6 +1233,11 @@ class PFloatType < PNumericType
|
|
1167
1233
|
param 'NamedArgs', :hash_args
|
1168
1234
|
end
|
1169
1235
|
|
1236
|
+
argument_mismatch :on_error do
|
1237
|
+
param 'Any', :from
|
1238
|
+
optional_param 'Boolean', :abs
|
1239
|
+
end
|
1240
|
+
|
1170
1241
|
def from_args(from, abs = false)
|
1171
1242
|
result = from_convertible(from)
|
1172
1243
|
abs ? result.abs : result
|
@@ -1178,8 +1249,6 @@ class PFloatType < PNumericType
|
|
1178
1249
|
|
1179
1250
|
def from_convertible(from)
|
1180
1251
|
case from
|
1181
|
-
when NilClass
|
1182
|
-
throw :undefined_value
|
1183
1252
|
when Float
|
1184
1253
|
from
|
1185
1254
|
when Integer
|
@@ -1190,7 +1259,7 @@ class PFloatType < PNumericType
|
|
1190
1259
|
1.0
|
1191
1260
|
when FalseClass
|
1192
1261
|
0.0
|
1193
|
-
|
1262
|
+
else
|
1194
1263
|
begin
|
1195
1264
|
# support a binary as float
|
1196
1265
|
if from[0] == '0' && from[1].downcase == 'b'
|
@@ -1212,9 +1281,15 @@ class PFloatType < PNumericType
|
|
1212
1281
|
end
|
1213
1282
|
raise TypeConversionError.new(e.message)
|
1214
1283
|
end
|
1284
|
+
end
|
1285
|
+
end
|
1286
|
+
|
1287
|
+
def on_error(from, _ = false)
|
1288
|
+
if from.is_a?(String)
|
1289
|
+
_("The string '%{str}' cannot be converted to Float") % { str: from }
|
1215
1290
|
else
|
1216
|
-
t =
|
1217
|
-
|
1291
|
+
t = TypeCalculator.singleton.infer(from).generalize
|
1292
|
+
_("Value of type %{type} cannot be converted to Float") % { type: t }
|
1218
1293
|
end
|
1219
1294
|
end
|
1220
1295
|
end
|
@@ -1238,7 +1313,7 @@ class PCollectionType < PAnyType
|
|
1238
1313
|
attr_reader :size_type
|
1239
1314
|
|
1240
1315
|
def initialize(size_type)
|
1241
|
-
@size_type = size_type
|
1316
|
+
@size_type = size_type.nil? ? nil : size_type.to_size
|
1242
1317
|
end
|
1243
1318
|
|
1244
1319
|
def accept(visitor, guard)
|
@@ -1435,7 +1510,7 @@ class PStringType < PScalarDataType
|
|
1435
1510
|
end
|
1436
1511
|
size_type_or_value = deprecated_multi_args[0]
|
1437
1512
|
end
|
1438
|
-
@size_type_or_value = size_type_or_value
|
1513
|
+
@size_type_or_value = size_type_or_value.is_a?(PIntegerType) ? size_type_or_value.to_size : size_type_or_value
|
1439
1514
|
end
|
1440
1515
|
|
1441
1516
|
def accept(visitor, guard)
|
@@ -1576,7 +1651,7 @@ class PStringType < PScalarDataType
|
|
1576
1651
|
# Must match exactly when value is a string
|
1577
1652
|
@size_type_or_value.nil? || @size_type_or_value == o.size_type_or_value
|
1578
1653
|
when PEnumType
|
1579
|
-
@size_type_or_value.nil? ? true : o.values.size == 1 &&
|
1654
|
+
@size_type_or_value.nil? ? true : o.values.size == 1 && !o.case_insensitive? && o.values[0]
|
1580
1655
|
when PPatternType
|
1581
1656
|
@size_type_or_value.nil?
|
1582
1657
|
else
|
@@ -1785,46 +1860,73 @@ class PBooleanType < PScalarDataType
|
|
1785
1860
|
create_ptype(loader, ir, 'ScalarDataType')
|
1786
1861
|
end
|
1787
1862
|
|
1863
|
+
attr_reader :value
|
1864
|
+
|
1865
|
+
def initialize(value = nil)
|
1866
|
+
@value = value
|
1867
|
+
end
|
1868
|
+
|
1869
|
+
def eql?(o)
|
1870
|
+
o.is_a?(PBooleanType) && @value == o.value
|
1871
|
+
end
|
1872
|
+
|
1873
|
+
def generalize
|
1874
|
+
PBooleanType::DEFAULT
|
1875
|
+
end
|
1876
|
+
|
1877
|
+
def hash
|
1878
|
+
31 ^ @value.hash
|
1879
|
+
end
|
1880
|
+
|
1788
1881
|
def instance?(o, guard = nil)
|
1789
|
-
o == true || o == false
|
1882
|
+
(o == true || o == false) && (@value.nil? || value == o)
|
1790
1883
|
end
|
1791
1884
|
|
1792
1885
|
def self.new_function(type)
|
1793
1886
|
@new_function ||= Puppet::Functions.create_loaded_function(:new_boolean, type.loader) do
|
1794
1887
|
dispatch :from_args do
|
1795
|
-
param
|
1888
|
+
param "Variant[Integer, Float, Boolean, Enum['false','true','yes','no','y','n',true]]", :from
|
1889
|
+
end
|
1890
|
+
|
1891
|
+
argument_mismatch :on_error do
|
1892
|
+
param 'Any', :from
|
1796
1893
|
end
|
1797
1894
|
|
1798
1895
|
def from_args(from)
|
1799
1896
|
from = from.downcase if from.is_a?(String)
|
1800
1897
|
case from
|
1801
|
-
when NilClass
|
1802
|
-
throw :undefined_value
|
1803
1898
|
when Float
|
1804
1899
|
from != 0.0
|
1805
1900
|
when Integer
|
1806
1901
|
from != 0
|
1807
|
-
when
|
1808
|
-
from
|
1809
|
-
when 'false', 'no', 'n'
|
1902
|
+
when false, 'false', 'no', 'n'
|
1810
1903
|
false
|
1811
|
-
|
1904
|
+
else
|
1812
1905
|
true
|
1906
|
+
end
|
1907
|
+
end
|
1908
|
+
|
1909
|
+
def on_error(from)
|
1910
|
+
if from.is_a?(String)
|
1911
|
+
_("The string '%{str}' cannot be converted to Boolean") % { str: from }
|
1813
1912
|
else
|
1814
|
-
|
1913
|
+
t = TypeCalculator.singleton.infer(from).generalize
|
1914
|
+
_("Value of type %{type} cannot be converted to Boolean") % { type: t }
|
1815
1915
|
end
|
1816
1916
|
end
|
1817
1917
|
end
|
1818
1918
|
end
|
1819
1919
|
|
1820
1920
|
DEFAULT = PBooleanType.new
|
1921
|
+
TRUE = PBooleanType.new(true)
|
1922
|
+
FALSE = PBooleanType.new(false)
|
1821
1923
|
|
1822
1924
|
protected
|
1823
1925
|
|
1824
1926
|
# @api private
|
1825
1927
|
#
|
1826
1928
|
def _assignable?(o, guard)
|
1827
|
-
o.is_a?(PBooleanType)
|
1929
|
+
o.is_a?(PBooleanType) && (@value.nil? || @value == o.value)
|
1828
1930
|
end
|
1829
1931
|
end
|
1830
1932
|
|
@@ -1956,7 +2058,6 @@ class PStructType < PAnyType
|
|
1956
2058
|
if self == DEFAULT
|
1957
2059
|
PIterableType.new(PHashType::DEFAULT_KEY_PAIR_TUPLE)
|
1958
2060
|
else
|
1959
|
-
tc = TypeCalculator.singleton
|
1960
2061
|
PIterableType.new(
|
1961
2062
|
PTupleType.new([
|
1962
2063
|
PVariantType.maybe_create(@elements.map {|se| se.key_type }),
|
@@ -2260,11 +2361,11 @@ class PCallableType < PAnyType
|
|
2260
2361
|
def self.register_ptype(loader, ir)
|
2261
2362
|
create_ptype(loader, ir, 'AnyType',
|
2262
2363
|
'param_types' => {
|
2263
|
-
KEY_TYPE => POptionalType.new(PTupleType::DEFAULT),
|
2364
|
+
KEY_TYPE => POptionalType.new(PTypeType.new(PTupleType::DEFAULT)),
|
2264
2365
|
KEY_VALUE => nil
|
2265
2366
|
},
|
2266
2367
|
'block_type' => {
|
2267
|
-
KEY_TYPE => POptionalType.new(PCallableType::DEFAULT),
|
2368
|
+
KEY_TYPE => POptionalType.new(PTypeType.new(PCallableType::DEFAULT)),
|
2268
2369
|
KEY_VALUE => nil
|
2269
2370
|
},
|
2270
2371
|
'return_type' => {
|
@@ -2346,7 +2447,7 @@ class PCallableType < PAnyType
|
|
2346
2447
|
|
2347
2448
|
# @api private
|
2348
2449
|
def callable_args?(required_callable_t, guard)
|
2349
|
-
# If the required callable is
|
2450
|
+
# If the required callable is equal or more specific than self, self is acceptable arguments
|
2350
2451
|
required_callable_t.assignable?(self, guard)
|
2351
2452
|
end
|
2352
2453
|
|
@@ -2503,41 +2604,43 @@ class PArrayType < PCollectionType
|
|
2503
2604
|
def self.new_function(type)
|
2504
2605
|
@new_function ||= Puppet::Functions.create_loaded_function(:new_array, type.loader) do
|
2505
2606
|
|
2506
|
-
dispatch :
|
2507
|
-
param '
|
2508
|
-
optional_param 'Boolean',
|
2607
|
+
dispatch :to_array do
|
2608
|
+
param 'Variant[Array,Hash,Binary,Iterable]', :from
|
2609
|
+
optional_param 'Boolean[false]', :wrap
|
2610
|
+
end
|
2611
|
+
|
2612
|
+
dispatch :wrapped do
|
2613
|
+
param 'Any', :from
|
2614
|
+
param 'Boolean[true]', :wrap
|
2509
2615
|
end
|
2510
2616
|
|
2511
|
-
|
2617
|
+
argument_mismatch :on_error do
|
2618
|
+
param 'Any', :from
|
2619
|
+
optional_param 'Boolean', :wrap
|
2620
|
+
end
|
2621
|
+
|
2622
|
+
def wrapped(from, _)
|
2623
|
+
from.is_a?(Array) ? from : [from]
|
2624
|
+
end
|
2625
|
+
|
2626
|
+
def to_array(from, _ = false)
|
2512
2627
|
case from
|
2513
|
-
when NilClass
|
2514
|
-
if wrap
|
2515
|
-
[nil]
|
2516
|
-
else
|
2517
|
-
throw :undefined_value
|
2518
|
-
end
|
2519
2628
|
when Array
|
2520
2629
|
from
|
2521
2630
|
when Hash
|
2522
|
-
|
2523
|
-
|
2631
|
+
from.to_a
|
2524
2632
|
when PBinaryType::Binary
|
2525
2633
|
# For older rubies, the #bytes method returns an Enumerator that must be rolled out
|
2526
|
-
|
2527
|
-
|
2634
|
+
from.binary_buffer.bytes.to_a
|
2528
2635
|
else
|
2529
|
-
|
2530
|
-
[from]
|
2531
|
-
else
|
2532
|
-
if PIterableType::DEFAULT.instance?(from)
|
2533
|
-
Iterable.on(from).to_a
|
2534
|
-
else
|
2535
|
-
t = Puppet::Pops::Types::TypeCalculator.singleton.infer(from).generalize
|
2536
|
-
raise TypeConversionError.new("Value of type '#{t}' cannot be converted to Array")
|
2537
|
-
end
|
2538
|
-
end
|
2636
|
+
Iterable.on(from).to_a
|
2539
2637
|
end
|
2540
2638
|
end
|
2639
|
+
|
2640
|
+
def on_error(from, _ = false)
|
2641
|
+
t = TypeCalculator.singleton.infer(from).generalize
|
2642
|
+
_("Value of type %{type} cannot be converted to Array") % { type: t }
|
2643
|
+
end
|
2541
2644
|
end
|
2542
2645
|
end
|
2543
2646
|
|
@@ -2738,14 +2841,12 @@ class PHashType < PCollectionType
|
|
2738
2841
|
|
2739
2842
|
def from_array(from)
|
2740
2843
|
case from
|
2741
|
-
when NilClass
|
2742
|
-
throw :undefined_value
|
2743
2844
|
when Array
|
2744
2845
|
if from.size == 0
|
2745
2846
|
{}
|
2746
2847
|
else
|
2747
2848
|
unless from.size % 2 == 0
|
2748
|
-
raise TypeConversionError.new(
|
2849
|
+
raise TypeConversionError.new(_('odd number of arguments for Hash'))
|
2749
2850
|
end
|
2750
2851
|
Hash[*from]
|
2751
2852
|
end
|
@@ -2755,8 +2856,8 @@ class PHashType < PCollectionType
|
|
2755
2856
|
if PIterableType::DEFAULT.instance?(from)
|
2756
2857
|
Hash[*Iterable.on(from).to_a]
|
2757
2858
|
else
|
2758
|
-
t =
|
2759
|
-
raise TypeConversionError.new("Value of type
|
2859
|
+
t = TypeCalculator.singleton.infer(from).generalize
|
2860
|
+
raise TypeConversionError.new(_("Value of type %{type} cannot be converted to Hash") % { type: t })
|
2760
2861
|
end
|
2761
2862
|
end
|
2762
2863
|
end
|
@@ -2924,6 +3025,20 @@ class PVariantType < PAnyType
|
|
2924
3025
|
|
2925
3026
|
DEFAULT = PVariantType.new(EMPTY_ARRAY)
|
2926
3027
|
|
3028
|
+
def assignable?(o, guard = nil)
|
3029
|
+
# an empty Variant does not match Undef (it is void - not even undef)
|
3030
|
+
if o.is_a?(PUndefType) && types.empty?
|
3031
|
+
return false
|
3032
|
+
end
|
3033
|
+
|
3034
|
+
return super unless o.is_a?(PVariantType)
|
3035
|
+
# If empty, all Variant types match irrespective of the types they hold (including being empty)
|
3036
|
+
return true if types.empty?
|
3037
|
+
# Since this variant is not empty, an empty Variant cannot match, because it matches nothing
|
3038
|
+
# otherwise all types in o must be assignable to this
|
3039
|
+
!o.types.empty? && o.types.all? { |vt| super(vt, guard) }
|
3040
|
+
end
|
3041
|
+
|
2927
3042
|
protected
|
2928
3043
|
|
2929
3044
|
# @api private
|
@@ -2948,8 +3063,9 @@ class PVariantType < PAnyType
|
|
2948
3063
|
|
2949
3064
|
# @api private
|
2950
3065
|
def merge_enums(array)
|
3066
|
+
# Merge case sensitive enums and strings
|
2951
3067
|
if array.size > 1
|
2952
|
-
parts = array.partition {|t| t.is_a?(PEnumType) && !t.values.empty? || t.is_a?(PStringType) && !t.value.nil? }
|
3068
|
+
parts = array.partition {|t| t.is_a?(PEnumType) && !t.values.empty? && !t.case_insensitive? || t.is_a?(PStringType) && !t.value.nil? }
|
2953
3069
|
enums = parts[0]
|
2954
3070
|
if enums.size > 1
|
2955
3071
|
others = parts[1]
|
@@ -2957,6 +3073,20 @@ class PVariantType < PAnyType
|
|
2957
3073
|
array = others
|
2958
3074
|
end
|
2959
3075
|
end
|
3076
|
+
|
3077
|
+
# Merge case insensitive enums
|
3078
|
+
if array.size > 1
|
3079
|
+
parts = array.partition {|t| t.is_a?(PEnumType) && !t.values.empty? && t.case_insensitive? }
|
3080
|
+
enums = parts[0]
|
3081
|
+
if enums.size > 1
|
3082
|
+
others = parts[1]
|
3083
|
+
values = []
|
3084
|
+
enums.each { |enum| enum.values.each { |value| values << value.downcase }}
|
3085
|
+
values.uniq!
|
3086
|
+
others << PEnumType.new(values, true)
|
3087
|
+
array = others
|
3088
|
+
end
|
3089
|
+
end
|
2960
3090
|
array
|
2961
3091
|
end
|
2962
3092
|
|
@@ -3513,6 +3643,8 @@ require_relative 'p_timespan_type'
|
|
3513
3643
|
require_relative 'p_timestamp_type'
|
3514
3644
|
require_relative 'p_binary_type'
|
3515
3645
|
require_relative 'p_init_type'
|
3646
|
+
require_relative 'p_object_type_extension'
|
3647
|
+
require_relative 'p_uri_type'
|
3516
3648
|
require_relative 'type_set_reference'
|
3517
3649
|
require_relative 'implementation_registry'
|
3518
3650
|
require_relative 'tree_iterators'
|