puppet 3.3.2 → 3.4.0.rc1
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/CONTRIBUTING.md +22 -0
- data/Gemfile +11 -2
- data/README.md +13 -17
- data/README_DEVELOPER.md +1 -1
- data/Rakefile +1 -1
- data/examples/hiera/README.md +4 -4
- data/ext/debian/puppetmaster.init +1 -0
- data/ext/debian/rules +2 -5
- data/ext/nagios/check_puppet.rb +7 -7
- data/ext/osx/file_mapping.yaml +1 -1
- data/ext/osx/preflight.erb +34 -19
- data/ext/rack/{files/config.ru → config.ru} +0 -0
- data/ext/rack/{files/apache2.conf → example-passenger-vhost.conf} +6 -0
- data/ext/redhat/puppet.spec.erb +20 -2
- data/ext/systemd/{puppetagent.service → puppet.service} +0 -0
- data/lib/hiera_puppet.rb +2 -2
- data/lib/puppet/agent.rb +1 -6
- data/lib/puppet/application.rb +15 -2
- data/lib/puppet/application/agent.rb +2 -7
- data/lib/puppet/application/apply.rb +8 -13
- data/lib/puppet/application/cert.rb +47 -7
- data/lib/puppet/application/device.rb +1 -6
- data/lib/puppet/application/face_base.rb +1 -1
- data/lib/puppet/application/filebucket.rb +1 -1
- data/lib/puppet/application/inspect.rb +3 -12
- data/lib/puppet/application/master.rb +1 -6
- data/lib/puppet/application/queue.rb +1 -6
- data/lib/puppet/application/resource.rb +2 -6
- data/lib/puppet/coercion.rb +11 -0
- data/lib/puppet/configurer.rb +5 -3
- data/lib/puppet/configurer/downloader.rb +3 -1
- data/lib/puppet/configurer/plugin_handler.rb +10 -0
- data/lib/puppet/confine.rb +80 -0
- data/lib/puppet/{provider/confine → confine}/exists.rb +3 -3
- data/lib/puppet/{provider/confine → confine}/false.rb +2 -2
- data/lib/puppet/{provider/confine → confine}/feature.rb +2 -2
- data/lib/puppet/{provider/confine → confine}/true.rb +2 -2
- data/lib/puppet/{provider/confine → confine}/variable.rb +2 -2
- data/lib/puppet/{provider/confine_collection.rb → confine_collection.rb} +4 -4
- data/lib/puppet/{provider/confiner.rb → confiner.rb} +4 -4
- data/lib/puppet/daemon.rb +2 -6
- data/lib/puppet/data_binding.rb +2 -30
- data/lib/puppet/defaults.rb +283 -174
- data/lib/puppet/error.rb +1 -0
- data/lib/puppet/external/nagios.rb +0 -2
- data/lib/puppet/external/nagios/base.rb +4 -3
- data/lib/puppet/external/nagios/grammar.ry +173 -112
- data/lib/puppet/external/nagios/parser.rb +233 -184
- data/lib/puppet/face/file/store.rb +1 -1
- data/lib/puppet/face/module/generate.rb +5 -7
- data/lib/puppet/face/parser.rb +12 -2
- data/lib/puppet/face/plugin.rb +6 -0
- data/lib/puppet/feature/base.rb +16 -0
- data/lib/puppet/feature/external_facts.rb +5 -0
- data/lib/puppet/feature/libuser.rb +1 -1
- data/lib/puppet/feature/msgpack.rb +1 -0
- data/lib/puppet/feature/rails.rb +2 -2
- data/lib/puppet/file_bucket/dipper.rb +8 -6
- data/lib/puppet/file_bucket/file.rb +17 -1
- data/lib/puppet/file_serving/base.rb +21 -10
- data/lib/puppet/file_serving/configuration.rb +5 -7
- data/lib/puppet/file_serving/configuration/parser.rb +1 -1
- data/lib/puppet/file_serving/content.rb +1 -1
- data/lib/puppet/file_serving/fileset.rb +3 -3
- data/lib/puppet/file_serving/metadata.rb +22 -18
- data/lib/puppet/file_serving/mount/file.rb +1 -1
- data/lib/puppet/file_serving/mount/pluginfacts.rb +35 -0
- data/lib/puppet/file_system.rb +3 -0
- data/lib/puppet/file_system/file.rb +261 -0
- data/lib/puppet/file_system/file18.rb +5 -0
- data/lib/puppet/file_system/file19.rb +5 -0
- data/lib/puppet/file_system/file19windows.rb +113 -0
- data/lib/puppet/file_system/memory_file.rb +31 -0
- data/lib/puppet/file_system/tempfile.rb +20 -0
- data/lib/puppet/indirector/active_record.rb +1 -0
- data/lib/puppet/indirector/catalog/compiler.rb +28 -0
- data/lib/puppet/indirector/certificate_request/memory.rb +6 -0
- data/lib/puppet/indirector/data_binding/hiera.rb +46 -2
- data/lib/puppet/indirector/direct_file_server.rb +2 -2
- data/lib/puppet/indirector/facts/facter.rb +25 -0
- data/lib/puppet/indirector/file_bucket_file/file.rb +60 -74
- data/lib/puppet/indirector/indirection.rb +5 -1
- data/lib/puppet/indirector/json.rb +1 -1
- data/lib/puppet/indirector/key/ca.rb +4 -0
- data/lib/puppet/indirector/key/file.rb +7 -3
- data/lib/puppet/indirector/key/memory.rb +6 -0
- data/lib/puppet/indirector/node/write_only_yaml.rb +2 -2
- data/lib/puppet/indirector/request.rb +17 -11
- data/lib/puppet/indirector/resource/ral.rb +5 -0
- data/lib/puppet/indirector/resource/rest.rb +1 -0
- data/lib/puppet/indirector/resource/store_configs.rb +4 -0
- data/lib/puppet/indirector/rest.rb +2 -1
- data/lib/puppet/indirector/ssl_file.rb +7 -7
- data/lib/puppet/indirector/terminus.rb +4 -0
- data/lib/puppet/indirector/yaml.rb +3 -3
- data/lib/puppet/interface/documentation.rb +4 -11
- data/lib/puppet/module.rb +19 -6
- data/lib/puppet/module_tool/applications/builder.rb +1 -1
- data/lib/puppet/module_tool/applications/installer.rb +1 -1
- data/lib/puppet/module_tool/checksums.rb +1 -1
- data/lib/puppet/module_tool/dependency.rb +7 -3
- data/lib/puppet/module_tool/metadata.rb +6 -2
- data/lib/puppet/module_tool/tar.rb +2 -1
- data/lib/puppet/module_tool/tar/gnu.rb +6 -2
- data/lib/puppet/module_tool/tar/mini.rb +2 -0
- data/lib/puppet/module_tool/tar/solaris.rb +2 -5
- data/lib/puppet/network/authconfig.rb +0 -2
- data/lib/puppet/network/authentication.rb +1 -1
- data/lib/puppet/network/authstore.rb +6 -7
- data/lib/puppet/network/format.rb +2 -3
- data/lib/puppet/network/format_handler.rb +16 -11
- data/lib/puppet/network/format_support.rb +14 -0
- data/lib/puppet/network/formats.rb +26 -0
- data/lib/puppet/network/http/connection.rb +8 -41
- data/lib/puppet/network/http/handler.rb +28 -32
- data/lib/puppet/network/http/webrick.rb +15 -22
- data/lib/puppet/network/http_pool.rb +43 -9
- data/lib/puppet/network/rights.rb +0 -0
- data/lib/puppet/node.rb +24 -8
- data/lib/puppet/node/environment.rb +18 -20
- data/lib/puppet/node/facts.rb +23 -6
- data/lib/puppet/parameter.rb +15 -2
- data/lib/puppet/parameter/boolean.rb +5 -0
- data/lib/puppet/parameter/value_collection.rb +6 -4
- data/lib/puppet/parser/ast/resourceparam.rb +2 -1
- data/lib/puppet/parser/compiler.rb +25 -9
- data/lib/puppet/parser/files.rb +1 -1
- data/lib/puppet/parser/functions.rb +12 -21
- data/lib/puppet/parser/functions/collect.rb +6 -35
- data/lib/puppet/parser/functions/contain.rb +26 -0
- data/lib/puppet/parser/functions/create_resources.rb +5 -0
- data/lib/puppet/parser/functions/extlookup.rb +2 -2
- data/lib/puppet/parser/functions/file.rb +1 -1
- data/lib/puppet/parser/functions/{reject.rb → filter.rb} +13 -12
- data/lib/puppet/parser/functions/fqdn_rand.rb +13 -5
- data/lib/puppet/parser/functions/include.rb +18 -1
- data/lib/puppet/parser/functions/map.rb +44 -0
- data/lib/puppet/parser/functions/select.rb +6 -38
- data/lib/puppet/parser/lexer.rb +1 -1
- data/lib/puppet/parser/parser_support.rb +1 -1
- data/lib/puppet/parser/resource.rb +6 -45
- data/lib/puppet/parser/scope.rb +33 -2
- data/lib/puppet/parser/type_loader.rb +4 -60
- data/lib/puppet/pops/binder/bindings_loader.rb +1 -1
- data/lib/puppet/pops/binder/config/binder_config.rb +3 -3
- data/lib/puppet/pops/binder/hiera2/bindings_provider.rb +1 -1
- data/lib/puppet/pops/binder/scheme_handler/confdir_hiera_scheme.rb +1 -1
- data/lib/puppet/pops/binder/scheme_handler/module_hiera_scheme.rb +2 -2
- data/lib/puppet/pops/issues.rb +4 -0
- data/lib/puppet/pops/model/ast_transformer.rb +4 -1
- data/lib/puppet/pops/model/model_label_provider.rb +1 -1
- data/lib/puppet/pops/parser/egrammar.ra +5 -24
- data/lib/puppet/pops/parser/eparser.rb +859 -902
- data/lib/puppet/pops/parser/lexer.rb +48 -30
- data/lib/puppet/pops/parser/parser_support.rb +1 -1
- data/lib/puppet/pops/patterns.rb +4 -4
- data/lib/puppet/pops/utils.rb +1 -1
- data/lib/puppet/pops/validation/checker3_1.rb +25 -20
- data/lib/puppet/provider.rb +23 -6
- data/lib/puppet/provider/aixobject.rb +0 -0
- data/lib/puppet/provider/augeas/augeas.rb +21 -5
- data/lib/puppet/provider/confine.rb +5 -79
- data/lib/puppet/provider/cron/crontab.rb +0 -0
- data/lib/puppet/provider/exec.rb +9 -7
- data/lib/puppet/provider/exec/posix.rb +10 -1
- data/lib/puppet/provider/exec/windows.rb +1 -1
- data/lib/puppet/provider/file/posix.rb +1 -0
- data/lib/puppet/provider/file/windows.rb +16 -5
- data/lib/puppet/provider/group/aix.rb +0 -0
- data/lib/puppet/provider/group/windows_adsi.rb +33 -1
- data/lib/puppet/provider/macauthorization/macauthorization.rb +1 -1
- data/lib/puppet/provider/mailalias/aliases.rb +0 -0
- data/lib/puppet/provider/maillist/mailman.rb +0 -0
- data/lib/puppet/provider/mount/parsed.rb +0 -0
- data/lib/puppet/provider/nameservice/directoryservice.rb +3 -3
- data/lib/puppet/provider/package/appdmg.rb +1 -1
- data/lib/puppet/provider/package/apple.rb +1 -1
- data/lib/puppet/provider/package/apt.rb +1 -1
- data/lib/puppet/provider/package/aptitude.rb +0 -0
- data/lib/puppet/provider/package/blastwave.rb +1 -1
- data/lib/puppet/provider/package/dpkg.rb +1 -1
- data/lib/puppet/provider/package/fink.rb +1 -1
- data/lib/puppet/provider/package/freebsd.rb +0 -0
- data/lib/puppet/provider/package/gem.rb +0 -0
- data/lib/puppet/provider/package/macports.rb +0 -0
- data/lib/puppet/provider/package/msi.rb +4 -10
- data/lib/puppet/provider/package/nim.rb +8 -8
- data/lib/puppet/provider/package/openbsd.rb +1 -1
- data/lib/puppet/provider/package/opkg.rb +0 -0
- data/lib/puppet/provider/package/pacman.rb +2 -2
- data/lib/puppet/provider/package/pkgdmg.rb +1 -1
- data/lib/puppet/provider/package/pkgutil.rb +1 -1
- data/lib/puppet/provider/package/ports.rb +0 -0
- data/lib/puppet/provider/package/rpm.rb +39 -3
- data/lib/puppet/provider/package/sun.rb +3 -3
- data/lib/puppet/provider/package/sunfreeware.rb +0 -0
- data/lib/puppet/provider/package/windows.rb +12 -19
- data/lib/puppet/provider/package/windows/package.rb +1 -1
- data/lib/puppet/provider/package/yum.rb +2 -2
- data/lib/puppet/provider/parsedfile.rb +0 -0
- data/lib/puppet/provider/port/parsed.rb +0 -0
- data/lib/puppet/provider/service/base.rb +0 -0
- data/lib/puppet/provider/service/bsd.rb +3 -3
- data/lib/puppet/provider/service/daemontools.rb +8 -8
- data/lib/puppet/provider/service/debian.rb +0 -0
- data/lib/puppet/provider/service/freebsd.rb +3 -3
- data/lib/puppet/provider/service/init.rb +5 -4
- data/lib/puppet/provider/service/launchd.rb +35 -24
- data/lib/puppet/provider/service/openbsd.rb +23 -0
- data/lib/puppet/provider/service/redhat.rb +0 -0
- data/lib/puppet/provider/service/runit.rb +3 -3
- data/lib/puppet/provider/service/smf.rb +0 -0
- data/lib/puppet/provider/service/src.rb +0 -0
- data/lib/puppet/provider/service/systemd.rb +0 -0
- data/lib/puppet/provider/service/upstart.rb +3 -3
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +2 -2
- data/lib/puppet/provider/sshkey/parsed.rb +0 -0
- data/lib/puppet/provider/user/aix.rb +0 -0
- data/lib/puppet/provider/user/directoryservice.rb +1 -1
- data/lib/puppet/provider/user/useradd.rb +1 -1
- data/lib/puppet/provider/zone/solaris.rb +1 -1
- data/lib/puppet/rails/benchmark.rb +1 -1
- data/lib/puppet/reference/configuration.rb +1 -2
- data/lib/puppet/reference/indirection.rb +12 -14
- data/lib/puppet/relationship.rb +7 -4
- data/lib/puppet/reports.rb +2 -2
- data/lib/puppet/reports/rrdgraph.rb +1 -1
- data/lib/puppet/reports/store.rb +3 -3
- data/lib/puppet/reports/tagmail.rb +2 -2
- data/lib/puppet/resource.rb +66 -8
- data/lib/puppet/resource/catalog.rb +18 -25
- data/lib/puppet/resource/status.rb +10 -4
- data/lib/puppet/run.rb +6 -2
- data/lib/puppet/settings.rb +39 -119
- data/lib/puppet/settings/base_setting.rb +8 -9
- data/lib/puppet/settings/directory_setting.rb +8 -0
- data/lib/puppet/settings/file_setting.rb +35 -1
- data/lib/puppet/settings/priority_setting.rb +42 -0
- data/lib/puppet/ssl.rb +4 -0
- data/lib/puppet/ssl/certificate.rb +18 -0
- data/lib/puppet/ssl/certificate_authority.rb +101 -72
- data/lib/puppet/ssl/certificate_authority/autosign_command.rb +44 -0
- data/lib/puppet/ssl/certificate_authority/interface.rb +21 -17
- data/lib/puppet/ssl/certificate_factory.rb +38 -12
- data/lib/puppet/ssl/certificate_request.rb +201 -47
- data/lib/puppet/ssl/certificate_request_attributes.rb +34 -0
- data/lib/puppet/ssl/certificate_revocation_list.rb +2 -2
- data/lib/puppet/ssl/host.rb +21 -10
- data/lib/puppet/ssl/inventory.rb +6 -10
- data/lib/puppet/ssl/key.rb +1 -1
- data/lib/puppet/ssl/oids.rb +78 -0
- data/lib/puppet/ssl/validator.rb +41 -97
- data/lib/puppet/ssl/validator/default_validator.rb +153 -0
- data/lib/puppet/ssl/validator/no_validator.rb +17 -0
- data/lib/puppet/status.rb +4 -0
- data/lib/puppet/test/test_helper.rb +5 -0
- data/lib/puppet/transaction.rb +13 -0
- data/lib/puppet/transaction/event.rb +8 -3
- data/lib/puppet/transaction/report.rb +6 -2
- data/lib/puppet/transaction/resource_harness.rb +173 -115
- data/lib/puppet/type.rb +30 -13
- data/lib/puppet/type/augeas.rb +12 -46
- data/lib/puppet/type/component.rb +1 -7
- data/lib/puppet/type/cron.rb +0 -0
- data/lib/puppet/type/exec.rb +13 -1
- data/lib/puppet/type/file.rb +19 -10
- data/lib/puppet/type/file/checksum.rb +0 -0
- data/lib/puppet/type/file/content.rb +3 -0
- data/lib/puppet/type/file/ensure.rb +33 -15
- data/lib/puppet/type/file/group.rb +0 -0
- data/lib/puppet/type/file/mode.rb +6 -2
- data/lib/puppet/type/file/owner.rb +0 -0
- data/lib/puppet/type/file/source.rb +65 -14
- data/lib/puppet/type/file/target.rb +6 -6
- data/lib/puppet/type/file/type.rb +0 -0
- data/lib/puppet/type/filebucket.rb +0 -0
- data/lib/puppet/type/group.rb +18 -0
- data/lib/puppet/type/host.rb +0 -0
- data/lib/puppet/type/k5login.rb +4 -4
- data/lib/puppet/type/mailalias.rb +0 -0
- data/lib/puppet/type/maillist.rb +0 -0
- data/lib/puppet/type/mount.rb +15 -1
- data/lib/puppet/type/package.rb +7 -1
- data/lib/puppet/type/port.rb +0 -0
- data/lib/puppet/type/schedule.rb +9 -4
- data/lib/puppet/type/service.rb +1 -1
- data/lib/puppet/type/sshkey.rb +0 -0
- data/lib/puppet/type/tidy.rb +1 -1
- data/lib/puppet/type/user.rb +3 -0
- data/lib/puppet/type/yumrepo.rb +8 -6
- data/lib/puppet/type/zpool.rb +0 -0
- data/lib/puppet/util.rb +4 -31
- data/lib/puppet/util/adsi.rb +73 -17
- data/lib/puppet/util/autoload.rb +3 -3
- data/lib/puppet/util/backups.rb +4 -4
- data/lib/puppet/util/cacher.rb +7 -13
- data/lib/puppet/util/checksums.rb +2 -2
- data/lib/puppet/util/classgen.rb +3 -1
- data/lib/puppet/util/colors.rb +1 -0
- data/lib/puppet/util/command_line.rb +5 -0
- data/lib/puppet/util/docs.rb +33 -27
- data/lib/puppet/util/execution.rb +42 -18
- data/lib/puppet/util/filetype.rb +3 -3
- data/lib/puppet/util/instance_loader.rb +2 -2
- data/lib/puppet/util/instrumentation.rb +23 -42
- data/lib/puppet/util/instrumentation/data.rb +11 -4
- data/lib/puppet/util/instrumentation/indirection_probe.rb +11 -4
- data/lib/puppet/util/instrumentation/instrumentable.rb +7 -14
- data/lib/puppet/util/instrumentation/listener.rb +15 -8
- data/lib/puppet/util/instrumentation/listeners/log.rb +4 -10
- data/lib/puppet/util/instrumentation/listeners/performance.rb +8 -14
- data/lib/puppet/util/limits.rb +12 -0
- data/lib/puppet/util/lockfile.rb +2 -2
- data/lib/puppet/util/log.rb +14 -6
- data/lib/puppet/util/log/destinations.rb +23 -1
- data/lib/puppet/util/metric.rb +9 -3
- data/lib/puppet/util/monkey_patches.rb +7 -2
- data/lib/puppet/util/network_device/config.rb +1 -1
- data/lib/puppet/util/plugins.rb +1 -1
- data/lib/puppet/util/posix.rb +0 -0
- data/lib/puppet/util/profiler.rb +7 -2
- data/lib/puppet/util/provider_features.rb +2 -2
- data/lib/puppet/util/rdoc.rb +28 -30
- data/lib/puppet/util/rdoc/code_objects.rb +75 -25
- data/lib/puppet/util/rdoc/generators/puppet_generator.rb +1 -1
- data/lib/puppet/util/rdoc/parser.rb +12 -487
- data/lib/puppet/util/rdoc/parser/puppet_parser_core.rb +477 -0
- data/lib/puppet/util/rdoc/parser/puppet_parser_rdoc1.rb +19 -0
- data/lib/puppet/util/rdoc/parser/puppet_parser_rdoc2.rb +14 -0
- data/lib/puppet/util/reference.rb +1 -1
- data/lib/puppet/util/resource_template.rb +1 -1
- data/lib/puppet/util/selinux.rb +1 -1
- data/lib/puppet/util/storage.rb +2 -2
- data/lib/puppet/util/suidmanager.rb +1 -1
- data/lib/puppet/util/tag_set.rb +29 -0
- data/lib/puppet/util/tagging.rb +8 -24
- data/lib/puppet/util/watched_file.rb +1 -1
- data/lib/puppet/util/watcher.rb +1 -1
- data/lib/puppet/util/windows.rb +3 -0
- data/lib/puppet/util/windows/access_control_entry.rb +84 -0
- data/lib/puppet/util/windows/access_control_list.rb +106 -0
- data/lib/puppet/util/windows/file.rb +213 -0
- data/lib/puppet/util/windows/process.rb +199 -0
- data/lib/puppet/util/windows/root_certs.rb +52 -37
- data/lib/puppet/util/windows/security.rb +270 -245
- data/lib/puppet/util/windows/security_descriptor.rb +62 -0
- data/lib/puppet/util/windows/sid.rb +26 -4
- data/lib/puppet/version.rb +2 -2
- data/spec/fixtures/releases/jamtur01-apache/lib/puppet/provider/a2mod/debian.rb +1 -1
- data/spec/fixtures/unit/indirector/{hiera → data_binding/hiera}/global.yaml +0 -0
- data/spec/fixtures/unit/indirector/data_binding/hiera/invalid.yaml +1 -0
- data/spec/fixtures/unit/module/trailing-comma.json +24 -0
- data/spec/fixtures/unit/util/monkey_patches/x509.pem +32 -0
- data/spec/integration/application/apply_spec.rb +1 -1
- data/spec/integration/application/doc_spec.rb +1 -1
- data/spec/integration/configurer_spec.rb +4 -2
- data/spec/integration/data_binding.rb +100 -0
- data/spec/integration/indirector/catalog/compiler_spec.rb +16 -13
- data/spec/integration/indirector/direct_file_server_spec.rb +3 -5
- data/spec/integration/indirector/file_content/file_server_spec.rb +2 -2
- data/spec/integration/node/facts_spec.rb +1 -1
- data/spec/integration/node_spec.rb +1 -1
- data/spec/integration/parser/compiler_spec.rb +90 -0
- data/spec/integration/parser/parser_spec.rb +2 -2
- data/spec/integration/provider/cron/crontab_spec.rb +3 -5
- data/spec/integration/resource/catalog_spec.rb +1 -1
- data/spec/integration/ssl/autosign_spec.rb +90 -0
- data/spec/integration/ssl/certificate_authority_spec.rb +62 -69
- data/spec/integration/ssl/certificate_revocation_list_spec.rb +1 -1
- data/spec/integration/ssl/host_spec.rb +1 -1
- data/spec/integration/transaction_spec.rb +13 -13
- data/spec/integration/type/exec_spec.rb +2 -2
- data/spec/integration/type/file_spec.rb +287 -45
- data/spec/integration/type/tidy_spec.rb +3 -3
- data/spec/integration/util/rdoc/parser_spec.rb +236 -35
- data/spec/integration/util/settings_spec.rb +1 -1
- data/spec/integration/util/windows/process_spec.rb +22 -0
- data/spec/integration/util/windows/security_spec.rb +316 -106
- data/spec/lib/matchers/containment_matchers.rb +52 -0
- data/spec/lib/puppet_spec/compiler.rb +6 -0
- data/spec/lib/puppet_spec/files.rb +20 -21
- data/spec/shared_behaviours/documentation_on_faces.rb +3 -3
- data/spec/shared_behaviours/file_server_terminus.rb +2 -2
- data/spec/shared_contexts/platform.rb +1 -0
- data/spec/spec_helper.rb +13 -1
- data/spec/unit/agent_spec.rb +0 -12
- data/spec/unit/application/agent_spec.rb +4 -4
- data/spec/unit/application/apply_spec.rb +18 -2
- data/spec/unit/application/cert_spec.rb +8 -6
- data/spec/unit/application/device_spec.rb +1 -1
- data/spec/unit/application/filebucket_spec.rb +1 -1
- data/spec/unit/application/inspect_spec.rb +1 -1
- data/spec/unit/application_spec.rb +24 -0
- data/spec/unit/configurer/downloader_spec.rb +8 -7
- data/spec/unit/configurer/fact_handler_spec.rb +23 -0
- data/spec/unit/configurer/plugin_handler_spec.rb +7 -2
- data/spec/unit/configurer_spec.rb +15 -5
- data/spec/unit/{provider/confine → confine}/exists_spec.rb +12 -12
- data/spec/unit/{provider/confine → confine}/false_spec.rb +9 -9
- data/spec/unit/{provider/confine → confine}/feature_spec.rb +10 -10
- data/spec/unit/{provider/confine → confine}/true_spec.rb +7 -7
- data/spec/unit/{provider/confine → confine}/variable_spec.rb +16 -16
- data/spec/unit/{provider/confine_collection_spec.rb → confine_collection_spec.rb} +30 -30
- data/spec/unit/{provider/confine_spec.rb → confine_spec.rb} +11 -11
- data/spec/unit/{provider/confiner_spec.rb → confiner_spec.rb} +4 -4
- data/spec/unit/face/parser_spec.rb +54 -0
- data/spec/unit/file_bucket/dipper_spec.rb +2 -2
- data/spec/unit/file_serving/base_spec.rb +32 -9
- data/spec/unit/file_serving/configuration_spec.rb +7 -7
- data/spec/unit/file_serving/content_spec.rb +12 -7
- data/spec/unit/file_serving/fileset_spec.rb +57 -27
- data/spec/unit/file_serving/metadata_spec.rb +74 -12
- data/spec/unit/file_serving/mount/file_spec.rb +10 -10
- data/spec/unit/file_serving/mount/pluginfacts_spec.rb +73 -0
- data/spec/unit/file_system/file_spec.rb +486 -0
- data/spec/unit/file_system/tempfile_spec.rb +48 -0
- data/spec/unit/graph/relationship_graph_spec.rb +0 -6
- data/spec/unit/hiera_puppet_spec.rb +2 -2
- data/spec/unit/indirector/catalog/compiler_spec.rb +15 -19
- data/spec/unit/indirector/certificate_status/file_spec.rb +30 -40
- data/spec/unit/indirector/data_binding/hiera_spec.rb +95 -2
- data/spec/unit/indirector/direct_file_server_spec.rb +6 -6
- data/spec/unit/indirector/facts/facter_spec.rb +33 -0
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +61 -52
- data/spec/unit/indirector/file_metadata/file_spec.rb +2 -2
- data/spec/unit/indirector/file_server_spec.rb +4 -4
- data/spec/unit/indirector/json_spec.rb +4 -4
- data/spec/unit/indirector/key/file_spec.rb +13 -14
- data/spec/unit/indirector/resource/ral_spec.rb +7 -0
- data/spec/unit/indirector/resource/store_configs_spec.rb +11 -0
- data/spec/unit/indirector/rest_spec.rb +7 -3
- data/spec/unit/indirector/ssl_file_spec.rb +14 -17
- data/spec/unit/indirector/yaml_spec.rb +4 -4
- data/spec/unit/module_spec.rb +43 -15
- data/spec/unit/module_tool/tar/gnu_spec.rb +2 -2
- data/spec/unit/module_tool/tar/solaris_spec.rb +2 -2
- data/spec/unit/module_tool/tar_spec.rb +45 -0
- data/spec/unit/network/authconfig_spec.rb +2 -1
- data/spec/unit/network/authentication_spec.rb +2 -2
- data/spec/unit/network/format_handler_spec.rb +2 -2
- data/spec/unit/network/formats_spec.rb +24 -0
- data/spec/unit/network/http/connection_spec.rb +76 -199
- data/spec/unit/network/http/handler_spec.rb +33 -34
- data/spec/unit/network/http_pool_spec.rb +8 -5
- data/spec/unit/node/environment_spec.rb +76 -90
- data/spec/unit/node/facts_spec.rb +20 -3
- data/spec/unit/node_spec.rb +43 -0
- data/spec/unit/parameter/boolean_spec.rb +22 -12
- data/spec/unit/parser/ast/resourceparam_spec.rb +51 -0
- data/spec/unit/parser/compiler_spec.rb +103 -35
- data/spec/unit/parser/eparser_adapter_spec.rb +12 -12
- data/spec/unit/parser/files_spec.rb +11 -11
- data/spec/unit/parser/functions/contain_spec.rb +185 -0
- data/spec/unit/parser/functions/create_resources_spec.rb +13 -5
- data/spec/unit/parser/functions/generate_spec.rb +1 -1
- data/spec/unit/parser/functions_spec.rb +2 -2
- data/spec/unit/parser/lexer_spec.rb +1 -1
- data/spec/unit/parser/methods/each_spec.rb +1 -1
- data/spec/unit/parser/methods/{select_spec.rb → filter_spec.rb} +11 -11
- data/spec/unit/parser/methods/map_spec.rb +95 -0
- data/spec/unit/parser/methods/reduce_spec.rb +12 -11
- data/spec/unit/parser/methods/shared.rb +5 -5
- data/spec/unit/parser/methods/slice_spec.rb +13 -13
- data/spec/unit/parser/parser_spec.rb +1 -1
- data/spec/unit/parser/resource/param_spec.rb +44 -0
- data/spec/unit/parser/resource_spec.rb +16 -15
- data/spec/unit/pops/model/ast_transformer_spec.rb +18 -4
- data/spec/unit/pops/parser/lexer_spec.rb +22 -5
- data/spec/unit/pops/parser/parse_calls_spec.rb +5 -5
- data/spec/unit/pops/transformer/transform_calls_spec.rb +6 -6
- data/spec/unit/pops/transformer/transform_containers_spec.rb +2 -2
- data/spec/unit/pops/validator/validator_spec.rb +31 -0
- data/spec/unit/provider/augeas/augeas_spec.rb +57 -2
- data/spec/unit/provider/exec/posix_spec.rb +8 -3
- data/spec/unit/provider/file/posix_spec.rb +2 -2
- data/spec/unit/provider/group/windows_adsi_spec.rb +70 -3
- data/spec/unit/provider/nameservice/directoryservice_spec.rb +3 -3
- data/spec/unit/provider/package/apt_spec.rb +1 -1
- data/spec/unit/provider/package/msi_spec.rb +15 -42
- data/spec/unit/provider/package/openbsd_spec.rb +3 -3
- data/spec/unit/provider/package/rpm_spec.rb +56 -13
- data/spec/unit/provider/package/windows_spec.rb +15 -19
- data/spec/unit/provider/service/base_spec.rb +1 -1
- data/spec/unit/provider/service/daemontools_spec.rb +18 -8
- data/spec/unit/provider/service/freebsd_spec.rb +3 -3
- data/spec/unit/provider/service/gentoo_spec.rb +5 -2
- data/spec/unit/provider/service/init_spec.rb +17 -17
- data/spec/unit/provider/service/launchd_spec.rb +76 -23
- data/spec/unit/provider/service/openbsd_spec.rb +125 -0
- data/spec/unit/provider/service/openwrt_spec.rb +1 -1
- data/spec/unit/provider/service/runit_spec.rb +12 -5
- data/spec/unit/provider/service/upstart_spec.rb +4 -4
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +5 -5
- data/spec/unit/provider/user/directoryservice_spec.rb +4 -4
- data/spec/unit/provider/zone/solaris_spec.rb +1 -1
- data/spec/unit/provider_spec.rb +2 -2
- data/spec/unit/reports/http_spec.rb +19 -34
- data/spec/unit/reports/store_spec.rb +2 -2
- data/spec/unit/resource/catalog_spec.rb +81 -11
- data/spec/unit/resource/status_spec.rb +11 -1
- data/spec/unit/resource/type_spec.rb +30 -1
- data/spec/unit/resource_spec.rb +40 -4
- data/spec/unit/settings/file_setting_spec.rb +2 -2
- data/spec/unit/settings/path_setting_spec.rb +2 -2
- data/spec/unit/settings/priority_setting_spec.rb +66 -0
- data/spec/unit/settings_spec.rb +16 -31
- data/spec/unit/ssl/certificate_authority/autosign_command_spec.rb +30 -0
- data/spec/unit/ssl/certificate_authority_spec.rb +129 -134
- data/spec/unit/ssl/certificate_factory_spec.rb +18 -0
- data/spec/unit/ssl/certificate_request_attributes_spec.rb +61 -0
- data/spec/unit/ssl/certificate_request_spec.rb +103 -0
- data/spec/unit/ssl/certificate_spec.rb +31 -18
- data/spec/unit/ssl/host_spec.rb +34 -8
- data/spec/unit/ssl/inventory_spec.rb +27 -62
- data/spec/unit/ssl/key_spec.rb +4 -4
- data/spec/unit/ssl/oids_spec.rb +48 -0
- data/spec/unit/ssl/validator_spec.rb +49 -6
- data/spec/unit/status_spec.rb +9 -0
- data/spec/unit/transaction/event_spec.rb +1 -9
- data/spec/unit/transaction/report_spec.rb +20 -1
- data/spec/unit/transaction/resource_harness_spec.rb +60 -210
- data/spec/unit/transaction_spec.rb +54 -8
- data/spec/unit/type/component_spec.rb +2 -2
- data/spec/unit/type/exec_spec.rb +14 -7
- data/spec/unit/type/file/content_spec.rb +13 -2
- data/spec/unit/type/file/ctime_spec.rb +1 -1
- data/spec/unit/type/file/mode_spec.rb +48 -2
- data/spec/unit/type/file/mtime_spec.rb +1 -1
- data/spec/unit/type/file/source_spec.rb +177 -7
- data/spec/unit/type/file_spec.rb +63 -71
- data/spec/unit/type/group_spec.rb +20 -0
- data/spec/unit/type/k5login_spec.rb +3 -3
- data/spec/unit/type/mount_spec.rb +53 -0
- data/spec/unit/type/nagios_spec.rb +216 -0
- data/spec/unit/type/package_spec.rb +7 -1
- data/spec/unit/type/schedule_spec.rb +6 -0
- data/spec/unit/type/service_spec.rb +3 -3
- data/spec/unit/type/tidy_spec.rb +14 -14
- data/spec/unit/type/user_spec.rb +9 -0
- data/spec/unit/type_spec.rb +86 -4
- data/spec/unit/util/adsi_spec.rb +120 -12
- data/spec/unit/util/autoload_spec.rb +14 -14
- data/spec/unit/util/backups_spec.rb +29 -21
- data/spec/unit/util/checksums_spec.rb +2 -1
- data/spec/unit/util/command_line_spec.rb +41 -0
- data/spec/unit/util/docs_spec.rb +91 -0
- data/spec/unit/util/execution_spec.rb +26 -2
- data/spec/unit/util/filetype_spec.rb +7 -7
- data/spec/unit/util/lockfile_spec.rb +2 -2
- data/spec/unit/util/log/destinations_spec.rb +32 -0
- data/spec/unit/util/monkey_patches_spec.rb +41 -0
- data/spec/unit/util/pidlock_spec.rb +6 -6
- data/spec/unit/util/rdoc/parser_spec.rb +15 -13
- data/spec/unit/util/rdoc_spec.rb +18 -24
- data/spec/unit/util/resource_template_spec.rb +3 -3
- data/spec/unit/util/selinux_spec.rb +4 -2
- data/spec/unit/util/storage_spec.rb +4 -4
- data/spec/unit/util/suidmanager_spec.rb +7 -0
- data/spec/unit/util/tag_set_spec.rb +46 -0
- data/spec/unit/util/tagging_spec.rb +82 -45
- data/spec/unit/util/watcher_spec.rb +4 -1
- data/spec/unit/util/windows/access_control_entry_spec.rb +67 -0
- data/spec/unit/util/windows/access_control_list_spec.rb +133 -0
- data/spec/unit/util/windows/root_certs_spec.rb +10 -8
- data/spec/unit/util/windows/security_descriptor_spec.rb +117 -0
- data/spec/unit/util/windows/sid_spec.rb +69 -0
- data/spec/unit/util_spec.rb +7 -7
- data/tasks/ci.rake +17 -36
- metadata +2811 -2746
- checksums.yaml +0 -7
- data/examples/mac_automount.pp +0 -16
- data/examples/mcx_dock_absent.pp +0 -4
- data/examples/mcx_dock_default.pp +0 -118
- data/examples/mcx_dock_full.pp +0 -125
- data/examples/mcx_dock_invalid.pp +0 -9
- data/examples/mcx_nogroup.pp +0 -118
- data/examples/mcx_notexists_absent.pp +0 -4
- data/ext/rack/README +0 -58
- data/ext/rack/manifest.pp +0 -59
- data/lib/puppet/external/lock.rb +0 -63
- data/lib/puppet/indirector/hiera.rb +0 -39
- data/lib/puppet/parser/functions/foreach.rb +0 -95
- data/spec/integration/network/server/webrick_spec.rb +0 -76
- data/spec/integration/parser/functions_spec.rb +0 -16
- data/spec/unit/indirector/hiera_spec.rb +0 -154
- data/spec/unit/parser/methods/collect_spec.rb +0 -153
- data/spec/unit/parser/methods/foreach_spec.rb +0 -91
- data/spec/unit/parser/methods/reject_spec.rb +0 -73
- data/spec/unit/resource/resource_type.json +0 -34
@@ -0,0 +1,185 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'puppet_spec/compiler'
|
4
|
+
require 'puppet/parser/functions'
|
5
|
+
require 'matchers/containment_matchers'
|
6
|
+
require 'matchers/include_in_order'
|
7
|
+
|
8
|
+
describe 'The "contain" function' do
|
9
|
+
include PuppetSpec::Compiler
|
10
|
+
include ContainmentMatchers
|
11
|
+
|
12
|
+
it "includes the class" do
|
13
|
+
catalog = compile_to_catalog(<<-MANIFEST)
|
14
|
+
class contained {
|
15
|
+
notify { "contained": }
|
16
|
+
}
|
17
|
+
|
18
|
+
class container {
|
19
|
+
contain contained
|
20
|
+
}
|
21
|
+
|
22
|
+
include container
|
23
|
+
MANIFEST
|
24
|
+
|
25
|
+
expect(catalog.classes).to include("contained")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "makes the class contained in the current class" do
|
29
|
+
catalog = compile_to_catalog(<<-MANIFEST)
|
30
|
+
class contained {
|
31
|
+
notify { "contained": }
|
32
|
+
}
|
33
|
+
|
34
|
+
class container {
|
35
|
+
contain contained
|
36
|
+
}
|
37
|
+
|
38
|
+
include container
|
39
|
+
MANIFEST
|
40
|
+
|
41
|
+
expect(catalog).to contain_class("contained").in("container")
|
42
|
+
end
|
43
|
+
|
44
|
+
it "can contain multiple classes" do
|
45
|
+
catalog = compile_to_catalog(<<-MANIFEST)
|
46
|
+
class a {
|
47
|
+
notify { "a": }
|
48
|
+
}
|
49
|
+
|
50
|
+
class b {
|
51
|
+
notify { "b": }
|
52
|
+
}
|
53
|
+
|
54
|
+
class container {
|
55
|
+
contain a, b
|
56
|
+
}
|
57
|
+
|
58
|
+
include container
|
59
|
+
MANIFEST
|
60
|
+
|
61
|
+
expect(catalog).to contain_class("a").in("container")
|
62
|
+
expect(catalog).to contain_class("b").in("container")
|
63
|
+
end
|
64
|
+
|
65
|
+
context "when containing a class in multiple classes" do
|
66
|
+
it "creates a catalog with all containment edges" do
|
67
|
+
catalog = compile_to_catalog(<<-MANIFEST)
|
68
|
+
class contained {
|
69
|
+
notify { "contained": }
|
70
|
+
}
|
71
|
+
|
72
|
+
class container {
|
73
|
+
contain contained
|
74
|
+
}
|
75
|
+
|
76
|
+
class another {
|
77
|
+
contain contained
|
78
|
+
}
|
79
|
+
|
80
|
+
include container
|
81
|
+
include another
|
82
|
+
MANIFEST
|
83
|
+
|
84
|
+
expect(catalog).to contain_class("contained").in("container")
|
85
|
+
expect(catalog).to contain_class("contained").in("another")
|
86
|
+
end
|
87
|
+
|
88
|
+
it "and there are no dependencies applies successfully" do
|
89
|
+
manifest = <<-MANIFEST
|
90
|
+
class contained {
|
91
|
+
notify { "contained": }
|
92
|
+
}
|
93
|
+
|
94
|
+
class container {
|
95
|
+
contain contained
|
96
|
+
}
|
97
|
+
|
98
|
+
class another {
|
99
|
+
contain contained
|
100
|
+
}
|
101
|
+
|
102
|
+
include container
|
103
|
+
include another
|
104
|
+
MANIFEST
|
105
|
+
|
106
|
+
expect { apply_compiled_manifest(manifest) }.not_to raise_error
|
107
|
+
end
|
108
|
+
|
109
|
+
it "and there are explicit dependencies on the containing class causes a dependency cycle" do
|
110
|
+
manifest = <<-MANIFEST
|
111
|
+
class contained {
|
112
|
+
notify { "contained": }
|
113
|
+
}
|
114
|
+
|
115
|
+
class container {
|
116
|
+
contain contained
|
117
|
+
}
|
118
|
+
|
119
|
+
class another {
|
120
|
+
contain contained
|
121
|
+
}
|
122
|
+
|
123
|
+
include container
|
124
|
+
include another
|
125
|
+
|
126
|
+
Class["container"] -> Class["another"]
|
127
|
+
MANIFEST
|
128
|
+
|
129
|
+
expect { apply_compiled_manifest(manifest) }.to raise_error(
|
130
|
+
Puppet::Error,
|
131
|
+
/Found 1 dependency cycle/
|
132
|
+
)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
it "does not create duplicate edges" do
|
137
|
+
catalog = compile_to_catalog(<<-MANIFEST)
|
138
|
+
class contained {
|
139
|
+
notify { "contained": }
|
140
|
+
}
|
141
|
+
|
142
|
+
class container {
|
143
|
+
contain contained
|
144
|
+
contain contained
|
145
|
+
}
|
146
|
+
|
147
|
+
include container
|
148
|
+
MANIFEST
|
149
|
+
|
150
|
+
contained = catalog.resource("Class", "contained")
|
151
|
+
container = catalog.resource("Class", "container")
|
152
|
+
|
153
|
+
expect(catalog.edges_between(container, contained)).to have(1).item
|
154
|
+
end
|
155
|
+
|
156
|
+
context "when a containing class has a dependency order" do
|
157
|
+
it "the contained class is applied in that order" do
|
158
|
+
catalog = compile_to_relationship_graph(<<-MANIFEST)
|
159
|
+
class contained {
|
160
|
+
notify { "contained": }
|
161
|
+
}
|
162
|
+
|
163
|
+
class container {
|
164
|
+
contain contained
|
165
|
+
}
|
166
|
+
|
167
|
+
class first {
|
168
|
+
notify { "first": }
|
169
|
+
}
|
170
|
+
|
171
|
+
class last {
|
172
|
+
notify { "last": }
|
173
|
+
}
|
174
|
+
|
175
|
+
include container, first, last
|
176
|
+
|
177
|
+
Class["first"] -> Class["container"] -> Class["last"]
|
178
|
+
MANIFEST
|
179
|
+
|
180
|
+
expect(order_resources_traversed_in(catalog)).to include_in_order(
|
181
|
+
"Notify[first]", "Notify[contained]", "Notify[last]"
|
182
|
+
)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
@@ -23,6 +23,14 @@ describe 'function for dynamically creating resources' do
|
|
23
23
|
expect { @scope.function_create_resources(['foo', 'bar', 'blah', 'baz']) }.to raise_error(ArgumentError, 'create_resources(): wrong number of arguments (4; must be 2 or 3)')
|
24
24
|
end
|
25
25
|
|
26
|
+
it 'should require second argument to be a hash' do
|
27
|
+
expect { @scope.function_create_resources(['foo','bar']) }.to raise_error(ArgumentError, 'create_resources(): second argument must be a hash')
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should require optional third argument to be a hash' do
|
31
|
+
expect { @scope.function_create_resources(['foo',{},'foo']) }.to raise_error(ArgumentError, 'create_resources(): third argument, if provided, must be a hash')
|
32
|
+
end
|
33
|
+
|
26
34
|
describe 'when creating native types' do
|
27
35
|
it 'empty hash should not cause resources to be added' do
|
28
36
|
noop_catalog = compile_to_catalog("create_resources('file', {})")
|
@@ -75,12 +83,12 @@ describe 'function for dynamically creating resources' do
|
|
75
83
|
end
|
76
84
|
|
77
85
|
describe 'when dynamically creating resource types' do
|
78
|
-
it 'should be able to create defined
|
86
|
+
it 'should be able to create defined resource types' do
|
79
87
|
catalog = compile_to_catalog(<<-MANIFEST)
|
80
88
|
define foocreateresource($one) {
|
81
89
|
notify { $name: message => $one }
|
82
90
|
}
|
83
|
-
|
91
|
+
|
84
92
|
create_resources('foocreateresource', {'blah'=>{'one'=>'two'}})
|
85
93
|
MANIFEST
|
86
94
|
catalog.resource(:notify, "blah")['message'].should == 'two'
|
@@ -92,7 +100,7 @@ describe 'function for dynamically creating resources' do
|
|
92
100
|
define foocreateresource($one) {
|
93
101
|
notify { $name: message => $one }
|
94
102
|
}
|
95
|
-
|
103
|
+
|
96
104
|
create_resources('foocreateresource', {'blah'=>{}})
|
97
105
|
MANIFEST
|
98
106
|
}.to raise_error(Puppet::Error, 'Must pass one to Foocreateresource[blah] on node foonode')
|
@@ -103,7 +111,7 @@ describe 'function for dynamically creating resources' do
|
|
103
111
|
define foocreateresource($one) {
|
104
112
|
notify { $name: message => $one }
|
105
113
|
}
|
106
|
-
|
114
|
+
|
107
115
|
create_resources('foocreateresource', {'blah'=>{'one'=>'two'}, 'blaz'=>{'one'=>'three'}})
|
108
116
|
MANIFEST
|
109
117
|
|
@@ -118,7 +126,7 @@ describe 'function for dynamically creating resources' do
|
|
118
126
|
}
|
119
127
|
|
120
128
|
notify { test: }
|
121
|
-
|
129
|
+
|
122
130
|
create_resources('foocreateresource', {'blah'=>{'one'=>'two', 'require' => 'Notify[test]'}})
|
123
131
|
MANIFEST
|
124
132
|
|
@@ -45,7 +45,7 @@ describe "the generate function" do
|
|
45
45
|
scope.function_generate([command]).should == 'yay'
|
46
46
|
end
|
47
47
|
|
48
|
-
describe "on Windows", :
|
48
|
+
describe "on Windows", :if => Puppet.features.microsoft_windows? do
|
49
49
|
it "should accept the tilde in the path" do
|
50
50
|
command = "C:/DOCUME~1/ADMINI~1/foo.bat"
|
51
51
|
Dir.expects(:chdir).with(File.dirname(command)).returns("yay")
|
@@ -128,7 +128,7 @@ describe Puppet::Parser::Functions do
|
|
128
128
|
|
129
129
|
describe "::get_function" do
|
130
130
|
it "can retrieve a function defined on the *root* environment" do
|
131
|
-
|
131
|
+
$environment = nil
|
132
132
|
function = Puppet::Parser::Functions.newfunction("atest", :type => :rvalue) do
|
133
133
|
nil
|
134
134
|
end
|
@@ -162,7 +162,7 @@ describe Puppet::Parser::Functions do
|
|
162
162
|
|
163
163
|
describe "::merged_functions" do
|
164
164
|
it "returns functions in both the current and root environment" do
|
165
|
-
|
165
|
+
$environment = nil
|
166
166
|
func_a = Puppet::Parser::Functions.newfunction("test_a", :type => :rvalue) do
|
167
167
|
nil
|
168
168
|
end
|
@@ -861,7 +861,7 @@ describe "when trying to lex a non-existent file" do
|
|
861
861
|
it "should return an empty list of tokens" do
|
862
862
|
lexer = Puppet::Parser::Lexer.new
|
863
863
|
lexer.file = nofile = tmpfile('lexer')
|
864
|
-
File.
|
864
|
+
Puppet::FileSystem::File.exist?(nofile).should == false
|
865
865
|
|
866
866
|
lexer.fullscan.should == [[false,false]]
|
867
867
|
end
|
@@ -26,7 +26,7 @@ describe 'the each method' do
|
|
26
26
|
it 'each on an array selecting each value - function call style' do
|
27
27
|
catalog = compile_to_catalog(<<-MANIFEST)
|
28
28
|
$a = [1,2,3]
|
29
|
-
each ($a) |$index, $v|
|
29
|
+
each ($a) |$index, $v| {
|
30
30
|
file { "/file_$v": ensure => present }
|
31
31
|
}
|
32
32
|
MANIFEST
|
@@ -4,17 +4,17 @@ require 'puppet_spec/compiler'
|
|
4
4
|
|
5
5
|
require 'unit/parser/methods/shared'
|
6
6
|
|
7
|
-
describe 'the
|
7
|
+
describe 'the filter method' do
|
8
8
|
include PuppetSpec::Compiler
|
9
9
|
|
10
10
|
before :each do
|
11
11
|
Puppet[:parser] = 'future'
|
12
12
|
end
|
13
13
|
|
14
|
-
it 'should
|
14
|
+
it 'should filter on an array (all berries)' do
|
15
15
|
catalog = compile_to_catalog(<<-MANIFEST)
|
16
16
|
$a = ['strawberry','blueberry','orange']
|
17
|
-
$a.
|
17
|
+
$a.filter |$x|{ $x =~ /berry$/}.each |$v|{
|
18
18
|
file { "/file_$v": ensure => present }
|
19
19
|
}
|
20
20
|
MANIFEST
|
@@ -26,7 +26,7 @@ describe 'the select method' do
|
|
26
26
|
it 'should produce an array when acting on an array' do
|
27
27
|
catalog = compile_to_catalog(<<-MANIFEST)
|
28
28
|
$a = ['strawberry','blueberry','orange']
|
29
|
-
$b = $a.
|
29
|
+
$b = $a.filter |$x|{ $x =~ /berry$/}
|
30
30
|
file { "/file_${b[0]}": ensure => present }
|
31
31
|
file { "/file_${b[1]}": ensure => present }
|
32
32
|
MANIFEST
|
@@ -35,10 +35,10 @@ describe 'the select method' do
|
|
35
35
|
catalog.resource(:file, "/file_blueberry")['ensure'].should == 'present'
|
36
36
|
end
|
37
37
|
|
38
|
-
it '
|
38
|
+
it 'filters on a hash (all berries) by key' do
|
39
39
|
catalog = compile_to_catalog(<<-MANIFEST)
|
40
40
|
$a = {'strawberry'=>'red','blueberry'=>'blue','orange'=>'orange'}
|
41
|
-
$a.
|
41
|
+
$a.filter |$x|{ $x[0] =~ /berry$/}.each |$v|{
|
42
42
|
file { "/file_${v[0]}": ensure => present }
|
43
43
|
}
|
44
44
|
MANIFEST
|
@@ -50,7 +50,7 @@ describe 'the select method' do
|
|
50
50
|
it 'should produce a hash when acting on a hash' do
|
51
51
|
catalog = compile_to_catalog(<<-MANIFEST)
|
52
52
|
$a = {'strawberry'=>'red','blueberry'=>'blue','orange'=>'orange'}
|
53
|
-
$b = $a.
|
53
|
+
$b = $a.filter |$x|{ $x[0] =~ /berry$/}
|
54
54
|
file { "/file_${b['strawberry']}": ensure => present }
|
55
55
|
file { "/file_${b['blueberry']}": ensure => present }
|
56
56
|
file { "/file_${b['orange']}": ensure => present }
|
@@ -62,10 +62,10 @@ describe 'the select method' do
|
|
62
62
|
catalog.resource(:file, "/file_")['ensure'].should == 'present'
|
63
63
|
end
|
64
64
|
|
65
|
-
it '
|
65
|
+
it 'filters on a hash (all berries) by value' do
|
66
66
|
catalog = compile_to_catalog(<<-MANIFEST)
|
67
67
|
$a = {'strawb'=>'red berry','blueb'=>'blue berry','orange'=>'orange fruit'}
|
68
|
-
$a.
|
68
|
+
$a.filter |$x|{ $x[1] =~ /berry$/}.each |$v|{
|
69
69
|
file { "/file_${v[0]}": ensure => present }
|
70
70
|
}
|
71
71
|
MANIFEST
|
@@ -74,6 +74,6 @@ describe 'the select method' do
|
|
74
74
|
catalog.resource(:file, "/file_blueb")['ensure'].should == 'present'
|
75
75
|
end
|
76
76
|
|
77
|
-
it_should_behave_like 'all iterative functions argument checks', '
|
78
|
-
it_should_behave_like 'all iterative functions hash handling', '
|
77
|
+
it_should_behave_like 'all iterative functions argument checks', 'filter'
|
78
|
+
it_should_behave_like 'all iterative functions hash handling', 'filter'
|
79
79
|
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'puppet'
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'puppet_spec/compiler'
|
4
|
+
|
5
|
+
require 'unit/parser/methods/shared'
|
6
|
+
|
7
|
+
describe 'the map method' do
|
8
|
+
include PuppetSpec::Compiler
|
9
|
+
|
10
|
+
before :each do
|
11
|
+
Puppet[:parser] = "future"
|
12
|
+
end
|
13
|
+
|
14
|
+
context "using future parser" do
|
15
|
+
it 'map on an array (multiplying each value by 2)' do
|
16
|
+
catalog = compile_to_catalog(<<-MANIFEST)
|
17
|
+
$a = [1,2,3]
|
18
|
+
$a.map |$x|{ $x*2}.each |$v|{
|
19
|
+
file { "/file_$v": ensure => present }
|
20
|
+
}
|
21
|
+
MANIFEST
|
22
|
+
|
23
|
+
catalog.resource(:file, "/file_2")['ensure'].should == 'present'
|
24
|
+
catalog.resource(:file, "/file_4")['ensure'].should == 'present'
|
25
|
+
catalog.resource(:file, "/file_6")['ensure'].should == 'present'
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'map on a hash selecting keys' do
|
29
|
+
catalog = compile_to_catalog(<<-MANIFEST)
|
30
|
+
$a = {'a'=>1,'b'=>2,'c'=>3}
|
31
|
+
$a.map |$x|{ $x[0]}.each |$k|{
|
32
|
+
file { "/file_$k": ensure => present }
|
33
|
+
}
|
34
|
+
MANIFEST
|
35
|
+
|
36
|
+
catalog.resource(:file, "/file_a")['ensure'].should == 'present'
|
37
|
+
catalog.resource(:file, "/file_b")['ensure'].should == 'present'
|
38
|
+
catalog.resource(:file, "/file_c")['ensure'].should == 'present'
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'each on a hash selecting value' do
|
42
|
+
catalog = compile_to_catalog(<<-MANIFEST)
|
43
|
+
$a = {'a'=>1,'b'=>2,'c'=>3}
|
44
|
+
$a.map |$x|{ $x[1]}.each |$k|{
|
45
|
+
file { "/file_$k": ensure => present }
|
46
|
+
}
|
47
|
+
MANIFEST
|
48
|
+
|
49
|
+
catalog.resource(:file, "/file_1")['ensure'].should == 'present'
|
50
|
+
catalog.resource(:file, "/file_2")['ensure'].should == 'present'
|
51
|
+
catalog.resource(:file, "/file_3")['ensure'].should == 'present'
|
52
|
+
end
|
53
|
+
|
54
|
+
context "handles data type corner cases" do
|
55
|
+
it "map gets values that are false" do
|
56
|
+
catalog = compile_to_catalog(<<-MANIFEST)
|
57
|
+
$a = [false,false]
|
58
|
+
$a.map |$x| { $x }.each |$i, $v| {
|
59
|
+
file { "/file_$i.$v": ensure => present }
|
60
|
+
}
|
61
|
+
MANIFEST
|
62
|
+
|
63
|
+
catalog.resource(:file, "/file_0.false")['ensure'].should == 'present'
|
64
|
+
catalog.resource(:file, "/file_1.false")['ensure'].should == 'present'
|
65
|
+
end
|
66
|
+
|
67
|
+
it "map gets values that are nil" do
|
68
|
+
Puppet::Parser::Functions.newfunction(:nil_array, :type => :rvalue) do |args|
|
69
|
+
[nil]
|
70
|
+
end
|
71
|
+
catalog = compile_to_catalog(<<-MANIFEST)
|
72
|
+
$a = nil_array()
|
73
|
+
$a.map |$x| { $x }.each |$i, $v| {
|
74
|
+
file { "/file_$i.$v": ensure => present }
|
75
|
+
}
|
76
|
+
MANIFEST
|
77
|
+
|
78
|
+
catalog.resource(:file, "/file_0.")['ensure'].should == 'present'
|
79
|
+
end
|
80
|
+
|
81
|
+
it "map gets values that are undef" do
|
82
|
+
catalog = compile_to_catalog(<<-MANIFEST)
|
83
|
+
$a = [$does_not_exist]
|
84
|
+
$a.map |$x = "something"| { $x }.each |$i, $v| {
|
85
|
+
file { "/file_$i.$v": ensure => present }
|
86
|
+
}
|
87
|
+
MANIFEST
|
88
|
+
|
89
|
+
catalog.resource(:file, "/file_0.")['ensure'].should == 'present'
|
90
|
+
end
|
91
|
+
end
|
92
|
+
it_should_behave_like 'all iterative functions argument checks', 'map'
|
93
|
+
it_should_behave_like 'all iterative functions hash handling', 'map'
|
94
|
+
end
|
95
|
+
end
|