puppet 5.3.7 → 5.4.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- 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 +216 -178
- 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
@@ -9,7 +9,17 @@ module PuppetObject
|
|
9
9
|
#
|
10
10
|
# @return [PObjectType] the type
|
11
11
|
def _pcore_type
|
12
|
-
self.class._pcore_type
|
12
|
+
t = self.class._pcore_type
|
13
|
+
if t.parameterized?
|
14
|
+
unless instance_variable_defined?(:@_cached_ptype)
|
15
|
+
# Create a parameterized type based on the values of this instance that
|
16
|
+
# contains a parameter value for each type parameter that matches an
|
17
|
+
# attribute by name and type of value
|
18
|
+
@_cached_ptype = PObjectTypeExtension.create_from_instance(t, self)
|
19
|
+
end
|
20
|
+
t = @_cached_ptype
|
21
|
+
end
|
22
|
+
t
|
13
23
|
end
|
14
24
|
|
15
25
|
def _pcore_all_contents(path, &block)
|
@@ -21,6 +31,10 @@ module PuppetObject
|
|
21
31
|
def _pcore_init_hash
|
22
32
|
{}
|
23
33
|
end
|
34
|
+
|
35
|
+
def to_s
|
36
|
+
TypeFormatter.string(self)
|
37
|
+
end
|
24
38
|
end
|
25
39
|
end
|
26
40
|
end
|
@@ -226,56 +226,56 @@ class RubyGenerator < TypeFormatter
|
|
226
226
|
eq_names = obj.equality
|
227
227
|
end
|
228
228
|
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
bld << " },\n"
|
244
|
-
end
|
229
|
+
# Output type safe hash constructor
|
230
|
+
bld << "\n def self.from_hash(init_hash)\n"
|
231
|
+
bld << ' from_asserted_hash(' << namespace_relative(segments, TypeAsserter.name) << '.assert_instance_of('
|
232
|
+
bld << "'" << obj.label << " initializer', _pcore_type.init_hash_type, init_hash))\n end\n\n def self.from_asserted_hash(init_hash)\n new"
|
233
|
+
unless non_opt.empty? && opt.empty?
|
234
|
+
bld << "(\n"
|
235
|
+
non_opt.each { |ip| bld << " init_hash['" << ip.name << "'],\n" }
|
236
|
+
opt.each do |ip|
|
237
|
+
if ip.value.nil?
|
238
|
+
bld << " init_hash['" << ip.name << "'],\n"
|
239
|
+
else
|
240
|
+
bld << " init_hash.fetch('" << ip.name << "') { "
|
241
|
+
default_string(bld, ip)
|
242
|
+
bld << " },\n"
|
245
243
|
end
|
246
|
-
bld.chomp!(",\n")
|
247
|
-
bld << ')'
|
248
244
|
end
|
249
|
-
bld
|
245
|
+
bld.chomp!(",\n")
|
246
|
+
bld << ')'
|
247
|
+
end
|
248
|
+
bld << "\n end\n"
|
250
249
|
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
end
|
271
|
-
bld << ' new('
|
272
|
-
non_opt.each { |a| bld << rname(a.name) << ', ' }
|
273
|
-
opt.each { |a| bld << rname(a.name) << ', ' }
|
274
|
-
bld.chomp!(', ')
|
275
|
-
bld << ')'
|
250
|
+
# Output type safe constructor
|
251
|
+
bld << "\n def self.create"
|
252
|
+
if init_params.empty?
|
253
|
+
bld << "\n new"
|
254
|
+
else
|
255
|
+
bld << '('
|
256
|
+
non_opt.each { |ip| bld << rname(ip.name) << ', ' }
|
257
|
+
opt.each do |ip|
|
258
|
+
bld << rname(ip.name) << ' = '
|
259
|
+
default_string(bld, ip)
|
260
|
+
bld << ', '
|
261
|
+
end
|
262
|
+
bld.chomp!(', ')
|
263
|
+
bld << ")\n"
|
264
|
+
bld << ' ta = ' << namespace_relative(segments, TypeAsserter.name) << "\n"
|
265
|
+
bld << " attrs = _pcore_type.attributes(true)\n"
|
266
|
+
init_params.each do |a|
|
267
|
+
bld << " ta.assert_instance_of('" << a.container.name << '[' << a.name << ']'
|
268
|
+
bld << "', attrs['" << a.name << "'].type, " << rname(a.name) << ")\n"
|
276
269
|
end
|
277
|
-
bld <<
|
270
|
+
bld << ' new('
|
271
|
+
non_opt.each { |a| bld << rname(a.name) << ', ' }
|
272
|
+
opt.each { |a| bld << rname(a.name) << ', ' }
|
273
|
+
bld.chomp!(', ')
|
274
|
+
bld << ')'
|
275
|
+
end
|
276
|
+
bld << "\n end\n"
|
278
277
|
|
278
|
+
unless obj.parent.is_a?(PObjectType) && obj_attrs.empty?
|
279
279
|
# Output attr_readers
|
280
280
|
unless obj_attrs.empty?
|
281
281
|
bld << "\n"
|
@@ -335,9 +335,7 @@ class RubyGenerator < TypeFormatter
|
|
335
335
|
end
|
336
336
|
end
|
337
337
|
|
338
|
-
|
339
|
-
bld << "\n def _pcore_init_hash\n {}\n end\n" unless obj.parent.is_a?(PObjectType)
|
340
|
-
else
|
338
|
+
unless obj_attrs.empty? && obj.parent.nil?
|
341
339
|
bld << "\n def _pcore_init_hash\n"
|
342
340
|
bld << ' result = '
|
343
341
|
bld << (obj.parent.nil? ? '{}' : 'super')
|
@@ -384,12 +382,6 @@ class RubyGenerator < TypeFormatter
|
|
384
382
|
bld << " path.pop\n end\n"
|
385
383
|
end
|
386
384
|
|
387
|
-
unless obj.parent.is_a?(PObjectType)
|
388
|
-
bld << "\n def to_s\n"
|
389
|
-
bld << ' ' << namespace_relative(segments, TypeFormatter.name) << ".string(self)\n"
|
390
|
-
bld << " end\n"
|
391
|
-
end
|
392
|
-
|
393
385
|
# Output function placeholders
|
394
386
|
obj.functions(false).each_value do |func|
|
395
387
|
code_annotation = RubyMethod.annotate(func)
|
@@ -569,6 +569,10 @@ class StringConverter
|
|
569
569
|
end
|
570
570
|
end
|
571
571
|
|
572
|
+
def string_PObjectTypeExtension(val_type, val, format_map, indentation)
|
573
|
+
string_PObjectType(val_type.base_type, val, format_map, indentation)
|
574
|
+
end
|
575
|
+
|
572
576
|
def string_PRuntimeType(val_type, val, format_map, indent)
|
573
577
|
# Before giving up on this, and use a string representation of the unknown
|
574
578
|
# object, a check is made to see if the object can present itself as
|
@@ -715,7 +719,7 @@ class StringConverter
|
|
715
719
|
when :c
|
716
720
|
char = [val].pack("U")
|
717
721
|
char = f.alt? ? "\"#{char}\"" : char
|
718
|
-
|
722
|
+
Kernel.format(f.orig_fmt.gsub('c','s'), char)
|
719
723
|
|
720
724
|
when :s
|
721
725
|
fmt = f.alt? ? 'p' : 's'
|
@@ -1089,6 +1093,23 @@ class StringConverter
|
|
1089
1093
|
end
|
1090
1094
|
end
|
1091
1095
|
|
1096
|
+
# @api private
|
1097
|
+
def string_PURIType(val_type, val, format_map, indentation)
|
1098
|
+
f = get_format(val_type, format_map)
|
1099
|
+
case f.format
|
1100
|
+
when :p
|
1101
|
+
fmt = TypeFormatter.singleton
|
1102
|
+
indentation = indentation.indenting(f.alt? || indentation.is_indenting?)
|
1103
|
+
fmt = fmt.indented(indentation.level, 2) if indentation.is_indenting?
|
1104
|
+
fmt.string(val)
|
1105
|
+
when :s
|
1106
|
+
str_val = val.to_s
|
1107
|
+
Kernel.format(f.orig_fmt, f.alt? ? puppet_quote(str_val) : str_val)
|
1108
|
+
else
|
1109
|
+
raise FormatError.new('URI', f.format, 'sp')
|
1110
|
+
end
|
1111
|
+
end
|
1112
|
+
|
1092
1113
|
# Maps the inferred type of o to a formatting rule
|
1093
1114
|
def get_format(val_t, format_options)
|
1094
1115
|
fmt = format_options.find {|k,_| k.assignable?(val_t) }
|
@@ -10,7 +10,7 @@ module Types
|
|
10
10
|
#
|
11
11
|
module TypeAcceptor
|
12
12
|
# @param type [PAnyType] the type that we accept a visit from
|
13
|
-
# @param
|
13
|
+
# @param guard [RecursionGuard] the guard against self recursion
|
14
14
|
def visit(type, guard)
|
15
15
|
end
|
16
16
|
end
|
@@ -108,7 +108,7 @@ class TypeCalculator
|
|
108
108
|
# Answers, does the given callable accept the arguments given in args (an array or a tuple)
|
109
109
|
# @param callable [PCallableType] - the callable
|
110
110
|
# @param args [PArrayType, PTupleType] args optionally including a lambda callable at the end
|
111
|
-
# @return [
|
111
|
+
# @return [Boolean] true if the callable accepts the arguments
|
112
112
|
#
|
113
113
|
# @api public
|
114
114
|
def self.callable?(callable, args)
|
@@ -516,7 +516,11 @@ class TypeCalculator
|
|
516
516
|
return PRuntimeType.new(:ruby, nil) if name.nil? # anonymous class that doesn't implement PuppetObject is impossible to infer
|
517
517
|
ir = Loaders.implementation_registry
|
518
518
|
type = ir.nil? ? nil : ir.type_for_module(name)
|
519
|
-
|
519
|
+
return PRuntimeType.new(:ruby, name) if type.nil?
|
520
|
+
if type.is_a?(PObjectType) && type.parameterized?
|
521
|
+
type = PObjectTypeExtension.create_from_instance(type, o)
|
522
|
+
end
|
523
|
+
type
|
520
524
|
end
|
521
525
|
end
|
522
526
|
|
@@ -615,12 +619,17 @@ class TypeCalculator
|
|
615
619
|
|
616
620
|
# @api private
|
617
621
|
def infer_TrueClass(o)
|
618
|
-
PBooleanType::
|
622
|
+
PBooleanType::TRUE
|
619
623
|
end
|
620
624
|
|
621
625
|
# @api private
|
622
626
|
def infer_FalseClass(o)
|
623
|
-
PBooleanType::
|
627
|
+
PBooleanType::FALSE
|
628
|
+
end
|
629
|
+
|
630
|
+
# @api private
|
631
|
+
def infer_URI(o)
|
632
|
+
PURIType.new(o)
|
624
633
|
end
|
625
634
|
|
626
635
|
# @api private
|
@@ -129,7 +129,13 @@ module TypeFactory
|
|
129
129
|
# @api public
|
130
130
|
#
|
131
131
|
def self.enum(*values)
|
132
|
-
|
132
|
+
last = values.last
|
133
|
+
case_insensitive = false
|
134
|
+
if last == true || last == false
|
135
|
+
case_insensitive = last
|
136
|
+
values = values[0...-1]
|
137
|
+
end
|
138
|
+
PEnumType.new(values, case_insensitive)
|
133
139
|
end
|
134
140
|
|
135
141
|
# Produces the Variant type, optionally with the "one of" types
|
@@ -192,8 +198,8 @@ module TypeFactory
|
|
192
198
|
# @param hash [{String=>Object}] the hash of feature groups
|
193
199
|
# @return [PObjectType] the created type
|
194
200
|
#
|
195
|
-
def self.object(hash = nil)
|
196
|
-
hash.nil? || hash.empty? ? PObjectType::DEFAULT : PObjectType.new(hash)
|
201
|
+
def self.object(hash = nil, loader = nil)
|
202
|
+
hash.nil? || hash.empty? ? PObjectType::DEFAULT : PObjectType.new(hash, loader)
|
197
203
|
end
|
198
204
|
|
199
205
|
def self.type_set(hash = nil)
|
@@ -229,8 +235,8 @@ module TypeFactory
|
|
229
235
|
# Produces the Boolean type
|
230
236
|
# @api public
|
231
237
|
#
|
232
|
-
def self.boolean
|
233
|
-
PBooleanType::DEFAULT
|
238
|
+
def self.boolean(value = nil)
|
239
|
+
value.nil? ? PBooleanType::DEFAULT : (value ? PBooleanType::TRUE : PBooleanType::FALSE)
|
234
240
|
end
|
235
241
|
|
236
242
|
# Produces the Any type
|
@@ -513,6 +519,24 @@ module TypeFactory
|
|
513
519
|
inst_type.nil? ? PTypeType::DEFAULT : PTypeType.new(inst_type)
|
514
520
|
end
|
515
521
|
|
522
|
+
# Produces a type for Error
|
523
|
+
# @api public
|
524
|
+
#
|
525
|
+
def self.error
|
526
|
+
@error_t ||= TypeParser.singleton.parse('Error', Loaders.loaders.puppet_system_loader)
|
527
|
+
end
|
528
|
+
|
529
|
+
def self.task
|
530
|
+
@task_t ||= TypeParser.singleton.parse('Task')
|
531
|
+
end
|
532
|
+
|
533
|
+
# Produces a type for URI[String or Hash]
|
534
|
+
# @api public
|
535
|
+
#
|
536
|
+
def self.uri(string_uri_or_hash = nil)
|
537
|
+
string_uri_or_hash.nil? ? PURIType::DEFAULT : PURIType.new(string_uri_or_hash)
|
538
|
+
end
|
539
|
+
|
516
540
|
# Produce a type corresponding to the class of given unless given is a
|
517
541
|
# String, Class or a PAnyType. When a String is given this is taken as
|
518
542
|
# a classname.
|
@@ -149,7 +149,9 @@ class TypeFormatter
|
|
149
149
|
def string_PDefaultType(_) ; @bld << 'Default' ; end
|
150
150
|
|
151
151
|
# @api private
|
152
|
-
def string_PBooleanType(
|
152
|
+
def string_PBooleanType(t)
|
153
|
+
append_array('Boolean', t.value.nil?) { append_string(t.value) }
|
154
|
+
end
|
153
155
|
|
154
156
|
# @api private
|
155
157
|
def string_PScalarType(_) ; @bld << 'Scalar' ; end
|
@@ -213,7 +215,13 @@ class TypeFormatter
|
|
213
215
|
|
214
216
|
# @api private
|
215
217
|
def string_PEnumType(t)
|
216
|
-
append_array('Enum', t.values.empty?)
|
218
|
+
append_array('Enum', t.values.empty?) do
|
219
|
+
append_strings(t.values)
|
220
|
+
if t.case_insensitive?
|
221
|
+
@bld << COMMA_SEP
|
222
|
+
append_string(true)
|
223
|
+
end
|
224
|
+
end
|
217
225
|
end
|
218
226
|
|
219
227
|
# @api private
|
@@ -322,12 +330,34 @@ class TypeFormatter
|
|
322
330
|
append_array('Pattern', t.patterns.empty?) { append_strings(t.patterns.map(&:regexp)) }
|
323
331
|
end
|
324
332
|
|
333
|
+
|
325
334
|
# @api private
|
326
335
|
def string_PCollectionType(t)
|
327
336
|
range = range_array_part(t.size_type)
|
328
337
|
append_array('Collection', range.empty? ) { append_elements(range) }
|
329
338
|
end
|
330
339
|
|
340
|
+
def string_Object(t)
|
341
|
+
type = TypeCalculator.infer(t)
|
342
|
+
if type.is_a?(PObjectTypeExtension)
|
343
|
+
type = type.base_type
|
344
|
+
end
|
345
|
+
if type.is_a?(PObjectType)
|
346
|
+
init_hash = type.extract_init_hash(t)
|
347
|
+
@bld << type.name << '('
|
348
|
+
if @indent
|
349
|
+
append_indented_string(init_hash, @indent, @indent_width, true)
|
350
|
+
@bld.chomp!
|
351
|
+
else
|
352
|
+
append_string(init_hash)
|
353
|
+
end
|
354
|
+
@bld << ')'
|
355
|
+
else
|
356
|
+
@bld << 'Instance of '
|
357
|
+
append_string(type)
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
331
361
|
def string_PuppetObject(t)
|
332
362
|
@bld << t._pcore_type.name << '('
|
333
363
|
if @indent
|
@@ -339,6 +369,22 @@ class TypeFormatter
|
|
339
369
|
@bld << ')'
|
340
370
|
end
|
341
371
|
|
372
|
+
# @api private
|
373
|
+
def string_PURIType(t)
|
374
|
+
append_array('URI', t.parameters.nil?) { append_string(t._pcore_init_hash['parameters']) }
|
375
|
+
end
|
376
|
+
|
377
|
+
def string_URI(t)
|
378
|
+
@bld << 'URI('
|
379
|
+
if @indent
|
380
|
+
append_indented_string(t.to_s, @indent, @indent_width, true)
|
381
|
+
@bld.chomp!
|
382
|
+
else
|
383
|
+
append_string(t.to_s)
|
384
|
+
end
|
385
|
+
@bld << ')'
|
386
|
+
end
|
387
|
+
|
342
388
|
# @api private
|
343
389
|
def string_PUnitType(_)
|
344
390
|
@bld << 'Unit'
|
@@ -460,6 +506,17 @@ class TypeFormatter
|
|
460
506
|
end
|
461
507
|
end
|
462
508
|
|
509
|
+
def string_PObjectTypeExtension(t)
|
510
|
+
append_array(@type_set ? @type_set.name_for(t, t.name) : t.name, false) do
|
511
|
+
ips = t.init_parameters
|
512
|
+
if ips.is_a?(Array)
|
513
|
+
append_strings(ips)
|
514
|
+
else
|
515
|
+
append_string(ips)
|
516
|
+
end
|
517
|
+
end
|
518
|
+
end
|
519
|
+
|
463
520
|
# @api private
|
464
521
|
def string_PSensitiveType(t)
|
465
522
|
append_array('Sensitive', PAnyType::DEFAULT == t.type) { append_string(t.type) }
|
@@ -539,7 +596,7 @@ class TypeFormatter
|
|
539
596
|
end
|
540
597
|
|
541
598
|
# @api private
|
542
|
-
def string_NilClass(t) ; @bld << (@ruby ? 'nil' : '
|
599
|
+
def string_NilClass(t) ; @bld << (@ruby ? 'nil' : 'undef') ; end
|
543
600
|
|
544
601
|
# @api private
|
545
602
|
def string_Numeric(t) ; @bld << t.to_s ; end
|
@@ -623,7 +680,13 @@ class TypeFormatter
|
|
623
680
|
end
|
624
681
|
|
625
682
|
def range_array_part(t)
|
626
|
-
t.nil? || t.unbounded?
|
683
|
+
if t.nil? || t.unbounded?
|
684
|
+
EMPTY_ARRAY
|
685
|
+
else
|
686
|
+
result = [t.from.nil? ? 'default' : t.from.to_s]
|
687
|
+
result << t.to.to_s unless t.to.nil?
|
688
|
+
result
|
689
|
+
end
|
627
690
|
end
|
628
691
|
|
629
692
|
def append_object_hash(hash)
|
@@ -33,6 +33,10 @@ class TypeParser
|
|
33
33
|
# @api public
|
34
34
|
#
|
35
35
|
def parse(string, context = nil)
|
36
|
+
# quick "peephole" optimization of common data types
|
37
|
+
if t = self.class.opt_type_map[string]
|
38
|
+
return t
|
39
|
+
end
|
36
40
|
model = @parser.parse_string(string)
|
37
41
|
interpret(model.model.body, context)
|
38
42
|
end
|
@@ -200,7 +204,72 @@ class TypeParser
|
|
200
204
|
'semver' => TypeFactory.sem_ver,
|
201
205
|
'semverrange' => TypeFactory.sem_ver_range,
|
202
206
|
'timestamp' => TypeFactory.timestamp,
|
203
|
-
'timespan' => TypeFactory.timespan
|
207
|
+
'timespan' => TypeFactory.timespan,
|
208
|
+
'uri' => TypeFactory.uri,
|
209
|
+
}.freeze
|
210
|
+
end
|
211
|
+
|
212
|
+
# @api private
|
213
|
+
def self.opt_type_map
|
214
|
+
# Map of common (and simple to optimize) data types in string form
|
215
|
+
# (Note that some types are the result of evaluation even if they appear to be simple
|
216
|
+
# - for example 'Data' and they cannot be optimized this way since the factory calls
|
217
|
+
# back to the parser for evaluation).
|
218
|
+
#
|
219
|
+
@opt_type_map ||= {
|
220
|
+
'Integer' => TypeFactory.integer,
|
221
|
+
'Float' => TypeFactory.float,
|
222
|
+
'Numeric' => TypeFactory.numeric,
|
223
|
+
|
224
|
+
'String' => TypeFactory.string,
|
225
|
+
'String[1]' => TypeFactory.string(TypeFactory.range(1, :default)),
|
226
|
+
|
227
|
+
'Binary' => TypeFactory.binary,
|
228
|
+
|
229
|
+
'Boolean' => TypeFactory.boolean,
|
230
|
+
'Boolean[true]' => TypeFactory.boolean(true),
|
231
|
+
'Boolean[false]' => TypeFactory.boolean(false),
|
232
|
+
|
233
|
+
'Array' => TypeFactory.array_of_any,
|
234
|
+
'Array[1]' => TypeFactory.array_of(TypeFactory.any, TypeFactory.range(1, :default)),
|
235
|
+
|
236
|
+
'Hash' => TypeFactory.hash_of_any,
|
237
|
+
'Collection' => TypeFactory.collection,
|
238
|
+
'Scalar' => TypeFactory.scalar,
|
239
|
+
|
240
|
+
'Scalardata' => TypeFactory.scalar_data,
|
241
|
+
'ScalarData' => TypeFactory.scalar_data,
|
242
|
+
|
243
|
+
'Catalogentry' => TypeFactory.catalog_entry,
|
244
|
+
'CatalogEntry' => TypeFactory.catalog_entry,
|
245
|
+
|
246
|
+
'Undef' => TypeFactory.undef,
|
247
|
+
'Default' => TypeFactory.default,
|
248
|
+
'Any' => TypeFactory.any,
|
249
|
+
'Type' => TypeFactory.type_type,
|
250
|
+
'Callable' => TypeFactory.all_callables,
|
251
|
+
|
252
|
+
'Semver' => TypeFactory.sem_ver,
|
253
|
+
'SemVer' => TypeFactory.sem_ver,
|
254
|
+
|
255
|
+
'Semverrange' => TypeFactory.sem_ver_range,
|
256
|
+
'SemVerRange' => TypeFactory.sem_ver_range,
|
257
|
+
|
258
|
+
'Timestamp' => TypeFactory.timestamp,
|
259
|
+
'TimeStamp' => TypeFactory.timestamp,
|
260
|
+
|
261
|
+
'Timespan' => TypeFactory.timespan,
|
262
|
+
'TimeSpan' => TypeFactory.timespan,
|
263
|
+
|
264
|
+
'Uri' => TypeFactory.uri,
|
265
|
+
'URI' => TypeFactory.uri,
|
266
|
+
|
267
|
+
'Optional[Integer]' => TypeFactory.optional(TypeFactory.integer),
|
268
|
+
'Optional[String]' => TypeFactory.optional(TypeFactory.string),
|
269
|
+
'Optional[String[1]]' => TypeFactory.optional(TypeFactory.string(TypeFactory.range(1, :default))),
|
270
|
+
'Optional[Array]' => TypeFactory.optional(TypeFactory.array_of_any),
|
271
|
+
'Optional[Hash]' => TypeFactory.optional(TypeFactory.hash_of_any),
|
272
|
+
|
204
273
|
}.freeze
|
205
274
|
end
|
206
275
|
|
@@ -340,16 +409,27 @@ class TypeParser
|
|
340
409
|
TypeFactory.regexp(parameters[0])
|
341
410
|
|
342
411
|
when 'enum'
|
343
|
-
# 1..m parameters being
|
412
|
+
# 1..m parameters being string
|
413
|
+
last = parameters.last
|
414
|
+
case_insensitive = false
|
415
|
+
if last == true || last == false
|
416
|
+
parameters = parameters[0...-1]
|
417
|
+
case_insensitive = last
|
418
|
+
end
|
344
419
|
raise_invalid_parameters_error('Enum', '1 or more', parameters.size) unless parameters.size >= 1
|
345
420
|
parameters.each { |p| raise Puppet::ParseError, _('Enum parameters must be identifiers or strings') unless p.is_a?(String) }
|
346
|
-
|
421
|
+
PEnumType.new(parameters, case_insensitive)
|
347
422
|
|
348
423
|
when 'pattern'
|
349
424
|
# 1..m parameters being strings or regular expressions
|
350
425
|
raise_invalid_parameters_error('Pattern', '1 or more', parameters.size) unless parameters.size >= 1
|
351
426
|
TypeFactory.pattern(*parameters)
|
352
427
|
|
428
|
+
when 'uri'
|
429
|
+
# 1 parameter which is a string or a URI
|
430
|
+
raise_invalid_parameters_error('URI', '1', parameters.size) unless parameters.size == 1
|
431
|
+
TypeFactory.uri(parameters[0])
|
432
|
+
|
353
433
|
when 'variant'
|
354
434
|
# 1..m parameters being strings or regular expressions
|
355
435
|
raise_invalid_parameters_error('Variant', '1 or more', parameters.size) unless parameters.size >= 1
|
@@ -393,6 +473,12 @@ class TypeParser
|
|
393
473
|
raise_invalid_type_specification_error(ast) unless h.is_a?(Hash)
|
394
474
|
TypeFactory.struct(h)
|
395
475
|
|
476
|
+
when 'boolean'
|
477
|
+
raise_invalid_parameters_error('Boolean', '1', parameters.size) unless parameters.size == 1
|
478
|
+
p = parameters[0]
|
479
|
+
raise Puppet::ParseError, 'Boolean parameter must be true or false' unless p == true || p == false
|
480
|
+
TypeFactory.boolean(p)
|
481
|
+
|
396
482
|
when 'integer'
|
397
483
|
if parameters.size == 1
|
398
484
|
case parameters[0]
|
@@ -485,7 +571,7 @@ class TypeParser
|
|
485
571
|
assert_type(ast, param) unless param.is_a?(String)
|
486
572
|
TypeFactory.optional(param)
|
487
573
|
|
488
|
-
when 'any', 'data', 'catalogentry', '
|
574
|
+
when 'any', 'data', 'catalogentry', 'scalar', 'undef', 'numeric', 'default', 'semverrange'
|
489
575
|
raise_unparameterized_type_error(qref)
|
490
576
|
|
491
577
|
when 'notundef'
|
@@ -536,6 +622,8 @@ class TypeParser
|
|
536
622
|
elsif type.is_a?(PResourceType)
|
537
623
|
raise_invalid_parameters_error(qref.cased_value, 1, parameters.size) unless parameters.size == 1
|
538
624
|
TypeFactory.resource(type.type_name, parameters[0])
|
625
|
+
elsif type.is_a?(PObjectType)
|
626
|
+
PObjectTypeExtension.create(type, parameters)
|
539
627
|
else
|
540
628
|
# Must be a type alias. They can't use parameters (yet)
|
541
629
|
raise_unparameterized_type_error(qref)
|