puppet 3.5.1-x86-mingw32 → 3.6.0.rc1-x86-mingw32
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 +5 -0
- data/Gemfile +17 -9
- data/README.md +1 -0
- data/conf/fileserver.conf +4 -3
- data/ext/README.environment +8 -0
- data/ext/build_defaults.yaml +1 -1
- data/ext/debian/control +2 -2
- data/ext/debian/puppet-common.dirs +4 -0
- data/ext/debian/rules +4 -0
- data/ext/emacs/puppet-mode-init.el +1 -1
- data/ext/emacs/puppet-mode.el +36 -17
- data/ext/redhat/client.init +3 -3
- data/ext/redhat/puppet.spec.erb +9 -0
- data/ext/systemd/puppet.service +3 -4
- data/ext/systemd/puppetmaster.service +1 -3
- data/install.rb +1 -1
- data/lib/puppet.rb +2 -1
- data/lib/puppet/agent.rb +1 -1
- data/lib/puppet/application.rb +17 -17
- data/lib/puppet/application/doc.rb +1 -1
- data/lib/puppet/configurer.rb +4 -1
- data/lib/puppet/configurer/downloader.rb +13 -12
- data/lib/puppet/configurer/plugin_handler.rb +3 -3
- data/lib/puppet/context.rb +6 -1
- data/lib/puppet/defaults.rb +82 -12
- data/lib/puppet/environments.rb +169 -13
- data/lib/puppet/external/nagios/grammar.ry +2 -0
- data/lib/puppet/external/nagios/parser.rb +28 -19
- data/lib/puppet/face/config.rb +19 -6
- data/lib/puppet/face/module/generate.rb +209 -7
- data/lib/puppet/face/module/install.rb +17 -16
- data/lib/puppet/face/module/list.rb +83 -82
- data/lib/puppet/face/module/search.rb +1 -1
- data/lib/puppet/face/module/upgrade.rb +10 -9
- data/lib/puppet/face/parser.rb +3 -2
- data/lib/puppet/face/plugin.rb +8 -4
- data/lib/puppet/file_bucket/dipper.rb +6 -3
- data/lib/puppet/file_bucket/file.rb +4 -2
- data/lib/puppet/file_serving/metadata.rb +1 -1
- data/lib/puppet/file_system/memory_file.rb +27 -1
- data/lib/puppet/file_system/memory_impl.rb +15 -1
- data/lib/puppet/forge.rb +148 -52
- data/lib/puppet/forge/cache.rb +5 -1
- data/lib/puppet/forge/errors.rb +10 -0
- data/lib/puppet/forge/repository.rb +61 -26
- data/lib/puppet/functions.rb +548 -0
- data/lib/puppet/functions/assert_type.rb +42 -0
- data/lib/puppet/functions/import.rb +7 -0
- data/lib/puppet/indirector/facts/facter.rb +1 -1
- data/lib/puppet/indirector/file_bucket_file/file.rb +3 -2
- data/lib/puppet/indirector/rest.rb +18 -0
- data/lib/puppet/loaders.rb +20 -0
- data/lib/puppet/module.rb +2 -2
- data/lib/puppet/module_tool.rb +40 -14
- data/lib/puppet/module_tool/applications.rb +0 -1
- data/lib/puppet/module_tool/applications/application.rb +35 -26
- data/lib/puppet/module_tool/applications/builder.rb +16 -6
- data/lib/puppet/module_tool/applications/checksummer.rb +25 -19
- data/lib/puppet/module_tool/applications/installer.rb +196 -35
- data/lib/puppet/module_tool/applications/searcher.rb +1 -0
- data/lib/puppet/module_tool/applications/uninstaller.rb +7 -1
- data/lib/puppet/module_tool/applications/unpacker.rb +57 -31
- data/lib/puppet/module_tool/applications/upgrader.rb +221 -65
- data/lib/puppet/module_tool/checksums.rb +5 -8
- data/lib/puppet/module_tool/errors/installer.rb +12 -44
- data/lib/puppet/module_tool/errors/shared.rb +84 -11
- data/lib/puppet/module_tool/errors/upgrader.rb +16 -45
- data/lib/puppet/module_tool/install_directory.rb +7 -6
- data/lib/puppet/module_tool/installed_modules.rb +92 -0
- data/lib/puppet/module_tool/local_tarball.rb +91 -0
- data/lib/puppet/module_tool/metadata.rb +119 -115
- data/lib/puppet/module_tool/modulefile.rb +9 -9
- data/lib/puppet/module_tool/shared_behaviors.rb +19 -7
- data/lib/puppet/module_tool/skeleton/templates/generator/README.md.erb +79 -0
- data/lib/puppet/module_tool/skeleton/templates/generator/Rakefile +18 -0
- data/lib/puppet/module_tool/skeleton/templates/generator/metadata.json.erb +1 -0
- data/lib/puppet/module_tool/skeleton/templates/generator/spec/classes/init_spec.rb.erb +7 -0
- data/lib/puppet/module_tool/tar.rb +3 -7
- data/lib/puppet/module_tool/tar/gnu.rb +21 -9
- data/lib/puppet/module_tool/tar/mini.rb +2 -8
- data/lib/puppet/network/http/api/v1.rb +1 -1
- data/lib/puppet/network/http/api/v2/authorization.rb +4 -2
- data/lib/puppet/network/http/issues.rb +1 -0
- data/lib/puppet/network/http_pool.rb +15 -6
- data/lib/puppet/node/environment.rb +91 -20
- data/lib/puppet/parser/ast/pops_bridge.rb +44 -3
- data/lib/puppet/parser/collector.rb +1 -1
- data/lib/puppet/parser/compiler.rb +50 -7
- data/lib/puppet/parser/functions.rb +6 -0
- data/lib/puppet/parser/functions/generate.rb +1 -1
- data/lib/puppet/parser/resource.rb +1 -1
- data/lib/puppet/pops.rb +22 -1
- data/lib/puppet/pops/adapters.rb +8 -1
- data/lib/puppet/pops/binder/bindings_composer.rb +1 -1
- data/lib/puppet/pops/binder/bindings_factory.rb +1 -1
- data/lib/puppet/pops/binder/config/binder_config_checker.rb +1 -1
- data/lib/puppet/pops/binder/producers.rb +2 -2
- data/lib/puppet/pops/evaluator/access_operator.rb +65 -25
- data/lib/puppet/pops/evaluator/callable_signature.rb +101 -0
- data/lib/puppet/pops/evaluator/closure.rb +57 -2
- data/lib/puppet/pops/evaluator/compare_operator.rb +1 -1
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +9 -11
- data/lib/puppet/pops/evaluator/runtime3_support.rb +72 -21
- data/lib/puppet/pops/functions/dispatch.rb +71 -0
- data/lib/puppet/pops/functions/dispatcher.rb +237 -0
- data/lib/puppet/pops/functions/function.rb +77 -0
- data/lib/puppet/pops/issues.rb +12 -0
- data/lib/puppet/pops/loader/base_loader.rb +102 -0
- data/lib/puppet/pops/loader/dependency_loader.rb +60 -0
- data/lib/puppet/pops/loader/gem_support.rb +49 -0
- data/lib/puppet/pops/loader/loader.rb +180 -0
- data/lib/puppet/pops/loader/loader_paths.rb +137 -0
- data/lib/puppet/pops/loader/module_loaders.rb +242 -0
- data/lib/puppet/pops/loader/null_loader.rb +44 -0
- data/lib/puppet/pops/loader/ruby_function_instantiator.rb +34 -0
- data/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +109 -0
- data/lib/puppet/pops/loader/simple_environment_loader.rb +20 -0
- data/lib/puppet/pops/loader/static_loader.rb +69 -0
- data/lib/puppet/pops/loader/uri_helper.rb +22 -0
- data/lib/puppet/pops/loaders.rb +240 -0
- data/lib/puppet/pops/model/factory.rb +13 -5
- data/lib/puppet/pops/model/model_tree_dumper.rb +12 -4
- data/lib/puppet/pops/parser/egrammar.ra +31 -18
- data/lib/puppet/pops/parser/eparser.rb +1137 -1106
- data/lib/puppet/pops/parser/lexer2.rb +17 -16
- data/lib/puppet/pops/semantic_error.rb +17 -0
- data/lib/puppet/pops/types/type_calculator.rb +150 -15
- data/lib/puppet/pops/types/type_factory.rb +69 -0
- data/lib/puppet/pops/types/type_parser.rb +9 -0
- data/lib/puppet/pops/types/types.rb +65 -4
- data/lib/puppet/pops/validation/checker4_0.rb +1 -1
- data/lib/puppet/pops/validation/validator_factory_4_0.rb +1 -1
- data/lib/puppet/property/list.rb +1 -1
- data/lib/puppet/provider/augeas/augeas.rb +2 -2
- data/lib/puppet/provider/cron/crontab.rb +13 -2
- data/lib/puppet/provider/package.rb +24 -0
- data/lib/puppet/provider/package/apt.rb +6 -1
- data/lib/puppet/provider/package/gem.rb +8 -2
- data/lib/puppet/provider/package/msi.rb +0 -15
- data/lib/puppet/provider/package/openbsd.rb +0 -24
- data/lib/puppet/provider/package/rpm.rb +3 -29
- data/lib/puppet/provider/package/windows.rb +0 -15
- data/lib/puppet/provider/package/yum.rb +101 -24
- data/lib/puppet/provider/package/yumhelper.py +31 -1
- data/lib/puppet/provider/package/zypper.rb +10 -28
- data/lib/puppet/provider/service/debian.rb +1 -1
- data/lib/puppet/provider/service/init.rb +3 -0
- data/lib/puppet/provider/service/openbsd.rb +318 -0
- data/lib/puppet/provider/service/redhat.rb +6 -3
- data/lib/puppet/provider/service/systemd.rb +2 -2
- data/lib/puppet/provider/yumrepo/inifile.rb +115 -42
- data/lib/puppet/resource.rb +13 -9
- data/lib/puppet/resource/catalog.rb +12 -6
- data/lib/puppet/resource/type_collection.rb +3 -3
- data/lib/puppet/settings.rb +57 -36
- data/lib/puppet/settings/config_file.rb +5 -0
- data/lib/puppet/settings/environment_conf.rb +147 -0
- data/lib/puppet/settings/ttl_setting.rb +48 -0
- data/lib/puppet/ssl/certificate_authority.rb +2 -3
- data/lib/puppet/ssl/certificate_authority/autosign_command.rb +1 -1
- data/lib/puppet/ssl/certificate_request.rb +4 -4
- data/lib/puppet/ssl/validator/default_validator.rb +2 -2
- data/lib/puppet/status.rb +1 -1
- data/lib/puppet/test/test_helper.rb +1 -0
- data/lib/puppet/type/augeas.rb +13 -1
- data/lib/puppet/type/cron.rb +32 -18
- data/lib/puppet/type/file.rb +4 -2
- data/lib/puppet/type/file/checksum.rb +15 -5
- data/lib/puppet/type/file/content.rb +3 -1
- data/lib/puppet/type/file/source.rb +5 -5
- data/lib/puppet/type/package.rb +12 -17
- data/lib/puppet/type/resources.rb +3 -1
- data/lib/puppet/type/scheduled_task.rb +4 -5
- data/lib/puppet/type/service.rb +12 -2
- data/lib/puppet/type/user.rb +106 -0
- data/lib/puppet/type/yumrepo.rb +9 -1
- data/lib/puppet/util/checksums.rb +60 -1
- data/lib/puppet/util/diff.rb +3 -1
- data/lib/puppet/util/execution.rb +20 -16
- data/lib/puppet/util/feature.rb +3 -0
- data/lib/puppet/util/logging.rb +19 -12
- data/lib/puppet/util/rubygems.rb +10 -0
- data/lib/puppet/util/watched_file.rb +1 -1
- data/lib/puppet/util/windows/security.rb +5 -3
- data/lib/puppet/vendor/load_semantic.rb +1 -0
- data/lib/puppet/vendor/require_vendored.rb +2 -0
- data/lib/puppet/vendor/semantic/Gemfile +20 -0
- data/lib/puppet/vendor/semantic/Rakefile +69 -0
- data/lib/puppet/vendor/semantic/lib/semantic.rb +7 -0
- data/lib/puppet/vendor/semantic/lib/semantic/dependency.rb +181 -0
- data/lib/puppet/vendor/semantic/lib/semantic/dependency/graph.rb +60 -0
- data/lib/puppet/vendor/semantic/lib/semantic/dependency/graph_node.rb +117 -0
- data/lib/puppet/vendor/semantic/lib/semantic/dependency/module_release.rb +46 -0
- data/lib/puppet/vendor/semantic/lib/semantic/dependency/source.rb +25 -0
- data/lib/puppet/vendor/semantic/lib/semantic/dependency/unsatisfiable_graph.rb +31 -0
- data/lib/puppet/vendor/semantic/lib/semantic/version.rb +168 -0
- data/lib/puppet/vendor/semantic/lib/semantic/version_range.rb +424 -0
- data/lib/puppet/vendor/semantic/spec/spec_helper.rb +24 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/graph_node_spec.rb +141 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/graph_spec.rb +162 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/module_release_spec.rb +143 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/source_spec.rb +5 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/unsatisfiable_graph_spec.rb +44 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency_spec.rb +383 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/version_range_spec.rb +307 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/version_spec.rb +608 -0
- data/lib/puppet/version.rb +1 -1
- data/spec/fixtures/java.tgz +0 -0
- data/spec/fixtures/stdlib.tgz +0 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/usee/lib/puppet/functions/usee/callee.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/user/lib/puppet/functions/user/caller.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/user/metadata.json +9 -0
- data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/lib/puppet/functions/modulea/rb_func_a.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/lib/puppet/functions/rb_func_a.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/manifests/init.pp +3 -0
- data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/metadata.json +19 -0
- data/spec/fixtures/unit/pops/loaders/loaders/wo_metadata_module/modules/moduleb/lib/puppet/functions/moduleb/rb_func_b.rb +6 -0
- data/spec/fixtures/unit/pops/loaders/loaders/wo_metadata_module/modules/moduleb/manifests/init.pp +3 -0
- data/spec/fixtures/unit/provider/naginator/define_empty_param +6 -0
- data/spec/fixtures/unit/provider/service/systemd/list_unit_files_services +7 -0
- data/spec/fixtures/unit/type/user/authorized_keys +5 -0
- data/spec/integration/application/apply_spec.rb +1 -2
- data/spec/integration/configurer_spec.rb +2 -2
- data/spec/integration/faces/plugin_spec.rb +62 -0
- data/spec/integration/indirector/catalog/compiler_spec.rb +1 -1
- data/spec/integration/indirector/catalog/queue_spec.rb +1 -1
- data/spec/integration/node/environment_spec.rb +2 -2
- data/spec/integration/parser/future_compiler_spec.rb +96 -142
- data/spec/integration/parser/ruby_manifest_spec.rb +0 -5
- data/spec/integration/provider/cron/crontab_spec.rb +35 -0
- data/spec/integration/type/file_spec.rb +74 -72
- data/spec/integration/util/windows/security_spec.rb +17 -0
- data/spec/lib/matchers/resource.rb +45 -13
- data/spec/lib/puppet_spec/files.rb +18 -0
- data/spec/lib/puppet_spec/module_tool/shared_functions.rb +56 -0
- data/spec/lib/puppet_spec/module_tool/stub_source.rb +133 -0
- data/spec/shared_contexts/checksums.rb +55 -0
- data/spec/unit/application/apply_spec.rb +10 -7
- data/spec/unit/application/doc_spec.rb +17 -10
- data/spec/unit/application/indirection_base_spec.rb +18 -10
- data/spec/unit/application/inspect_spec.rb +22 -20
- data/spec/unit/configurer/downloader_spec.rb +7 -6
- data/spec/unit/configurer/plugin_handler_spec.rb +5 -8
- data/spec/unit/configurer_spec.rb +1 -1
- data/spec/unit/context_spec.rb +23 -0
- data/spec/unit/environments_spec.rb +274 -16
- data/spec/unit/face/config_spec.rb +111 -11
- data/spec/unit/face/module/install_spec.rb +14 -85
- data/spec/unit/face/module/list_spec.rb +108 -62
- data/spec/unit/face/module/search_spec.rb +1 -1
- data/spec/unit/face/module/uninstall_spec.rb +21 -42
- data/spec/unit/face/parser_spec.rb +5 -2
- data/spec/unit/file_bucket/dipper_spec.rb +92 -86
- data/spec/unit/file_bucket/file_spec.rb +23 -75
- data/spec/unit/file_serving/metadata_spec.rb +74 -74
- data/spec/unit/forge/module_release_spec.rb +131 -0
- data/spec/unit/forge/repository_spec.rb +21 -20
- data/spec/unit/forge_spec.rb +99 -23
- data/spec/unit/functions/assert_type_spec.rb +59 -0
- data/spec/unit/functions4_spec.rb +671 -0
- data/spec/unit/indirector/catalog/static_compiler_spec.rb +2 -2
- data/spec/unit/indirector/facts/facter_spec.rb +9 -3
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +156 -155
- data/spec/unit/indirector/rest_spec.rb +8 -0
- data/spec/unit/interface/face_collection_spec.rb +35 -23
- data/spec/unit/module_spec.rb +20 -8
- data/spec/unit/module_tool/applications/builder_spec.rb +40 -12
- data/spec/unit/module_tool/applications/checksummer_spec.rb +86 -105
- data/spec/unit/module_tool/applications/installer_spec.rb +293 -261
- data/spec/unit/module_tool/applications/searcher_spec.rb +1 -1
- data/spec/unit/module_tool/applications/uninstaller_spec.rb +90 -154
- data/spec/unit/module_tool/applications/unpacker_spec.rb +12 -12
- data/spec/unit/module_tool/applications/upgrader_spec.rb +286 -18
- data/spec/unit/module_tool/metadata_spec.rb +223 -14
- data/spec/unit/module_tool/tar/gnu_spec.rb +12 -9
- data/spec/unit/module_tool/tar/mini_spec.rb +1 -1
- data/spec/unit/module_tool/tar_spec.rb +4 -18
- data/spec/unit/module_tool_spec.rb +123 -27
- data/spec/unit/network/formats_spec.rb +2 -2
- data/spec/unit/network/http_pool_spec.rb +21 -0
- data/spec/unit/network/rights_spec.rb +10 -8
- data/spec/unit/node/environment_spec.rb +27 -2
- data/spec/unit/parser/collector_spec.rb +1 -1
- data/spec/unit/parser/compiler_spec.rb +1 -1
- data/spec/unit/parser/functions/generate_spec.rb +4 -0
- data/spec/unit/pops/evaluator/access_ops_spec.rb +50 -11
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +25 -0
- data/spec/unit/pops/loaders/dependency_loader_spec.rb +44 -0
- data/spec/unit/pops/loaders/loader_paths_spec.rb +66 -0
- data/spec/unit/pops/loaders/loaders_spec.rb +105 -0
- data/spec/unit/pops/loaders/module_loaders_spec.rb +119 -0
- data/spec/unit/pops/loaders/static_loader_spec.rb +46 -0
- data/spec/unit/pops/types/type_calculator_spec.rb +145 -10
- data/spec/unit/pops/types/type_factory_spec.rb +101 -0
- data/spec/unit/pops/types/type_parser_spec.rb +22 -0
- data/spec/unit/property/list_spec.rb +9 -1
- data/spec/unit/provider/augeas/augeas_spec.rb +58 -11
- data/spec/unit/provider/cron/crontab_spec.rb +1 -0
- data/spec/unit/provider/cron/parsed_spec.rb +15 -0
- data/spec/unit/provider/naginator_spec.rb +14 -0
- data/spec/unit/provider/package/apt_spec.rb +78 -64
- data/spec/unit/provider/package/gem_spec.rb +15 -0
- data/spec/unit/provider/package/rpm_spec.rb +6 -6
- data/spec/unit/provider/package/windows_spec.rb +1 -1
- data/spec/unit/provider/package/yum_spec.rb +199 -104
- data/spec/unit/provider/package/zypper_spec.rb +41 -15
- data/spec/unit/provider/service/openbsd_spec.rb +129 -22
- data/spec/unit/provider/service/redhat_spec.rb +18 -4
- data/spec/unit/provider/service/systemd_spec.rb +5 -9
- data/spec/unit/provider/service/upstart_spec.rb +1 -1
- data/spec/unit/provider/user/directoryservice_spec.rb +10 -0
- data/spec/unit/provider/yumrepo/inifile_spec.rb +171 -15
- data/spec/unit/resource/catalog_spec.rb +20 -104
- data/spec/unit/resource/type_collection_spec.rb +10 -9
- data/spec/unit/settings/config_file_spec.rb +29 -6
- data/spec/unit/settings/environment_conf_spec.rb +51 -0
- data/spec/unit/settings_spec.rb +97 -12
- data/spec/unit/ssl/certificate_authority_spec.rb +2 -0
- data/spec/unit/type/augeas_spec.rb +1 -1
- data/spec/unit/type/cron_spec.rb +6 -7
- data/spec/unit/type/file/checksum_spec.rb +6 -0
- data/spec/unit/type/file/content_spec.rb +277 -207
- data/spec/unit/type/file_spec.rb +9 -7
- data/spec/unit/type/user_spec.rb +106 -18
- data/spec/unit/type/yumrepo_spec.rb +8 -0
- data/spec/unit/util/checksums_spec.rb +12 -5
- data/spec/unit/util/diff_spec.rb +8 -0
- data/spec/unit/util/execution_spec.rb +4 -4
- data/spec/unit/util/feature_spec.rb +2 -0
- data/spec/unit/util/logging_spec.rb +14 -4
- data/spec/unit/util/rdoc/parser_spec.rb +5 -4
- data/spec/unit/util/rubygems_spec.rb +14 -0
- data/tasks/parallel.rake +2 -2
- metadata +154 -21
- checksums.yaml +0 -7
- data/lib/puppet/module_tool/applications/generator.rb +0 -142
- data/lib/puppet/module_tool/skeleton.rb +0 -37
- data/lib/puppet/module_tool/skeleton/templates/generator/Modulefile.erb +0 -11
- data/lib/puppet/module_tool/skeleton/templates/generator/README.erb +0 -16
- data/lib/puppet/module_tool/tar/solaris.rb +0 -5
- data/spec/fixtures/unit/provider/service/systemd/list_units_services +0 -17
- data/spec/unit/module_tool/tar/solaris_spec.rb +0 -22
@@ -0,0 +1,42 @@
|
|
1
|
+
# Returns the given value if it is an instance of the given type, and raises an error otherwise.
|
2
|
+
#
|
3
|
+
# @example how to assert type
|
4
|
+
# # assert that `$b` is a non empty `String` and assign to `$a`
|
5
|
+
# $a = assert_type(String[1], $b)
|
6
|
+
#
|
7
|
+
# See the documentation for "The Puppet Type System" for more information about types.
|
8
|
+
#
|
9
|
+
Puppet::Functions.create_function(:assert_type) do
|
10
|
+
dispatch :assert_type do
|
11
|
+
param 'Type', 'type'
|
12
|
+
param 'Optional[Object]', 'value'
|
13
|
+
end
|
14
|
+
|
15
|
+
dispatch :assert_type_s do
|
16
|
+
param 'String', 'type_string'
|
17
|
+
param 'Optional[Object]', 'value'
|
18
|
+
end
|
19
|
+
|
20
|
+
# @param type [Type] the type the value must be an instance of
|
21
|
+
# @param value [Optional[Object]] the value to assert
|
22
|
+
#
|
23
|
+
def assert_type(type, value)
|
24
|
+
unless Puppet::Pops::Types::TypeCalculator.instance?(type,value)
|
25
|
+
inferred_type = Puppet::Pops::Types::TypeCalculator.infer(value)
|
26
|
+
# Do not give all the details - i.e. format as Integer, instead of Integer[n, n] for exact value, which
|
27
|
+
# is just confusing. (OTOH: may need to revisit, or provide a better "type diff" output.
|
28
|
+
#
|
29
|
+
actual = Puppet::Pops::Types::TypeCalculator.generalize!(inferred_type)
|
30
|
+
raise Puppet::ParseError, "assert_type(): Expected type #{type} does not match actual: #{actual}"
|
31
|
+
end
|
32
|
+
value
|
33
|
+
end
|
34
|
+
|
35
|
+
# @param type_string [String] the type the value must be an instance of given in String form
|
36
|
+
# @param value [Optional[Object]] the value to assert
|
37
|
+
#
|
38
|
+
def assert_type_s(type_string, value)
|
39
|
+
t = Puppet::Pops::Types::TypeParser.new.parse(type_string)
|
40
|
+
assert_type(t, value)
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# The import function raises an error when called to inform the user that import is no longer supported.
|
2
|
+
#
|
3
|
+
Puppet::Functions.create_function(:import) do
|
4
|
+
def import(*args)
|
5
|
+
raise Puppet::Pops::SemanticError.new(Puppet::Pops::Issues::DISCONTINUED_IMPORT)
|
6
|
+
end
|
7
|
+
end
|
@@ -15,7 +15,7 @@ class Puppet::Node::Facts::Facter < Puppet::Indirector::Code
|
|
15
15
|
|
16
16
|
def self.load_fact_plugins
|
17
17
|
# Add any per-module fact directories to the factpath
|
18
|
-
module_fact_dirs = Puppet
|
18
|
+
module_fact_dirs = Puppet.lookup(:current_environment).modulepath.collect do |d|
|
19
19
|
["lib", "plugins"].map do |subdirectory|
|
20
20
|
Dir.glob("#{d}/*/#{subdirectory}/facter")
|
21
21
|
end
|
@@ -104,8 +104,9 @@ module Puppet::FileBucketFile
|
|
104
104
|
if path == '' # Treat "md5/<checksum>/" like "md5/<checksum>"
|
105
105
|
path = nil
|
106
106
|
end
|
107
|
-
raise "Unsupported checksum type #{checksum_type.inspect}" if checksum_type !=
|
108
|
-
|
107
|
+
raise ArgumentError, "Unsupported checksum type #{checksum_type.inspect}" if checksum_type != Puppet[:digest_algorithm]
|
108
|
+
expected = method(checksum_type + "_hex_length").call
|
109
|
+
raise "Invalid checksum #{checksum.inspect}" if checksum !~ /^[0-9a-f]{#{expected}}$/
|
109
110
|
[checksum, path]
|
110
111
|
end
|
111
112
|
|
@@ -103,6 +103,20 @@ class Puppet::Indirector::REST < Puppet::Indirector::Terminus
|
|
103
103
|
result = deserialize_find(content_type, body)
|
104
104
|
result.name = request.key if result.respond_to?(:name=)
|
105
105
|
result
|
106
|
+
|
107
|
+
elsif is_http_404?(response)
|
108
|
+
# 404 gets special treatment as the indirector API can not produce a meaningful
|
109
|
+
# reason to why something is not found - it may not be the thing the user is
|
110
|
+
# expecting to find that is missing, but something else (like the environment).
|
111
|
+
# While this way of handling the issue is not perfect, there is at least a warning
|
112
|
+
# that makes a user aware of the reason for the failure.
|
113
|
+
#
|
114
|
+
content_type, body = parse_response(response)
|
115
|
+
msg = "Find #{uri_with_query_string} resulted in 404 with the message: #{body}"
|
116
|
+
# warn_once
|
117
|
+
Puppet::Util::Warnings.maybe_log(msg, self.class){ Puppet.warning msg }
|
118
|
+
nil
|
119
|
+
|
106
120
|
else
|
107
121
|
nil
|
108
122
|
end
|
@@ -195,6 +209,10 @@ class Puppet::Indirector::REST < Puppet::Indirector::Terminus
|
|
195
209
|
end
|
196
210
|
end
|
197
211
|
|
212
|
+
def is_http_404?(response)
|
213
|
+
response.code == "404"
|
214
|
+
end
|
215
|
+
|
198
216
|
def convert_to_http_error(response)
|
199
217
|
message = "Error #{response.code} on SERVER: #{(response.body||'').empty? ? response.message : uncompress_body(response)}"
|
200
218
|
Net::HTTPError.new(message, response)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Puppet
|
2
|
+
module Pops
|
3
|
+
require 'puppet/pops/loaders'
|
4
|
+
|
5
|
+
module Loader
|
6
|
+
require 'puppet/pops/loader/loader'
|
7
|
+
require 'puppet/pops/loader/base_loader'
|
8
|
+
require 'puppet/pops/loader/gem_support'
|
9
|
+
require 'puppet/pops/loader/module_loaders'
|
10
|
+
require 'puppet/pops/loader/dependency_loader'
|
11
|
+
require 'puppet/pops/loader/null_loader'
|
12
|
+
require 'puppet/pops/loader/static_loader'
|
13
|
+
require 'puppet/pops/loader/ruby_function_instantiator'
|
14
|
+
require 'puppet/pops/loader/ruby_legacy_function_instantiator'
|
15
|
+
require 'puppet/pops/loader/loader_paths'
|
16
|
+
require 'puppet/pops/loader/simple_environment_loader'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
data/lib/puppet/module.rb
CHANGED
@@ -32,7 +32,7 @@ class Puppet::Module
|
|
32
32
|
env.module(modname)
|
33
33
|
end
|
34
34
|
|
35
|
-
attr_reader :name, :environment, :path
|
35
|
+
attr_reader :name, :environment, :path, :metadata
|
36
36
|
attr_writer :environment
|
37
37
|
|
38
38
|
attr_accessor :dependencies, :forge_name
|
@@ -113,7 +113,7 @@ class Puppet::Module
|
|
113
113
|
end
|
114
114
|
|
115
115
|
def load_metadata
|
116
|
-
data = JSON.parse
|
116
|
+
@metadata = data = JSON.parse(File.read(metadata_file))
|
117
117
|
@forge_name = data['name'].gsub('-', '/') if data['name']
|
118
118
|
|
119
119
|
[:source, :author, :version, :license, :puppetversion, :dependencies].each do |attr|
|
data/lib/puppet/module_tool.rb
CHANGED
@@ -10,7 +10,7 @@ module Puppet
|
|
10
10
|
extend Puppet::Util::Colors
|
11
11
|
|
12
12
|
# Directory and names that should not be checksummed.
|
13
|
-
ARTIFACTS = ['pkg', /^\./, /^~/, /^#/, 'coverage', '
|
13
|
+
ARTIFACTS = ['pkg', /^\./, /^~/, /^#/, 'coverage', 'checksums.json', 'REVISION']
|
14
14
|
FULL_MODULE_NAME_PATTERN = /\A([^-\/|.]+)[-|\/](.+)\z/
|
15
15
|
REPOSITORY_URL = Puppet.settings[:module_repository]
|
16
16
|
|
@@ -56,14 +56,14 @@ module Puppet
|
|
56
56
|
end
|
57
57
|
|
58
58
|
# Analyse path to see if it is a module root directory by detecting a
|
59
|
-
# file named 'Modulefile' in the directory.
|
59
|
+
# file named 'metadata.json' or 'Modulefile' in the directory.
|
60
60
|
#
|
61
61
|
# @param path [Pathname, String] path to analyse
|
62
62
|
# @return [Boolean] true if the path is a module root, false otherwise
|
63
63
|
def self.is_module_root?(path)
|
64
64
|
path = Pathname.new(path) if path.class == String
|
65
65
|
|
66
|
-
FileTest.file?(path + 'Modulefile')
|
66
|
+
FileTest.file?(path + 'metadata.json') || FileTest.file?(path + 'Modulefile')
|
67
67
|
end
|
68
68
|
|
69
69
|
# Builds a formatted tree from a list of node hashes containing +:text+
|
@@ -90,16 +90,19 @@ module Puppet
|
|
90
90
|
|
91
91
|
def self.build_tree(mods, dir)
|
92
92
|
mods.each do |mod|
|
93
|
-
version_string = mod[:version]
|
93
|
+
version_string = mod[:version].to_s.sub(/^(?!v)/, 'v')
|
94
94
|
|
95
95
|
if mod[:action] == :upgrade
|
96
|
-
previous_version = mod[:previous_version].sub(/^(?!v)/, 'v')
|
96
|
+
previous_version = mod[:previous_version].to_s.sub(/^(?!v)/, 'v')
|
97
97
|
version_string = "#{previous_version} -> #{version_string}"
|
98
98
|
end
|
99
99
|
|
100
|
-
mod[:text] = "#{mod[:
|
101
|
-
mod[:text] += " [#{mod[:path]}]" unless mod[:path] == dir
|
102
|
-
|
100
|
+
mod[:text] = "#{mod[:name]} (#{colorize(:cyan, version_string)})"
|
101
|
+
mod[:text] += " [#{mod[:path]}]" unless mod[:path].to_s == dir.to_s
|
102
|
+
|
103
|
+
deps = (mod[:dependencies] || [])
|
104
|
+
deps.sort! { |a, b| a[:name] <=> b[:name] }
|
105
|
+
build_tree(deps, dir)
|
103
106
|
end
|
104
107
|
end
|
105
108
|
|
@@ -111,23 +114,46 @@ module Puppet
|
|
111
114
|
# modifying the options parameter. This same hash is referenced both
|
112
115
|
# when_invoked and when_rendering. For this reason, we are not returning
|
113
116
|
# a duplicate.
|
117
|
+
# @todo Validate the above note...
|
114
118
|
#
|
115
119
|
# An :environment_instance and a :target_dir are added/updated in the
|
116
120
|
# options parameter.
|
117
121
|
#
|
118
122
|
# @api private
|
119
123
|
def self.set_option_defaults(options)
|
120
|
-
current_environment =
|
121
|
-
|
124
|
+
current_environment = environment_from_options(options)
|
125
|
+
|
126
|
+
modulepath = [options[:target_dir]] + current_environment.full_modulepath
|
122
127
|
|
123
|
-
face_environment = current_environment.override_with(
|
124
|
-
:modulepath => modulepath.compact
|
125
|
-
)
|
128
|
+
face_environment = current_environment.override_with(:modulepath => modulepath.compact)
|
126
129
|
|
127
130
|
options[:environment_instance] = face_environment
|
131
|
+
|
128
132
|
# Note: environment will have expanded the path
|
129
133
|
options[:target_dir] = face_environment.full_modulepath.first
|
130
134
|
end
|
135
|
+
|
136
|
+
# Given a hash of options, we should discover or create a
|
137
|
+
# {Puppet::Node::Environment} instance that reflects the provided options.
|
138
|
+
#
|
139
|
+
# Generally speaking, the `:modulepath` parameter should supercede all
|
140
|
+
# others, the `:environment` parameter should follow after that, and we
|
141
|
+
# should default to Puppet's current environment.
|
142
|
+
#
|
143
|
+
# @param options [{Symbol => Object}] the options to derive environment from
|
144
|
+
# @return [Puppet::Node::Environment] the environment described by the options
|
145
|
+
def self.environment_from_options(options)
|
146
|
+
if options[:modulepath]
|
147
|
+
path = options[:modulepath].split(File::PATH_SEPARATOR)
|
148
|
+
Puppet::Node::Environment.create(:anonymous, path, '')
|
149
|
+
elsif options[:environment].is_a?(Puppet::Node::Environment)
|
150
|
+
options[:environment]
|
151
|
+
elsif options[:environment]
|
152
|
+
Puppet.lookup(:environments).get(options[:environment])
|
153
|
+
else
|
154
|
+
Puppet.lookup(:current_environment)
|
155
|
+
end
|
156
|
+
end
|
131
157
|
end
|
132
158
|
end
|
133
159
|
|
@@ -139,5 +165,5 @@ require 'puppet/module_tool/contents_description'
|
|
139
165
|
require 'puppet/module_tool/dependency'
|
140
166
|
require 'puppet/module_tool/metadata'
|
141
167
|
require 'puppet/module_tool/modulefile'
|
142
|
-
require 'puppet/
|
168
|
+
require 'puppet/forge/cache'
|
143
169
|
require 'puppet/forge'
|
@@ -5,7 +5,6 @@ module Puppet::ModuleTool
|
|
5
5
|
require 'puppet/module_tool/applications/application'
|
6
6
|
require 'puppet/module_tool/applications/builder'
|
7
7
|
require 'puppet/module_tool/applications/checksummer'
|
8
|
-
require 'puppet/module_tool/applications/generator'
|
9
8
|
require 'puppet/module_tool/applications/installer'
|
10
9
|
require 'puppet/module_tool/applications/searcher'
|
11
10
|
require 'puppet/module_tool/applications/unpacker'
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'semver'
|
3
|
+
require 'json'
|
3
4
|
require 'puppet/util/colors'
|
4
5
|
|
5
6
|
module Puppet::ModuleTool
|
@@ -26,42 +27,50 @@ module Puppet::ModuleTool
|
|
26
27
|
when Net::HTTPOK, Net::HTTPCreated
|
27
28
|
Puppet.notice success
|
28
29
|
else
|
29
|
-
errors =
|
30
|
+
errors = JSON.parse(response.body)['error'] rescue "HTTP #{response.code}, #{response.body}"
|
30
31
|
Puppet.warning "#{failure} (#{errors})"
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
34
|
-
def metadata(
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
35
|
+
def metadata(require_metadata = false)
|
36
|
+
return @metadata if @metadata
|
37
|
+
@metadata = Puppet::ModuleTool::Metadata.new
|
38
|
+
|
39
|
+
unless @path
|
40
|
+
raise ArgumentError, "Could not determine module path"
|
41
|
+
end
|
42
|
+
|
43
|
+
modulefile_path = File.join(@path, 'Modulefile')
|
44
|
+
metadata_path = File.join(@path, 'metadata.json')
|
45
|
+
|
46
|
+
if File.file?(modulefile_path)
|
47
|
+
if File.file?(metadata_path)
|
48
|
+
Puppet.warning "Modulefile is deprecated. Using metadata.json."
|
49
|
+
else
|
50
|
+
Puppet.warning "Modulefile is deprecated. Building metadata.json from Modulefile."
|
49
51
|
end
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
52
|
+
end
|
53
|
+
|
54
|
+
if File.file?(metadata_path)
|
55
|
+
File.open(metadata_path) do |f|
|
56
|
+
begin
|
57
|
+
@metadata.update(JSON.load(f))
|
58
|
+
rescue JSON::ParserError => ex
|
59
|
+
raise ArgumentError, "Could not parse JSON #{metadata_path}", ex.backtrace
|
58
60
|
end
|
59
61
|
end
|
62
|
+
|
63
|
+
elsif File.file?(modulefile_path)
|
64
|
+
Puppet::ModuleTool::ModulefileReader.evaluate(@metadata, modulefile_path)
|
65
|
+
|
66
|
+
elsif require_metadata
|
67
|
+
raise ArgumentError, "No metadata found for module #{@path}"
|
60
68
|
end
|
61
|
-
|
69
|
+
|
70
|
+
return @metadata
|
62
71
|
end
|
63
72
|
|
64
|
-
def
|
73
|
+
def load_metadata!
|
65
74
|
@metadata = nil
|
66
75
|
metadata(true)
|
67
76
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'fileutils'
|
2
|
+
require 'json'
|
2
3
|
|
3
4
|
module Puppet::ModuleTool
|
4
5
|
module Applications
|
@@ -11,10 +12,10 @@ module Puppet::ModuleTool
|
|
11
12
|
end
|
12
13
|
|
13
14
|
def run
|
14
|
-
|
15
|
+
load_metadata!
|
15
16
|
create_directory
|
16
17
|
copy_contents
|
17
|
-
|
18
|
+
write_json
|
18
19
|
Puppet.notice "Building #{@path} for release"
|
19
20
|
pack
|
20
21
|
relative = Pathname.new(archive_file).relative_path_from(Pathname.new(File.expand_path(Dir.pwd)))
|
@@ -40,7 +41,7 @@ module Puppet::ModuleTool
|
|
40
41
|
def pack
|
41
42
|
FileUtils.rm archive_file rescue nil
|
42
43
|
|
43
|
-
tar = Puppet::ModuleTool::Tar.instance
|
44
|
+
tar = Puppet::ModuleTool::Tar.instance
|
44
45
|
Dir.chdir(@pkg_path) do
|
45
46
|
tar.pack(metadata.release_name, archive_file)
|
46
47
|
end
|
@@ -65,9 +66,18 @@ module Puppet::ModuleTool
|
|
65
66
|
end
|
66
67
|
end
|
67
68
|
|
68
|
-
def
|
69
|
-
File.
|
70
|
-
|
69
|
+
def write_json
|
70
|
+
metadata_path = File.join(build_path, 'metadata.json')
|
71
|
+
|
72
|
+
unless File.exist?(metadata_path)
|
73
|
+
# Legacy build: Metadata was parsed from Modulefile; write it out
|
74
|
+
File.open(metadata_path, 'w') do |f|
|
75
|
+
f.write(metadata.to_json)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
File.open(File.join(build_path, 'checksums.json'), 'w') do |f|
|
80
|
+
f.write(PSON.pretty_generate(Checksums.new(@path)))
|
71
81
|
end
|
72
82
|
end
|
73
83
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'json'
|
1
2
|
require 'puppet/module_tool/checksums'
|
2
3
|
|
3
4
|
module Puppet::ModuleTool
|
@@ -11,23 +12,16 @@ module Puppet::ModuleTool
|
|
11
12
|
|
12
13
|
def run
|
13
14
|
changes = []
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
path = @path + child_path
|
25
|
-
unless path.exist? && canonical_checksum == sums.checksum(path)
|
26
|
-
changes << child_path
|
27
|
-
end
|
15
|
+
sums = Puppet::ModuleTool::Checksums.new(@path)
|
16
|
+
checksums.each do |child_path, canonical_checksum|
|
17
|
+
|
18
|
+
# Avoid checksumming the checksums.json file
|
19
|
+
next if File.basename(child_path) == "checksums.json"
|
20
|
+
|
21
|
+
path = @path + child_path
|
22
|
+
unless path.exist? && canonical_checksum == sums.checksum(path)
|
23
|
+
changes << child_path
|
28
24
|
end
|
29
|
-
else
|
30
|
-
raise ArgumentError, "No metadata.json found."
|
31
25
|
end
|
32
26
|
|
33
27
|
# Return an Array of strings representing file paths of files that have
|
@@ -44,12 +38,24 @@ module Puppet::ModuleTool
|
|
44
38
|
|
45
39
|
private
|
46
40
|
|
47
|
-
def
|
48
|
-
|
41
|
+
def checksums
|
42
|
+
if checksums_file.exist?
|
43
|
+
JSON.parse(checksums_file.read)
|
44
|
+
elsif metadata_file.exist?
|
45
|
+
# Check metadata.json too; legacy modules store their checksums there.
|
46
|
+
JSON.parse(metadata_file.read)['checksums'] or
|
47
|
+
raise ArgumentError, "No file containing checksums found."
|
48
|
+
else
|
49
|
+
raise ArgumentError, "No file containing checksums found."
|
50
|
+
end
|
49
51
|
end
|
50
52
|
|
51
53
|
def metadata_file
|
52
|
-
|
54
|
+
@path + 'metadata.json'
|
55
|
+
end
|
56
|
+
|
57
|
+
def checksums_file
|
58
|
+
@path + 'checksums.json'
|
53
59
|
end
|
54
60
|
end
|
55
61
|
end
|