puppet 4.5.3-universal-darwin → 4.6.1-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 +7 -0
- data/Gemfile +10 -1
- data/ext/debian/control +2 -4
- data/ext/project_data.yaml +4 -4
- data/install.rb +6 -2
- data/lib/puppet.rb +3 -1
- data/lib/puppet/agent/locker.rb +1 -1
- data/lib/puppet/application.rb +6 -4
- data/lib/puppet/application/agent.rb +2 -1
- data/lib/puppet/application/cert.rb +35 -2
- data/lib/puppet/application/device.rb +1 -1
- data/lib/puppet/application/generate.rb +5 -0
- data/lib/puppet/application/lookup.rb +3 -3
- data/lib/puppet/application_support.rb +1 -1
- data/lib/puppet/compilable_resource_type.rb +15 -0
- data/lib/puppet/configurer.rb +67 -10
- data/lib/puppet/configurer/plugin_handler.rb +2 -4
- data/lib/puppet/data_providers/hiera_config.rb +1 -1
- data/lib/puppet/defaults.rb +34 -7
- data/lib/puppet/environments.rb +4 -2
- data/lib/puppet/error.rb +1 -1
- data/lib/puppet/external/dot.rb +1 -1
- data/lib/puppet/face/ca.rb +4 -1
- data/lib/puppet/face/certificate.rb +7 -1
- data/lib/puppet/face/epp.rb +5 -5
- data/lib/puppet/face/generate.rb +64 -0
- data/lib/puppet/face/help.rb +19 -13
- data/lib/puppet/face/man.rb +1 -1
- data/lib/puppet/feature/external_facts.rb +1 -1
- data/lib/puppet/file_system.rb +16 -0
- data/lib/puppet/file_system/file_impl.rb +5 -0
- data/lib/puppet/file_system/memory_impl.rb +4 -0
- data/lib/puppet/file_system/path_pattern.rb +1 -0
- data/lib/puppet/file_system/windows.rb +19 -0
- data/lib/puppet/functions.rb +3 -5
- data/lib/puppet/functions/assert_type.rb +1 -1
- data/lib/puppet/functions/defined.rb +7 -5
- data/lib/puppet/functions/dig.rb +2 -18
- data/lib/puppet/functions/hiera.rb +1 -1
- data/lib/puppet/functions/lest.rb +1 -37
- data/lib/puppet/functions/new.rb +2 -473
- data/lib/puppet/functions/reverse_each.rb +2 -59
- data/lib/puppet/functions/scanf.rb +4 -4
- data/lib/puppet/functions/step.rb +1 -63
- data/lib/puppet/functions/then.rb +1 -61
- data/lib/puppet/functions/type.rb +1 -40
- data/lib/puppet/functions/unwrap.rb +40 -0
- data/lib/puppet/generate/models/type/property.rb +70 -0
- data/lib/puppet/generate/models/type/type.rb +57 -0
- data/lib/puppet/generate/templates/type/pcore.erb +41 -0
- data/lib/puppet/generate/type.rb +239 -0
- data/lib/puppet/graph/simple_graph.rb +2 -6
- data/lib/puppet/indirector/catalog/static_compiler.rb +5 -2
- data/lib/puppet/indirector/facts/facter.rb +1 -1
- data/lib/puppet/indirector/key/ca.rb +2 -2
- data/lib/puppet/indirector/request.rb +25 -4
- data/lib/puppet/indirector/rest.rb +73 -3
- data/lib/puppet/info_service/class_information_service.rb +1 -2
- data/lib/puppet/interface/documentation.rb +1 -1
- data/lib/puppet/loaders.rb +2 -0
- data/lib/puppet/metatype/manager.rb +6 -6
- data/lib/puppet/module.rb +8 -1
- data/lib/puppet/module_tool.rb +2 -2
- data/lib/puppet/module_tool/checksums.rb +1 -1
- data/lib/puppet/module_tool/errors/installer.rb +2 -2
- data/lib/puppet/module_tool/metadata.rb +1 -1
- data/lib/puppet/network/http/api/indirected_routes.rb +23 -32
- data/lib/puppet/network/http/rack/rest.rb +15 -1
- data/lib/puppet/network/rights.rb +1 -11
- data/lib/puppet/node/environment.rb +7 -3
- data/lib/puppet/node/facts.rb +1 -1
- data/lib/puppet/parameter.rb +23 -3
- data/lib/puppet/parameter/boolean.rb +1 -1
- data/lib/puppet/parameter/value.rb +1 -1
- data/lib/puppet/parser.rb +0 -1
- data/lib/puppet/parser/ast/pops_bridge.rb +1 -1
- data/lib/puppet/parser/ast/resource.rb +5 -0
- data/lib/puppet/parser/ast/resource_instance.rb +5 -1
- data/lib/puppet/parser/ast/resourceparam.rb +5 -0
- data/lib/puppet/parser/compiler.rb +14 -17
- data/lib/puppet/parser/compiler/catalog_validator/relationship_validator.rb +1 -1
- data/lib/puppet/parser/environment_compiler.rb +10 -0
- data/lib/puppet/parser/functions/create_resources.rb +39 -24
- data/lib/puppet/parser/functions/defined.rb +2 -26
- data/lib/puppet/parser/functions/dig.rb +29 -0
- data/lib/puppet/parser/functions/lest.rb +49 -0
- data/lib/puppet/parser/functions/new.rb +530 -0
- data/lib/puppet/parser/functions/require.rb +1 -1
- data/lib/puppet/parser/functions/reverse_each.rb +83 -0
- data/lib/puppet/parser/functions/scanf.rb +4 -4
- data/lib/puppet/parser/functions/step.rb +84 -0
- data/lib/puppet/parser/functions/then.rb +73 -0
- data/lib/puppet/parser/functions/type.rb +53 -0
- data/lib/puppet/parser/resource.rb +16 -7
- data/lib/puppet/parser/scope.rb +36 -28
- data/lib/puppet/parser/type_loader.rb +1 -1
- data/lib/puppet/plugins/data_providers/data_provider.rb +1 -1
- data/lib/puppet/pops.rb +13 -0
- data/lib/puppet/pops/adapters.rb +49 -49
- data/lib/puppet/pops/binder/scheme_handler/confdir_scheme.rb +1 -1
- data/lib/puppet/pops/evaluator/access_operator.rb +39 -2
- data/lib/puppet/pops/evaluator/closure.rb +39 -13
- data/lib/puppet/pops/evaluator/collector_transformer.rb +10 -1
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +16 -11
- data/lib/puppet/pops/evaluator/external_syntax_support.rb +1 -1
- data/lib/puppet/pops/evaluator/json_strict_literal_evaluator.rb +0 -1
- data/lib/puppet/pops/evaluator/literal_evaluator.rb +0 -1
- data/lib/puppet/pops/evaluator/relationship_operator.rb +1 -2
- data/lib/puppet/pops/evaluator/runtime3_resource_support.rb +119 -0
- data/lib/puppet/pops/evaluator/runtime3_support.rb +19 -45
- data/lib/puppet/pops/functions/function.rb +5 -0
- data/lib/puppet/pops/issues.rb +1 -1
- data/lib/puppet/pops/label_provider.rb +2 -2
- data/lib/puppet/pops/loader/base_loader.rb +12 -15
- data/lib/puppet/pops/loader/loader.rb +15 -50
- data/lib/puppet/pops/loader/loader_paths.rb +28 -2
- data/lib/puppet/pops/loader/module_loaders.rb +16 -1
- data/lib/puppet/pops/loader/null_loader.rb +17 -1
- data/lib/puppet/pops/loader/puppet_function_instantiator.rb +12 -11
- data/lib/puppet/pops/loader/puppet_resource_type_impl_instantiator.rb +80 -0
- data/lib/puppet/pops/loader/ruby_function_instantiator.rb +2 -3
- data/lib/puppet/pops/loader/runtime3_type_loader.rb +52 -13
- data/lib/puppet/pops/loader/static_loader.rb +55 -0
- data/lib/puppet/pops/loader/type_definition_instantiator.rb +30 -14
- data/lib/puppet/pops/loader/typed_name.rb +50 -0
- data/lib/puppet/pops/loaders.rb +64 -19
- data/lib/puppet/pops/merge_strategy.rb +7 -7
- data/lib/puppet/pops/migration/migration_checker.rb +4 -0
- data/lib/puppet/pops/model/model_label_provider.rb +2 -0
- data/lib/puppet/pops/parser/egrammar.ra +8 -5
- data/lib/puppet/pops/parser/eparser.rb +1550 -1498
- data/lib/puppet/pops/parser/evaluating_parser.rb +1 -1
- data/lib/puppet/pops/parser/interpolation_support.rb +7 -0
- data/lib/puppet/pops/parser/lexer2.rb +14 -1
- data/lib/puppet/pops/parser/locator.rb +30 -1
- data/lib/puppet/pops/parser/parser_support.rb +0 -3
- data/lib/puppet/pops/parser/slurp_support.rb +3 -3
- data/lib/puppet/pops/patterns.rb +9 -1
- data/lib/puppet/pops/pcore.rb +67 -11
- data/lib/puppet/pops/puppet_stack.rb +43 -0
- data/lib/puppet/pops/resource/param.rb +51 -0
- data/lib/puppet/pops/resource/resource_type_impl.rb +301 -0
- data/lib/puppet/pops/resource/resource_type_set.pcore +21 -0
- data/lib/puppet/pops/serialization.rb +17 -0
- data/lib/puppet/pops/serialization/abstract_reader.rb +149 -0
- data/lib/puppet/pops/serialization/abstract_writer.rb +179 -0
- data/lib/puppet/pops/serialization/deserializer.rb +60 -0
- data/lib/puppet/pops/serialization/extension.rb +126 -0
- data/lib/puppet/pops/serialization/instance_reader.rb +19 -0
- data/lib/puppet/pops/serialization/instance_writer.rb +14 -0
- data/lib/puppet/pops/serialization/json.rb +247 -0
- data/lib/puppet/pops/serialization/object.rb +63 -0
- data/lib/puppet/pops/serialization/rgen.rb +151 -0
- data/lib/puppet/pops/serialization/serializer.rb +91 -0
- data/lib/puppet/pops/serialization/time_factory.rb +66 -0
- data/lib/puppet/pops/types/annotatable.rb +36 -0
- data/lib/puppet/pops/types/implementation_registry.rb +3 -8
- data/lib/puppet/pops/types/p_meta_type.rb +83 -0
- data/lib/puppet/pops/types/p_object_type.rb +110 -117
- data/lib/puppet/pops/types/p_runtime_type.rb +13 -0
- data/lib/puppet/pops/types/p_sem_ver_range_type.rb +23 -0
- data/lib/puppet/pops/types/p_sem_ver_type.rb +30 -2
- data/lib/puppet/pops/types/p_sensitive_type.rb +69 -0
- data/lib/puppet/pops/types/p_type_set_type.rb +361 -0
- data/lib/puppet/pops/types/puppet_object.rb +0 -5
- data/lib/puppet/pops/types/ruby_generator.rb +9 -2
- data/lib/puppet/pops/types/type_calculator.rb +6 -1
- data/lib/puppet/pops/types/type_factory.rb +14 -12
- data/lib/puppet/pops/types/type_formatter.rb +78 -33
- data/lib/puppet/pops/types/type_mismatch_describer.rb +0 -2
- data/lib/puppet/pops/types/type_parser.rb +27 -2
- data/lib/puppet/pops/types/type_set_reference.rb +59 -0
- data/lib/puppet/pops/types/types.rb +366 -13
- data/lib/puppet/pops/validation.rb +4 -4
- data/lib/puppet/pops/validation/checker4_0.rb +5 -2
- data/lib/puppet/pops/visitor.rb +2 -2
- data/lib/puppet/property.rb +64 -5
- data/lib/puppet/provider.rb +1 -1
- data/lib/puppet/provider/aixobject.rb +3 -3
- data/lib/puppet/provider/group/aix.rb +4 -4
- data/lib/puppet/provider/macauthorization/macauthorization.rb +1 -1
- data/lib/puppet/provider/mailalias/aliases.rb +1 -1
- data/lib/puppet/provider/mcx/mcxcontent.rb +2 -2
- data/lib/puppet/provider/mount/parsed.rb +1 -1
- data/lib/puppet/provider/nameservice/directoryservice.rb +5 -5
- data/lib/puppet/provider/package/appdmg.rb +3 -3
- data/lib/puppet/provider/package/apple.rb +1 -1
- data/lib/puppet/provider/package/dnf.rb +5 -0
- data/lib/puppet/provider/package/nim.rb +1 -1
- data/lib/puppet/provider/package/pacman.rb +2 -2
- data/lib/puppet/provider/package/pip.rb +5 -3
- data/lib/puppet/provider/package/pip3.rb +1 -1
- data/lib/puppet/provider/package/pkg.rb +5 -5
- data/lib/puppet/provider/package/pkgdmg.rb +4 -4
- data/lib/puppet/provider/package/pkgin.rb +1 -1
- data/lib/puppet/provider/package/pkgutil.rb +1 -1
- data/lib/puppet/provider/package/portage.rb +48 -8
- data/lib/puppet/provider/package/sun.rb +1 -1
- data/lib/puppet/provider/package/tdnf.rb +28 -0
- data/lib/puppet/provider/package/yum.rb +22 -4
- data/lib/puppet/provider/parsedfile.rb +2 -2
- data/lib/puppet/provider/service/base.rb +1 -1
- data/lib/puppet/provider/service/bsd.rb +1 -1
- data/lib/puppet/provider/service/daemontools.rb +2 -2
- data/lib/puppet/provider/service/debian.rb +3 -3
- data/lib/puppet/provider/service/init.rb +5 -3
- data/lib/puppet/provider/service/launchd.rb +16 -2
- data/lib/puppet/provider/service/runit.rb +1 -1
- data/lib/puppet/provider/service/smf.rb +8 -1
- data/lib/puppet/provider/service/systemd.rb +39 -6
- 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/directoryservice.rb +4 -3
- data/lib/puppet/provider/user/hpux.rb +1 -1
- data/lib/puppet/provider/user/user_role_add.rb +1 -1
- data/lib/puppet/provider/user/windows_adsi.rb +3 -0
- data/lib/puppet/provider/zfs/zfs.rb +1 -1
- data/lib/puppet/reference/type.rb +1 -1
- data/lib/puppet/resource.rb +33 -7
- data/lib/puppet/resource/capability_finder.rb +74 -54
- data/lib/puppet/resource/status.rb +11 -2
- data/lib/puppet/settings.rb +17 -6
- data/lib/puppet/settings/environment_conf.rb +1 -1
- data/lib/puppet/settings/server_list_setting.rb +20 -0
- data/lib/puppet/ssl/certificate_authority.rb +32 -9
- data/lib/puppet/ssl/certificate_authority/interface.rb +164 -24
- data/lib/puppet/ssl/host.rb +3 -3
- data/lib/puppet/ssl/oids.rb +10 -0
- data/lib/puppet/ssl/validator/default_validator.rb +2 -2
- data/lib/puppet/test/test_helper.rb +2 -2
- data/lib/puppet/transaction.rb +12 -0
- data/lib/puppet/transaction/additional_resource_generator.rb +1 -1
- data/lib/puppet/transaction/event.rb +29 -2
- data/lib/puppet/transaction/event_manager.rb +1 -1
- data/lib/puppet/transaction/persistence.rb +84 -0
- data/lib/puppet/transaction/report.rb +49 -2
- data/lib/puppet/transaction/resource_harness.rb +98 -18
- data/lib/puppet/type.rb +63 -21
- data/lib/puppet/type/augeas.rb +3 -3
- data/lib/puppet/type/cron.rb +1 -1
- data/lib/puppet/type/file.rb +39 -2
- data/lib/puppet/type/file/data_sync.rb +13 -5
- data/lib/puppet/type/host.rb +1 -1
- data/lib/puppet/type/mount.rb +2 -6
- data/lib/puppet/type/notify.rb +1 -1
- data/lib/puppet/type/package.rb +1 -1
- data/lib/puppet/type/resources.rb +1 -1
- data/lib/puppet/type/scheduled_task.rb +1 -1
- data/lib/puppet/type/ssh_authorized_key.rb +2 -2
- data/lib/puppet/type/tidy.rb +1 -1
- data/lib/puppet/type/yumrepo.rb +3 -3
- data/lib/puppet/type/zone.rb +1 -1
- data/lib/puppet/util.rb +2 -2
- data/lib/puppet/util/classgen.rb +1 -1
- data/lib/puppet/util/command_line.rb +6 -2
- data/lib/puppet/util/command_line/trollop.rb +1 -1
- data/lib/puppet/util/execution.rb +2 -2
- data/lib/puppet/util/http_proxy.rb +1 -1
- data/lib/puppet/util/inifile.rb +1 -1
- data/lib/puppet/util/instance_loader.rb +1 -1
- data/lib/puppet/util/logging.rb +1 -1
- data/lib/puppet/util/multi_match.rb +1 -1
- data/lib/puppet/util/plist.rb +15 -5
- data/lib/puppet/util/profiler.rb +1 -1
- data/lib/puppet/util/profiler/around_profiler.rb +1 -1
- data/lib/puppet/util/psych_support.rb +1 -1
- data/lib/puppet/util/rdoc.rb +2 -2
- data/lib/puppet/util/rubygems.rb +1 -1
- data/lib/puppet/util/watcher/periodic_watcher.rb +2 -2
- data/lib/puppet/util/windows/access_control_entry.rb +1 -1
- data/lib/puppet/util/windows/adsi.rb +30 -8
- data/lib/puppet/util/windows/api_types.rb +1 -1
- data/lib/puppet/util/windows/file.rb +59 -0
- data/lib/puppet/util/windows/process.rb +10 -0
- data/lib/puppet/util/windows/security.rb +1 -1
- data/lib/puppet/util/windows/user.rb +22 -4
- data/lib/puppet/util/yaml.rb +15 -3
- data/lib/puppet/vendor/deep_merge/test/test_deep_merge.rb +1 -1
- data/lib/puppet/vendor/rgen_patch.rb +1 -1
- data/lib/puppet/version.rb +2 -2
- data/spec/fixtures/unit/pops/loaders/loaders/no_modules/manifests/site.pp +10 -0
- data/spec/integration/agent/logging_spec.rb +15 -14
- data/spec/integration/application/apply_spec.rb +1 -0
- data/spec/integration/directory_environments_spec.rb +16 -0
- data/spec/integration/environments/settings_spec.rb +32 -4
- data/spec/integration/faces/documentation_spec.rb +1 -1
- data/spec/integration/network/http/api/indirected_routes_spec.rb +33 -0
- data/spec/integration/node/environment_spec.rb +21 -0
- data/spec/integration/parser/collection_spec.rb +10 -0
- data/spec/integration/parser/compiler_spec.rb +76 -840
- data/spec/integration/parser/functions/require_spec.rb +3 -3
- data/spec/integration/parser/parameter_defaults_spec.rb +6 -2
- data/spec/integration/parser/pcore_resource_spec.rb +208 -0
- data/spec/integration/parser/resource_expressions_spec.rb +4 -2
- data/spec/integration/provider/yumrepo_spec.rb +4 -1
- data/spec/integration/transaction/report_spec.rb +666 -0
- data/spec/integration/type/file_spec.rb +11 -12
- data/spec/integration/util/windows/adsi_spec.rb +99 -0
- data/spec/integration/util/windows/principal_spec.rb +109 -60
- data/spec/integration/util/windows/process_spec.rb +4 -2
- data/spec/integration/util/windows/security_spec.rb +34 -8
- data/spec/integration/util/windows/user_spec.rb +26 -4
- data/spec/lib/puppet_spec/files.rb +2 -2
- data/spec/lib/puppet_spec/network.rb +12 -8
- data/spec/shared_examples/rhel_package_provider.rb +341 -0
- data/spec/spec_helper.rb +8 -2
- data/spec/unit/application/cert_spec.rb +20 -0
- data/spec/unit/configurer/plugin_handler_spec.rb +0 -26
- data/spec/unit/configurer_spec.rb +46 -0
- data/spec/unit/defaults_spec.rb +14 -0
- data/spec/unit/face/generate_spec.rb +230 -0
- data/spec/unit/face/help_spec.rb +53 -0
- data/spec/unit/face/parser_spec.rb +6 -0
- data/spec/unit/face/plugin_spec.rb +0 -4
- data/spec/unit/file_system_spec.rb +85 -0
- data/spec/unit/functions/lookup_spec.rb +4 -4
- data/spec/unit/functions/match_spec.rb +2 -2
- data/spec/unit/functions/regsubst_spec.rb +1 -1
- data/spec/unit/functions/split_spec.rb +1 -1
- data/spec/unit/functions/unwrap_spec.rb +29 -0
- data/spec/unit/functions/versioncmp_spec.rb +1 -1
- data/spec/unit/functions4_spec.rb +8 -8
- data/spec/unit/indirector/facts/facter_spec.rb +1 -9
- data/spec/unit/indirector/rest_spec.rb +95 -9
- data/spec/unit/module_spec.rb +43 -7
- data/spec/unit/module_tool/applications/installer_spec.rb +10 -1
- data/spec/unit/module_tool/applications/unpacker_spec.rb +2 -1
- data/spec/unit/module_tool/applications/upgrader_spec.rb +8 -0
- data/spec/unit/module_tool/tar/mini_spec.rb +3 -3
- data/spec/unit/network/http/api/indirected_routes_spec.rb +49 -58
- data/spec/unit/network/http/api/master/v3_spec.rb +7 -4
- data/spec/unit/network/rights_spec.rb +1 -1
- data/spec/unit/parameter_spec.rb +11 -0
- data/spec/unit/parser/compiler_spec.rb +19 -33
- data/spec/unit/{appmgmt_spec.rb → parser/environment_compiler_spec.rb} +12 -1
- data/spec/unit/parser/functions/create_resources_spec.rb +76 -4
- data/spec/unit/parser/functions/require_spec.rb +2 -2
- data/spec/unit/parser/resource_spec.rb +21 -11
- data/spec/unit/parser/scope_spec.rb +1 -5
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +1 -1
- data/spec/unit/pops/loaders/dependency_loader_spec.rb +1 -1
- data/spec/unit/pops/loaders/loader_paths_spec.rb +1 -1
- data/spec/unit/pops/loaders/loaders_spec.rb +63 -5
- data/spec/unit/pops/loaders/module_loaders_spec.rb +2 -2
- data/spec/unit/pops/loaders/static_loader_spec.rb +1 -1
- data/spec/unit/pops/parser/lexer2_spec.rb +27 -3
- data/spec/unit/pops/parser/parse_basic_expressions_spec.rb +8 -0
- data/spec/unit/pops/parser/parse_calls_spec.rb +9 -0
- data/spec/unit/pops/puppet_stack_spec.rb +79 -0
- data/spec/unit/pops/resource/resource_type_impl_spec.rb +37 -0
- data/spec/unit/pops/serialization/packer_spec.rb +153 -0
- data/spec/unit/pops/serialization/rgen_spec.rb +88 -0
- data/spec/unit/pops/serialization/serialization_spec.rb +228 -0
- data/spec/unit/pops/types/p_object_type_spec.rb +44 -2
- data/spec/unit/pops/types/p_sem_ver_type_spec.rb +42 -0
- data/spec/unit/pops/types/p_sensitive_type_spec.rb +139 -0
- data/spec/unit/pops/types/p_type_set_type_spec.rb +424 -0
- data/spec/unit/pops/types/ruby_generator_spec.rb +497 -181
- data/spec/unit/pops/types/type_calculator_spec.rb +10 -4
- data/spec/unit/pops/types/type_formatter_spec.rb +1 -1
- data/spec/unit/pops/types/type_mismatch_describer_spec.rb +2 -2
- data/spec/unit/pops/types/type_parser_spec.rb +1 -1
- data/spec/unit/pops/types/types_spec.rb +1 -1
- data/spec/unit/pops/validator/validator_spec.rb +18 -1
- data/spec/unit/property_spec.rb +48 -11
- data/spec/unit/provider/group/windows_adsi_spec.rb +11 -1
- data/spec/unit/provider/package/dnf_spec.rb +1 -99
- data/spec/unit/provider/package/pacman_spec.rb +4 -4
- data/spec/unit/provider/package/pip_spec.rb +14 -0
- data/spec/unit/provider/package/pkg_spec.rb +6 -0
- data/spec/unit/provider/package/pkgdmg_spec.rb +0 -3
- data/spec/unit/provider/package/portage_spec.rb +64 -8
- data/spec/unit/provider/package/tdnf_spec.rb +18 -0
- data/spec/unit/provider/package/windows/package_spec.rb +4 -1
- data/spec/unit/provider/package/windows_spec.rb +8 -2
- data/spec/unit/provider/package/yum_spec.rb +6 -377
- data/spec/unit/provider/service/base_spec.rb +6 -0
- data/spec/unit/provider/service/debian_spec.rb +16 -7
- data/spec/unit/provider/service/gentoo_spec.rb +6 -0
- data/spec/unit/provider/service/init_spec.rb +7 -0
- data/spec/unit/provider/service/launchd_spec.rb +35 -4
- data/spec/unit/provider/service/openrc_spec.rb +6 -0
- data/spec/unit/provider/service/smf_spec.rb +31 -6
- data/spec/unit/provider/service/src_spec.rb +6 -0
- data/spec/unit/provider/service/systemd_spec.rb +70 -20
- data/spec/unit/provider/service/upstart_spec.rb +6 -0
- data/spec/unit/provider/user/aix_spec.rb +7 -0
- data/spec/unit/provider/user/directoryservice_spec.rb +30 -1
- data/spec/unit/provider/user/windows_adsi_spec.rb +19 -0
- data/spec/unit/resource/capability_finder_spec.rb +51 -3
- data/spec/unit/resource/catalog_spec.rb +5 -0
- data/spec/unit/resource/type_spec.rb +2 -2
- data/spec/unit/resource_spec.rb +19 -0
- data/spec/unit/settings_spec.rb +13 -0
- data/spec/unit/ssl/certificate_authority/interface_spec.rb +176 -10
- data/spec/unit/ssl/certificate_authority_spec.rb +63 -22
- data/spec/unit/ssl/host_spec.rb +1 -1
- data/spec/unit/ssl/oids_spec.rb +24 -21
- data/spec/unit/transaction/event_spec.rb +3 -1
- data/spec/unit/transaction/persistence_spec.rb +173 -0
- data/spec/unit/transaction/report_spec.rb +64 -1
- data/spec/unit/transaction/resource_harness_spec.rb +91 -0
- data/spec/unit/type/file/content_spec.rb +47 -15
- data/spec/unit/type/file_spec.rb +28 -0
- data/spec/unit/type/mount_spec.rb +5 -12
- data/spec/unit/type/yumrepo_spec.rb +1 -5
- data/spec/unit/type_spec.rb +32 -0
- data/spec/unit/util/command_line_spec.rb +11 -0
- data/spec/unit/util/execution_spec.rb +1 -1
- data/spec/unit/util/plist_spec.rb +16 -3
- data/spec/unit/util/storage_spec.rb +4 -1
- data/spec/unit/util/windows/adsi_spec.rb +23 -2
- data/spec/unit/util/windows/file_spec.rb +56 -1
- data/spec/unit/util/windows/sid_spec.rb +31 -7
- data/spec/unit/util/yaml_spec.rb +12 -0
- data/spec/unit/util_spec.rb +87 -20
- metadata +89 -34
- data/ext/puppetlisten/puppetlisten.rb +0 -77
- data/ext/puppetlisten/puppetrun.rb +0 -38
- data/lib/puppet/resource/type_collection_helper.rb +0 -7
- data/spec/unit/parser/functions/defined_spec.rb +0 -120
- data/spec/unit/resource/type_collection_helper_spec.rb +0 -24
@@ -55,7 +55,7 @@ class EvaluatingParser
|
|
55
55
|
|
56
56
|
# Create a closure that can be called in the given scope
|
57
57
|
def closure(model, scope)
|
58
|
-
Evaluator::Closure.new(evaluator, model, scope)
|
58
|
+
Evaluator::Closure::Dynamic.new(evaluator, model, scope)
|
59
59
|
end
|
60
60
|
|
61
61
|
def evaluate(scope, model)
|
@@ -185,11 +185,18 @@ module Puppet::Pops::Parser::InterpolationSupport
|
|
185
185
|
scn = @scanner
|
186
186
|
ctx = @lexing_context
|
187
187
|
queue = @token_queue
|
188
|
+
queue_base = @token_queue[0]
|
188
189
|
|
189
190
|
scn.skip(self.class::PATTERN_WS)
|
190
191
|
queue_size = queue.size
|
191
192
|
until scn.eos? do
|
192
193
|
if token = lex_token
|
194
|
+
if token.equal?(queue_base)
|
195
|
+
# A nested #interpolate_dq call shifted the queue_base token from the @token_queue. It must
|
196
|
+
# be put back since it is intended for the top level #interpolate_dq call only.
|
197
|
+
queue.insert(0, token)
|
198
|
+
next # all relevant tokens are already on the queue
|
199
|
+
end
|
193
200
|
token_name = token[0]
|
194
201
|
ctx[:after] = token_name
|
195
202
|
if token_name == :RBRACE && ctx[:brace_count] == brace_count
|
@@ -37,6 +37,7 @@ class Lexer2
|
|
37
37
|
TOKEN_RBRACE = [:RBRACE, '}'.freeze, 1].freeze
|
38
38
|
TOKEN_SELBRACE = [:SELBRACE, '{'.freeze, 1].freeze
|
39
39
|
TOKEN_LPAREN = [:LPAREN, '('.freeze, 1].freeze
|
40
|
+
TOKEN_WSLPAREN = [:WSLPAREN, '('.freeze, 1].freeze
|
40
41
|
TOKEN_RPAREN = [:RPAREN, ')'.freeze, 1].freeze
|
41
42
|
|
42
43
|
TOKEN_EQUALS = [:EQUALS, '='.freeze, 1].freeze
|
@@ -219,7 +220,17 @@ class Lexer2
|
|
219
220
|
end
|
220
221
|
end,
|
221
222
|
']' => lambda { emit(TOKEN_RBRACK, @scanner.pos) },
|
222
|
-
'(' => lambda
|
223
|
+
'(' => lambda do
|
224
|
+
before = @scanner.pos
|
225
|
+
# If first on a line, or only whitespace between start of line and '('
|
226
|
+
# then the token is special to avoid being taken as start of a call.
|
227
|
+
line_start = @lexing_context[:line_lexical_start]
|
228
|
+
if before == line_start || @scanner.string.byteslice(line_start, before - line_start) =~ /\A[[:blank:]\r]+\Z/
|
229
|
+
emit(TOKEN_WSLPAREN, before)
|
230
|
+
else
|
231
|
+
emit(TOKEN_LPAREN, before)
|
232
|
+
end
|
233
|
+
end,
|
223
234
|
')' => lambda { emit(TOKEN_RPAREN, @scanner.pos) },
|
224
235
|
';' => lambda { emit(TOKEN_SEMIC, @scanner.pos) },
|
225
236
|
'?' => lambda { emit(TOKEN_QMARK, @scanner.pos) },
|
@@ -489,6 +500,7 @@ class Lexer2
|
|
489
500
|
else
|
490
501
|
@scanner.pos += 1
|
491
502
|
end
|
503
|
+
ctx[:line_lexical_start] = @scanner.pos
|
492
504
|
nil
|
493
505
|
end,
|
494
506
|
'' => lambda { nil } # when the peek(1) returns empty
|
@@ -656,6 +668,7 @@ class Lexer2
|
|
656
668
|
@lexing_context = {
|
657
669
|
:brace_count => 0,
|
658
670
|
:after => nil,
|
671
|
+
:line_lexical_start => 0
|
659
672
|
}
|
660
673
|
appm_mode = Puppet[:app_management] ? :with_appm : :without_appm
|
661
674
|
@appm_keywords = APP_MANAGEMENT_TOKENS[appm_mode]
|
@@ -8,7 +8,7 @@ class Locator
|
|
8
8
|
#
|
9
9
|
def self.locator(string, file, index = nil, char_offsets = false)
|
10
10
|
if char_offsets
|
11
|
-
LocatorForChars.new(string, file, index)
|
11
|
+
LocatorForChars.new(string, file, index)
|
12
12
|
else
|
13
13
|
Locator19.new(string, file, index)
|
14
14
|
end
|
@@ -205,6 +205,15 @@ class Locator
|
|
205
205
|
return low
|
206
206
|
end
|
207
207
|
|
208
|
+
def hash
|
209
|
+
[string, file, line_index].hash
|
210
|
+
end
|
211
|
+
|
212
|
+
# Equal method needed by serializer to perform tabulation
|
213
|
+
def eql?(o)
|
214
|
+
self.class == o.class && string == o.string && file == o.file && line_index == o.line_index
|
215
|
+
end
|
216
|
+
|
208
217
|
# Common impl for 18 and 19 since scanner is byte based
|
209
218
|
def compute_line_index
|
210
219
|
scanner = StringScanner.new(string)
|
@@ -262,6 +271,26 @@ class Locator
|
|
262
271
|
# strings are frozen).
|
263
272
|
#
|
264
273
|
class Locator19 < AbstractLocator
|
274
|
+
include Types::PuppetObject
|
275
|
+
|
276
|
+
def self._ptype
|
277
|
+
@type
|
278
|
+
end
|
279
|
+
|
280
|
+
# The Locator is not part of the Ecore model so no ObjectType is automatically inferred. Instead the
|
281
|
+
# type is explicitly added here.
|
282
|
+
# TODO: LocatorForChars is never added. It looks like it could be removed (remnant from Ruby 1.8 compatibility?)
|
283
|
+
# @api private
|
284
|
+
def self.register_ptype(loader, ir)
|
285
|
+
@type = Pcore::create_object_type(loader, ir, self, 'Puppet::AST::Locator', 'Any',
|
286
|
+
'string' => Types::PStringType::DEFAULT,
|
287
|
+
'file' => Types::PStringType::DEFAULT,
|
288
|
+
'line_index' => {
|
289
|
+
Types::KEY_TYPE => Types::POptionalType.new(Types::PArrayType.new(Types::PIntegerType::DEFAULT)),
|
290
|
+
Types::KEY_VALUE => nil
|
291
|
+
}
|
292
|
+
).resolve(Types::TypeParser.singleton, loader)
|
293
|
+
end
|
265
294
|
|
266
295
|
# Returns the offset on line (first offset on a line is 0).
|
267
296
|
# Ruby 19 is multibyte but has no character position methods, must use byteslice
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'puppet/parser/functions'
|
2
2
|
require 'puppet/parser/files'
|
3
3
|
require 'puppet/resource/type_collection'
|
4
|
-
require 'puppet/resource/type_collection_helper'
|
5
4
|
require 'puppet/resource/type'
|
6
5
|
require 'monitor'
|
7
6
|
|
@@ -22,8 +21,6 @@ class Parser
|
|
22
21
|
#
|
23
22
|
Factory = Model::Factory
|
24
23
|
|
25
|
-
include Puppet::Resource::TypeCollectionHelper
|
26
|
-
|
27
24
|
attr_accessor :lexer
|
28
25
|
attr_reader :definitions
|
29
26
|
|
@@ -11,9 +11,9 @@ module Parser
|
|
11
11
|
module SlurpSupport
|
12
12
|
include LexerSupport
|
13
13
|
|
14
|
-
SLURP_SQ_PATTERN = /(?:[^\\]
|
15
|
-
SLURP_DQ_PATTERN = /(?:[^\\]
|
16
|
-
SLURP_UQ_PATTERN = /(?:[^\\]
|
14
|
+
SLURP_SQ_PATTERN = /(?:[^\\]|^)(?:[\\]{2})*[']/
|
15
|
+
SLURP_DQ_PATTERN = /(?:[^\\]|^)(?:[\\]{2})*(["]|[$]\{?)/
|
16
|
+
SLURP_UQ_PATTERN = /(?:[^\\]|^)(?:[\\]{2})*([$]\{?|\z)/
|
17
17
|
# unquoted, no escapes
|
18
18
|
SLURP_UQNE_PATTERN = /(\$\{?|\z)/m
|
19
19
|
SLURP_ALL_PATTERN = /.*(\z)/m
|
data/lib/puppet/pops/patterns.rb
CHANGED
@@ -30,17 +30,25 @@ module Puppet::Pops::Patterns
|
|
30
30
|
#
|
31
31
|
CLASSREF_EXT = %r{\A((::){0,1}[A-Z][\w]*)+\z}
|
32
32
|
|
33
|
+
# Same as CLASSREF_EXT but cannot start with '::'
|
34
|
+
#
|
35
|
+
CLASSREF_EXT_DECL = %r{\A[A-Z][\w]*(?:::[A-Z][\w]*)*\z}
|
36
|
+
|
33
37
|
# CLASSREF matches a class reference the way it is represented internally in the
|
34
38
|
# model (i.e. in lower case).
|
35
39
|
#
|
36
40
|
CLASSREF = %r{\A((::){0,1}[a-z][\w]*)+\z}
|
37
41
|
|
42
|
+
# Same as CLASSREF but cannot start with '::'
|
43
|
+
#
|
44
|
+
CLASSREF_DECL = %r{\A[a-z][\w]*(?:::[a-z][\w]*)*\z}
|
45
|
+
|
38
46
|
# DOLLAR_VAR matches a variable name including the initial $ character
|
39
47
|
DOLLAR_VAR = %r{\$(::)?(\w+::)*\w+}
|
40
48
|
|
41
49
|
# VAR_NAME matches the name part of a variable (The $ character is not included)
|
42
50
|
# Note, that only the final segment may start with an underscore.
|
43
|
-
VAR_NAME = %r{\A(
|
51
|
+
VAR_NAME = %r{\A(?:(::)?[a-z]\w*)*(?:(::)?[a-z_]\w*)\z}
|
44
52
|
|
45
53
|
# PARAM_NAME matches the name part of a parameter (The $ character is not included)
|
46
54
|
PARAM_NAME = %r{\A[a-z_]\w*\z}
|
data/lib/puppet/pops/pcore.rb
CHANGED
@@ -2,29 +2,85 @@ require 'uri'
|
|
2
2
|
|
3
3
|
module Puppet::Pops
|
4
4
|
module Pcore
|
5
|
-
|
5
|
+
TYPE_URI_RX = Types::TypeFactory.regexp(URI.regexp)
|
6
|
+
TYPE_URI = Types::TypeFactory.pattern(TYPE_URI_RX)
|
7
|
+
TYPE_SIMPLE_TYPE_NAME = Types::TypeFactory.pattern(/\A[A-Z]\w*\z/)
|
8
|
+
TYPE_QUALIFIED_REFERENCE = Types::TypeFactory.pattern(/\A[A-Z][\w]*(?:::[A-Z][\w]*)*\z/)
|
9
|
+
|
10
|
+
KEY_PCORE_URI = 'pcore_uri'.freeze
|
11
|
+
KEY_PCORE_VERSION = 'pcore_version'.freeze
|
12
|
+
|
13
|
+
PCORE_URI = 'http://puppet.com/2016.1/pcore'
|
14
|
+
PCORE_VERSION = Semantic::Version.new(1,0,0)
|
15
|
+
PARSABLE_PCORE_VERSIONS = Semantic::VersionRange.parse('1.x')
|
16
|
+
|
17
|
+
RUNTIME_NAME_AUTHORITY = 'http://puppet.com/2016.1/runtime'
|
6
18
|
|
7
19
|
def self.init(loader, ir)
|
8
|
-
add_alias('
|
20
|
+
add_alias('Pcore::URI_RX', TYPE_URI_RX, loader)
|
21
|
+
add_alias('Pcore::URI', TYPE_URI, loader)
|
22
|
+
add_alias('Pcore::SimpleTypeName', TYPE_SIMPLE_TYPE_NAME, loader)
|
23
|
+
add_alias('Pcore::TypeName', TYPE_QUALIFIED_REFERENCE, loader)
|
24
|
+
add_alias('Pcore::QRef', TYPE_QUALIFIED_REFERENCE, loader)
|
25
|
+
Types::TypedModelObject.register_ptypes(loader, ir)
|
26
|
+
|
27
|
+
ir.register_implementation_namespace('Pcore', 'Puppet::Pops::Pcore', loader)
|
28
|
+
ir.register_implementation_namespace('Puppet::AST', 'Puppet::Pops::Model', loader)
|
29
|
+
ast_type_set = Serialization::RGen::TypeGenerator.new.generate_type_set('Puppet::AST', Puppet::Pops::Model, loader)
|
30
|
+
|
31
|
+
# Extend the Puppet::AST type set with the Locator (it's not an RGen class, but nevertheless, used in the model)
|
32
|
+
ast_ts_i12n = ast_type_set.i12n_hash
|
33
|
+
ast_ts_i12n['types'] = ast_ts_i12n['types'].merge('Locator' => Parser::Locator::Locator19.register_ptype(loader, ir))
|
34
|
+
add_type(Types::PTypeSetType.new(ast_ts_i12n), loader)
|
35
|
+
|
36
|
+
Resource.register_ptypes(loader, ir)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Create and register a new `Object` type in the Puppet Type System and map it to an implementation class
|
40
|
+
#
|
41
|
+
# @param loader [Loader::Loader] The loader where the new type will be registered
|
42
|
+
# @param ir [ImplementationRegistry] The implementation registry that maps this class to the new type
|
43
|
+
# @param impl_class [Class] The class that is the implementation of the type
|
44
|
+
# @param type_name [String] The fully qualified name of the new type
|
45
|
+
# @param parent_name [String,nil] The fully qualified name of the parent type
|
46
|
+
# @param attributes_hash [Hash{String => Object}] A hash of attribute definitions for the new type
|
47
|
+
# @param functions_hash [Hash{String => Object}] A hash of function definitions for the new type
|
48
|
+
# @param equality [Array<String>] An array with names of attributes that participate in equality comparison
|
49
|
+
# @return [PObjectType] the created type. Not yet resolved
|
50
|
+
#
|
51
|
+
# @api private
|
52
|
+
def self.create_object_type(loader, ir, impl_class, type_name, parent_name, attributes_hash = EMPTY_HASH, functions_hash = EMPTY_HASH, equality = nil)
|
53
|
+
i12n_hash = {}
|
54
|
+
i12n_hash[Types::KEY_PARENT] = Types::PTypeReferenceType.new(parent_name) unless parent_name.nil?
|
55
|
+
i12n_hash[Types::KEY_ATTRIBUTES] = attributes_hash unless attributes_hash.empty?
|
56
|
+
i12n_hash[Types::KEY_FUNCTIONS] = functions_hash unless functions_hash.empty?
|
57
|
+
i12n_hash[Types::KEY_EQUALITY] = equality unless equality.nil?
|
58
|
+
ir.register_implementation(type_name, impl_class, loader)
|
59
|
+
add_type(Types::PObjectType.new(type_name, i12n_hash), loader)
|
60
|
+
end
|
9
61
|
|
10
|
-
|
62
|
+
def self.add_object_type(name, body, loader)
|
63
|
+
add_type(Types::PObjectType.new(name, Parser::EvaluatingParser.new.parse_string(body).current.body), loader)
|
11
64
|
end
|
12
65
|
|
13
|
-
def self.add_alias(name, type, loader)
|
14
|
-
add_type(Types::PTypeAliasType.new(name, nil, type), loader)
|
66
|
+
def self.add_alias(name, type, loader, name_authority = RUNTIME_NAME_AUTHORITY)
|
67
|
+
add_type(Types::PTypeAliasType.new(name, nil, type), loader, name_authority)
|
15
68
|
end
|
16
69
|
|
17
|
-
def self.add_type(type, loader)
|
18
|
-
loader.set_entry(Loader::
|
70
|
+
def self.add_type(type, loader, name_authority = RUNTIME_NAME_AUTHORITY)
|
71
|
+
loader.set_entry(Loader::TypedName.new(:type, type.name.downcase, name_authority), type)
|
72
|
+
type
|
19
73
|
end
|
20
74
|
|
21
|
-
def self.register_implementations(
|
22
|
-
Loaders.loaders.register_implementations(
|
75
|
+
def self.register_implementations(impls, name_authority = RUNTIME_NAME_AUTHORITY)
|
76
|
+
Loaders.loaders.register_implementations(impls, name_authority = RUNTIME_NAME_AUTHORITY)
|
23
77
|
end
|
24
78
|
|
25
|
-
def self.register_aliases(aliases)
|
79
|
+
def self.register_aliases(aliases, name_authority = RUNTIME_NAME_AUTHORITY)
|
26
80
|
loader = Loaders.loaders.private_environment_loader
|
27
|
-
aliases.each
|
81
|
+
aliases.each do |name, type_string|
|
82
|
+
add_type(Types::PTypeAliasType.new(name, Types::TypeFactory.type_reference(type_string), nil), loader, name_authority)
|
83
|
+
end
|
28
84
|
end
|
29
85
|
end
|
30
86
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Puppet::Pops
|
2
|
+
# Module for making a call such that there is an identifiable entry on
|
3
|
+
# the ruby call stack enabling getting a puppet call stack
|
4
|
+
# To use this make a call with:
|
5
|
+
# ```
|
6
|
+
# Puppet::Pops::PuppetStack.stack(file, line, receiver, message, args)
|
7
|
+
# ```
|
8
|
+
# To get the stack call:
|
9
|
+
# ```
|
10
|
+
# Puppet::Pops::PuppetStack.stacktrace
|
11
|
+
#
|
12
|
+
# When getting a backtrace in Ruby, the puppet stack frames are
|
13
|
+
# identified as coming from "in 'stack'" and having a ".pp" file
|
14
|
+
# name.
|
15
|
+
# To support testing, a given file that is an empty string, or nil
|
16
|
+
# as well as a nil line number are supported. Such stack frames
|
17
|
+
# will be represented with the text `unknown` and `0´ respectively.
|
18
|
+
#
|
19
|
+
module PuppetStack
|
20
|
+
# Sends a message to an obj such that it appears to come from
|
21
|
+
# file, line when calling stacktrace.
|
22
|
+
#
|
23
|
+
def self.stack(file, line, obj, message, args, &block)
|
24
|
+
file = '' if file.nil?
|
25
|
+
line = 0 if line.nil?
|
26
|
+
|
27
|
+
if block_given?
|
28
|
+
Kernel.eval("obj.send(message, *args, &block)", Kernel.binding(), file, line)
|
29
|
+
else
|
30
|
+
Kernel.eval("obj.send(message, *args)", Kernel.binding(), file, line)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.stacktrace
|
35
|
+
result = caller().reduce([]) do |memo, loc|
|
36
|
+
if loc =~ /^(.*\.pp)?:([0-9]+):in `stack'/
|
37
|
+
memo << [$1.nil? ? 'unknown' : $1, $2.to_i]
|
38
|
+
end
|
39
|
+
memo
|
40
|
+
end.reverse
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# An implementation of the interface Puppet::Resource
|
2
|
+
# that adapts the 3.x compiler and catalog expectations on
|
3
|
+
# a resource instance. This instance is backed by a
|
4
|
+
# pcore representation of the resource type an instance of this
|
5
|
+
# ruby class.
|
6
|
+
#
|
7
|
+
# This class must inherit from Puppet::Resource because of the
|
8
|
+
# class expectations in existing logic.
|
9
|
+
#
|
10
|
+
# This implementation does not support
|
11
|
+
# * setting 'strict' - strictness (must refer to an existing type) is always true
|
12
|
+
# * does not support the indirector
|
13
|
+
#
|
14
|
+
#
|
15
|
+
module Puppet::Pops
|
16
|
+
module Resource
|
17
|
+
class Param
|
18
|
+
# This make this class instantiateable from Puppet
|
19
|
+
include Puppet::Pops::Types::PuppetObject
|
20
|
+
|
21
|
+
def self.register_ptype(loader, ir)
|
22
|
+
@ptype = Pcore::create_object_type(loader, ir, self, 'Puppet::Resource::Param', nil,
|
23
|
+
{
|
24
|
+
Types::KEY_TYPE => Types::PType::DEFAULT,
|
25
|
+
Types::KEY_NAME => Types::PStringType::NON_EMPTY,
|
26
|
+
'name_var' => {
|
27
|
+
Types::KEY_TYPE => Types::PBooleanType::DEFAULT,
|
28
|
+
Types::KEY_VALUE => false
|
29
|
+
}
|
30
|
+
},
|
31
|
+
EMPTY_HASH,
|
32
|
+
[Types::KEY_NAME]
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
attr_reader :name
|
37
|
+
attr_reader :type
|
38
|
+
attr_reader :name_var
|
39
|
+
|
40
|
+
def initialize(type, name, name_var = false)
|
41
|
+
@type = type
|
42
|
+
@name = name
|
43
|
+
@name_var = name_var
|
44
|
+
end
|
45
|
+
|
46
|
+
def self._ptype
|
47
|
+
@ptype
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,301 @@
|
|
1
|
+
require_relative 'param'
|
2
|
+
|
3
|
+
module Puppet::Pops
|
4
|
+
module Resource
|
5
|
+
|
6
|
+
def self.register_ptypes(loader, ir)
|
7
|
+
types = [Param, ResourceTypeImpl].map do |c|
|
8
|
+
c.register_ptype(loader, ir)
|
9
|
+
end
|
10
|
+
types.each {|t| t.resolve(Types::TypeParser.singleton, loader) }
|
11
|
+
end
|
12
|
+
|
13
|
+
class ResourceTypeImpl
|
14
|
+
# Make instances of this class directly createable from the Puppet Language
|
15
|
+
# as object.
|
16
|
+
#
|
17
|
+
include Puppet::Pops::Types::PuppetObject
|
18
|
+
|
19
|
+
# Instances of ResourceTypeImpl can be used as the type of a Puppet::Parser::Resource/Puppet::Resource when compiling
|
20
|
+
#
|
21
|
+
include Puppet::CompilableResourceType
|
22
|
+
|
23
|
+
# Returns the Puppet Type for this instance.
|
24
|
+
def self._ptype
|
25
|
+
@ptype
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.register_ptype(loader, ir)
|
29
|
+
param_ref = Types::PTypeReferenceType.new('Puppet::Resource::Param')
|
30
|
+
@ptype = Pcore::create_object_type(loader, ir, self, 'Puppet::Resource::ResourceType3', nil,
|
31
|
+
{
|
32
|
+
Types::KEY_NAME => Types::PStringType::NON_EMPTY,
|
33
|
+
'properties' => {
|
34
|
+
Types::KEY_TYPE => Types::PArrayType.new(param_ref),
|
35
|
+
Types::KEY_VALUE => EMPTY_ARRAY
|
36
|
+
},
|
37
|
+
'parameters' => {
|
38
|
+
Types::KEY_TYPE => Types::PArrayType.new(param_ref),
|
39
|
+
Types::KEY_VALUE => EMPTY_ARRAY
|
40
|
+
},
|
41
|
+
'title_patterns_hash' => {
|
42
|
+
Types::KEY_TYPE => Types::POptionalType.new(
|
43
|
+
Types::PHashType.new(Types::PRegexpType::DEFAULT, Types::PArrayType.new(Types::PStringType::NON_EMPTY))),
|
44
|
+
Types::KEY_VALUE => nil
|
45
|
+
},
|
46
|
+
'isomorphic' => {
|
47
|
+
Types::KEY_TYPE => Types::PBooleanType::DEFAULT,
|
48
|
+
Types::KEY_VALUE => true
|
49
|
+
},
|
50
|
+
},
|
51
|
+
EMPTY_HASH,
|
52
|
+
[Types::KEY_NAME]
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
# Compares this type against the given _other_ (type) and returns -1, 0, or +1 depending on the order.
|
57
|
+
# @param other [Object] the object to compare against (produces nil, if not kind of Type}
|
58
|
+
# @return [-1, 0, +1, nil] produces -1 if this type is before the given _other_ type, 0 if equals, and 1 if after.
|
59
|
+
# Returns nil, if the given _other_ is not a kind of Type.
|
60
|
+
# @see Comparable
|
61
|
+
#
|
62
|
+
def <=>(other)
|
63
|
+
# Order is only maintained against other types, not arbitrary objects.
|
64
|
+
# The natural order is based on the reference name used when comparing
|
65
|
+
return nil unless other.is_a?(Puppet::CompilableResourceType)
|
66
|
+
# against other type instances.
|
67
|
+
self.ref <=> other.ref
|
68
|
+
end
|
69
|
+
|
70
|
+
METAPARAMS = [
|
71
|
+
:noop,
|
72
|
+
:schedule,
|
73
|
+
:audit,
|
74
|
+
:loglevel,
|
75
|
+
:alias,
|
76
|
+
:tag,
|
77
|
+
:require,
|
78
|
+
:subscribe,
|
79
|
+
:before,
|
80
|
+
:notify,
|
81
|
+
:stage,
|
82
|
+
:export,
|
83
|
+
:consume
|
84
|
+
].freeze
|
85
|
+
|
86
|
+
# Speed up lookup
|
87
|
+
METAPARAMSET = Set.new(METAPARAMS).freeze
|
88
|
+
|
89
|
+
attr_reader :name
|
90
|
+
attr_reader :properties
|
91
|
+
attr_reader :parameters
|
92
|
+
attr_reader :title_patterns_hash
|
93
|
+
attr_reader :title_patterns
|
94
|
+
attr_reader :isomorphic
|
95
|
+
|
96
|
+
def initialize(name, properties = EMPTY_ARRAY, parameters = EMPTY_ARRAY, title_patterns_hash = nil, isomorphic = true)
|
97
|
+
@name = name
|
98
|
+
@properties = properties
|
99
|
+
@parameters = parameters
|
100
|
+
@title_patterns_hash = title_patterns_hash
|
101
|
+
@isomorphic = isomorphic
|
102
|
+
|
103
|
+
# Compute attributes hash
|
104
|
+
# Compute key_names (possibly compound key if there are multiple name vars).
|
105
|
+
@attributes = {}
|
106
|
+
@key_attributes = []
|
107
|
+
|
108
|
+
# Name to kind of attribute
|
109
|
+
@attr_types = {}
|
110
|
+
|
111
|
+
# Add all meta params
|
112
|
+
METAPARAMS.each {|p| @attr_types[p] = :meta }
|
113
|
+
|
114
|
+
@property_set = Set.new(properties.map do |p|
|
115
|
+
symname = p.name.to_sym
|
116
|
+
@attributes[symname] = p
|
117
|
+
@key_attributes << symname if p.name_var
|
118
|
+
@attr_types[symname] = :property
|
119
|
+
symname
|
120
|
+
end).freeze
|
121
|
+
|
122
|
+
@param_set = Set.new(parameters.map do |p|
|
123
|
+
symname = p.name.to_sym
|
124
|
+
@attributes[symname] = p
|
125
|
+
@key_attributes << symname if p.name_var
|
126
|
+
@attr_types[symname] = :param
|
127
|
+
symname
|
128
|
+
end).freeze
|
129
|
+
|
130
|
+
# API for title patterns is [ [regexp, [ [ [sym, <lambda>], [sym, <lambda>] ] ] ] ]
|
131
|
+
# Where lambdas are optional. This resource type impl does not support lambdas
|
132
|
+
# Note that the pcore file has a simpler hashmap that is post processed here
|
133
|
+
# since the structure must have Symbol instances for names which the .pp representation
|
134
|
+
# does not deliver.
|
135
|
+
#
|
136
|
+
@title_patterns =
|
137
|
+
case @key_attributes.length
|
138
|
+
when 0
|
139
|
+
# TechDebt: The case of specifying title patterns when having no name vars is unspecified behavior in puppet
|
140
|
+
# Here it is silently ignored.
|
141
|
+
[]
|
142
|
+
when 1
|
143
|
+
if @title_pattners_hash.nil?
|
144
|
+
[ [ /(.*)/m, [ [@key_attributes.first] ] ] ]
|
145
|
+
else
|
146
|
+
# TechDebt: The case of having one namevar and an empty title patterns is unspecified behavior in puppet.
|
147
|
+
# Here, it may lead to an empty map which may or may not trigger the wanted/expected behavior.
|
148
|
+
#
|
149
|
+
@title_patterns_hash.map {|k,v| [ k, [ v.map {|n| n.to_sym } ] ] }
|
150
|
+
end
|
151
|
+
else
|
152
|
+
if @title_patterns_hash.nil? || @title_patterns_hash.empty?
|
153
|
+
# TechDebt: While title patterns must be specified when more than one is used, they do not have
|
154
|
+
# to match/set them all since some namevars can be omitted (to support the use case in
|
155
|
+
# the 'package' type where 'provider' attribute is handled as part of the key without being
|
156
|
+
# set from the title.
|
157
|
+
#
|
158
|
+
raise Puppet::DevError,"you must specify title patterns when there are two or more key attributes"
|
159
|
+
end
|
160
|
+
@title_patterns_hash.nil? ? [] : @title_patterns_hash.map {|k,v| [ k, [ v.map {|n| n.to_sym } ] ] }
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
# Override CompilableResource inclusion
|
165
|
+
def is_3x_ruby_plugin?
|
166
|
+
false
|
167
|
+
end
|
168
|
+
|
169
|
+
# Answers if the parameter name is a parameter/attribute of this type
|
170
|
+
# This is part of the Puppet::Type API
|
171
|
+
# Check if used when compiling (it is triggered in an apply)
|
172
|
+
#
|
173
|
+
def valid_parameter?(name)
|
174
|
+
@attributes.include?(name) || METAPARAMSET.include?(name)
|
175
|
+
end
|
176
|
+
|
177
|
+
# The type implementation of finish does a lot of things
|
178
|
+
# * iterates over all parameters and calls post_compile on them if the parameter impl responds to post_compile
|
179
|
+
# * validates the relationship parameters
|
180
|
+
#
|
181
|
+
# This implementation does nothing - it is assumed that the catalog is already validated
|
182
|
+
# via the relationship validator (done late in the game).
|
183
|
+
def finish()
|
184
|
+
# Do nothing.
|
185
|
+
end
|
186
|
+
|
187
|
+
# This is called on a resource type
|
188
|
+
# it performs tagging if it is a Class or Node.
|
189
|
+
# It also ensure the parent type is in the catalog, but that is weird since
|
190
|
+
# resource types cannot really inherit
|
191
|
+
def instantiate_resource(scope, resource)
|
192
|
+
# Do nothing because nothing is needed when compiling.
|
193
|
+
|
194
|
+
# This is what the Puppet::Type implementation does
|
195
|
+
# None of this should be needed
|
196
|
+
|
197
|
+
# # Make sure our parent class has been evaluated, if we have one.
|
198
|
+
# if parent && !scope.catalog.resource(resource.type, parent)
|
199
|
+
# parent_type(scope).ensure_in_catalog(scope)
|
200
|
+
# end
|
201
|
+
|
202
|
+
# This will never happen
|
203
|
+
|
204
|
+
# if ['Class', 'Node'].include? resource.type
|
205
|
+
# scope.catalog.tag(*resource.tags)
|
206
|
+
# end
|
207
|
+
end
|
208
|
+
|
209
|
+
# Being isomorphic in puppet means that the resource is managing a state
|
210
|
+
# (as opposed to a resource like Exec that is a function, possibly with side effect.
|
211
|
+
# In a Ruby implementation of a resource type, @isomorphic = false is used to turn
|
212
|
+
# off isomorphism, it is true by default.
|
213
|
+
# This is part of the Puppet::Type API.
|
214
|
+
#
|
215
|
+
def isomorphic?
|
216
|
+
@isomorphic
|
217
|
+
end
|
218
|
+
|
219
|
+
# Produces the names of the attributes that make out the unique id of a resource
|
220
|
+
#
|
221
|
+
def key_attributes
|
222
|
+
@key_attributes
|
223
|
+
end
|
224
|
+
|
225
|
+
# Gives a type a chance to issue deprecations for parameters.
|
226
|
+
# @param title [String] the title of the resource of this type
|
227
|
+
# @param attributes [Array<Param>] the set parameters in the resource instance
|
228
|
+
def deprecate_params(title, attributes)
|
229
|
+
# TODO: Current API somewhat unclear, if done at type level, or per
|
230
|
+
# Param.
|
231
|
+
end
|
232
|
+
|
233
|
+
#######################
|
234
|
+
# UNSUPPORTED STUFF
|
235
|
+
#######################
|
236
|
+
|
237
|
+
# Applications are not supported
|
238
|
+
def application?
|
239
|
+
false
|
240
|
+
end
|
241
|
+
|
242
|
+
############################
|
243
|
+
# DON'T KNOW YET
|
244
|
+
############################
|
245
|
+
|
246
|
+
|
247
|
+
##################################################
|
248
|
+
# NEVER CALLED COMPILE SIDE FOR A COMPILATION
|
249
|
+
##################################################
|
250
|
+
|
251
|
+
# Answers :property, :param or :meta depending on the type of the attribute
|
252
|
+
# According to original version, this is called millions of times
|
253
|
+
# and a cache is required.
|
254
|
+
# @param name [Symbol]
|
255
|
+
def attrtype(name)
|
256
|
+
raise NotImplementedError, "attrtype() - returns the kind (:meta, :param, or :property) of the parameter"
|
257
|
+
# @attr_types[name]
|
258
|
+
end
|
259
|
+
|
260
|
+
# Returns the implementation of a param/property/attribute - i.e. a Param class
|
261
|
+
def attrclass(name)
|
262
|
+
raise NotImplementedError, "attrclass() - returns the (param) class of the parameter"
|
263
|
+
end
|
264
|
+
|
265
|
+
# PROBABLY NOT USED WHEN COMPILING
|
266
|
+
# Returns the names of all attributes in a defined order:
|
267
|
+
# * all key attributes (the composite id)
|
268
|
+
# * :provider if it is specified
|
269
|
+
# * all properties
|
270
|
+
# * all parameters
|
271
|
+
# * meta parameters
|
272
|
+
#
|
273
|
+
def allattrs
|
274
|
+
raise NotImplementedError, "allattrs() - return all attribute names in order - probably not used master side"
|
275
|
+
# key_attributes | (parameters & [:provider]) | properties.collect { |property| property.name } | parameters | metaparams
|
276
|
+
end
|
277
|
+
|
278
|
+
# Sets "applies to host"
|
279
|
+
def apply_to
|
280
|
+
raise NotImplementedError, "apply_to() - probably used when selecting a provider (device/host support)"
|
281
|
+
end
|
282
|
+
|
283
|
+
def apply_to_host
|
284
|
+
raise NotImplementedError, "apply_to_host() - probably used when selecting a provider (device/host support)"
|
285
|
+
end
|
286
|
+
|
287
|
+
def apply_to_device
|
288
|
+
raise NotImplementedError, "apply_to_device() - probably used when selecting a provider (device/host support)"
|
289
|
+
end
|
290
|
+
|
291
|
+
def apply_to_all
|
292
|
+
raise NotImplementedError, "apply_to_all() - probably used when selecting a provider (device/host support)"
|
293
|
+
end
|
294
|
+
|
295
|
+
def can_apply_to_target(target)
|
296
|
+
raise NotImplementedError, "can_apply_to_target() - probably used when selecting a provider (device/host support)"
|
297
|
+
end
|
298
|
+
|
299
|
+
end
|
300
|
+
end
|
301
|
+
end
|