puppet 5.3.7-universal-darwin → 5.4.0-universal-darwin
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 +218 -180
- 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
data/lib/puppet/environments.rb
CHANGED
@@ -138,6 +138,23 @@ module Puppet::Environments
|
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
141
|
+
class StaticDirectory < Static
|
142
|
+
# Accepts a single environment in the given directory having the given name (not required to be reflected as the name
|
143
|
+
# of the directory)
|
144
|
+
#
|
145
|
+
def initialize(env_name, env_dir, environment)
|
146
|
+
super(environment)
|
147
|
+
@env_dir = env_dir
|
148
|
+
@env_name = env_name
|
149
|
+
end
|
150
|
+
|
151
|
+
# @!macro loader_get_conf
|
152
|
+
def get_conf(name)
|
153
|
+
return nil unless name == @env_name
|
154
|
+
Puppet::Settings::EnvironmentConf.load_from(@env_dir, '')
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
141
158
|
# Reads environments from a directory on disk. Each environment is
|
142
159
|
# represented as a sub-directory. The environment's manifest setting is the
|
143
160
|
# `manifest` directory of the environment directory. The environment's
|
data/lib/puppet/error.rb
CHANGED
@@ -68,6 +68,23 @@ module Puppet
|
|
68
68
|
msg = _("%{message} on node %{node}") % { message: msg, node: node } if node
|
69
69
|
msg
|
70
70
|
end
|
71
|
+
|
72
|
+
def self.from_issue_and_stack(issue, args = {})
|
73
|
+
stacktrace = Puppet::Pops::PuppetStack.stacktrace()
|
74
|
+
if stacktrace.size > 0
|
75
|
+
filename, line = stacktrace[0]
|
76
|
+
else
|
77
|
+
filename = nil
|
78
|
+
line = nil
|
79
|
+
end
|
80
|
+
self.new(
|
81
|
+
issue.format(args),
|
82
|
+
filename,
|
83
|
+
line,
|
84
|
+
nil,
|
85
|
+
nil,
|
86
|
+
issue.issue_code)
|
87
|
+
end
|
71
88
|
end
|
72
89
|
|
73
90
|
# An error that already contains location information in the message text
|
data/lib/puppet/etc.rb
CHANGED
@@ -109,7 +109,7 @@ module Puppet::Etc
|
|
109
109
|
# Defines Puppet::Etc::Passwd struct class. Contains all of the original
|
110
110
|
# member fields of Etc::Passwd, and additional "canonical_" versions of
|
111
111
|
# these fields as well. API compatible with Etc::Passwd. Because Struct.new
|
112
|
-
# defines a new Class object, we
|
112
|
+
# defines a new Class object, we memoize to avoid superfluous extra Class
|
113
113
|
# instantiations.
|
114
114
|
def puppet_etc_passwd_class
|
115
115
|
@password_class ||= Struct.new(*Etc::Passwd.members, *Etc::Passwd.members.map { |member| "canonical_#{member}".to_sym })
|
@@ -133,7 +133,7 @@ module Puppet::Etc
|
|
133
133
|
# @api private
|
134
134
|
# @param [Etc::Passwd or Etc::Group struct]
|
135
135
|
# @return [Puppet::Etc::Passwd or Puppet::Etc::Group struct] a new struct
|
136
|
-
# object with the original struct values
|
136
|
+
# object with the original struct values overridden to UTF-8, if valid. For
|
137
137
|
# invalid values originating in UTF-8, invalid characters are replaced with
|
138
138
|
# '?'. For each member the struct also contains a corresponding
|
139
139
|
# :canonical_<member name> struct member.
|
@@ -341,7 +341,7 @@ module PSON
|
|
341
341
|
'"' << PSON.utf8_to_pson(self) << '"'
|
342
342
|
end
|
343
343
|
|
344
|
-
# Module that holds the
|
344
|
+
# Module that holds the extending methods if, the String module is
|
345
345
|
# included.
|
346
346
|
module Extend
|
347
347
|
# Raw Strings are PSON Objects (the raw bytes are stored in an array for the
|
data/lib/puppet/face/config.rb
CHANGED
@@ -129,4 +129,49 @@ https://puppet.com/docs/puppet/latest/configuration.html#environment
|
|
129
129
|
nil
|
130
130
|
end
|
131
131
|
end
|
132
|
+
|
133
|
+
action(:delete) do
|
134
|
+
summary _("Delete a Puppet setting.")
|
135
|
+
arguments _("(<setting>")
|
136
|
+
#TRANSLATORS 'main' is a specific section name and should not be translated
|
137
|
+
description "Deletes a setting from the specified section. (The default is the section 'main')."
|
138
|
+
notes <<-'EOT'
|
139
|
+
By default, this action deletes the configuration setting from the 'main'
|
140
|
+
configuration domain. Use the '--section' flags to delete settings from other
|
141
|
+
configuration domains.
|
142
|
+
EOT
|
143
|
+
examples <<-'EOT'
|
144
|
+
Delete the setting 'setting_name' from the 'main' configuration domain:
|
145
|
+
|
146
|
+
$ puppet config delete setting_name
|
147
|
+
|
148
|
+
Delete the setting 'setting_name' from the 'master' configuration domain:
|
149
|
+
|
150
|
+
$ puppet config delete setting_name --section master
|
151
|
+
EOT
|
152
|
+
|
153
|
+
when_invoked do |name, options|
|
154
|
+
options[:section] = options[:section].to_s # If value was left as default - set to default string
|
155
|
+
|
156
|
+
path = Puppet::FileSystem.pathname(Puppet.settings.which_configuration_file)
|
157
|
+
if Puppet::FileSystem.exist?(path)
|
158
|
+
Puppet::FileSystem.open(path, nil, 'r+:UTF-8') do |file|
|
159
|
+
Puppet::Settings::IniFile.update(file) do |config|
|
160
|
+
setting_string = config.delete(options[:section], name)
|
161
|
+
if setting_string
|
162
|
+
puts(_("Deleted setting from '%{section_name}': '%{setting_string}'") %
|
163
|
+
{ section_name: options[:section], name: name, setting_string: setting_string.strip })
|
164
|
+
else
|
165
|
+
Puppet.warning(_("No setting found in configuration file for section '%{section_name}' setting name '%{name}'") %
|
166
|
+
{ section_name: options[:section], name: name })
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
else
|
171
|
+
#TRANSLATORS the 'puppet.conf' is a specific file and should not be translated
|
172
|
+
Puppet.warning(_("The puppet.conf file does not exist %{puppet_conf}") % { puppet_conf: path })
|
173
|
+
end
|
174
|
+
nil
|
175
|
+
end
|
176
|
+
end
|
132
177
|
end
|
data/lib/puppet/face/epp.rb
CHANGED
@@ -63,7 +63,7 @@ Puppet::Face.define(:epp, '0.0.1') do
|
|
63
63
|
when_invoked do |*args|
|
64
64
|
options = args.pop
|
65
65
|
# pass a dummy node, as facts are not needed for validation
|
66
|
-
options[:node] =
|
66
|
+
options[:node] = Puppet::Node.new("testnode", :facts => Puppet::Node::Facts.new("facts", {}))
|
67
67
|
compiler = create_compiler(options)
|
68
68
|
|
69
69
|
status = true # no validation error yet
|
@@ -145,7 +145,7 @@ Puppet::Face.define(:epp, '0.0.1') do
|
|
145
145
|
require 'puppet/pops'
|
146
146
|
options = args.pop
|
147
147
|
# pass a dummy node, as facts are not needed for dump
|
148
|
-
options[:node] =
|
148
|
+
options[:node] = Puppet::Node.new("testnode", :facts => Puppet::Node::Facts.new("facts", {}))
|
149
149
|
options[:header] = options[:header].nil? ? true : options[:header]
|
150
150
|
options[:validate] = options[:validate].nil? ? true : options[:validate]
|
151
151
|
|
@@ -176,7 +176,7 @@ Puppet::Face.define(:epp, '0.0.1') do
|
|
176
176
|
end
|
177
177
|
|
178
178
|
show_filename = templates.count > 1
|
179
|
-
|
179
|
+
templates.each do |file|
|
180
180
|
buffer.print dump_parse(Puppet::FileSystem.read(file, :encoding => 'utf-8'), file, options, show_filename)
|
181
181
|
end
|
182
182
|
|
@@ -4,6 +4,7 @@ Puppet::Face.define(:module, '1.0.0') do
|
|
4
4
|
description <<-EOT
|
5
5
|
Prepares a local module for release on the Puppet Forge by building a
|
6
6
|
ready-to-upload archive file.
|
7
|
+
Note: Module build uses MD5 checksums, which are prohibited on FIPS enabled systems.
|
7
8
|
|
8
9
|
This action uses the metadata.json file in the module directory to set metadata
|
9
10
|
used by the Forge. See <https://docs.puppetlabs.com/puppet/latest/reference/modules_publishing.html> for more
|
@@ -129,6 +129,8 @@ Puppet::Face.define(:module, '1.0.0') do
|
|
129
129
|
puts _("Finished; module generated in %{path}.") % { path: path }
|
130
130
|
result.join("\n")
|
131
131
|
end
|
132
|
+
|
133
|
+
deprecate
|
132
134
|
end
|
133
135
|
end
|
134
136
|
|
@@ -136,6 +138,9 @@ module Puppet::ModuleTool::Generate
|
|
136
138
|
module_function
|
137
139
|
|
138
140
|
def generate(metadata, skip_interview = false)
|
141
|
+
#TRANSLATORS 'puppet module generate' is the name of the puppet command and 'Puppet Development Kit' is the name of the software package replacing this action and should not be translated.
|
142
|
+
Puppet.deprecation_warning _("`puppet module generate` is deprecated and will be removed in a future release. This action has been replaced by Puppet Development Kit. For more information visit https://puppet.com/docs/pdk/latest/pdk.html.")
|
143
|
+
|
139
144
|
interview(metadata) unless skip_interview
|
140
145
|
destination = duplicate_skeleton(metadata)
|
141
146
|
all_files = destination.basename + '**/*'
|
@@ -8,6 +8,7 @@ Puppet::Face.define(:module, '1.0.0') do
|
|
8
8
|
summary _("Install a module from the Puppet Forge or a release archive.")
|
9
9
|
description <<-EOT
|
10
10
|
Installs a module from the Puppet Forge or from a release archive file.
|
11
|
+
Note: Module install uses MD5 checksums, which are prohibited on FIPS enabled systems.
|
11
12
|
|
12
13
|
The specified module will be installed into the directory
|
13
14
|
specified with the `--target-dir` option, which defaults to the first
|
@@ -44,13 +44,15 @@ Puppet::Face.define(:module, '1.0.0') do
|
|
44
44
|
min_widths = Hash[ *headers.map { |k,v| [k, v.length] }.flatten ]
|
45
45
|
min_widths['full_name'] = min_widths['author'] = 12
|
46
46
|
|
47
|
-
min_width = min_widths.inject(0) { |sum,pair| sum
|
47
|
+
min_width = min_widths.inject(0) { |sum,pair| sum + pair.last } + (padding.length * (headers.length - 1))
|
48
48
|
|
49
49
|
terminal_width = [Puppet::Util::Terminal.width, min_width].max
|
50
50
|
|
51
51
|
columns = results[:answers].inject(min_widths) do |hash, result|
|
52
|
+
deprecated_buffer = result['deprecated_at'].nil? ? 0 : 11 # ' DEPRECATED'.length
|
53
|
+
|
52
54
|
{
|
53
|
-
'full_name' => [ hash['full_name'], result['full_name'].length
|
55
|
+
'full_name' => [ hash['full_name'], result['full_name'].length + deprecated_buffer ].max,
|
54
56
|
'desc' => [ hash['desc'], result['desc'].length ].max,
|
55
57
|
'author' => [ hash['author'], "@#{result['author']}".length ].max,
|
56
58
|
'tag_list' => [ hash['tag_list'], result['tag_list'].join(' ').length ].max,
|
@@ -80,12 +82,14 @@ Puppet::Face.define(:module, '1.0.0') do
|
|
80
82
|
highlight = proc do |s|
|
81
83
|
s = s.gsub(term, colorize(:green, term))
|
82
84
|
s = s.gsub(term.gsub('/', '-'), colorize(:green, term.gsub('/', '-'))) if term =~ /\//
|
85
|
+
s = s.gsub(' DEPRECATED', colorize(:red, ' DEPRECATED'))
|
83
86
|
s
|
84
87
|
end
|
85
88
|
|
86
89
|
format % [ headers['full_name'], headers['desc'], headers['author'], headers['tag_list'] ] +
|
87
90
|
results[:answers].map do |match|
|
88
91
|
name, desc, author, keywords = %w{full_name desc author tag_list}.map { |k| match[k] }
|
92
|
+
name += ' DEPRECATED' unless match['deprecated_at'].nil?
|
89
93
|
desc = desc[0...(columns['desc'] - 3)] + '...' if desc.length > columns['desc']
|
90
94
|
highlight[format % [ name.sub('/', '-'), desc, "@#{author}", [keywords].flatten.join(' ') ]]
|
91
95
|
end.join
|
@@ -4,6 +4,7 @@ Puppet::Face.define(:module, '1.0.0') do
|
|
4
4
|
description <<-EOT
|
5
5
|
Uninstalls a puppet module from the modulepath (or a specific
|
6
6
|
target directory).
|
7
|
+
Note: Module uninstall uses MD5 checksums, which are prohibited on FIPS enabled systems.
|
7
8
|
EOT
|
8
9
|
|
9
10
|
returns _("Hash of module objects representing uninstalled modules and related errors.")
|
data/lib/puppet/face/parser.rb
CHANGED
data/lib/puppet/face/plugin.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'puppet/face'
|
2
|
-
require 'puppet/configurer/downloader_factory'
|
3
2
|
require 'puppet/configurer/plugin_handler'
|
4
3
|
|
5
4
|
Puppet::Face.define(:plugin, '0.0.1') do
|
@@ -42,8 +41,7 @@ Puppet::Face.define(:plugin, '0.0.1') do
|
|
42
41
|
when_invoked do |options|
|
43
42
|
remote_environment_for_plugins = Puppet::Node::Environment.remote(Puppet[:environment])
|
44
43
|
|
45
|
-
|
46
|
-
handler = Puppet::Configurer::PluginHandler.new(factory)
|
44
|
+
handler = Puppet::Configurer::PluginHandler.new()
|
47
45
|
handler.download_plugins(remote_environment_for_plugins)
|
48
46
|
end
|
49
47
|
|
data/lib/puppet/feature/base.rb
CHANGED
@@ -17,7 +17,6 @@ class Puppet::FileBucket::Dipper
|
|
17
17
|
# Emulate the XMLRPC client
|
18
18
|
server = hash[:Server]
|
19
19
|
port = hash[:Port] || Puppet[:masterport]
|
20
|
-
environment = Puppet[:environment]
|
21
20
|
|
22
21
|
if hash.include?(:Path)
|
23
22
|
@local_path = hash[:Path]
|
@@ -46,7 +45,7 @@ class Puppet::FileBucket::Dipper
|
|
46
45
|
|
47
46
|
# Make a HEAD request for the file so that we don't waste time
|
48
47
|
# uploading it if it already exists in the bucket.
|
49
|
-
unless Puppet::FileBucket::File.indirection.head(file_bucket_path)
|
48
|
+
unless Puppet::FileBucket::File.indirection.head(file_bucket_path, :bucket_path => file_bucket_file.bucket_path)
|
50
49
|
Puppet::FileBucket::File.indirection.save(file_bucket_file, dest_path)
|
51
50
|
end
|
52
51
|
|
@@ -37,7 +37,7 @@ class Puppet::FileServing::HttpMetadata < Puppet::FileServing::Metadata
|
|
37
37
|
def collect
|
38
38
|
# Prefer the checksum_type from the indirector request options
|
39
39
|
# but fall back to the alternative otherwise
|
40
|
-
[ @checksum_type, :md5, :mtime ].each do |type|
|
40
|
+
[ @checksum_type, :md5, :sha256, :sha384, :sha512, :sha224, :mtime ].each do |type|
|
41
41
|
@checksum_type = type
|
42
42
|
@checksum = @checksums[type]
|
43
43
|
return if @checksum
|
@@ -144,7 +144,7 @@ class Puppet::FileSystem::Uniquefile < DelegateClass(File)
|
|
144
144
|
def try_convert_to_hash(h)
|
145
145
|
begin
|
146
146
|
h.to_hash
|
147
|
-
rescue NoMethodError
|
147
|
+
rescue NoMethodError
|
148
148
|
nil
|
149
149
|
end
|
150
150
|
end
|
@@ -154,7 +154,7 @@ class Puppet::FileSystem::Uniquefile < DelegateClass(File)
|
|
154
154
|
def tmpdir
|
155
155
|
tmp = '.'
|
156
156
|
if $SAFE > 0
|
157
|
-
|
157
|
+
@@systmpdir
|
158
158
|
else
|
159
159
|
for dir in [ Puppet::Util.get_env('TMPDIR'), Puppet::Util.get_env('TMP'), Puppet::Util.get_env('TEMP'), @@systmpdir, '/tmp']
|
160
160
|
if dir and stat = File.stat(dir) and stat.directory? and stat.writable?
|
data/lib/puppet/forge.rb
CHANGED
@@ -167,6 +167,8 @@ class Puppet::Forge < SemanticPuppet::Dependency::Source
|
|
167
167
|
def prepare
|
168
168
|
return @unpacked_into if @unpacked_into
|
169
169
|
|
170
|
+
Puppet.warning "#{@metadata['name']} has been deprecated by its author! View module on Puppet Forge for more info." if deprecated?
|
171
|
+
|
170
172
|
download(@data['file_uri'], tmpfile)
|
171
173
|
validate_checksum(tmpfile, @data['file_md5'])
|
172
174
|
unpack(tmpfile, tmpdir)
|
@@ -210,6 +212,10 @@ class Puppet::Forge < SemanticPuppet::Dependency::Source
|
|
210
212
|
raise RuntimeError, _("Could not extract contents of module archive: %{message}") % { message: e.message }
|
211
213
|
end
|
212
214
|
end
|
215
|
+
|
216
|
+
def deprecated?
|
217
|
+
@data['module'] && (@data['module']['deprecated_at'] != nil)
|
218
|
+
end
|
213
219
|
end
|
214
220
|
|
215
221
|
private
|
data/lib/puppet/functions.rb
CHANGED
@@ -186,8 +186,12 @@ module Puppet::Functions
|
|
186
186
|
# and it will fail unless protected with an if defined? if the local
|
187
187
|
# variable does not exist in the block's binder.
|
188
188
|
#
|
189
|
-
|
190
|
-
|
189
|
+
begin
|
190
|
+
loader = block.binding.eval('loader_injected_arg if defined?(loader_injected_arg)')
|
191
|
+
create_loaded_function(func_name, loader, function_base, &block)
|
192
|
+
rescue StandardError => e
|
193
|
+
raise ArgumentError, _("Function Load Error for function '%{function_name}': %{message}") % {function_name: func_name, message: e.message}
|
194
|
+
end
|
191
195
|
end
|
192
196
|
|
193
197
|
# Creates a function in, or in a local loader under the given loader.
|
@@ -474,8 +478,8 @@ module Puppet::Functions
|
|
474
478
|
type = @all_callables
|
475
479
|
name = type_and_name[0]
|
476
480
|
when 2
|
477
|
-
|
478
|
-
type = Puppet::Pops::Types::TypeParser.singleton.parse(
|
481
|
+
type, name = type_and_name
|
482
|
+
type = Puppet::Pops::Types::TypeParser.singleton.parse(type, loader) unless type.is_a?(Puppet::Pops::Types::PAnyType)
|
479
483
|
else
|
480
484
|
raise ArgumentError, _("block_param accepts max 2 arguments (type, name), got %{size}.") % { size: type_and_name.size }
|
481
485
|
end
|
@@ -513,7 +517,9 @@ module Puppet::Functions
|
|
513
517
|
#
|
514
518
|
# @api public
|
515
519
|
def return_type(type)
|
516
|
-
|
520
|
+
unless type.is_a?(String) || type.is_a?(Puppet::Pops::Types::PAnyType)
|
521
|
+
raise ArgumentError, _("Argument to 'return_type' must be a String reference to a Puppet Data Type. Got %{type_class}") % { type_class: type.class }
|
522
|
+
end
|
517
523
|
@return_type = type
|
518
524
|
end
|
519
525
|
|
@@ -528,7 +534,7 @@ module Puppet::Functions
|
|
528
534
|
raise ArgumentError, _("Parameter name argument must be a Symbol. Got %{name_class}") % { name_class: name.class }
|
529
535
|
end
|
530
536
|
|
531
|
-
if type.is_a?(String)
|
537
|
+
if type.is_a?(String) || type.is_a?(Puppet::Pops::Types::PAnyType)
|
532
538
|
@types << type
|
533
539
|
@names << name
|
534
540
|
# mark what should be picked for this position when dispatching
|
@@ -571,14 +577,27 @@ module Puppet::Functions
|
|
571
577
|
# @api private
|
572
578
|
def create_callable(types, block_type, return_type, from, to)
|
573
579
|
mapped_types = types.map do |t|
|
574
|
-
Puppet::Pops::Types::
|
580
|
+
t.is_a?(Puppet::Pops::Types::PAnyType) ? t : internal_type_parse(t, loader)
|
575
581
|
end
|
576
582
|
param_types = Puppet::Pops::Types::PTupleType.new(mapped_types, from > 0 && from == to ? nil : Puppet::Pops::Types::PIntegerType.new(from, to))
|
577
|
-
return_type =
|
583
|
+
return_type = internal_type_parse(return_type, loader) unless return_type.nil? || return_type.is_a?(Puppet::Pops::Types::PAnyType)
|
578
584
|
Puppet::Pops::Types::PCallableType.new(param_types, block_type, return_type)
|
579
585
|
end
|
586
|
+
|
587
|
+
def internal_type_parse(type_string, loader)
|
588
|
+
begin
|
589
|
+
Puppet::Pops::Types::TypeParser.singleton.parse(type_string, loader)
|
590
|
+
rescue StandardError => e
|
591
|
+
raise ArgumentError, _("Parsing of type string '\"%{type_string}\"' failed with message: <%{message}>.\n") % {
|
592
|
+
type_string: type_string,
|
593
|
+
message: e.message
|
594
|
+
}
|
595
|
+
end
|
596
|
+
end
|
597
|
+
private :internal_type_parse
|
580
598
|
end
|
581
599
|
|
600
|
+
|
582
601
|
# The LocalTypeAliasBuilder is used by the 'local_types' method to collect the individual
|
583
602
|
# type aliases given by the function's author.
|
584
603
|
#
|
@@ -601,9 +620,31 @@ module Puppet::Functions
|
|
601
620
|
# @api public
|
602
621
|
#
|
603
622
|
def type(assignment_string)
|
604
|
-
|
623
|
+
# Get location to use in case of error - this produces ruby filename and where call to 'type' occurred
|
624
|
+
# but strips off the rest of the internal "where" as it is not meaningful to user.
|
625
|
+
#
|
626
|
+
rb_location = caller[0]
|
627
|
+
|
628
|
+
begin
|
629
|
+
result = parser.parse_string("type #{assignment_string}", nil)
|
630
|
+
rescue StandardError => e
|
631
|
+
rb_location = rb_location.gsub(/:in.*$/, '')
|
632
|
+
# Create a meaningful location for parse errors - show both what went wrong with the parsing
|
633
|
+
# and in which ruby file it was found.
|
634
|
+
raise ArgumentError, _("Parsing of 'type \"%{assignment_string}\"' failed with message: <%{message}>.\n" +
|
635
|
+
"Called from <%{ruby_file_location}>") % {
|
636
|
+
assignment_string: assignment_string,
|
637
|
+
message: e.message,
|
638
|
+
ruby_file_location: rb_location
|
639
|
+
}
|
640
|
+
end
|
605
641
|
unless result.body.kind_of?(Puppet::Pops::Model::TypeAlias)
|
606
|
-
|
642
|
+
rb_location = rb_location.gsub(/:in.*$/, '')
|
643
|
+
raise ArgumentError, _("Expected a type alias assignment on the form 'AliasType = T', got '%{assignment_string}'.\n"+
|
644
|
+
"Called from <%{ruby_file_location}>") % {
|
645
|
+
assignment_string: assignment_string,
|
646
|
+
ruby_file_location: rb_location
|
647
|
+
}
|
607
648
|
end
|
608
649
|
@local_types << result.body
|
609
650
|
end
|
@@ -616,30 +657,7 @@ module Puppet::Functions
|
|
616
657
|
#
|
617
658
|
# This is a private, internal, system for creating functions. It supports
|
618
659
|
# everything that the public function definition system supports as well as a
|
619
|
-
# few extra features.
|
620
|
-
#
|
621
|
-
# Injection Support
|
622
|
-
# ===
|
623
|
-
# The Function API supports injection of data and services. It is possible to
|
624
|
-
# make injection that takes effect when the function is loaded (for services
|
625
|
-
# and runtime configuration that does not change depending on how/from where
|
626
|
-
# in what context the function is called. It is also possible to inject and
|
627
|
-
# weave argument values into a call.
|
628
|
-
#
|
629
|
-
# Injection of attributes
|
630
|
-
# ---
|
631
|
-
# Injection of attributes is performed by one of the methods `attr_injected`,
|
632
|
-
# and `attr_injected_producer`. The injected attributes are available via
|
633
|
-
# accessor method calls.
|
634
|
-
#
|
635
|
-
# @example using injected attributes
|
636
|
-
# Puppet::Functions.create_function('test') do
|
637
|
-
# attr_injected String, :larger, 'message_larger'
|
638
|
-
# attr_injected String, :smaller, 'message_smaller'
|
639
|
-
# def test(a, b)
|
640
|
-
# a > b ? larger() : smaller()
|
641
|
-
# end
|
642
|
-
# end
|
660
|
+
# few extra features such as injection of well known parameters.
|
643
661
|
#
|
644
662
|
# @api private
|
645
663
|
class InternalFunction < Function
|
@@ -663,26 +681,22 @@ module Puppet::Functions
|
|
663
681
|
end
|
664
682
|
end
|
665
683
|
|
666
|
-
# @note WARNING: This style of creating functions is not public. It is a system
|
667
|
-
# under development that will be used for creating "system" functions.
|
668
|
-
#
|
669
684
|
# Injection and Weaving of parameters
|
670
685
|
# ---
|
671
|
-
# It is possible to inject and weave parameters into a call.
|
672
|
-
# parameters are not part of the parameters passed from the Puppet
|
673
|
-
# they can not be overridden by parameters given as arguments in the
|
674
|
-
# They are invisible to the Puppet Language.
|
686
|
+
# It is possible to inject and weave a set of well known parameters into a call.
|
687
|
+
# These extra parameters are not part of the parameters passed from the Puppet
|
688
|
+
# logic, and they can not be overridden by parameters given as arguments in the
|
689
|
+
# call. They are invisible to the Puppet Language.
|
675
690
|
#
|
676
691
|
# @example using injected parameters
|
677
692
|
# Puppet::Functions.create_function('test') do
|
678
693
|
# dispatch :test do
|
679
694
|
# param 'Scalar', 'a'
|
680
695
|
# param 'Scalar', 'b'
|
681
|
-
#
|
682
|
-
# injected_param 'String', 'smaller', 'message_smaller'
|
696
|
+
# scope_param
|
683
697
|
# end
|
684
|
-
# def test(a, b,
|
685
|
-
# a > b ?
|
698
|
+
# def test(a, b, scope)
|
699
|
+
# a > b ? scope['a'] : scope['b']
|
686
700
|
# end
|
687
701
|
# end
|
688
702
|
#
|
@@ -690,54 +704,22 @@ module Puppet::Functions
|
|
690
704
|
#
|
691
705
|
# test(10, 20)
|
692
706
|
#
|
693
|
-
# Using injected value as default
|
694
|
-
# ---
|
695
|
-
# Default value assignment is handled by using the regular Ruby mechanism (a
|
696
|
-
# value is assigned to the variable). The dispatch simply indicates that the
|
697
|
-
# value is optional. If the default value should be injected, it can be
|
698
|
-
# handled different ways depending on what is desired:
|
699
|
-
#
|
700
|
-
# * by calling the accessor method for an injected Function class attribute.
|
701
|
-
# This is suitable if the value is constant across all instantiations of the
|
702
|
-
# function, and across all calls.
|
703
|
-
# * by injecting a parameter into the call
|
704
|
-
# to the left of the parameter, and then assigning that as the default value.
|
705
|
-
# * One of the above forms, but using an injected producer instead of a
|
706
|
-
# directly injected value.
|
707
|
-
#
|
708
|
-
# @example method with injected default values
|
709
|
-
# Puppet::Functions.create_function('test') do
|
710
|
-
# dispatch :test do
|
711
|
-
# injected_param String, 'b_default', 'b_default_value_key'
|
712
|
-
# param 'Scalar', 'a'
|
713
|
-
# param 'Scalar', 'b'
|
714
|
-
# end
|
715
|
-
# def test(b_default, a, b = b_default)
|
716
|
-
# # ...
|
717
|
-
# end
|
718
|
-
# end
|
719
|
-
#
|
720
707
|
# @api private
|
721
708
|
class InternalDispatchBuilder < DispatcherBuilder
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
@weaving << [@injections.size()-1]
|
709
|
+
# Inject parameter for `Puppet::Parser::Scope`
|
710
|
+
def scope_param
|
711
|
+
inject(:scope)
|
726
712
|
end
|
727
|
-
|
728
|
-
#
|
729
|
-
|
730
|
-
|
731
|
-
@injections << [type, name, injection_name]
|
732
|
-
# mark what should be picked for this position when dispatching
|
733
|
-
@weaving << [@injections.size() -1]
|
713
|
+
|
714
|
+
# Inject parameter for `Puppet::Pal::ScriptCompiler`
|
715
|
+
def script_compiler_param
|
716
|
+
inject(:pal_script_compiler)
|
734
717
|
end
|
735
718
|
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
@injections << [type, name, injection_name, :producer]
|
719
|
+
private
|
720
|
+
|
721
|
+
def inject(injection_name)
|
722
|
+
@injections << injection_name
|
741
723
|
# mark what should be picked for this position when dispatching
|
742
724
|
@weaving << [@injections.size()-1]
|
743
725
|
end
|