puppet 5.4.0 → 5.5.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.
- data/Gemfile +3 -3
- data/MAINTAINERS +0 -19
- data/README.md +5 -5
- data/Rakefile +26 -0
- data/conf/auth.conf +5 -0
- data/ext/project_data.yaml +1 -0
- data/ext/regexp_nodes/regexp_nodes.rb +3 -4
- data/lib/puppet/application/apply.rb +1 -1
- data/lib/puppet/application/cert.rb +3 -1
- data/lib/puppet/application/device.rb +100 -13
- data/lib/puppet/application/facts.rb +5 -0
- data/lib/puppet/application/lookup.rb +12 -2
- data/lib/puppet/configurer.rb +37 -17
- data/lib/puppet/confine.rb +4 -1
- data/lib/puppet/datatypes.rb +1 -1
- data/lib/puppet/environments.rb +1 -1
- data/lib/puppet/error.rb +6 -3
- data/lib/puppet/external/dot.rb +0 -7
- data/lib/puppet/external/nagios/parser.rb +1 -1
- data/lib/puppet/face/config.rb +92 -10
- data/lib/puppet/face/epp.rb +31 -6
- data/lib/puppet/face/facts.rb +49 -0
- data/lib/puppet/face/help.rb +33 -35
- data/lib/puppet/face/help/action.erb +1 -1
- data/lib/puppet/face/help/face.erb +1 -1
- data/lib/puppet/face/man.rb +55 -12
- data/lib/puppet/face/parser.rb +30 -3
- data/lib/puppet/file_bucket/file.rb +0 -2
- data/lib/puppet/file_serving/base.rb +10 -10
- data/lib/puppet/forge.rb +3 -3
- data/lib/puppet/forge/errors.rb +3 -3
- data/lib/puppet/functions.rb +1 -3
- data/lib/puppet/functions/alert.rb +1 -1
- data/lib/puppet/functions/all.rb +6 -6
- data/lib/puppet/functions/annotate.rb +10 -10
- data/lib/puppet/functions/any.rb +6 -6
- data/lib/puppet/functions/assert_type.rb +4 -4
- data/lib/puppet/functions/binary_file.rb +14 -2
- data/lib/puppet/functions/break.rb +31 -2
- data/lib/puppet/functions/call.rb +4 -4
- data/lib/puppet/functions/contain.rb +19 -3
- data/lib/puppet/functions/convert_to.rb +6 -5
- data/lib/puppet/functions/crit.rb +1 -1
- data/lib/puppet/functions/debug.rb +1 -1
- data/lib/puppet/functions/defined.rb +11 -9
- data/lib/puppet/functions/dig.rb +26 -2
- data/lib/puppet/functions/each.rb +8 -8
- data/lib/puppet/functions/emerg.rb +1 -1
- data/lib/puppet/functions/empty.rb +79 -0
- data/lib/puppet/functions/err.rb +1 -1
- data/lib/puppet/functions/eyaml_lookup_key.rb +3 -1
- data/lib/puppet/functions/filter.rb +7 -7
- data/lib/puppet/functions/find_file.rb +15 -1
- data/lib/puppet/functions/flatten.rb +64 -0
- data/lib/puppet/functions/hiera.rb +6 -6
- data/lib/puppet/functions/hiera_array.rb +6 -6
- data/lib/puppet/functions/hiera_hash.rb +6 -6
- data/lib/puppet/functions/hiera_include.rb +8 -8
- data/lib/puppet/functions/include.rb +28 -2
- data/lib/puppet/functions/info.rb +1 -1
- data/lib/puppet/functions/inline_epp.rb +2 -2
- data/lib/puppet/functions/join.rb +56 -0
- data/lib/puppet/functions/json_data.rb +2 -2
- data/lib/puppet/functions/keys.rb +25 -0
- data/lib/puppet/functions/length.rb +44 -0
- data/lib/puppet/functions/lest.rb +39 -1
- data/lib/puppet/functions/lookup.rb +2 -1
- data/lib/puppet/functions/map.rb +10 -9
- data/lib/puppet/functions/match.rb +6 -6
- data/lib/puppet/functions/new.rb +995 -2
- data/lib/puppet/functions/next.rb +1 -1
- data/lib/puppet/functions/notice.rb +1 -1
- data/lib/puppet/functions/reduce.rb +6 -6
- data/lib/puppet/functions/regsubst.rb +9 -3
- data/lib/puppet/functions/require.rb +36 -2
- data/lib/puppet/functions/return.rb +1 -1
- data/lib/puppet/functions/reverse_each.rb +71 -2
- data/lib/puppet/functions/slice.rb +23 -9
- data/lib/puppet/functions/split.rb +12 -10
- data/lib/puppet/functions/step.rb +73 -1
- data/lib/puppet/functions/strftime.rb +176 -2
- data/lib/puppet/functions/then.rb +65 -2
- data/lib/puppet/functions/tree_each.rb +19 -19
- data/lib/puppet/functions/type.rb +42 -1
- data/lib/puppet/functions/unique.rb +13 -13
- data/lib/puppet/functions/unwrap.rb +8 -4
- data/lib/puppet/functions/values.rb +25 -0
- data/lib/puppet/functions/versioncmp.rb +1 -1
- data/lib/puppet/functions/warning.rb +1 -1
- data/lib/puppet/functions/with.rb +6 -4
- data/lib/puppet/functions/yaml_data.rb +3 -1
- data/lib/puppet/indirector/certificate_status/file.rb +1 -1
- data/lib/puppet/indirector/facts/facter.rb +1 -3
- data/lib/puppet/indirector/facts/rest.rb +21 -0
- data/lib/puppet/indirector/facts/yaml.rb +0 -4
- data/lib/puppet/indirector/rest.rb +2 -2
- data/lib/puppet/module.rb +3 -3
- data/lib/puppet/module/task.rb +2 -3
- data/lib/puppet/module_tool/applications/application.rb +4 -4
- data/lib/puppet/module_tool/applications/builder.rb +2 -2
- data/lib/puppet/module_tool/applications/checksummer.rb +3 -3
- data/lib/puppet/module_tool/applications/unpacker.rb +2 -2
- data/lib/puppet/module_tool/metadata.rb +3 -3
- data/lib/puppet/network/authconfig.rb +1 -1
- data/lib/puppet/network/format_support.rb +1 -1
- data/lib/puppet/network/formats.rb +5 -7
- data/lib/puppet/network/http/api/indirected_routes.rb +1 -0
- data/lib/puppet/network/http/api/master/v3/environment.rb +2 -2
- data/lib/puppet/network/http/api/master/v3/environments.rb +2 -2
- data/lib/puppet/network/http/error.rb +3 -3
- data/lib/puppet/network/resolver.rb +1 -2
- data/lib/puppet/parser/compiler.rb +12 -5
- data/lib/puppet/parser/compiler/catalog_validator/env_relationship_validator.rb +1 -1
- data/lib/puppet/parser/functions/fqdn_rand.rb +15 -4
- data/lib/puppet/parser/functions/new.rb +31 -46
- data/lib/puppet/parser/parser_factory.rb +1 -1
- data/lib/puppet/parser/resource.rb +1 -1
- data/lib/puppet/parser/type_loader.rb +11 -11
- data/lib/puppet/pops/evaluator/closure.rb +1 -1
- data/lib/puppet/pops/evaluator/collector_transformer.rb +1 -1
- data/lib/puppet/pops/evaluator/epp_evaluator.rb +2 -2
- data/lib/puppet/pops/evaluator/runtime3_resource_support.rb +2 -2
- data/lib/puppet/pops/evaluator/runtime3_support.rb +5 -2
- data/lib/puppet/pops/functions/dispatch.rb +1 -1
- data/lib/puppet/pops/issue_reporter.rb +18 -1
- data/lib/puppet/pops/issues.rb +6 -3
- data/lib/puppet/pops/loader/ruby_data_type_instantiator.rb +1 -2
- data/lib/puppet/pops/loader/ruby_function_instantiator.rb +1 -2
- data/lib/puppet/pops/loader/task_instantiator.rb +5 -5
- data/lib/puppet/pops/loader/type_definition_instantiator.rb +4 -1
- data/lib/puppet/pops/loaders.rb +18 -7
- data/lib/puppet/pops/lookup/global_data_provider.rb +1 -1
- data/lib/puppet/pops/lookup/lookup_adapter.rb +55 -6
- data/lib/puppet/pops/model/factory.rb +6 -3
- data/lib/puppet/pops/model/model_tree_dumper.rb +4 -0
- data/lib/puppet/pops/model/pn_transformer.rb +400 -0
- data/lib/puppet/pops/parser/egrammar.ra +1 -1
- data/lib/puppet/pops/parser/eparser.rb +1 -1
- data/lib/puppet/pops/parser/heredoc_support.rb +1 -1
- data/lib/puppet/pops/parser/lexer_support.rb +3 -2
- data/lib/puppet/pops/parser/locator.rb +0 -2
- data/lib/puppet/pops/parser/pn_parser.rb +316 -0
- data/lib/puppet/pops/pcore.rb +17 -17
- data/lib/puppet/pops/pn.rb +236 -0
- data/lib/puppet/pops/serialization/json.rb +7 -7
- data/lib/puppet/pops/types/class_loader.rb +6 -3
- data/lib/puppet/pops/types/implementation_registry.rb +28 -35
- data/lib/puppet/pops/types/p_object_type.rb +3 -3
- data/lib/puppet/pops/types/p_timespan_type.rb +2 -2
- data/lib/puppet/pops/types/p_type_set_type.rb +24 -1
- data/lib/puppet/pops/types/ruby_generator.rb +3 -4
- data/lib/puppet/pops/types/type_calculator.rb +1 -1
- data/lib/puppet/pops/types/type_factory.rb +0 -4
- data/lib/puppet/pops/types/type_mismatch_describer.rb +1 -1
- data/lib/puppet/pops/types/type_parser.rb +14 -7
- data/lib/puppet/pops/types/types.rb +1 -1
- data/lib/puppet/pops/utils.rb +2 -2
- data/lib/puppet/pops/validation/checker4_0.rb +6 -2
- data/lib/puppet/provider/group/groupadd.rb +3 -1
- data/lib/puppet/provider/group/windows_adsi.rb +4 -7
- data/lib/puppet/provider/nameservice.rb +3 -3
- data/lib/puppet/provider/package/pacman.rb +4 -4
- data/lib/puppet/provider/package/pip.rb +3 -3
- data/lib/puppet/provider/package/pkgdmg.rb +3 -3
- data/lib/puppet/provider/package/pkgutil.rb +2 -2
- data/lib/puppet/provider/package/portage.rb +9 -9
- data/lib/puppet/provider/package/zypper.rb +2 -2
- data/lib/puppet/provider/service/base.rb +1 -1
- data/lib/puppet/provider/service/smf.rb +3 -2
- data/lib/puppet/provider/service/systemd.rb +1 -1
- data/lib/puppet/provider/user/useradd.rb +6 -2
- data/lib/puppet/provider/user/windows_adsi.rb +1 -1
- data/lib/puppet/provider/yumrepo/inifile.rb +20 -9
- data/lib/puppet/provider/zfs/zfs.rb +1 -1
- data/lib/puppet/reference/configuration.rb +2 -0
- data/lib/puppet/reference/type.rb +11 -11
- data/lib/puppet/resource.rb +1 -1
- data/lib/puppet/resource/capability_finder.rb +5 -5
- data/lib/puppet/resource/catalog.rb +6 -3
- data/lib/puppet/resource/status.rb +9 -2
- data/lib/puppet/resource/type.rb +1 -1
- data/lib/puppet/settings.rb +31 -19
- data/lib/puppet/settings/base_setting.rb +5 -0
- data/lib/puppet/settings/config_file.rb +1 -1
- data/lib/puppet/settings/ttl_setting.rb +5 -0
- data/lib/puppet/ssl/certificate_factory.rb +2 -2
- data/lib/puppet/ssl/certificate_request.rb +0 -2
- data/lib/puppet/syntax_checkers/json.rb +1 -1
- data/lib/puppet/transaction/additional_resource_generator.rb +2 -2
- data/lib/puppet/transaction/event.rb +1 -1
- data/lib/puppet/transaction/report.rb +18 -12
- data/lib/puppet/type.rb +9 -13
- data/lib/puppet/type/augeas.rb +2 -2
- data/lib/puppet/type/cron.rb +11 -6
- data/lib/puppet/type/exec.rb +1 -1
- data/lib/puppet/type/file.rb +4 -5
- data/lib/puppet/type/host.rb +1 -1
- data/lib/puppet/type/k5login.rb +30 -54
- data/lib/puppet/type/package.rb +3 -3
- data/lib/puppet/type/schedule.rb +12 -12
- data/lib/puppet/type/scheduled_task.rb +2 -2
- data/lib/puppet/type/ssh_authorized_key.rb +5 -5
- data/lib/puppet/type/sshkey.rb +2 -2
- data/lib/puppet/type/tidy.rb +1 -1
- data/lib/puppet/type/user.rb +1 -1
- data/lib/puppet/type/yumrepo.rb +26 -5
- data/lib/puppet/util.rb +0 -4
- data/lib/puppet/util/backups.rb +1 -1
- data/lib/puppet/util/inifile.rb +3 -4
- data/lib/puppet/util/json.rb +68 -0
- data/lib/puppet/util/json_lockfile.rb +3 -3
- data/lib/puppet/util/log.rb +2 -5
- data/lib/puppet/util/log/destinations.rb +2 -2
- data/lib/puppet/util/network_device/cisco/facts.rb +1 -1
- data/lib/puppet/util/plist.rb +1 -1
- data/lib/puppet/util/reference.rb +1 -8
- data/lib/puppet/util/tagging.rb +1 -1
- data/lib/puppet/util/warnings.rb +0 -2
- data/lib/puppet/util/windows/adsi.rb +15 -18
- data/lib/puppet/util/windows/com.rb +2 -1
- data/lib/puppet/util/windows/file.rb +2 -2
- data/lib/puppet/util/windows/principal.rb +7 -6
- data/lib/puppet/util/windows/sid.rb +60 -7
- data/lib/puppet/util/windows/taskscheduler.rb +0 -9
- data/lib/puppet/version.rb +1 -1
- data/lib/puppet_pal.rb +53 -48
- data/locales/ja/puppet.po +1357 -912
- data/locales/puppet.pot +549 -466
- data/man/man5/puppet.conf.5 +103 -20
- data/man/man8/puppet-agent.8 +6 -2
- 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 +35 -1
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +33 -11
- data/man/man8/puppet-doc.8 +1 -1
- data/man/man8/puppet-epp.8 +34 -12
- data/man/man8/puppet-facts.8 +50 -1
- data/man/man8/puppet-filebucket.8 +38 -11
- 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 +10 -4
- data/man/man8/puppet-master.8 +1 -1
- data/man/man8/puppet-module.8 +15 -6
- data/man/man8/puppet-node.8 +1 -1
- data/man/man8/puppet-parser.8 +31 -8
- 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-script.8 +67 -0
- data/man/man8/puppet-status.8 +1 -1
- data/man/man8/puppet.8 +3 -3
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/awesome2/lib/puppet_x/awesome2/echo_scheme_handler.rb +1 -1
- data/spec/integration/application/apply_spec.rb +15 -15
- data/spec/integration/application/lookup_spec.rb +21 -0
- data/spec/integration/faces/config_spec.rb +16 -4
- data/spec/integration/network/http/api/indirected_routes_spec.rb +5 -5
- data/spec/integration/parser/catalog_spec.rb +1 -1
- data/spec/integration/parser/collection_spec.rb +2 -2
- data/spec/integration/parser/compiler_spec.rb +17 -18
- data/spec/integration/parser/pcore_resource_spec.rb +2 -2
- data/spec/integration/parser/scope_spec.rb +2 -2
- data/spec/integration/ssl/certificate_authority_spec.rb +7 -7
- data/spec/integration/ssl/certificate_revocation_list_spec.rb +1 -1
- data/spec/integration/ssl/key_spec.rb +1 -1
- data/spec/integration/transaction/report_spec.rb +3 -3
- data/spec/integration/transaction_spec.rb +0 -1
- data/spec/integration/type/file_spec.rb +10 -11
- data/spec/integration/type_spec.rb +1 -2
- data/spec/integration/util/windows/adsi_spec.rb +86 -1
- data/spec/integration/util/windows/principal_spec.rb +11 -2
- data/spec/integration/util/windows/security_spec.rb +2 -2
- data/spec/lib/matchers/json.rb +4 -4
- data/spec/lib/puppet_spec/language.rb +34 -35
- data/spec/lib/puppet_spec/module_tool/shared_functions.rb +2 -2
- data/spec/shared_behaviours/file_server_terminus.rb +0 -2
- data/spec/shared_behaviours/things_that_declare_options.rb +2 -2
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/application/cert_spec.rb +21 -9
- data/spec/unit/application/device_spec.rb +96 -2
- data/spec/unit/application/face_base_spec.rb +2 -2
- data/spec/unit/application/lookup_spec.rb +0 -1
- data/spec/unit/configurer_spec.rb +14 -0
- data/spec/unit/confine_spec.rb +16 -0
- data/spec/unit/data_providers/hiera_data_provider_spec.rb +4 -4
- data/spec/unit/datatypes_spec.rb +49 -0
- data/spec/unit/environments_spec.rb +7 -0
- data/spec/unit/face/config_spec.rb +116 -12
- data/spec/unit/face/epp_face_spec.rb +53 -2
- data/spec/unit/face/facts_spec.rb +53 -0
- data/spec/unit/face/help_spec.rb +62 -69
- data/spec/unit/face/man_spec.rb +26 -0
- data/spec/unit/face/module/list_spec.rb +0 -1
- data/spec/unit/face/parser_spec.rb +78 -0
- data/spec/unit/file_bucket/dipper_spec.rb +0 -4
- data/spec/unit/file_serving/content_spec.rb +0 -1
- data/spec/unit/file_serving/fileset_spec.rb +0 -1
- data/spec/unit/file_serving/metadata_spec.rb +0 -1
- data/spec/unit/file_serving/terminus_selector_spec.rb +0 -2
- data/spec/unit/forge_spec.rb +1 -2
- data/spec/unit/functions/assert_type_spec.rb +1 -1
- data/spec/unit/functions/empty_spec.rb +77 -0
- data/spec/unit/functions/epp_spec.rb +1 -1
- data/spec/unit/functions/flatten_spec.rb +31 -0
- data/spec/unit/functions/include_spec.rb +2 -2
- data/spec/unit/functions/inline_epp_spec.rb +1 -1
- data/spec/unit/functions/join_spec.rb +33 -0
- data/spec/unit/functions/keys_spec.rb +31 -0
- data/spec/unit/functions/length_spec.rb +50 -0
- data/spec/unit/functions/lookup_fixture_spec.rb +1 -1
- data/spec/unit/functions/lookup_spec.rb +52 -0
- data/spec/unit/functions/shared.rb +1 -1
- data/spec/unit/functions/values_spec.rb +30 -0
- data/spec/unit/functions/versioncmp_spec.rb +1 -1
- data/spec/unit/functions4_spec.rb +30 -32
- data/spec/unit/graph/title_hash_prioritizer_spec.rb +2 -1
- data/spec/unit/indirector/catalog/compiler_spec.rb +0 -15
- data/spec/unit/indirector/facts/rest_spec.rb +45 -0
- data/spec/unit/indirector/facts/yaml_spec.rb +6 -0
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +2 -2
- data/spec/unit/indirector/indirection_spec.rb +1 -1
- data/spec/unit/indirector/node/ldap_spec.rb +2 -2
- data/spec/unit/indirector/request_spec.rb +0 -2
- data/spec/unit/indirector/rest_spec.rb +2 -2
- data/spec/unit/indirector_spec.rb +0 -1
- data/spec/unit/info_service_spec.rb +1 -1
- data/spec/unit/interface/action_manager_spec.rb +1 -1
- data/spec/unit/interface/action_spec.rb +1 -1
- data/spec/unit/module_spec.rb +0 -5
- data/spec/unit/module_tool/applications/builder_spec.rb +1 -1
- data/spec/unit/module_tool/applications/unpacker_spec.rb +4 -4
- data/spec/unit/network/formats_spec.rb +5 -13
- data/spec/unit/network/http/api/indirected_routes_spec.rb +6 -2
- data/spec/unit/network/http/connection_spec.rb +1 -1
- data/spec/unit/network/http/handler_spec.rb +3 -2
- data/spec/unit/node/environment_spec.rb +1 -1
- data/spec/unit/node_spec.rb +3 -3
- data/spec/unit/parser/compiler_spec.rb +9 -2
- data/spec/unit/parser/environment_compiler_spec.rb +8 -8
- data/spec/unit/parser/functions/create_resources_spec.rb +1 -1
- data/spec/unit/parser/functions/fail_spec.rb +1 -1
- data/spec/unit/parser/functions/fqdn_rand_spec.rb +24 -0
- data/spec/unit/parser/functions/realize_spec.rb +1 -1
- data/spec/unit/parser/resource_spec.rb +0 -1
- data/spec/unit/parser/scope_spec.rb +3 -3
- data/spec/unit/parser/type_loader_spec.rb +1 -1
- data/spec/unit/pops/adaptable_spec.rb +0 -1
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +0 -3
- data/spec/unit/pops/evaluator/runtime3_converter_spec.rb +0 -4
- data/spec/unit/pops/factory_rspec_helper.rb +1 -1
- data/spec/unit/pops/factory_spec.rb +5 -5
- data/spec/unit/pops/issues_spec.rb +23 -8
- data/spec/unit/pops/loaders/loaders_spec.rb +24 -2
- data/spec/unit/pops/loaders/static_loader_spec.rb +1 -1
- data/spec/unit/pops/lookup/interpolation_spec.rb +5 -0
- data/spec/unit/pops/lookup/lookup_spec.rb +56 -0
- data/spec/unit/pops/model/pn_transformer_spec.rb +53 -0
- data/spec/unit/pops/parser/lexer2_spec.rb +14 -5
- data/spec/unit/pops/parser/parse_basic_expressions_spec.rb +9 -9
- data/spec/unit/pops/parser/parse_calls_spec.rb +1 -1
- data/spec/unit/pops/parser/parse_functions_spec.rb +1 -1
- data/spec/unit/pops/parser/parse_heredoc_spec.rb +3 -3
- data/spec/unit/pops/parser/parse_lambda_spec.rb +1 -1
- data/spec/unit/pops/parser/parse_resource_spec.rb +35 -35
- data/spec/unit/pops/parser/pn_parser_spec.rb +101 -0
- data/spec/unit/pops/pn_spec.rb +148 -0
- data/spec/unit/pops/types/iterable_spec.rb +1 -1
- data/spec/unit/pops/types/p_object_type_spec.rb +5 -5
- data/spec/unit/pops/types/p_timespan_type_spec.rb +11 -4
- data/spec/unit/pops/types/p_timestamp_type_spec.rb +9 -2
- data/spec/unit/pops/types/p_type_set_type_spec.rb +106 -2
- data/spec/unit/pops/types/ruby_generator_spec.rb +3 -8
- data/spec/unit/pops/types/string_converter_spec.rb +3 -3
- data/spec/unit/pops/types/type_calculator_spec.rb +1 -1
- data/spec/unit/pops/validator/validator_spec.rb +3 -1
- data/spec/unit/property_spec.rb +2 -2
- data/spec/unit/provider/aixobject_spec.rb +1 -1
- data/spec/unit/provider/cron/crontab_spec.rb +3 -3
- data/spec/unit/provider/exec/posix_spec.rb +6 -6
- data/spec/unit/provider/group/groupadd_spec.rb +4 -4
- data/spec/unit/provider/group/windows_adsi_spec.rb +79 -22
- data/spec/unit/provider/ldap_spec.rb +0 -1
- data/spec/unit/provider/nameservice_spec.rb +5 -5
- data/spec/unit/provider/package/rpm_spec.rb +3 -4
- data/spec/unit/provider/package/yum_spec.rb +6 -2
- data/spec/unit/provider/parsedfile_spec.rb +1 -1
- data/spec/unit/provider/service/base_spec.rb +2 -4
- data/spec/unit/provider/service/init_spec.rb +2 -2
- data/spec/unit/provider/service/openrc_spec.rb +2 -2
- data/spec/unit/provider/service/redhat_spec.rb +2 -2
- data/spec/unit/provider/service/smf_spec.rb +2 -0
- data/spec/unit/provider/service/systemd_spec.rb +3 -3
- data/spec/unit/provider/service/upstart_spec.rb +7 -7
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +0 -4
- data/spec/unit/provider/sshkey/parsed_spec.rb +0 -2
- data/spec/unit/provider/user/useradd_spec.rb +15 -9
- data/spec/unit/provider/user/windows_adsi_spec.rb +4 -4
- data/spec/unit/provider/yumrepo/inifile_spec.rb +76 -0
- data/spec/unit/puppet_pal_2pec.rb +4 -5
- data/spec/unit/resource/catalog_spec.rb +8 -3
- data/spec/unit/resource/status_spec.rb +15 -4
- data/spec/unit/resource/type_spec.rb +2 -3
- data/spec/unit/settings_spec.rb +9 -4
- data/spec/unit/ssl/certificate_authority_spec.rb +1 -9
- data/spec/unit/ssl/certificate_request_spec.rb +1 -2
- data/spec/unit/transaction/report_spec.rb +41 -0
- data/spec/unit/transaction_spec.rb +1 -1
- data/spec/unit/type/exec_spec.rb +7 -9
- data/spec/unit/type/file/selinux_spec.rb +0 -1
- data/spec/unit/type/file_spec.rb +4 -3
- data/spec/unit/type/k5login_spec.rb +79 -10
- data/spec/unit/type/mount_spec.rb +1 -1
- data/spec/unit/type/nagios_spec.rb +6 -6
- data/spec/unit/type/user_spec.rb +1 -1
- data/spec/unit/type/yumrepo_spec.rb +18 -0
- data/spec/unit/type/zfs_spec.rb +1 -1
- data/spec/unit/type_spec.rb +14 -15
- data/spec/unit/util/docs_spec.rb +1 -1
- data/spec/unit/util/execution_spec.rb +0 -1
- data/spec/unit/util/inifile_spec.rb +35 -4
- data/spec/unit/util/log/destinations_spec.rb +2 -2
- data/spec/unit/util/log_spec.rb +6 -5
- data/spec/unit/util/network_device/cisco/device_spec.rb +2 -2
- data/spec/unit/util/plist_spec.rb +3 -3
- data/spec/unit/util/selinux_spec.rb +2 -2
- data/spec/unit/util/tagging_spec.rb +1 -7
- data/spec/unit/util/windows/adsi_spec.rb +31 -27
- data/spec/unit/util/windows/sid_spec.rb +86 -15
- data/spec/unit/util_spec.rb +2 -2
- data/spec/watchr.rb +0 -1
- data/tasks/benchmark.rake +37 -0
- data/tasks/manpages.rake +1 -1
- metadata +71 -11
- checksums.yaml +0 -7
@@ -5,10 +5,6 @@ class Puppet::Node::Facts::Yaml < Puppet::Indirector::Yaml
|
|
5
5
|
desc "Store client facts as flat files, serialized using YAML, or
|
6
6
|
return deserialized facts from disk."
|
7
7
|
|
8
|
-
def allow_remote_requests?
|
9
|
-
false
|
10
|
-
end
|
11
|
-
|
12
8
|
def search(request)
|
13
9
|
node_names = []
|
14
10
|
Dir.glob(yaml_dir_path).each do |file|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'uri'
|
3
|
-
require 'json'
|
3
|
+
require 'puppet/util/json'
|
4
4
|
require 'semantic_puppet'
|
5
5
|
|
6
6
|
require 'puppet/network/http'
|
@@ -301,7 +301,7 @@ class Puppet::Indirector::REST < Puppet::Indirector::Terminus
|
|
301
301
|
elsif response['content-type'].is_a?(String)
|
302
302
|
content_type, body = parse_response(response)
|
303
303
|
if content_type =~ /[pj]son/
|
304
|
-
returned_message =
|
304
|
+
returned_message = Puppet::Util::Json.load(body)["message"]
|
305
305
|
else
|
306
306
|
returned_message = uncompress_body(response)
|
307
307
|
end
|
data/lib/puppet/module.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'puppet/util/logging'
|
2
2
|
require 'puppet/module/task'
|
3
|
-
require 'json'
|
3
|
+
require 'puppet/util/json'
|
4
4
|
require 'semantic_puppet/gem_version'
|
5
5
|
|
6
6
|
# Support for modules
|
@@ -202,10 +202,10 @@ class Puppet::Module
|
|
202
202
|
|
203
203
|
def read_metadata
|
204
204
|
md_file = metadata_file
|
205
|
-
md_file.nil? ? {} :
|
205
|
+
md_file.nil? ? {} : Puppet::Util::Json.load(File.read(md_file, :encoding => 'utf-8'))
|
206
206
|
rescue Errno::ENOENT
|
207
207
|
{}
|
208
|
-
rescue
|
208
|
+
rescue Puppet::Util::Json::ParseError => e
|
209
209
|
#TRANSLATORS 'metadata.json' is a specific file name and should not be translated.
|
210
210
|
msg = _("%{name} has an invalid and unparsable metadata.json file. The parse error: %{error}") % { name: name, error: e.message }
|
211
211
|
case Puppet[:strict]
|
data/lib/puppet/module/task.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'json'
|
2
1
|
require 'puppet/util/logging'
|
3
2
|
|
4
3
|
class Puppet::Module
|
@@ -72,8 +71,6 @@ class Puppet::Module
|
|
72
71
|
self.module == other.module
|
73
72
|
end
|
74
73
|
|
75
|
-
private
|
76
|
-
|
77
74
|
def self.new_with_files(pup_module, name, tasks_files)
|
78
75
|
files = tasks_files.map do |filename|
|
79
76
|
File.join(pup_module.tasks_directory, File.basename(filename))
|
@@ -82,9 +79,11 @@ class Puppet::Module
|
|
82
79
|
metadata_files, exe_files = files.partition { |f| is_tasks_metadata_filename?(f) }
|
83
80
|
Puppet::Module::Task.new(pup_module, name, exe_files, metadata_files.first)
|
84
81
|
end
|
82
|
+
private_class_method :new_with_files
|
85
83
|
|
86
84
|
def self.task_name_from_path(path)
|
87
85
|
return File.basename(path, '.*')
|
88
86
|
end
|
87
|
+
private_class_method :task_name_from_path
|
89
88
|
end
|
90
89
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'net/http'
|
2
|
-
require 'json'
|
2
|
+
require 'puppet/util/json'
|
3
3
|
require 'puppet/util/colors'
|
4
4
|
|
5
5
|
module Puppet::ModuleTool
|
@@ -26,7 +26,7 @@ module Puppet::ModuleTool
|
|
26
26
|
when Net::HTTPOK, Net::HTTPCreated
|
27
27
|
Puppet.notice success
|
28
28
|
else
|
29
|
-
errors =
|
29
|
+
errors = Puppet::Util::Json.load(response.body)['error'] rescue "HTTP #{response.code}, #{response.body}"
|
30
30
|
Puppet.warning "#{failure} (#{errors})"
|
31
31
|
end
|
32
32
|
end
|
@@ -48,8 +48,8 @@ module Puppet::ModuleTool
|
|
48
48
|
if File.file?(metadata_path)
|
49
49
|
File.open(metadata_path) do |f|
|
50
50
|
begin
|
51
|
-
@metadata.update(
|
52
|
-
rescue
|
51
|
+
@metadata.update(Puppet::Util::Json.load(f))
|
52
|
+
rescue Puppet::Util::Json::ParserError => ex
|
53
53
|
raise ArgumentError, _("Could not parse JSON %{metadata_path}") % { metadata_path: metadata_path }, ex.backtrace
|
54
54
|
end
|
55
55
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'fileutils'
|
2
|
-
require 'json'
|
2
|
+
require 'puppet/util/json'
|
3
3
|
require 'puppet/file_system'
|
4
4
|
require 'pathspec'
|
5
5
|
require 'facter'
|
@@ -140,7 +140,7 @@ module Puppet::ModuleTool
|
|
140
140
|
end
|
141
141
|
|
142
142
|
Puppet::FileSystem.open(File.join(build_path, 'checksums.json'), nil, 'wb') do |f|
|
143
|
-
f.write(
|
143
|
+
f.write(Puppet::Util::Json.dump(Checksums.new(build_path), :pretty => true))
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'json'
|
1
|
+
require 'puppet/util/json'
|
2
2
|
require 'puppet/module_tool/checksums'
|
3
3
|
|
4
4
|
module Puppet::ModuleTool
|
@@ -40,10 +40,10 @@ module Puppet::ModuleTool
|
|
40
40
|
|
41
41
|
def checksums
|
42
42
|
if checksums_file.exist?
|
43
|
-
|
43
|
+
Puppet::Util::Json.load(checksums_file.read)
|
44
44
|
elsif metadata_file.exist?
|
45
45
|
# Check metadata.json too; legacy modules store their checksums there.
|
46
|
-
|
46
|
+
Puppet::Util::Json.load(metadata_file.read)['checksums'] or
|
47
47
|
raise ArgumentError, _("No file containing checksums found.")
|
48
48
|
else
|
49
49
|
raise ArgumentError, _("No file containing checksums found.")
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'pathname'
|
2
2
|
require 'tmpdir'
|
3
|
-
require 'json'
|
3
|
+
require 'puppet/util/json'
|
4
4
|
require 'puppet/file_system'
|
5
5
|
|
6
6
|
module Puppet::ModuleTool
|
@@ -75,7 +75,7 @@ module Puppet::ModuleTool
|
|
75
75
|
|
76
76
|
# @api private
|
77
77
|
def module_name
|
78
|
-
metadata =
|
78
|
+
metadata = Puppet::Util::Json.load((root_dir + 'metadata.json').read)
|
79
79
|
metadata['name'][/-(.*)/, 1]
|
80
80
|
end
|
81
81
|
|
@@ -2,7 +2,7 @@ require 'puppet/util/methodhelper'
|
|
2
2
|
require 'puppet/module_tool'
|
3
3
|
require 'puppet/network/format_support'
|
4
4
|
require 'uri'
|
5
|
-
require 'json'
|
5
|
+
require 'puppet/util/json'
|
6
6
|
require 'set'
|
7
7
|
|
8
8
|
module Puppet::ModuleTool
|
@@ -102,8 +102,8 @@ module Puppet::ModuleTool
|
|
102
102
|
data = @data.dup.merge('dependencies' => dependencies)
|
103
103
|
|
104
104
|
contents = data.keys.map do |k|
|
105
|
-
value = (
|
106
|
-
"#{k.
|
105
|
+
value = (Puppet::Util::Json.dump(data[k], :pretty => true) rescue data[k].to_json)
|
106
|
+
%Q("#{k.to_s}": #{value})
|
107
107
|
end
|
108
108
|
|
109
109
|
"{\n" + contents.join(",\n").gsub(/^/, ' ') + "\n}\n"
|
@@ -38,7 +38,7 @@ module Puppet
|
|
38
38
|
{ :acl => "#{ca_url_prefix}/v1/certificate/", :method => :find, :authenticated => :any },
|
39
39
|
{ :acl => "#{ca_url_prefix}/v1/certificate_request", :method => [:find, :save], :authenticated => :any },
|
40
40
|
]
|
41
|
-
|
41
|
+
end
|
42
42
|
|
43
43
|
# Just proxy the setting methods to our rights stuff
|
44
44
|
[:allow, :deny].each do |method|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'puppet/network/format_handler'
|
2
|
-
require 'json'
|
2
|
+
require 'puppet/util/json'
|
3
3
|
|
4
4
|
Puppet::Network::FormatHandler.create_serialized_formats(:msgpack, :weight => 20, :mime => "application/x-msgpack", :required_methods => [:render_method, :intern_method], :intern_method => :from_data_hash) do
|
5
5
|
|
@@ -101,19 +101,17 @@ end
|
|
101
101
|
|
102
102
|
Puppet::Network::FormatHandler.create_serialized_formats(:json, :mime => 'application/json', :charset => Encoding::UTF_8, :weight => 15, :required_methods => [:render_method, :intern_method], :intern_method => :from_data_hash) do
|
103
103
|
def intern(klass, text)
|
104
|
-
data_to_instance(klass,
|
104
|
+
data_to_instance(klass, Puppet::Util::Json.load(text))
|
105
105
|
end
|
106
106
|
|
107
107
|
def intern_multiple(klass, text)
|
108
|
-
|
108
|
+
Puppet::Util::Json.load(text).collect do |data|
|
109
109
|
data_to_instance(klass, data)
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
113
|
-
# JSON monkey-patches Array, so this works.
|
114
|
-
# https://github.com/ruby/ruby/blob/ruby_1_9_3/ext/json/generator/generator.c#L1416
|
115
113
|
def render_multiple(instances)
|
116
|
-
instances
|
114
|
+
Puppet::Util::Json.dump(instances)
|
117
115
|
end
|
118
116
|
|
119
117
|
# Unlike PSON, we do not need to unwrap the data envelope, because legacy 3.x agents
|
@@ -162,7 +160,7 @@ Puppet::Network::FormatHandler.create(:console,
|
|
162
160
|
end
|
163
161
|
|
164
162
|
# ...or pretty-print the inspect outcome.
|
165
|
-
|
163
|
+
Puppet::Util::Json.dump(datum, :pretty => true, :quirks_mode => true)
|
166
164
|
end
|
167
165
|
|
168
166
|
def render_multiple(data)
|
@@ -265,6 +265,7 @@ class Puppet::Network::HTTP::API::IndirectedRoutes
|
|
265
265
|
# NOTE These specific hooks for paths are ridiculous, but it's a *many*-line
|
266
266
|
# fix to not need this, and our goal is to move away from the complication
|
267
267
|
# that leads to the fix being too long.
|
268
|
+
return :singular if indirection == "facts"
|
268
269
|
return :singular if indirection == "status"
|
269
270
|
return :singular if indirection == "certificate_status"
|
270
271
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'json'
|
1
|
+
require 'puppet/util/json'
|
2
2
|
require 'puppet/parser/environment_compiler'
|
3
3
|
|
4
4
|
class Puppet::Network::HTTP::API::Master::V3::Environment
|
@@ -15,7 +15,7 @@ class Puppet::Network::HTTP::API::Master::V3::Environment
|
|
15
15
|
|
16
16
|
env_graph = build_environment_graph(catalog)
|
17
17
|
|
18
|
-
response.respond_with(200, "application/json",
|
18
|
+
response.respond_with(200, "application/json", Puppet::Util::Json.dump(env_graph))
|
19
19
|
end
|
20
20
|
|
21
21
|
def build_environment_graph(catalog)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'json'
|
1
|
+
require 'puppet/util/json'
|
2
2
|
|
3
3
|
class Puppet::Network::HTTP::API::Master::V3::Environments
|
4
4
|
def initialize(env_loader)
|
@@ -6,7 +6,7 @@ class Puppet::Network::HTTP::API::Master::V3::Environments
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def call(request, response)
|
9
|
-
response.respond_with(200, "application/json",
|
9
|
+
response.respond_with(200, "application/json", Puppet::Util::Json.dump({
|
10
10
|
"search_paths" => @env_loader.search_paths,
|
11
11
|
"environments" => Hash[@env_loader.list.collect do |env|
|
12
12
|
[env.name, {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'json'
|
1
|
+
require 'puppet/util/json'
|
2
2
|
|
3
3
|
module Puppet::Network::HTTP::Error
|
4
4
|
Issues = Puppet::Network::HTTP::Issues
|
@@ -13,7 +13,7 @@ module Puppet::Network::HTTP::Error
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def to_json
|
16
|
-
|
16
|
+
Puppet::Util::Json.dump({:message => message, :issue_kind => @issue_kind})
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -67,7 +67,7 @@ module Puppet::Network::HTTP::Error
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def to_json
|
70
|
-
|
70
|
+
Puppet::Util::Json.dump({:message => message, :issue_kind => @issue_kind})
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
@@ -40,8 +40,6 @@ module Puppet::Network::Resolver
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
private
|
44
|
-
|
45
43
|
def self.each_priority(records)
|
46
44
|
pri_hash = records.inject({}) do |groups, element|
|
47
45
|
groups[element.priority] ||= []
|
@@ -53,6 +51,7 @@ module Puppet::Network::Resolver
|
|
53
51
|
yield key, pri_hash[key]
|
54
52
|
end
|
55
53
|
end
|
54
|
+
private_class_method :each_priority
|
56
55
|
|
57
56
|
def self.find_weighted_server(records)
|
58
57
|
return nil if records.nil? || records.empty?
|
@@ -41,7 +41,7 @@ class Puppet::Parser::Compiler
|
|
41
41
|
message = _("%{message} on node %{node}") % { message: detail, node: node.name }
|
42
42
|
Puppet.log_exception(detail, message)
|
43
43
|
raise Puppet::Error, message, detail.backtrace
|
44
|
-
|
44
|
+
end
|
45
45
|
|
46
46
|
attr_reader :node, :facts, :collections, :catalog, :resources, :relationships, :topscope
|
47
47
|
attr_reader :qualified_variables
|
@@ -460,10 +460,10 @@ class Puppet::Parser::Compiler
|
|
460
460
|
component_ref = args['component']
|
461
461
|
kind = args['kind']
|
462
462
|
|
463
|
-
# That component_ref is either a
|
463
|
+
# That component_ref is either a QREF or a Class['literal'|QREF] is asserted during validation so no
|
464
464
|
# need to check that here
|
465
|
-
if component_ref.is_a?(Puppet::Pops::Model::
|
466
|
-
component_name = component_ref.
|
465
|
+
if component_ref.is_a?(Puppet::Pops::Model::QualifiedReference)
|
466
|
+
component_name = component_ref.cased_value
|
467
467
|
component_type = 'type'
|
468
468
|
component = krt.find_definition(component_name)
|
469
469
|
else
|
@@ -664,7 +664,7 @@ class Puppet::Parser::Compiler
|
|
664
664
|
data[target] = source_data.merge(metaparams_as_data(target, names))
|
665
665
|
end
|
666
666
|
|
667
|
-
target.
|
667
|
+
target.merge_tags_from(source)
|
668
668
|
end
|
669
669
|
end
|
670
670
|
|
@@ -747,9 +747,16 @@ class Puppet::Parser::Compiler
|
|
747
747
|
# Set the node's parameters into the top-scope as variables.
|
748
748
|
def set_node_parameters
|
749
749
|
node.parameters.each do |param, value|
|
750
|
+
# We don't want to set @topscope['environment'] from the parameters,
|
751
|
+
# instead we want to get that from the node's environment itself in
|
752
|
+
# case a custom node terminus has done any mucking about with
|
753
|
+
# node.parameters.
|
754
|
+
next if param.to_s == 'environment'
|
750
755
|
# Ensure node does not leak Symbol instances in general
|
751
756
|
@topscope[param.to_s] = value.is_a?(Symbol) ? value.to_s : value
|
752
757
|
end
|
758
|
+
@topscope['environment'] = node.environment.name.to_s
|
759
|
+
|
753
760
|
# These might be nil.
|
754
761
|
catalog.client_version = node.parameters["clientversion"]
|
755
762
|
catalog.server_version = node.parameters["serverversion"]
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class Puppet::Parser::Compiler
|
2
2
|
# Validator that asserts that all capability resources that are referenced by 'consume' or 'require' has
|
3
3
|
# been exported by some other resource in the environment
|
4
|
-
|
4
|
+
class CatalogValidator::EnvironmentRelationshipValidator < CatalogValidator
|
5
5
|
|
6
6
|
def validate
|
7
7
|
assumed_exports = {}
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'digest/md5'
|
1
2
|
require 'digest/sha2'
|
2
3
|
|
3
4
|
Puppet::Parser::Functions::newfunction(:fqdn_rand, :arity => -2, :type => :rvalue, :doc =>
|
@@ -17,9 +18,19 @@ Puppet::Parser::Functions::newfunction(:fqdn_rand, :arity => -2, :type => :rvalu
|
|
17
18
|
`fqdn_rand(30, 'expensive job 2')` will produce totally different numbers.)") do |args|
|
18
19
|
max = args.shift.to_i
|
19
20
|
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
|
21
|
+
# Puppet 5.4's fqdn_rand function produces a different value than earlier versions
|
22
|
+
# for the same set of inputs.
|
23
|
+
# This causes problems because the values are often written into service configuration files.
|
24
|
+
# When they change, services get notified and restart.
|
25
|
+
|
26
|
+
# Restoring previous fqdn_rand behavior of calculating its seed value using MD5
|
27
|
+
# when running on a non-FIPS enabled platform and only using SHA256 on FIPS enabled
|
28
|
+
# platforms.
|
29
|
+
if Puppet::Util::Platform.fips_enabled?
|
30
|
+
seed = Digest::SHA256.hexdigest([self['::fqdn'],max,args].join(':')).hex
|
31
|
+
else
|
32
|
+
seed = Digest::MD5.hexdigest([self['::fqdn'],max,args].join(':')).hex
|
33
|
+
end
|
34
|
+
|
24
35
|
Puppet::Util.deterministic_rand_int(seed,max)
|
25
36
|
end
|
@@ -56,16 +56,14 @@ Would fail with an assertion error (since value is less than 0).
|
|
56
56
|
The following sections show the arguments and conversion rules
|
57
57
|
per data type built into the Puppet Type System.
|
58
58
|
|
59
|
-
Conversion to Optional[T] and NotUndef[T]
|
60
|
-
-----------------------------------------
|
59
|
+
### Conversion to Optional[T] and NotUndef[T]
|
61
60
|
|
62
61
|
Conversion to these data types is the same as a conversion to the type argument `T`.
|
63
62
|
In the case of `Optional[T]` it is accepted that the argument to convert may be `undef`.
|
64
63
|
It is however not acceptable to give other arguments (than `undef`) that cannot be
|
65
64
|
converted to `T`.
|
66
65
|
|
67
|
-
Conversion to Integer
|
68
|
-
---------------------
|
66
|
+
### Conversion to Integer
|
69
67
|
|
70
68
|
A new `Integer` can be created from `Integer`, `Float`, `Boolean`, and `String` values.
|
71
69
|
For conversion from `String` it is possible to specify the radix (base).
|
@@ -113,8 +111,7 @@ $a_number = Integer(true) # results in 1
|
|
113
111
|
$a_number = Integer(-38, 10, true) # results in 38
|
114
112
|
```
|
115
113
|
|
116
|
-
Conversion to Float
|
117
|
-
-------------------
|
114
|
+
### Conversion to Float
|
118
115
|
|
119
116
|
A new `Float` can be created from `Integer`, `Float`, `Boolean`, and `String` values.
|
120
117
|
For conversion from `String` both float and integer formats are supported.
|
@@ -126,15 +123,13 @@ function Float.new(
|
|
126
123
|
)
|
127
124
|
```
|
128
125
|
|
129
|
-
|
130
126
|
* For an integer, the floating point fraction of `.0` is added to the value.
|
131
127
|
* A `Boolean` `true` is converted to 1.0, and a `false` to 0.0
|
132
128
|
* In `String` format, integer prefixes for hex and binary are understood (but not octal since
|
133
129
|
floating point in string format may start with a '0').
|
134
130
|
* When `abs` is set to `true`, the result will be an absolute floating point value.
|
135
131
|
|
136
|
-
Conversion to Numeric
|
137
|
-
---------------------
|
132
|
+
### Conversion to Numeric
|
138
133
|
|
139
134
|
A new `Integer` or `Float` can be created from `Integer`, `Float`, `Boolean` and
|
140
135
|
`String` values.
|
@@ -163,8 +158,7 @@ $a_number = Numeric(-42.3, true) # results in 42.3
|
|
163
158
|
$a_number = Numeric(-42, true) # results in 42
|
164
159
|
```
|
165
160
|
|
166
|
-
Conversion to Timespan
|
167
|
-
-------------------
|
161
|
+
### Conversion to Timespan
|
168
162
|
|
169
163
|
A new `Timespan` can be created from `Integer`, `Float`, `String`, and `Hash` values. Several variants of the constructor are provided.
|
170
164
|
|
@@ -281,8 +275,7 @@ $duration = Timespan('10:03.5', '%M:%S.%L') # 10 minutes, 3 seconds, and 5 milli
|
|
281
275
|
$duration = Timespan('10:03.5', '%M:%S.%N') # 10 minutes, 3 seconds, and 5 nano-seconds
|
282
276
|
```
|
283
277
|
|
284
|
-
Conversion to Timestamp
|
285
|
-
-------------------
|
278
|
+
### Conversion to Timestamp
|
286
279
|
|
287
280
|
A new `Timestamp` can be created from `Integer`, `Float`, `String`, and `Hash` values. Several variants of the constructor are provided.
|
288
281
|
|
@@ -475,8 +468,8 @@ $ts = Timestamp('2016-08-24T12:13:14', default, 'PST') # 2016-08-24 20:13:14.0
|
|
475
468
|
|
476
469
|
```
|
477
470
|
|
478
|
-
Conversion to Type
|
479
|
-
|
471
|
+
### Conversion to Type
|
472
|
+
|
480
473
|
A new `Type` can be create from its `String` representation.
|
481
474
|
|
482
475
|
**Example:** Creating a type from a string
|
@@ -485,8 +478,7 @@ A new `Type` can be create from its `String` representation.
|
|
485
478
|
$t = Type.new('Integer[10]')
|
486
479
|
```
|
487
480
|
|
488
|
-
Conversion to String
|
489
|
-
--------------------
|
481
|
+
### Conversion to String
|
490
482
|
|
491
483
|
Conversion to `String` is the most comprehensive conversion as there are many
|
492
484
|
use cases where a string representation is wanted. The defaults for the many options
|
@@ -529,7 +521,7 @@ included in a string format.
|
|
529
521
|
Note that all data type supports the formats `s` and `p` with the meaning "default string representation" and
|
530
522
|
"default programmatic string representation" (which for example means that a String is quoted in 'p' format).
|
531
523
|
|
532
|
-
|
524
|
+
#### Signatures of String conversion
|
533
525
|
|
534
526
|
```puppet
|
535
527
|
type Format = Pattern[/^%([\s\+\-#0\[\{<\(\|]*)([1-9][0-9]*)?(?:\.([0-9]+))?([a-zA-Z])/]
|
@@ -587,7 +579,7 @@ $str = String([1,2,3], $formats) # produces '(0x1, 0x2, 0x3)'
|
|
587
579
|
The given formats are merged with the default formats, and matching of values to convert against format is based on
|
588
580
|
the specificity of the mapped type; for example, different formats can be used for short and long arrays.
|
589
581
|
|
590
|
-
|
582
|
+
#### Integer to String
|
591
583
|
|
592
584
|
| Format | Integer Formats
|
593
585
|
| ------ | ---------------
|
@@ -602,7 +594,7 @@ the specificity of the mapped type; for example, different formats can be used f
|
|
602
594
|
|
603
595
|
Defaults to `d`.
|
604
596
|
|
605
|
-
|
597
|
+
#### Float to String
|
606
598
|
|
607
599
|
| Format | Float formats
|
608
600
|
| ------ | -------------
|
@@ -616,7 +608,7 @@ Defaults to `d`.
|
|
616
608
|
|
617
609
|
Defaults to `p`.
|
618
610
|
|
619
|
-
|
611
|
+
#### String to String
|
620
612
|
|
621
613
|
| Format | String
|
622
614
|
| ------ | ------
|
@@ -630,7 +622,7 @@ Defaults to `p`.
|
|
630
622
|
|
631
623
|
Defaults to `s` at top level and `p` inside array or hash.
|
632
624
|
|
633
|
-
|
625
|
+
#### Boolean to String
|
634
626
|
|
635
627
|
| Format | Boolean Formats
|
636
628
|
| ---- | -------------------
|
@@ -641,14 +633,14 @@ Defaults to `s` at top level and `p` inside array or hash.
|
|
641
633
|
| s | String 'true' / 'false'.
|
642
634
|
| p | String 'true' / 'false'.
|
643
635
|
|
644
|
-
|
636
|
+
#### Regexp to String
|
645
637
|
|
646
638
|
| Format | Regexp Formats
|
647
639
|
| ---- | --------------
|
648
640
|
| s | No delimiters, quoted if alternative flag `#` is used.
|
649
641
|
| p | Delimiters `/ /`.
|
650
642
|
|
651
|
-
|
643
|
+
#### Undef to String
|
652
644
|
|
653
645
|
| Format | Undef formats
|
654
646
|
| ------ | -------------
|
@@ -661,7 +653,7 @@ Defaults to `s` at top level and `p` inside array or hash.
|
|
661
653
|
| V | String 'N/A'.
|
662
654
|
| u | String 'undef', or 'undefined' if alternative `#` flag is used.
|
663
655
|
|
664
|
-
|
656
|
+
#### Default value to String
|
665
657
|
|
666
658
|
| Format | Default formats
|
667
659
|
| ------ | ---------------
|
@@ -669,7 +661,7 @@ Defaults to `s` at top level and `p` inside array or hash.
|
|
669
661
|
| s | Same as d.
|
670
662
|
| p | Same as d.
|
671
663
|
|
672
|
-
|
664
|
+
#### Binary value to String
|
673
665
|
|
674
666
|
| Format | Default formats
|
675
667
|
| ------ | ---------------
|
@@ -686,7 +678,7 @@ Defaults to `s` at top level and `p` inside array or hash.
|
|
686
678
|
as hex escaped characters on the form `\\xHH` where `H` is a hex digit.
|
687
679
|
* The width and precision values are applied to the text part only in `%p` format.
|
688
680
|
|
689
|
-
|
681
|
+
#### Array & Tuple to String
|
690
682
|
|
691
683
|
| Format | Array/Tuple Formats
|
692
684
|
| ------ | -------------
|
@@ -701,7 +693,7 @@ The alternate form flag `#` will cause indentation of nested array or hash conta
|
|
701
693
|
it is taken as the maximum allowed length of a sequence of elements (not including delimiters). If this max length
|
702
694
|
is exceeded, each element will be indented.
|
703
695
|
|
704
|
-
|
696
|
+
#### Hash & Struct to String
|
705
697
|
|
706
698
|
| Format | Hash/Struct Formats
|
707
699
|
| ------ | -------------
|
@@ -715,14 +707,14 @@ more information about options.
|
|
715
707
|
|
716
708
|
The alternate form flag `#` will format each hash key/value entry indented on a separate line.
|
717
709
|
|
718
|
-
|
710
|
+
#### Type to String
|
719
711
|
|
720
712
|
| Format | Array/Tuple Formats
|
721
713
|
| ------ | -------------
|
722
714
|
| s | The same as `p`, quoted if alternative flag `#` is used.
|
723
715
|
| p | Outputs the type in string form as specified by the Puppet Language.
|
724
716
|
|
725
|
-
|
717
|
+
#### Flags
|
726
718
|
|
727
719
|
| Flag | Effect
|
728
720
|
| ------ | ------
|
@@ -733,8 +725,7 @@ The alternate form flag `#` will format each hash key/value entry indented on a
|
|
733
725
|
| 0 | Pad with 0 instead of space for widths larger than value.
|
734
726
|
| <[({\| | Defines an enclosing pair <> [] () {} or \| \| when used with a container type.
|
735
727
|
|
736
|
-
Conversion to Boolean
|
737
|
-
---
|
728
|
+
### Conversion to Boolean
|
738
729
|
|
739
730
|
Accepts a single value as argument:
|
740
731
|
|
@@ -745,8 +736,7 @@ Accepts a single value as argument:
|
|
745
736
|
* `false` if 'false', 'no', 'n' (case independent compare)
|
746
737
|
* Boolean is already boolean and is simply returned
|
747
738
|
|
748
|
-
Conversion to Array and Tuple
|
749
|
-
---
|
739
|
+
### Conversion to Array and Tuple
|
750
740
|
|
751
741
|
When given a single value as argument:
|
752
742
|
|
@@ -771,8 +761,7 @@ $arr = Array($value, true)
|
|
771
761
|
Conversion to a `Tuple` works exactly as conversion to an `Array`, only that the constructed array is
|
772
762
|
asserted against the given tuple type.
|
773
763
|
|
774
|
-
Conversion to Hash and Struct
|
775
|
-
---
|
764
|
+
### Conversion to Hash and Struct
|
776
765
|
|
777
766
|
Accepts a single value as argument:
|
778
767
|
|
@@ -811,8 +800,8 @@ Would notice the hash `{a => {b => {x => wine}}, b => {y => wine}}`
|
|
811
800
|
Conversion to a `Struct` works exactly as conversion to a `Hash`, only that the constructed hash is
|
812
801
|
asserted against the given struct type.
|
813
802
|
|
814
|
-
Conversion to a Regexp
|
815
|
-
|
803
|
+
### Conversion to a Regexp
|
804
|
+
|
816
805
|
A `String` can be converted into a `Regexp`
|
817
806
|
|
818
807
|
**Example**: Converting a String into a Regexp
|
@@ -824,8 +813,7 @@ if('foo.com' =~ $r) {
|
|
824
813
|
}
|
825
814
|
```
|
826
815
|
|
827
|
-
Creating a SemVer
|
828
|
-
---
|
816
|
+
### Creating a SemVer
|
829
817
|
|
830
818
|
A SemVer object represents a single [Semantic Version](http://semver.org/).
|
831
819
|
It can be created from a String, individual values for its parts, or a hash specifying the value per part.
|
@@ -874,8 +862,7 @@ notice(SemVer('2.3.4') =~ $t) # false
|
|
874
862
|
notice(SemVer('3.4.5') =~ $t) # true
|
875
863
|
```
|
876
864
|
|
877
|
-
Creating a SemVerRange
|
878
|
-
---
|
865
|
+
### Creating a SemVerRange
|
879
866
|
|
880
867
|
A `SemVerRange` object represents a range of `SemVer`. It can be created from
|
881
868
|
a `String`, or from two `SemVer` instances, where either end can be given as
|
@@ -909,10 +896,9 @@ function SemVerRange.new(
|
|
909
896
|
)
|
910
897
|
```
|
911
898
|
|
912
|
-
For examples of `SemVerRange` use see "Creating a SemVer"
|
899
|
+
For examples of `SemVerRange` use, see "Creating a SemVer".
|
913
900
|
|
914
|
-
Creating a Binary
|
915
|
-
---
|
901
|
+
### Creating a Binary
|
916
902
|
|
917
903
|
A `Binary` object represents a sequence of bytes and it can be created from a String in Base64 format,
|
918
904
|
an Array containing byte values. A Binary can also be created from a Hash containing the value to convert to
|
@@ -932,7 +918,6 @@ function Binary.new(
|
|
932
918
|
Optional[Base64Format] $format
|
933
919
|
)
|
934
920
|
|
935
|
-
|
936
921
|
function Binary.new(
|
937
922
|
Array[ByteInteger] $byte_array
|
938
923
|
}
|