puppet 3.2.4 → 3.3.0.rc2
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/COMMITTERS.md +101 -42
- data/Gemfile +15 -4
- data/README.md +5 -1
- data/README_DEVELOPER.md +117 -54
- data/Rakefile +4 -0
- data/ext/build_defaults.yaml +3 -2
- data/ext/debian/puppet-common.manpages +33 -1
- data/ext/gentoo/init.d/puppet +1 -1
- data/ext/gentoo/init.d/puppetmaster +1 -1
- data/ext/redhat/puppet.spec.erb +0 -1
- data/install.rb +2 -1
- data/lib/hiera/backend/puppet_backend.rb +1 -1
- data/lib/puppet/application.rb +10 -9
- data/lib/puppet/application/agent.rb +87 -93
- data/lib/puppet/application/apply.rb +0 -2
- data/lib/puppet/application/device.rb +3 -3
- data/lib/puppet/application/kick.rb +2 -2
- data/lib/puppet/application/master.rb +41 -19
- data/lib/puppet/application/queue.rb +5 -3
- data/lib/puppet/bindings.rb +147 -0
- data/lib/puppet/configurer.rb +25 -15
- data/lib/puppet/configurer/fact_handler.rb +2 -9
- data/lib/puppet/daemon.rb +44 -33
- data/lib/puppet/defaults.rb +57 -26
- data/lib/puppet/error.rb +1 -1
- data/lib/puppet/external/dot.rb +2 -2
- data/lib/puppet/external/nagios/base.rb +1 -6
- data/lib/puppet/external/pson/common.rb +2 -2
- data/lib/puppet/external/pson/pure/generator.rb +2 -2
- data/lib/puppet/external/pson/pure/parser.rb +1 -1
- data/lib/puppet/face/ca.rb +1 -1
- data/lib/puppet/face/config.rb +1 -1
- data/lib/puppet/face/help.rb +2 -2
- data/lib/puppet/face/module/list.rb +2 -2
- data/lib/puppet/feature/rails.rb +1 -1
- data/lib/puppet/file_bucket/dipper.rb +0 -1
- data/lib/puppet/file_serving/base.rb +1 -1
- data/lib/puppet/file_serving/configuration/parser.rb +20 -14
- data/lib/puppet/forge.rb +0 -32
- data/lib/puppet/forge/cache.rb +1 -1
- data/lib/puppet/forge/errors.rb +3 -3
- data/lib/puppet/forge/repository.rb +7 -42
- data/lib/puppet/graph.rb +11 -0
- data/lib/puppet/graph/key.rb +26 -0
- data/lib/puppet/graph/prioritizer.rb +29 -0
- data/lib/puppet/graph/random_prioritizer.rb +16 -0
- data/lib/puppet/{rb_tree_map.rb → graph/rb_tree_map.rb} +3 -3
- data/lib/puppet/graph/relationship_graph.rb +246 -0
- data/lib/puppet/graph/sequential_prioritizer.rb +31 -0
- data/lib/puppet/{simple_graph.rb → graph/simple_graph.rb} +22 -3
- data/lib/puppet/graph/title_hash_prioritizer.rb +16 -0
- data/lib/puppet/indirector.rb +2 -2
- data/lib/puppet/indirector/catalog/compiler.rb +10 -7
- data/lib/puppet/indirector/catalog/static_compiler.rb +50 -0
- data/lib/puppet/indirector/certificate/rest.rb +1 -1
- data/lib/puppet/indirector/exec.rb +1 -1
- data/lib/puppet/indirector/facts/facter.rb +2 -2
- data/lib/puppet/indirector/facts/inventory_active_record.rb +0 -1
- data/lib/puppet/indirector/facts/network_device.rb +1 -1
- data/lib/puppet/indirector/file_bucket_file/file.rb +0 -1
- data/lib/puppet/indirector/indirection.rb +2 -2
- data/lib/puppet/indirector/memory.rb +9 -0
- data/lib/puppet/indirector/node/ldap.rb +2 -4
- data/lib/puppet/indirector/report/processor.rb +1 -2
- data/lib/puppet/indirector/report/rest.rb +1 -1
- data/lib/puppet/indirector/request.rb +32 -10
- data/lib/puppet/indirector/resource/rest.rb +1 -1
- data/lib/puppet/indirector/resource_type/parser.rb +31 -12
- data/lib/puppet/interface.rb +1 -1
- data/lib/puppet/interface/documentation.rb +7 -11
- data/lib/puppet/interface/option.rb +1 -1
- data/lib/puppet/interface/option_builder.rb +1 -1
- data/lib/puppet/metatype/manager.rb +2 -2
- data/lib/puppet/module.rb +7 -1
- data/lib/puppet/module_tool.rb +1 -1
- data/lib/puppet/module_tool/applications/application.rb +10 -0
- data/lib/puppet/module_tool/applications/installer.rb +6 -3
- data/lib/puppet/module_tool/dependency.rb +2 -0
- data/lib/puppet/module_tool/errors/upgrader.rb +1 -1
- data/lib/puppet/module_tool/metadata.rb +25 -13
- data/lib/puppet/module_tool/modulefile.rb +7 -7
- data/lib/puppet/module_tool/shared_behaviors.rb +4 -2
- data/lib/puppet/module_tool/skeleton.rb +1 -1
- data/lib/puppet/module_tool/skeleton/templates/generator/manifests/init.pp.erb +5 -5
- data/lib/puppet/module_tool/skeleton/templates/generator/tests/init.pp.erb +5 -4
- data/lib/puppet/network/auth_config_parser.rb +3 -0
- data/lib/puppet/network/authconfig.rb +0 -1
- data/lib/puppet/network/authorization.rb +1 -1
- data/lib/puppet/network/authstore.rb +2 -2
- data/lib/puppet/network/format_handler.rb +25 -114
- data/lib/puppet/network/format_support.rb +106 -0
- data/lib/puppet/network/formats.rb +10 -4
- data/lib/puppet/network/http/compression.rb +1 -1
- data/lib/puppet/network/http/connection.rb +76 -32
- data/lib/puppet/network/http/handler.rb +122 -61
- data/lib/puppet/network/http/rack/rest.rb +1 -1
- data/lib/puppet/network/http/webrick/rest.rb +9 -3
- data/lib/puppet/network/http_pool.rb +2 -2
- data/lib/puppet/network/resolver.rb +1 -0
- data/lib/puppet/network/server.rb +5 -81
- data/lib/puppet/node/environment.rb +256 -13
- data/lib/puppet/node/facts.rb +28 -2
- data/lib/puppet/parameter.rb +27 -18
- data/lib/puppet/parameter/boolean.rb +20 -0
- data/lib/puppet/parameter/path.rb +1 -1
- data/lib/puppet/parameter/value.rb +1 -1
- data/lib/puppet/parameter/value_collection.rb +1 -1
- data/lib/puppet/parser/ast/arithmetic_operator.rb +8 -0
- data/lib/puppet/parser/ast/casestatement.rb +0 -3
- data/lib/puppet/parser/ast/lambda.rb +25 -6
- data/lib/puppet/parser/ast/leaf.rb +10 -3
- data/lib/puppet/parser/ast/nop.rb +1 -1
- data/lib/puppet/parser/ast/resource_override.rb +0 -2
- data/lib/puppet/parser/compiler.rb +92 -34
- data/lib/puppet/parser/files.rb +0 -5
- data/lib/puppet/parser/functions/create_resources.rb +23 -46
- data/lib/puppet/parser/functions/each.rb +0 -2
- data/lib/puppet/parser/functions/extlookup.rb +2 -2
- data/lib/puppet/parser/functions/foreach.rb +0 -2
- data/lib/puppet/parser/functions/hiera_include.rb +1 -1
- data/lib/puppet/parser/functions/lookup.rb +44 -0
- data/lib/puppet/parser/functions/slice.rb +1 -1
- data/lib/puppet/parser/grammar.ra +0 -1
- data/lib/puppet/parser/lexer.rb +0 -1
- data/lib/puppet/parser/parser.rb +0 -1
- data/lib/puppet/parser/parser_factory.rb +3 -2
- data/lib/puppet/parser/parser_support.rb +1 -1
- data/lib/puppet/parser/relationship.rb +1 -1
- data/lib/puppet/parser/scope.rb +49 -24
- data/lib/puppet/parser/type_loader.rb +13 -18
- data/lib/puppet/pops.rb +45 -0
- data/lib/puppet/pops/adaptable.rb +2 -2
- data/lib/puppet/pops/adapters.rb +4 -0
- data/lib/puppet/pops/binder/binder.rb +421 -0
- data/lib/puppet/pops/binder/binder_issues.rb +142 -0
- data/lib/puppet/pops/binder/bindings_checker.rb +217 -0
- data/lib/puppet/pops/binder/bindings_composer.rb +241 -0
- data/lib/puppet/pops/binder/bindings_factory.rb +847 -0
- data/lib/puppet/pops/binder/bindings_label_provider.rb +46 -0
- data/lib/puppet/pops/binder/bindings_loader.rb +79 -0
- data/lib/puppet/pops/binder/bindings_model.rb +215 -0
- data/lib/puppet/pops/binder/bindings_model_dumper.rb +205 -0
- data/lib/puppet/pops/binder/bindings_validator_factory.rb +28 -0
- data/lib/puppet/pops/binder/config/binder_config.rb +139 -0
- data/lib/puppet/pops/binder/config/binder_config_checker.rb +183 -0
- data/lib/puppet/pops/binder/config/diagnostic_producer.rb +32 -0
- data/lib/puppet/pops/binder/config/issues.rb +106 -0
- data/lib/puppet/pops/binder/hiera2.rb +10 -0
- data/lib/puppet/pops/binder/hiera2/bindings_provider.rb +148 -0
- data/lib/puppet/pops/binder/hiera2/config.rb +69 -0
- data/lib/puppet/pops/binder/hiera2/config_checker.rb +68 -0
- data/lib/puppet/pops/binder/hiera2/diagnostic_producer.rb +36 -0
- data/lib/puppet/pops/binder/hiera2/issues.rb +67 -0
- data/lib/puppet/pops/binder/hiera2/json_backend.rb +18 -0
- data/lib/puppet/pops/binder/hiera2/yaml_backend.rb +21 -0
- data/lib/puppet/pops/binder/injector.rb +688 -0
- data/lib/puppet/pops/binder/injector_entry.rb +53 -0
- data/lib/puppet/pops/binder/key_factory.rb +61 -0
- data/lib/puppet/pops/binder/producers.rb +829 -0
- data/lib/puppet/pops/binder/scheme_handler/confdir_hiera_scheme.rb +67 -0
- data/lib/puppet/pops/binder/scheme_handler/confdir_scheme.rb +34 -0
- data/lib/puppet/pops/binder/scheme_handler/module_hiera_scheme.rb +92 -0
- data/lib/puppet/pops/binder/scheme_handler/module_scheme.rb +84 -0
- data/lib/puppet/pops/binder/scheme_handler/symbolic_scheme.rb +54 -0
- data/lib/puppet/pops/binder/system_bindings.rb +72 -0
- data/lib/puppet/pops/issue_reporter.rb +75 -0
- data/lib/puppet/pops/issues.rb +9 -5
- data/lib/puppet/pops/model/ast_transformer.rb +4 -4
- data/lib/puppet/pops/model/ast_tree_dumper.rb +1 -1
- data/lib/puppet/pops/model/factory.rb +25 -13
- data/lib/puppet/pops/model/model.rb +1 -1
- data/lib/puppet/pops/model/tree_dumper.rb +2 -2
- data/lib/puppet/pops/parser/egrammar.ra +0 -1
- data/lib/puppet/pops/parser/eparser.rb +1 -2
- data/lib/puppet/pops/parser/evaluating_parser.rb +162 -0
- data/lib/puppet/pops/parser/lexer.rb +8 -6
- data/lib/puppet/pops/types/class_loader.rb +118 -0
- data/lib/puppet/pops/types/type_calculator.rb +557 -0
- data/lib/puppet/pops/types/type_factory.rb +147 -0
- data/lib/puppet/pops/types/type_parser.rb +117 -0
- data/lib/puppet/pops/types/types.rb +132 -0
- data/lib/puppet/pops/validation.rb +146 -17
- data/lib/puppet/pops/validation/checker3_1.rb +1 -1
- data/lib/puppet/pops/validation/validator_factory_3_1.rb +6 -16
- data/lib/puppet/property.rb +3 -3
- data/lib/puppet/property/keyvalue.rb +1 -1
- data/lib/puppet/provider.rb +2 -2
- data/lib/puppet/provider/aixobject.rb +19 -21
- data/lib/puppet/provider/augeas/augeas.rb +3 -1
- data/lib/puppet/provider/command.rb +2 -2
- data/lib/puppet/provider/group/aix.rb +1 -1
- data/lib/puppet/provider/group/ldap.rb +1 -1
- data/lib/puppet/provider/macauthorization/macauthorization.rb +1 -1
- data/lib/puppet/provider/mailalias/aliases.rb +3 -8
- data/lib/puppet/provider/mcx/mcxcontent.rb +7 -1
- data/lib/puppet/provider/mount.rb +8 -3
- data/lib/puppet/provider/nameservice.rb +1 -1
- data/lib/puppet/provider/nameservice/directoryservice.rb +5 -5
- data/lib/puppet/provider/package/appdmg.rb +1 -1
- data/lib/puppet/provider/package/apt.rb +0 -1
- data/lib/puppet/provider/package/dpkg.rb +86 -32
- data/lib/puppet/provider/package/fink.rb +0 -2
- data/lib/puppet/provider/package/freebsd.rb +0 -2
- data/lib/puppet/provider/package/openbsd.rb +57 -10
- data/lib/puppet/provider/package/opkg.rb +0 -1
- data/lib/puppet/provider/package/pacman.rb +0 -1
- data/lib/puppet/provider/package/pip.rb +1 -1
- data/lib/puppet/provider/package/pkgdmg.rb +17 -6
- data/lib/puppet/provider/package/pkgutil.rb +1 -1
- data/lib/puppet/provider/package/portage.rb +9 -1
- data/lib/puppet/provider/package/ports.rb +2 -2
- data/lib/puppet/provider/package/rpm.rb +29 -12
- data/lib/puppet/provider/package/rug.rb +1 -1
- data/lib/puppet/provider/package/urpmi.rb +11 -15
- data/lib/puppet/provider/package/windows/exe_package.rb +1 -1
- data/lib/puppet/provider/package/windows/package.rb +1 -26
- data/lib/puppet/provider/package/yum.rb +1 -1
- data/lib/puppet/provider/package/zypper.rb +22 -3
- data/lib/puppet/provider/parsedfile.rb +1 -12
- data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +1 -1
- data/lib/puppet/provider/service/base.rb +1 -1
- data/lib/puppet/provider/service/daemontools.rb +3 -3
- data/lib/puppet/provider/service/debian.rb +1 -1
- data/lib/puppet/provider/service/init.rb +14 -20
- data/lib/puppet/provider/service/openrc.rb +3 -1
- data/lib/puppet/provider/service/redhat.rb +5 -8
- data/lib/puppet/provider/service/runit.rb +3 -2
- data/lib/puppet/provider/service/systemd.rb +1 -1
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +1 -1
- data/lib/puppet/provider/sshkey/parsed.rb +0 -2
- data/lib/puppet/provider/user/aix.rb +25 -12
- data/lib/puppet/provider/user/directoryservice.rb +4 -7
- data/lib/puppet/provider/user/ldap.rb +0 -1
- data/lib/puppet/provider/user/user_role_add.rb +2 -0
- data/lib/puppet/provider/user/useradd.rb +1 -1
- data/lib/puppet/provider/zone/solaris.rb +1 -2
- data/lib/puppet/reference/metaparameter.rb +1 -1
- data/lib/puppet/reference/type.rb +1 -1
- data/lib/puppet/reports/rrdgraph.rb +1 -1
- data/lib/puppet/reports/tagmail.rb +1 -1
- data/lib/puppet/resource.rb +16 -4
- data/lib/puppet/resource/catalog.rb +111 -173
- data/lib/puppet/resource/status.rb +42 -3
- data/lib/puppet/resource/type.rb +33 -46
- data/lib/puppet/resource/type_collection.rb +19 -15
- data/lib/puppet/run.rb +5 -1
- data/lib/puppet/scheduler/scheduler.rb +14 -15
- data/lib/puppet/settings.rb +78 -41
- data/lib/puppet/settings/boolean_setting.rb +0 -2
- data/lib/puppet/settings/config_file.rb +0 -2
- data/lib/puppet/settings/directory_setting.rb +0 -2
- data/lib/puppet/settings/duration_setting.rb +0 -2
- data/lib/puppet/settings/enum_setting.rb +16 -0
- data/lib/puppet/settings/file_setting.rb +0 -2
- data/lib/puppet/settings/path_setting.rb +0 -2
- data/lib/puppet/settings/string_setting.rb +0 -3
- data/lib/puppet/settings/terminus_setting.rb +0 -2
- data/lib/puppet/ssl/certificate_authority.rb +102 -9
- data/lib/puppet/test/test_helper.rb +1 -0
- data/lib/puppet/transaction.rb +130 -292
- data/lib/puppet/transaction/additional_resource_generator.rb +126 -0
- data/lib/puppet/transaction/event.rb +16 -1
- data/lib/puppet/transaction/report.rb +34 -14
- data/lib/puppet/transaction/resource_harness.rb +16 -19
- data/lib/puppet/type.rb +59 -53
- data/lib/puppet/type/component.rb +0 -2
- data/lib/puppet/type/cron.rb +13 -2
- data/lib/puppet/type/exec.rb +5 -7
- data/lib/puppet/type/file.rb +9 -32
- data/lib/puppet/type/file/content.rb +4 -1
- data/lib/puppet/type/file/ctime.rb +3 -1
- data/lib/puppet/type/file/ensure.rb +1 -1
- data/lib/puppet/type/file/mode.rb +0 -1
- data/lib/puppet/type/file/mtime.rb +2 -1
- data/lib/puppet/type/group.rb +7 -9
- data/lib/puppet/type/host.rb +1 -2
- data/lib/puppet/type/mcx.rb +0 -1
- data/lib/puppet/type/mount.rb +38 -6
- data/lib/puppet/type/package.rb +2 -2
- data/lib/puppet/type/resources.rb +5 -4
- data/lib/puppet/type/schedule.rb +1 -4
- data/lib/puppet/type/selmodule.rb +1 -1
- data/lib/puppet/type/service.rb +1 -3
- data/lib/puppet/type/tidy.rb +3 -3
- data/lib/puppet/type/user.rb +9 -13
- data/lib/puppet/type/yumrepo.rb +11 -7
- data/lib/puppet/util.rb +14 -7
- data/lib/puppet/util/autoload.rb +0 -1
- data/lib/puppet/util/backups.rb +1 -3
- data/lib/puppet/util/classgen.rb +1 -1
- data/lib/puppet/util/command_line/puppet_option_parser.rb +1 -3
- data/lib/puppet/util/command_line/trollop.rb +1 -1
- data/lib/puppet/util/constant_inflector.rb +1 -2
- data/lib/puppet/util/errors.rb +1 -0
- data/lib/puppet/util/file_watcher.rb +28 -0
- data/lib/puppet/util/fileparsing.rb +1 -3
- data/lib/puppet/util/filetype.rb +0 -1
- data/lib/puppet/util/http_proxy.rb +38 -0
- data/lib/puppet/util/ldap/manager.rb +1 -2
- data/lib/puppet/util/log.rb +31 -10
- data/lib/puppet/util/log/destinations.rb +0 -50
- data/lib/puppet/util/metric.rb +8 -1
- data/lib/puppet/util/monkey_patches.rb +14 -148
- data/lib/puppet/util/network_device/cisco/facts.rb +1 -1
- data/lib/puppet/util/network_device/config.rb +6 -9
- data/lib/puppet/util/network_device/transport/ssh.rb +1 -1
- data/lib/puppet/util/pidlock.rb +3 -0
- data/lib/puppet/util/posix.rb +1 -1
- data/lib/puppet/util/profiler.rb +1 -1
- data/lib/puppet/util/rdoc.rb +1 -1
- data/lib/puppet/util/rdoc/generators/puppet_generator.rb +0 -1
- data/lib/puppet/util/rdoc/generators/template/puppet/puppet.rb +50 -42
- data/lib/puppet/util/retryaction.rb +0 -1
- data/lib/puppet/util/symbolic_file_mode.rb +5 -1
- data/lib/puppet/util/tagging.rb +0 -2
- data/lib/puppet/util/warnings.rb +3 -0
- data/lib/puppet/util/watched_file.rb +37 -0
- data/lib/puppet/util/watcher.rb +17 -0
- data/lib/puppet/util/watcher/change_watcher.rb +33 -0
- data/lib/puppet/util/watcher/periodic_watcher.rb +37 -0
- data/lib/puppet/util/watcher/timer.rb +19 -0
- data/lib/puppet/util/windows/user.rb +1 -1
- data/lib/puppet/version.rb +1 -1
- data/lib/puppetx.rb +109 -0
- data/lib/puppetx/puppet/bindings_scheme_handler.rb +130 -0
- data/lib/puppetx/puppet/hiera2_backend.rb +31 -0
- data/lib/puppetx/puppet/syntax_checker.rb +91 -0
- data/lib/puppetx/puppetlabs/syntax_checkers/json.rb +39 -0
- data/lib/semver.rb +1 -1
- data/man/man8/puppet-kick.8 +1 -1
- data/spec/fixtures/integration/provider/cron/crontab/unspecialized +15 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/hiera1config/binder_config.yaml +18 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/hiera1config/hiera.yaml +8 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/hiera1config/modules/good/common.yaml +1 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/hiera1config/modules/good/hiera.yaml +10 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/binder_config.yaml +19 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/common.yaml +1 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/hiera.yaml +11 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/localhost.yaml +1 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/awesome/common.yaml +3 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/awesome/hiera.yaml +13 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/awesome/lib/puppet/bindings/awesome/default.rb +4 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/awesome/lib/puppetx/awesome/echo_backend.rb +11 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/awesome/lib/puppetx/awesome/echo_scheme_handler.rb +18 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/awesome/localhost.yaml +1 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/bad/common.yaml +3 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/bad/hiera_config.yaml +9 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/good/common.yaml +2 -0
- data/spec/fixtures/unit/pops/binder/bindings_composer/ok/modules/good/hiera.yaml +11 -0
- data/spec/fixtures/unit/pops/binder/config/binder_config/ok/binder_config.yaml +9 -0
- data/spec/fixtures/unit/pops/binder/hiera2/bindings_provider/ok/hiera.yaml +9 -0
- data/spec/fixtures/unit/pops/binder/hiera2/bindings_provider/ok/node.example.com.json +9 -0
- data/spec/fixtures/unit/pops/binder/hiera2/bindings_provider/ok/node.example.com.yaml +5 -0
- data/spec/fixtures/unit/pops/binder/hiera2/config/bad_syntax/hiera.yaml +10 -0
- data/spec/fixtures/unit/pops/binder/hiera2/config/malformed_hierarchy/hiera.yaml +8 -0
- data/spec/fixtures/unit/pops/binder/hiera2/config/missing/foo.txt +1 -0
- data/spec/fixtures/unit/pops/binder/hiera2/config/no_backends/hiera.yaml +7 -0
- data/spec/fixtures/unit/pops/binder/hiera2/config/no_hierarchy/hiera.yaml +4 -0
- data/spec/fixtures/unit/pops/binder/hiera2/config/not_a_hash/hiera.yaml +2 -0
- data/spec/fixtures/unit/pops/binder/hiera2/config/ok/hiera.yaml +8 -0
- data/spec/fixtures/unit/pops/binder/hiera2/yaml_backend/empty/common.yaml +0 -0
- data/spec/fixtures/unit/pops/binder/hiera2/yaml_backend/invalid/common.yaml +1 -0
- data/spec/fixtures/unit/pops/binder/hiera2/yaml_backend/ok/common.yaml +2 -0
- data/spec/fixtures/unit/provider/package/openbsd/pkginfo_flavors.list +2 -0
- data/spec/integration/agent/logging_spec.rb +178 -0
- data/spec/integration/configurer_spec.rb +1 -1
- data/spec/integration/defaults_spec.rb +0 -6
- data/spec/integration/network/authconfig_spec.rb +19 -0
- data/spec/integration/network/server/webrick_spec.rb +10 -11
- data/spec/integration/parser/catalog_spec.rb +85 -0
- data/spec/integration/provider/cron/crontab_spec.rb +11 -0
- data/spec/integration/provider/mount_spec.rb +1 -0
- data/spec/integration/transaction_spec.rb +8 -8
- data/spec/integration/type/file_spec.rb +1 -1
- data/spec/integration/util/settings_spec.rb +58 -11
- data/spec/lib/matchers/include_in_order.rb +21 -0
- data/spec/lib/matchers/include_in_order_spec.rb +30 -0
- data/spec/lib/matchers/relationship_graph_matchers.rb +48 -0
- data/spec/lib/puppet_spec/compiler.rb +24 -0
- data/spec/lib/puppet_spec/pops.rb +16 -0
- data/spec/spec_helper.rb +0 -1
- data/spec/unit/application/agent_spec.rb +145 -145
- data/spec/unit/application/apply_spec.rb +1 -1
- data/spec/unit/application/doc_spec.rb +1 -1
- data/spec/unit/application/face_base_spec.rb +3 -3
- data/spec/unit/application/facts_spec.rb +1 -0
- data/spec/unit/application/master_spec.rb +0 -15
- data/spec/unit/application/queue_spec.rb +6 -12
- data/spec/unit/application/resource_spec.rb +1 -1
- data/spec/unit/configurer/fact_handler_spec.rb +19 -50
- data/spec/unit/configurer_spec.rb +23 -7
- data/spec/unit/daemon_spec.rb +97 -121
- data/spec/unit/defaults_spec.rb +44 -0
- data/spec/unit/face/node_spec.rb +2 -2
- data/spec/unit/file_serving/configuration/parser_spec.rb +23 -33
- data/spec/unit/file_serving/configuration_spec.rb +2 -2
- data/spec/unit/file_serving/mount/file_spec.rb +4 -4
- data/spec/unit/forge/repository_spec.rb +9 -29
- data/spec/unit/graph/key_spec.rb +41 -0
- data/spec/unit/{rb_tree_map_spec.rb → graph/rb_tree_map_spec.rb} +7 -7
- data/spec/unit/graph/relationship_graph_spec.rb +393 -0
- data/spec/unit/graph/sequential_prioritizer_spec.rb +32 -0
- data/spec/unit/{simple_graph_spec.rb → graph/simple_graph.rb} +42 -254
- data/spec/unit/graph/title_hash_prioritizer_spec.rb +49 -0
- data/spec/unit/hiera_puppet_spec.rb +1 -1
- data/spec/unit/indirector/catalog/active_record_spec.rb +4 -2
- data/spec/unit/indirector/catalog/compiler_spec.rb +20 -26
- data/spec/unit/indirector/face_spec.rb +1 -1
- data/spec/unit/indirector/facts/facter_spec.rb +11 -1
- data/spec/unit/indirector/facts/network_device_spec.rb +11 -1
- data/spec/unit/indirector/hiera_spec.rb +1 -1
- data/spec/unit/indirector/instrumentation_data/local_spec.rb +1 -1
- data/spec/unit/indirector/instrumentation_listener/local_spec.rb +1 -1
- data/spec/unit/indirector/request_spec.rb +92 -39
- data/spec/unit/indirector/rest_spec.rb +1 -0
- data/spec/unit/indirector_spec.rb +2 -2
- data/spec/unit/interface/option_builder_spec.rb +1 -0
- data/spec/unit/interface/option_spec.rb +1 -0
- data/spec/unit/interface_spec.rb +2 -2
- data/spec/unit/module_tool/applications/installer_spec.rb +49 -2
- data/spec/unit/module_tool/metadata_spec.rb +13 -0
- data/spec/unit/network/authstore_spec.rb +1 -1
- data/spec/unit/network/format_handler_spec.rb +33 -282
- data/spec/unit/network/format_support_spec.rb +199 -0
- data/spec/unit/network/formats_spec.rb +2 -2
- data/spec/unit/network/http/connection_spec.rb +88 -7
- data/spec/unit/network/http/handler_spec.rb +271 -249
- data/spec/unit/network/http/rack/rest_spec.rb +1 -1
- data/spec/unit/network/http/webrick/rest_spec.rb +73 -22
- data/spec/unit/network/http_pool_spec.rb +40 -0
- data/spec/unit/network/server_spec.rb +18 -207
- data/spec/unit/node/facts_spec.rb +68 -17
- data/spec/unit/other/selinux_spec.rb +24 -20
- data/spec/unit/parameter/boolean_spec.rb +25 -0
- data/spec/unit/parameter/value_collection_spec.rb +7 -7
- data/spec/unit/parameter_spec.rb +10 -13
- data/spec/unit/parser/ast/function_spec.rb +4 -4
- data/spec/unit/parser/ast/leaf_spec.rb +45 -6
- data/spec/unit/parser/collector_spec.rb +3 -3
- data/spec/unit/parser/compiler_spec.rb +4 -3
- data/spec/unit/parser/functions/create_resources_spec.rb +9 -25
- data/spec/unit/parser/functions/extlookup_spec.rb +2 -2
- data/spec/unit/parser/functions/hiera_include_spec.rb +12 -0
- data/spec/unit/parser/functions/lookup_spec.rb +96 -0
- data/spec/unit/parser/functions/regsubst_spec.rb +2 -2
- data/spec/unit/parser/functions/split_spec.rb +2 -2
- data/spec/unit/parser/functions/sprintf_spec.rb +1 -1
- data/spec/unit/parser/functions/versioncmp_spec.rb +2 -2
- data/spec/unit/parser/functions_spec.rb +7 -7
- data/spec/unit/parser/lexer_spec.rb +1 -1
- data/spec/unit/parser/methods/collect_spec.rb +43 -0
- data/spec/unit/parser/resource_spec.rb +9 -9
- data/spec/unit/parser/scope_spec.rb +45 -2
- data/spec/unit/parser/type_loader_spec.rb +159 -175
- data/spec/unit/pops/binder/binder_spec.rb +62 -0
- data/spec/unit/pops/binder/bindings_checker_spec.rb +196 -0
- data/spec/unit/pops/binder/bindings_composer_spec.rb +89 -0
- data/spec/unit/pops/binder/bindings_validator_factory_spec.rb +18 -0
- data/spec/unit/pops/binder/config/binder_config_spec.rb +48 -0
- data/spec/unit/pops/binder/hiera2/bindings_provider_spec.rb +74 -0
- data/spec/unit/pops/binder/hiera2/config_spec.rb +61 -0
- data/spec/unit/pops/binder/hiera2/yaml_backend_spec.rb +33 -0
- data/spec/unit/pops/binder/injector_spec.rb +789 -0
- data/spec/unit/pops/containment_spec.rb +1 -0
- data/spec/unit/pops/issues_spec.rb +1 -1
- data/spec/unit/pops/parser/evaluating_parser_spec.rb +88 -0
- data/spec/unit/pops/parser/lexer_spec.rb +1 -1
- data/spec/unit/pops/parser/parse_calls_spec.rb +4 -0
- data/spec/unit/pops/parser/parser_spec.rb +1 -1
- data/spec/unit/pops/types/type_calculator_spec.rb +484 -0
- data/spec/unit/pops/types/type_factory_spec.rb +65 -0
- data/spec/unit/pops/types/type_parser_spec.rb +93 -0
- data/spec/unit/property/list_spec.rb +1 -1
- data/spec/unit/property/ordered_list_spec.rb +1 -1
- data/spec/unit/provider/aixobject_spec.rb +101 -0
- data/spec/unit/provider/augeas/augeas_spec.rb +14 -3
- data/spec/unit/provider/mcx/mcxcontent_spec.rb +52 -16
- data/spec/unit/provider/mount/parsed_spec.rb +44 -56
- data/spec/unit/provider/mount_spec.rb +11 -2
- data/spec/unit/provider/naginator_spec.rb +8 -0
- data/spec/unit/provider/package/apt_spec.rb +5 -1
- data/spec/unit/provider/package/aptitude_spec.rb +9 -5
- data/spec/unit/provider/package/aptrpm_spec.rb +2 -2
- data/spec/unit/provider/package/dpkg_spec.rb +274 -99
- data/spec/unit/provider/package/openbsd_spec.rb +84 -1
- data/spec/unit/provider/package/opkg_spec.rb +3 -3
- data/spec/unit/provider/package/pip_spec.rb +16 -0
- data/spec/unit/provider/package/pkgdmg_spec.rb +62 -7
- data/spec/unit/provider/package/rpm_spec.rb +112 -21
- data/spec/unit/provider/package/urpmi.rb +80 -0
- data/spec/unit/provider/package/windows/exe_package_spec.rb +1 -1
- data/spec/unit/provider/package/yum_spec.rb +85 -0
- data/spec/unit/provider/package/zypper_spec.rb +25 -6
- data/spec/unit/provider/parsedfile_spec.rb +3 -2
- data/spec/unit/provider/service/init_spec.rb +10 -10
- data/spec/unit/provider/service/openrc_spec.rb +16 -0
- data/spec/unit/provider/service/openwrt_spec.rb +1 -1
- data/spec/unit/provider/service/redhat_spec.rb +7 -0
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +2 -2
- data/spec/unit/provider/user/aix_spec.rb +89 -0
- data/spec/unit/provider/user/directoryservice_spec.rb +11 -4
- data/spec/unit/provider/user/user_role_add_spec.rb +18 -0
- data/spec/unit/provider_spec.rb +2 -13
- data/spec/unit/reports/http_spec.rb +1 -1
- data/spec/unit/resource/catalog_spec.rb +23 -97
- data/spec/unit/resource/resource_type.json +34 -0
- data/spec/unit/resource/status_spec.rb +56 -0
- data/spec/unit/resource/type_collection_spec.rb +6 -6
- data/spec/unit/resource/type_spec.rb +25 -5
- data/spec/unit/resource_spec.rb +68 -24
- data/spec/unit/run_spec.rb +16 -0
- data/spec/unit/scheduler/scheduler_spec.rb +14 -27
- data/spec/unit/semver_spec.rb +5 -0
- data/spec/unit/settings/enum_setting_spec.rb +27 -0
- data/spec/unit/settings_spec.rb +53 -44
- data/spec/unit/ssl/certificate_authority_spec.rb +155 -19
- data/spec/unit/transaction/additional_resource_generator_spec.rb +419 -0
- data/spec/unit/transaction/event_manager_spec.rb +2 -2
- data/spec/unit/transaction/event_spec.rb +57 -0
- data/spec/unit/transaction/report_spec.rb +66 -0
- data/spec/unit/transaction/resource_harness_spec.rb +27 -20
- data/spec/unit/transaction_spec.rb +182 -390
- data/spec/unit/type/augeas_spec.rb +3 -3
- data/spec/unit/type/component_spec.rb +0 -9
- data/spec/unit/type/computer_spec.rb +1 -1
- data/spec/unit/type/cron_spec.rb +2 -2
- data/spec/unit/type/exec_spec.rb +4 -2
- data/spec/unit/type/file/content_spec.rb +11 -0
- data/spec/unit/type/file/group_spec.rb +1 -1
- data/spec/unit/type/file_spec.rb +16 -8
- data/spec/unit/type/mount_spec.rb +445 -259
- data/spec/unit/type/package_spec.rb +4 -4
- data/spec/unit/type/resources_spec.rb +30 -1
- data/spec/unit/type/user_spec.rb +26 -3
- data/spec/unit/type/yumrepo_spec.rb +7 -27
- data/spec/unit/type/zone_spec.rb +4 -1
- data/spec/unit/type_spec.rb +66 -33
- data/spec/unit/util/backups_spec.rb +3 -3
- data/spec/unit/util/http_proxy_spec.rb +83 -0
- data/spec/unit/util/log_spec.rb +79 -8
- data/spec/unit/util/metric_spec.rb +12 -0
- data/spec/unit/util/monkey_patches_spec.rb +6 -0
- data/spec/unit/util/network_device/config_spec.rb +26 -64
- data/spec/unit/util/pidlock_spec.rb +4 -1
- data/spec/unit/util/tagging_spec.rb +5 -9
- data/spec/unit/util/warnings_spec.rb +1 -1
- data/spec/unit/util/watched_file_spec.rb +52 -0
- data/spec/unit/util/watcher/periodic_watcher_spec.rb +52 -0
- data/spec/unit/util/watcher_spec.rb +56 -0
- data/spec/unit/util_spec.rb +16 -0
- metadata +2767 -2576
- data/ext/debian/puppet.manpages +0 -32
- data/ext/osx/PackageInfo.plist +0 -36
- data/ext/osx/createpackage.sh +0 -187
- data/ext/redhat/rundir-perms.patch +0 -28
- data/lib/puppet/external/base64.rb +0 -19
- data/lib/puppet/util/graph.rb +0 -27
- data/lib/puppet/util/loadedfile.rb +0 -61
- data/lib/puppet/util/log_paths.rb +0 -22
- data/lib/puppet/util/subclass_loader.rb +0 -78
- data/spec/monkey_patches/publicize_methods.rb +0 -11
- data/spec/unit/util/loadedfile_spec.rb +0 -71
@@ -0,0 +1,147 @@
|
|
1
|
+
# Helper module that makes creation of type objects simpler.
|
2
|
+
# @api public
|
3
|
+
#
|
4
|
+
module Puppet::Pops::Types::TypeFactory
|
5
|
+
@type_calculator = Puppet::Pops::Types::TypeCalculator.new()
|
6
|
+
|
7
|
+
Types = Puppet::Pops::Types
|
8
|
+
|
9
|
+
# Produces the Integer type
|
10
|
+
# @api public
|
11
|
+
#
|
12
|
+
def self.integer()
|
13
|
+
Types::PIntegerType.new()
|
14
|
+
end
|
15
|
+
|
16
|
+
# Produces the Float type
|
17
|
+
# @api public
|
18
|
+
#
|
19
|
+
def self.float()
|
20
|
+
Types::PFloatType.new()
|
21
|
+
end
|
22
|
+
|
23
|
+
# Produces a string representation of the type
|
24
|
+
# @api public
|
25
|
+
#
|
26
|
+
def self.label(t)
|
27
|
+
@type_calculator.string(t)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Produces the String type
|
31
|
+
# @api public
|
32
|
+
#
|
33
|
+
def self.string()
|
34
|
+
Types::PStringType.new()
|
35
|
+
end
|
36
|
+
|
37
|
+
# Produces the Boolean type
|
38
|
+
# @api public
|
39
|
+
#
|
40
|
+
def self.boolean()
|
41
|
+
Types::PBooleanType.new()
|
42
|
+
end
|
43
|
+
|
44
|
+
# Produces the Pattern type
|
45
|
+
# @api public
|
46
|
+
#
|
47
|
+
def self.pattern()
|
48
|
+
Types::PPatternType.new()
|
49
|
+
end
|
50
|
+
|
51
|
+
# Produces the Literal type
|
52
|
+
# @api public
|
53
|
+
#
|
54
|
+
def self.literal()
|
55
|
+
Types::PLiteralType.new()
|
56
|
+
end
|
57
|
+
|
58
|
+
# Produces the abstract type Collection
|
59
|
+
# @api public
|
60
|
+
#
|
61
|
+
def self.collection()
|
62
|
+
Types::PCollectionType.new()
|
63
|
+
end
|
64
|
+
|
65
|
+
# Produces the Data type
|
66
|
+
# @api public
|
67
|
+
#
|
68
|
+
def self.data()
|
69
|
+
Types::PDataType.new()
|
70
|
+
end
|
71
|
+
|
72
|
+
# Produces a type for Array[o] where o is either a type, or an instance for which a type is inferred.
|
73
|
+
# @api public
|
74
|
+
#
|
75
|
+
def self.array_of(o)
|
76
|
+
type = Types::PArrayType.new()
|
77
|
+
type.element_type = type_of(o)
|
78
|
+
type
|
79
|
+
end
|
80
|
+
|
81
|
+
# Produces a type for Hash[Literal, o] where o is either a type, or an instance for which a type is inferred.
|
82
|
+
# @api public
|
83
|
+
#
|
84
|
+
def self.hash_of(value, key = literal())
|
85
|
+
type = Types::PHashType.new()
|
86
|
+
type.key_type = type_of(key)
|
87
|
+
type.element_type = type_of(value)
|
88
|
+
type
|
89
|
+
end
|
90
|
+
|
91
|
+
# Produces a type for Array[Data]
|
92
|
+
# @api public
|
93
|
+
#
|
94
|
+
def self.array_of_data()
|
95
|
+
type = Types::PArrayType.new()
|
96
|
+
type.element_type = data()
|
97
|
+
type
|
98
|
+
end
|
99
|
+
|
100
|
+
# Produces a type for Hash[Literal, Data]
|
101
|
+
# @api public
|
102
|
+
#
|
103
|
+
def self.hash_of_data()
|
104
|
+
type = Types::PHashType.new()
|
105
|
+
type.key_type = literal()
|
106
|
+
type.element_type = data()
|
107
|
+
type
|
108
|
+
end
|
109
|
+
|
110
|
+
# Produce a type corresponding to the class of given unless given is a String, Class or a PObjectType.
|
111
|
+
# When a String is given this is taken as a classname.
|
112
|
+
#
|
113
|
+
def self.type_of(o)
|
114
|
+
if o.is_a?(Class)
|
115
|
+
@type_calculator.type(o)
|
116
|
+
elsif o.is_a?(Types::PObjectType)
|
117
|
+
o
|
118
|
+
elsif o.is_a?(String)
|
119
|
+
type = Types::PRubyType.new()
|
120
|
+
type.ruby_class = o
|
121
|
+
type
|
122
|
+
else
|
123
|
+
@type_calculator.infer(o)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
# Produces a type for a class or infers a type for something that is not a class
|
128
|
+
# @note
|
129
|
+
# To get the type for the class' class use `TypeCalculator.infer(c)`
|
130
|
+
#
|
131
|
+
# @overload ruby(o)
|
132
|
+
# @param o [Class] produces the type corresponding to the class (e.g. Integer becomes PIntegerType)
|
133
|
+
# @overload ruby(o)
|
134
|
+
# @param o [Object] produces the type corresponding to the instance class (e.g. 3 becomes PIntegerType)
|
135
|
+
#
|
136
|
+
# @api public
|
137
|
+
#
|
138
|
+
def self.ruby(o)
|
139
|
+
if o.is_a?(Class)
|
140
|
+
@type_calculator.type(o)
|
141
|
+
else
|
142
|
+
type = Types::PRubyType.new()
|
143
|
+
type.ruby_class = o.class.name
|
144
|
+
type
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
# This class provides parsing of Type Specification from a string into the Type
|
2
|
+
# Model that is produced by the Puppet::Pops::Types::TypeFactory.
|
3
|
+
#
|
4
|
+
# The Type Specifications that are parsed are the same as the stringified forms
|
5
|
+
# of types produced by the {Puppet::Pops::Types::TypeCalculator TypeCalculator}.
|
6
|
+
#
|
7
|
+
# @api public
|
8
|
+
class Puppet::Pops::Types::TypeParser
|
9
|
+
# @api private
|
10
|
+
TYPES = Puppet::Pops::Types::TypeFactory
|
11
|
+
|
12
|
+
# @api public
|
13
|
+
def initialize
|
14
|
+
@parser = Puppet::Pops::Parser::Parser.new()
|
15
|
+
@type_transformer = Puppet::Pops::Visitor.new(nil, "interpret", 0, 0)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Produces a *puppet type* based on the given string.
|
19
|
+
#
|
20
|
+
# @example
|
21
|
+
# parser.parse('Integer')
|
22
|
+
# parser.parse('Array[String]')
|
23
|
+
# parser.parse('Hash[Integer, Array[String]]')
|
24
|
+
#
|
25
|
+
# @param string [String] a string with the type expressed in stringified form as produced by the
|
26
|
+
# {Puppet::Pops::Types::TypeCalculator#string TypeCalculator#string} method.
|
27
|
+
# @return [Puppet::Pops::Types::PObjectType] a specialization of the PObjectType representing the type.
|
28
|
+
#
|
29
|
+
# @api public
|
30
|
+
#
|
31
|
+
def parse(string)
|
32
|
+
@string = string
|
33
|
+
model = @parser.parse_string(@string)
|
34
|
+
if model
|
35
|
+
interpret(model.current)
|
36
|
+
else
|
37
|
+
raise_invalid_type_specification_error
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# @api private
|
42
|
+
def interpret(ast)
|
43
|
+
@type_transformer.visit_this(self, ast)
|
44
|
+
end
|
45
|
+
|
46
|
+
# @api private
|
47
|
+
def interpret_Object(anything)
|
48
|
+
raise_invalid_type_specification_error
|
49
|
+
end
|
50
|
+
|
51
|
+
# @api private
|
52
|
+
def interpret_QualifiedReference(name_ast)
|
53
|
+
case name_ast.value
|
54
|
+
when "integer"
|
55
|
+
TYPES.integer
|
56
|
+
when "float"
|
57
|
+
TYPES.float
|
58
|
+
when "string"
|
59
|
+
TYPES.string
|
60
|
+
when "boolean"
|
61
|
+
TYPES.boolean
|
62
|
+
when "pattern"
|
63
|
+
TYPES.pattern
|
64
|
+
when "data"
|
65
|
+
TYPES.data
|
66
|
+
when "array"
|
67
|
+
TYPES.array_of_data
|
68
|
+
when "hash"
|
69
|
+
TYPES.hash_of_data
|
70
|
+
else
|
71
|
+
raise_unknown_type_error(name_ast)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# @api private
|
76
|
+
def interpret_AccessExpression(parameterized_ast)
|
77
|
+
parameters = parameterized_ast.keys.collect { |param| interpret(param) }
|
78
|
+
case parameterized_ast.left_expr.value
|
79
|
+
when "array"
|
80
|
+
if parameters.size != 1
|
81
|
+
raise_invalid_parameters_error("Array", 1, parameters.size)
|
82
|
+
end
|
83
|
+
TYPES.array_of(parameters[0])
|
84
|
+
when "hash"
|
85
|
+
if parameters.size == 1
|
86
|
+
TYPES.hash_of(parameters[0])
|
87
|
+
elsif parameters.size != 2
|
88
|
+
raise_invalid_parameters_error("Hash", "1 or 2", parameters.size)
|
89
|
+
else
|
90
|
+
TYPES.hash_of(parameters[1], parameters[0])
|
91
|
+
end
|
92
|
+
else
|
93
|
+
raise_unknown_type_error(parameterized_ast.left_expr)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
private
|
98
|
+
|
99
|
+
def raise_invalid_type_specification_error
|
100
|
+
raise Puppet::ParseError,
|
101
|
+
"The expression <#{@string}> is not a valid type specification."
|
102
|
+
end
|
103
|
+
|
104
|
+
def raise_invalid_parameters_error(type, required, given)
|
105
|
+
raise Puppet::ParseError,
|
106
|
+
"Invalid number of type parameters specified: #{type} requires #{required}, #{given} provided"
|
107
|
+
end
|
108
|
+
|
109
|
+
def raise_unknown_type_error(ast)
|
110
|
+
raise Puppet::ParseError, "Unknown type <#{original_text_of(ast)}>"
|
111
|
+
end
|
112
|
+
|
113
|
+
def original_text_of(ast)
|
114
|
+
position = Puppet::Pops::Adapters::SourcePosAdapter.adapt(ast)
|
115
|
+
position.extract_text_from_string(@string)
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,132 @@
|
|
1
|
+
require 'rgen/metamodel_builder'
|
2
|
+
|
3
|
+
# The Types model is a model of Puppet Language types.
|
4
|
+
#
|
5
|
+
# The exact relationship between types is not visible in this model wrt. the PDataType which is an abstraction
|
6
|
+
# of Literal, Array[Data], and Hash[Literal, Data] nested to any depth. This means it is not possible to
|
7
|
+
# infer the type by simply looking at the inheritance hierarchy. The {Puppet::Pops::Types::TypeCalculator} should
|
8
|
+
# be used to answer questions about types. The {Puppet::Pops::Types::TypeFactory} should be used to create an instance
|
9
|
+
# of a type whenever one is needed.
|
10
|
+
#
|
11
|
+
# @api public
|
12
|
+
#
|
13
|
+
module Puppet::Pops::Types
|
14
|
+
|
15
|
+
# The type of types.
|
16
|
+
# @api public
|
17
|
+
class PType < Puppet::Pops::Model::PopsObject
|
18
|
+
end
|
19
|
+
|
20
|
+
# Base type for all types except {Puppet::Pops::Types::PType PType}, the type of types.
|
21
|
+
# @api public
|
22
|
+
class PObjectType < Puppet::Pops::Model::PopsObject
|
23
|
+
|
24
|
+
module ClassModule
|
25
|
+
def hash
|
26
|
+
self.class.hash
|
27
|
+
end
|
28
|
+
|
29
|
+
def ==(o)
|
30
|
+
self.class == o.class
|
31
|
+
end
|
32
|
+
|
33
|
+
alias eql? ==
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
# @api public
|
39
|
+
class PNilType < PObjectType
|
40
|
+
end
|
41
|
+
|
42
|
+
# A flexible data type, being assignable to its subtypes as well as PArrayType and PHashType with element type assignable to PDataType.
|
43
|
+
#
|
44
|
+
# @api public
|
45
|
+
class PDataType < PObjectType
|
46
|
+
end
|
47
|
+
|
48
|
+
# Type that is PDataType compatible, but is not a PCollectionType.
|
49
|
+
# @api public
|
50
|
+
class PLiteralType < PDataType
|
51
|
+
end
|
52
|
+
|
53
|
+
# @api public
|
54
|
+
class PStringType < PLiteralType
|
55
|
+
end
|
56
|
+
|
57
|
+
# @api public
|
58
|
+
class PNumericType < PLiteralType
|
59
|
+
end
|
60
|
+
|
61
|
+
# @api public
|
62
|
+
class PIntegerType < PNumericType
|
63
|
+
end
|
64
|
+
|
65
|
+
# @api public
|
66
|
+
class PFloatType < PNumericType
|
67
|
+
end
|
68
|
+
|
69
|
+
# @api public
|
70
|
+
class PPatternType < PLiteralType
|
71
|
+
end
|
72
|
+
|
73
|
+
# @api public
|
74
|
+
class PBooleanType < PLiteralType
|
75
|
+
end
|
76
|
+
|
77
|
+
# @api public
|
78
|
+
class PCollectionType < PObjectType
|
79
|
+
contains_one_uni 'element_type', PObjectType
|
80
|
+
module ClassModule
|
81
|
+
def hash
|
82
|
+
[self.class, element_type].hash
|
83
|
+
end
|
84
|
+
|
85
|
+
def ==(o)
|
86
|
+
self.class == o.class && element_type == o.element_type
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# @api public
|
92
|
+
class PArrayType < PCollectionType
|
93
|
+
module ClassModule
|
94
|
+
def hash
|
95
|
+
[self.class, element_type].hash
|
96
|
+
end
|
97
|
+
|
98
|
+
def ==(o)
|
99
|
+
self.class == o.class && element_type == o.element_type
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
# @api public
|
105
|
+
class PHashType < PCollectionType
|
106
|
+
contains_one_uni 'key_type', PObjectType
|
107
|
+
module ClassModule
|
108
|
+
def hash
|
109
|
+
[self.class, key_type, element_type].hash
|
110
|
+
end
|
111
|
+
|
112
|
+
def ==(o)
|
113
|
+
self.class == o.class && key_type == o.key_type && element_type == o.element_type
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
# @api public
|
119
|
+
class PRubyType < PObjectType
|
120
|
+
has_attr 'ruby_class', String
|
121
|
+
module ClassModule
|
122
|
+
def hash
|
123
|
+
[self.class, ruby_class].hash
|
124
|
+
end
|
125
|
+
|
126
|
+
def ==(o)
|
127
|
+
self.class == o.class && ruby_class == o.ruby_class
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
end
|
@@ -1,18 +1,98 @@
|
|
1
1
|
# A module with base functionality for validation of a model.
|
2
2
|
#
|
3
|
-
# *
|
4
|
-
# *
|
5
|
-
# *
|
6
|
-
# *
|
3
|
+
# * **Factory** - an abstract factory implementation that makes it easier to create a new validation factory.
|
4
|
+
# * **SeverityProducer** - produces a severity (:error, :warning, :ignore) for a given Issue
|
5
|
+
# * **DiagnosticProducer** - produces a Diagnostic which binds an Issue to an occurrence of that issue
|
6
|
+
# * **Acceptor** - the receiver/sink/collector of computed diagnostics
|
7
|
+
# * **DiagnosticFormatter** - produces human readable output for a Diagnostic
|
7
8
|
#
|
8
9
|
module Puppet::Pops::Validation
|
10
|
+
|
11
|
+
# This class is an abstract base implementation of a _model validation factory_ that creates a validator instance
|
12
|
+
# and associates it with a fully configured DiagnosticProducer.
|
13
|
+
#
|
14
|
+
# A _validator_ is responsible for validating a model. There may be different versions of validation available
|
15
|
+
# for one and the same model; e.g. different semantics for different puppet versions, or different types of
|
16
|
+
# validation configuration depending on the context/type of validation that should be performed (static, vs. runtime, etc.).
|
17
|
+
#
|
18
|
+
# This class is abstract and must be subclassed. The subclass must implement the methods
|
19
|
+
# {#label_provider} and {#checker}. It is also expected that the sublcass will override
|
20
|
+
# the severity_producer and configure the issues that should be reported as errors (i.e. if they should be ignored, produce
|
21
|
+
# a warning, or a deprecation warning).
|
22
|
+
#
|
23
|
+
# @abstract Subclass must implement {#checker}, and {#label_provider}
|
24
|
+
# @api public
|
25
|
+
#
|
26
|
+
class Factory
|
27
|
+
|
28
|
+
# Produces a validator with the given acceptor as the recipient of produced diagnostics.
|
29
|
+
# The acceptor is where detected issues are received (and typically collected).
|
30
|
+
#
|
31
|
+
# @param acceptor [Acceptor] the acceptor is the receiver of all detected issues
|
32
|
+
# @return [#validate] a validator responding to `validate(model)`
|
33
|
+
#
|
34
|
+
# @api public
|
35
|
+
#
|
36
|
+
def validator(acceptor)
|
37
|
+
checker(diagnostic_producer(acceptor))
|
38
|
+
end
|
39
|
+
|
40
|
+
# Produces the diagnostics producer to use given an acceptor of issues.
|
41
|
+
#
|
42
|
+
# @param acceptor [Acceptor] the acceptor is the receiver of all detected issues
|
43
|
+
# @return [DiagnosticProducer] a detector of issues
|
44
|
+
#
|
45
|
+
# @api public
|
46
|
+
#
|
47
|
+
def diagnostic_producer(acceptor)
|
48
|
+
Puppet::Pops::Validation::DiagnosticProducer.new(acceptor, severity_producer(), label_provider())
|
49
|
+
end
|
50
|
+
|
51
|
+
# Produces the SeverityProducer to use
|
52
|
+
# Subclasses should implement and add specific overrides
|
53
|
+
#
|
54
|
+
# @return [SeverityProducer] a severity producer producing error, warning or ignore per issue
|
55
|
+
#
|
56
|
+
# @api public
|
57
|
+
#
|
58
|
+
def severity_producer
|
59
|
+
Puppet::Pops::Validation::SeverityProducer.new
|
60
|
+
end
|
61
|
+
|
62
|
+
# Produces the checker to use.
|
63
|
+
#
|
64
|
+
# @abstract
|
65
|
+
#
|
66
|
+
# @api public
|
67
|
+
#
|
68
|
+
def checker(diagnostic_producer)
|
69
|
+
raise NoMethodError, "checker"
|
70
|
+
end
|
71
|
+
|
72
|
+
# Produces the label provider to use.
|
73
|
+
#
|
74
|
+
# @abstract
|
75
|
+
#
|
76
|
+
# @api public
|
77
|
+
#
|
78
|
+
def label_provider
|
79
|
+
raise NoMethodError, "label_provider"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
9
83
|
# Decides on the severity of a given issue.
|
10
84
|
# The produced severity is one of `:error`, `:warning`, or `:ignore`.
|
11
85
|
# By default, a severity of `:error` is produced for all issues. To configure the severity
|
12
86
|
# of an issue call `#severity=(issue, level)`.
|
13
87
|
#
|
88
|
+
# @return [Symbol] a symbol representing the severity `:error`, `:warning`, or `:ignore`
|
89
|
+
#
|
90
|
+
# @api public
|
91
|
+
#
|
14
92
|
class SeverityProducer
|
93
|
+
|
15
94
|
# Creates a new instance where all issues are diagnosed as :error unless overridden.
|
95
|
+
# @api public
|
16
96
|
#
|
17
97
|
def initialize
|
18
98
|
# If diagnose is not set, the default is returned by the block
|
@@ -20,13 +100,17 @@ module Puppet::Pops::Validation
|
|
20
100
|
end
|
21
101
|
|
22
102
|
# Returns the severity of the given issue.
|
23
|
-
# @
|
103
|
+
# @return [Symbol] severity level :error, :warning, or :ignore
|
104
|
+
# @api public
|
24
105
|
#
|
25
|
-
def severity
|
106
|
+
def severity(issue)
|
26
107
|
assert_issue(issue)
|
27
108
|
@severities[issue]
|
28
109
|
end
|
29
110
|
|
111
|
+
# @see {#severity}
|
112
|
+
# @api public
|
113
|
+
#
|
30
114
|
def [] issue
|
31
115
|
severity issue
|
32
116
|
end
|
@@ -35,26 +119,35 @@ module Puppet::Pops::Validation
|
|
35
119
|
#
|
36
120
|
# @param issue [Puppet::Pops::Issues::Issue] the issue for which to set severity
|
37
121
|
# @param level [Symbol] the severity level (:error, :warning, or :ignore).
|
122
|
+
# @api public
|
38
123
|
#
|
39
|
-
def []=
|
124
|
+
def []=(issue, level)
|
40
125
|
assert_issue(issue)
|
41
126
|
assert_severity(level)
|
42
127
|
raise Puppet::DevError.new("Attempt to demote the hard issue '#{issue.issue_code}' to #{level}") unless issue.demotable? || level == :error
|
43
128
|
@severities[issue] = level
|
44
129
|
end
|
45
130
|
|
46
|
-
# Returns true if the issue should be reported or not.
|
47
|
-
# @
|
131
|
+
# Returns `true` if the issue should be reported or not.
|
132
|
+
# @return [Boolean] this implementation returns true for errors and warnings
|
133
|
+
#
|
134
|
+
# @api public
|
48
135
|
#
|
49
136
|
def should_report? issue
|
50
137
|
diagnose = self[issue]
|
51
138
|
diagnose == :error || diagnose == :warning || diagnose == :deprecation
|
52
139
|
end
|
53
140
|
|
141
|
+
# Checks if the given issue is valid.
|
142
|
+
# @api private
|
143
|
+
#
|
54
144
|
def assert_issue issue
|
55
145
|
raise Puppet::DevError.new("Attempt to get validation severity for something that is not an Issue. (Got #{issue.class})") unless issue.is_a? Puppet::Pops::Issues::Issue
|
56
146
|
end
|
57
147
|
|
148
|
+
# Checks if the given severity level is valid.
|
149
|
+
# @api private
|
150
|
+
#
|
58
151
|
def assert_severity level
|
59
152
|
raise Puppet::DevError.new("Illegal severity level: #{option}") unless [:ignore, :warning, :error, :deprecation].include? level
|
60
153
|
end
|
@@ -157,8 +250,11 @@ module Puppet::Pops::Validation
|
|
157
250
|
|
158
251
|
def format_location diagnostic
|
159
252
|
file = diagnostic.file
|
160
|
-
line =
|
161
|
-
|
253
|
+
line = pos = nil
|
254
|
+
if diagnostic.source_pos
|
255
|
+
line = diagnostic.source_pos.line
|
256
|
+
pos = diagnostic.source_pos.pos
|
257
|
+
end
|
162
258
|
if file && line && pos
|
163
259
|
"#{file}:#{line}:#{pos}:"
|
164
260
|
elsif file && line
|
@@ -187,8 +283,12 @@ module Puppet::Pops::Validation
|
|
187
283
|
# have to be used here for backwards compatibility.
|
188
284
|
def format_location diagnostic
|
189
285
|
file = diagnostic.file
|
190
|
-
line =
|
191
|
-
|
286
|
+
line = pos = nil
|
287
|
+
if diagnostic.source_pos
|
288
|
+
line = diagnostic.source_pos.line
|
289
|
+
pos = diagnostic.source_pos.pos
|
290
|
+
end
|
291
|
+
|
192
292
|
if file && line && pos
|
193
293
|
" at #{file}:#{line}:#{pos}"
|
194
294
|
elsif file and line
|
@@ -214,7 +314,7 @@ module Puppet::Pops::Validation
|
|
214
314
|
#
|
215
315
|
class Acceptor
|
216
316
|
|
217
|
-
# All
|
317
|
+
# All diagnostic in the order they were issued
|
218
318
|
attr_reader :diagnostics
|
219
319
|
|
220
320
|
# The number of :warning severity issues + number of :deprecation severity issues
|
@@ -261,7 +361,7 @@ module Puppet::Pops::Validation
|
|
261
361
|
end
|
262
362
|
|
263
363
|
def errors_and_warnings
|
264
|
-
@diagnostics.select {|d| d.severity != :
|
364
|
+
@diagnostics.select {|d| d.severity != :ignore }
|
265
365
|
end
|
266
366
|
|
267
367
|
# Returns the ignored diagnostics in the order thwy were reported (if reported at all)
|
@@ -269,9 +369,38 @@ module Puppet::Pops::Validation
|
|
269
369
|
@diagnostics.select {|d| d.severity == :ignore }
|
270
370
|
end
|
271
371
|
|
272
|
-
# Add a diagnostic to the set of diagnostics
|
372
|
+
# Add a diagnostic, or all diagnostics from another acceptor to the set of diagnostics
|
373
|
+
# @param diagnostic [Puppet::Pops::Validation::Diagnostic, Puppet::Pops::Validation::Acceptor] diagnostic(s) that should be accepted
|
273
374
|
def accept(diagnostic)
|
274
|
-
|
375
|
+
if diagnostic.is_a?(Acceptor)
|
376
|
+
diagnostic.diagnostics.each {|d| self.send(d.severity, d)}
|
377
|
+
else
|
378
|
+
self.send(diagnostic.severity, diagnostic)
|
379
|
+
end
|
380
|
+
end
|
381
|
+
|
382
|
+
# Prunes the contain diagnostics by removing those for which the given block returns true.
|
383
|
+
# The internal statistics is updated as a consequence of removing.
|
384
|
+
# @return [Array<Puppet::Pops::Validation::Diagnostic, nil] the removed set of diagnostics or nil if nothing was removed
|
385
|
+
#
|
386
|
+
def prune(&block)
|
387
|
+
removed = []
|
388
|
+
@diagnostics.delete_if do |d|
|
389
|
+
if should_remove = yield(d)
|
390
|
+
removed << d
|
391
|
+
end
|
392
|
+
should_remove
|
393
|
+
end
|
394
|
+
removed.each do |d|
|
395
|
+
case d.severity
|
396
|
+
when :error
|
397
|
+
@error_count -= 1
|
398
|
+
when :warning
|
399
|
+
@warning_count -= 1
|
400
|
+
# there is not ignore_count
|
401
|
+
end
|
402
|
+
end
|
403
|
+
removed.empty? ? nil : removed
|
275
404
|
end
|
276
405
|
|
277
406
|
private
|