puppet 4.7.1-universal-darwin → 4.8.0-universal-darwin

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (276) hide show
  1. data/Gemfile +0 -3
  2. data/MAINTAINERS +76 -0
  3. data/README.md +0 -6
  4. data/Rakefile +2 -2
  5. data/lib/puppet/agent.rb +3 -3
  6. data/lib/puppet/application/apply.rb +1 -1
  7. data/lib/puppet/configurer.rb +2 -2
  8. data/lib/puppet/data_providers.rb +1 -0
  9. data/lib/puppet/data_providers/data_adapter.rb +1 -0
  10. data/lib/puppet/data_providers/data_function_support.rb +1 -0
  11. data/lib/puppet/data_providers/function_env_data_provider.rb +1 -0
  12. data/lib/puppet/data_providers/function_module_data_provider.rb +1 -0
  13. data/lib/puppet/data_providers/hiera_config.rb +1 -0
  14. data/lib/puppet/data_providers/hiera_env_data_provider.rb +1 -0
  15. data/lib/puppet/data_providers/hiera_interpolate.rb +1 -0
  16. data/lib/puppet/data_providers/hiera_module_data_provider.rb +1 -0
  17. data/lib/puppet/data_providers/hiera_support.rb +1 -2
  18. data/lib/puppet/data_providers/json_data_provider_factory.rb +2 -0
  19. data/lib/puppet/data_providers/yaml_data_provider_factory.rb +2 -0
  20. data/lib/puppet/defaults.rb +20 -1
  21. data/lib/puppet/environments.rb +5 -2
  22. data/lib/puppet/face/catalog.rb +1 -1
  23. data/lib/puppet/face/epp.rb +57 -11
  24. data/lib/puppet/face/module/install.rb +6 -6
  25. data/lib/puppet/functions.rb +23 -24
  26. data/lib/puppet/functions/alert.rb +14 -0
  27. data/lib/puppet/functions/binary_file.rb +25 -0
  28. data/lib/puppet/functions/break.rb +22 -0
  29. data/lib/puppet/functions/contain.rb +33 -0
  30. data/lib/puppet/functions/crit.rb +14 -0
  31. data/lib/puppet/functions/debug.rb +14 -0
  32. data/lib/puppet/functions/emerg.rb +14 -0
  33. data/lib/puppet/functions/epp.rb +1 -1
  34. data/lib/puppet/functions/err.rb +14 -0
  35. data/lib/puppet/functions/find_file.rb +31 -0
  36. data/lib/puppet/functions/include.rb +21 -0
  37. data/lib/puppet/functions/info.rb +14 -0
  38. data/lib/puppet/functions/new.rb +1 -1
  39. data/lib/puppet/functions/next.rb +23 -0
  40. data/lib/puppet/functions/notice.rb +14 -0
  41. data/lib/puppet/functions/regsubst.rb +12 -16
  42. data/lib/puppet/functions/require.rb +37 -0
  43. data/lib/puppet/functions/return.rb +22 -0
  44. data/lib/puppet/functions/strftime.rb +35 -0
  45. data/lib/puppet/functions/warning.rb +14 -0
  46. data/lib/puppet/generate/models/type/type.rb +4 -0
  47. data/lib/puppet/generate/templates/type/pcore.erb +2 -1
  48. data/lib/puppet/indirector/face.rb +6 -1
  49. data/lib/puppet/network/http/error.rb +2 -2
  50. data/lib/puppet/network/http/handler.rb +2 -2
  51. data/lib/puppet/node/environment.rb +11 -0
  52. data/lib/puppet/parser/ast.rb +5 -0
  53. data/lib/puppet/parser/ast/pops_bridge.rb +17 -4
  54. data/lib/puppet/parser/compiler.rb +29 -1
  55. data/lib/puppet/parser/functions.rb +6 -0
  56. data/lib/puppet/parser/functions/assert_type.rb +1 -1
  57. data/lib/puppet/parser/functions/binary_file.rb +24 -0
  58. data/lib/puppet/parser/functions/break.rb +39 -0
  59. data/lib/puppet/parser/functions/contain.rb +7 -15
  60. data/lib/puppet/parser/functions/defined.rb +2 -2
  61. data/lib/puppet/parser/functions/dig.rb +1 -1
  62. data/lib/puppet/parser/functions/each.rb +1 -1
  63. data/lib/puppet/parser/functions/epp.rb +2 -2
  64. data/lib/puppet/parser/functions/filter.rb +1 -1
  65. data/lib/puppet/parser/functions/find_file.rb +28 -0
  66. data/lib/puppet/parser/functions/hiera.rb +4 -4
  67. data/lib/puppet/parser/functions/hiera_array.rb +1 -1
  68. data/lib/puppet/parser/functions/hiera_hash.rb +1 -1
  69. data/lib/puppet/parser/functions/hiera_include.rb +1 -1
  70. data/lib/puppet/parser/functions/include.rb +4 -8
  71. data/lib/puppet/parser/functions/inline_epp.rb +1 -1
  72. data/lib/puppet/parser/functions/lest.rb +1 -1
  73. data/lib/puppet/parser/functions/lookup.rb +4 -2
  74. data/lib/puppet/parser/functions/map.rb +1 -1
  75. data/lib/puppet/parser/functions/match.rb +1 -1
  76. data/lib/puppet/parser/functions/new.rb +414 -18
  77. data/lib/puppet/parser/functions/next.rb +38 -0
  78. data/lib/puppet/parser/functions/reduce.rb +1 -1
  79. data/lib/puppet/parser/functions/regsubst.rb +4 -2
  80. data/lib/puppet/parser/functions/require.rb +4 -27
  81. data/lib/puppet/parser/functions/return.rb +71 -0
  82. data/lib/puppet/parser/functions/reverse_each.rb +1 -1
  83. data/lib/puppet/parser/functions/scanf.rb +13 -8
  84. data/lib/puppet/parser/functions/slice.rb +1 -1
  85. data/lib/puppet/parser/functions/split.rb +1 -1
  86. data/lib/puppet/parser/functions/step.rb +1 -1
  87. data/lib/puppet/parser/functions/strftime.rb +185 -0
  88. data/lib/puppet/parser/functions/then.rb +1 -1
  89. data/lib/puppet/parser/functions/type.rb +1 -1
  90. data/lib/puppet/parser/functions/with.rb +3 -3
  91. data/lib/puppet/parser/resource.rb +8 -5
  92. data/lib/puppet/parser/scope.rb +1 -1
  93. data/lib/puppet/plugins/configuration.rb +8 -0
  94. data/lib/puppet/plugins/data_providers.rb +1 -0
  95. data/lib/puppet/plugins/data_providers/data_provider.rb +7 -28
  96. data/lib/puppet/plugins/data_providers/registry.rb +1 -0
  97. data/lib/puppet/pops.rb +4 -0
  98. data/lib/puppet/pops/evaluator/access_operator.rb +36 -5
  99. data/lib/puppet/pops/evaluator/closure.rb +81 -12
  100. data/lib/puppet/pops/evaluator/compare_operator.rb +24 -1
  101. data/lib/puppet/pops/evaluator/evaluator_impl.rb +29 -5
  102. data/lib/puppet/pops/evaluator/json_strict_literal_evaluator.rb +1 -1
  103. data/lib/puppet/pops/evaluator/runtime3_converter.rb +53 -62
  104. data/lib/puppet/pops/evaluator/runtime3_support.rb +15 -6
  105. data/lib/puppet/pops/functions/dispatch.rb +9 -2
  106. data/lib/puppet/pops/functions/dispatcher.rb +3 -1
  107. data/lib/puppet/pops/functions/function.rb +19 -2
  108. data/lib/puppet/pops/issues.rb +9 -0
  109. data/lib/puppet/pops/label_provider.rb +2 -2
  110. data/lib/puppet/pops/loader/loader.rb +17 -0
  111. data/lib/puppet/pops/loader/static_loader.rb +0 -41
  112. data/lib/puppet/pops/lookup.rb +12 -0
  113. data/lib/puppet/pops/lookup/context.rb +86 -0
  114. data/lib/puppet/pops/lookup/explainer.rb +46 -6
  115. data/lib/puppet/pops/lookup/invocation.rb +19 -0
  116. data/lib/puppet/pops/lookup/sub_lookup.rb +1 -1
  117. data/lib/puppet/pops/model/factory.rb +20 -8
  118. data/lib/puppet/pops/model/model_label_provider.rb +3 -0
  119. data/lib/puppet/pops/model/model_meta.rb +2 -0
  120. data/lib/puppet/pops/model/model_tree_dumper.rb +14 -0
  121. data/lib/puppet/pops/parser/egrammar.ra +11 -6
  122. data/lib/puppet/pops/parser/eparser.rb +1112 -1086
  123. data/lib/puppet/pops/parser/heredoc_support.rb +1 -2
  124. data/lib/puppet/pops/pcore.rb +1 -0
  125. data/lib/puppet/pops/puppet_stack.rb +3 -3
  126. data/lib/puppet/pops/resource/param.rb +5 -1
  127. data/lib/puppet/pops/resource/resource_type_impl.rb +8 -4
  128. data/lib/puppet/pops/resource/resource_type_set.pcore +1 -0
  129. data/lib/puppet/pops/serialization/abstract_reader.rb +19 -2
  130. data/lib/puppet/pops/serialization/abstract_writer.rb +16 -3
  131. data/lib/puppet/pops/serialization/deserializer.rb +5 -1
  132. data/lib/puppet/pops/serialization/extension.rb +2 -0
  133. data/lib/puppet/pops/serialization/json.rb +76 -26
  134. data/lib/puppet/pops/serialization/serializer.rb +5 -1
  135. data/lib/puppet/pops/serialization/time_factory.rb +2 -1
  136. data/lib/puppet/pops/time/timespan.rb +718 -0
  137. data/lib/puppet/pops/time/timestamp.rb +148 -0
  138. data/lib/puppet/pops/types/p_binary_type.rb +220 -0
  139. data/lib/puppet/pops/types/p_object_type.rb +12 -6
  140. data/lib/puppet/pops/types/p_sensitive_type.rb +5 -1
  141. data/lib/puppet/pops/types/p_timespan_type.rb +141 -0
  142. data/lib/puppet/pops/types/p_timestamp_type.rb +69 -0
  143. data/lib/puppet/pops/types/string_converter.rb +62 -0
  144. data/lib/puppet/pops/types/type_asserter.rb +1 -1
  145. data/lib/puppet/pops/types/type_calculator.rb +17 -3
  146. data/lib/puppet/pops/types/type_factory.rb +35 -1
  147. data/lib/puppet/pops/types/type_formatter.rb +64 -11
  148. data/lib/puppet/pops/types/type_mismatch_describer.rb +110 -61
  149. data/lib/puppet/pops/types/type_parser.rb +18 -4
  150. data/lib/puppet/pops/types/types.rb +98 -63
  151. data/lib/puppet/pops/validation.rb +9 -1
  152. data/lib/puppet/pops/validation/checker4_0.rb +7 -0
  153. data/lib/puppet/property.rb +1 -1
  154. data/lib/puppet/provider.rb +3 -6
  155. data/lib/puppet/provider/mcx/mcxcontent.rb +1 -1
  156. data/lib/puppet/provider/mount/parsed.rb +18 -4
  157. data/lib/puppet/provider/nameservice/directoryservice.rb +15 -7
  158. data/lib/puppet/provider/package/gem.rb +6 -1
  159. data/lib/puppet/provider/package/pip.rb +0 -1
  160. data/lib/puppet/provider/package/pkg.rb +5 -1
  161. data/lib/puppet/provider/package/pkgng.rb +1 -1
  162. data/lib/puppet/provider/package/yum.rb +10 -0
  163. data/lib/puppet/provider/service/launchd.rb +1 -0
  164. data/lib/puppet/provider/user/directoryservice.rb +6 -6
  165. data/lib/puppet/provider/yumrepo/inifile.rb +1 -1
  166. data/lib/puppet/provider/zpool/zpool.rb +1 -1
  167. data/lib/puppet/resource.rb +54 -12
  168. data/lib/puppet/resource/capability_finder.rb +15 -9
  169. data/lib/puppet/resource/catalog.rb +25 -6
  170. data/lib/puppet/resource/type.rb +3 -1
  171. data/lib/puppet/settings.rb +1 -1
  172. data/lib/puppet/settings/environment_conf.rb +12 -4
  173. data/lib/puppet/syntax_checkers/base64.rb +41 -0
  174. data/lib/puppet/syntax_checkers/json.rb +0 -2
  175. data/lib/puppet/transaction.rb +6 -0
  176. data/lib/puppet/transaction/additional_resource_generator.rb +5 -0
  177. data/lib/puppet/transaction/report.rb +7 -2
  178. data/lib/puppet/type.rb +2 -1
  179. data/lib/puppet/type/file/checksum.rb +1 -0
  180. data/lib/puppet/type/file/content.rb +4 -4
  181. data/lib/puppet/type/mount.rb +44 -0
  182. data/lib/puppet/type/ssh_authorized_key.rb +1 -1
  183. data/lib/puppet/type/tidy.rb +3 -0
  184. data/lib/puppet/type/user.rb +12 -6
  185. data/lib/puppet/util/log.rb +25 -0
  186. data/lib/puppet/util/plist.rb +8 -3
  187. data/lib/puppet/version.rb +1 -1
  188. data/lib/puppet_x.rb +7 -1
  189. data/spec/integration/application/apply_spec.rb +118 -0
  190. data/spec/integration/parser/compiler_spec.rb +28 -0
  191. data/spec/integration/parser/pcore_resource_spec.rb +40 -3
  192. data/spec/integration/provider/mount_spec.rb +2 -1
  193. data/spec/integration/util/windows/principal_spec.rb +2 -2
  194. data/spec/integration/util/windows/registry_spec.rb +4 -4
  195. data/spec/lib/puppet_spec/compiler.rb +5 -1
  196. data/spec/lib/puppet_spec/unindent.rb +5 -0
  197. data/spec/shared_contexts/types_setup.rb +6 -0
  198. data/spec/shared_examples/rhel_package_provider.rb +16 -0
  199. data/spec/spec_helper.rb +1 -0
  200. data/spec/unit/agent_spec.rb +11 -0
  201. data/spec/unit/application/lookup_spec.rb +94 -3
  202. data/spec/unit/capability_spec.rb +22 -0
  203. data/spec/unit/configurer_spec.rb +8 -0
  204. data/spec/unit/face/epp_face_spec.rb +22 -3
  205. data/spec/unit/functions/assert_type_spec.rb +3 -3
  206. data/spec/unit/functions/binary_file_spec.rb +46 -0
  207. data/spec/unit/functions/break_spec.rb +89 -0
  208. data/spec/unit/{parser/functions → functions}/contain_spec.rb +68 -3
  209. data/spec/unit/functions/find_file_spec.rb +69 -0
  210. data/spec/unit/functions/include_spec.rb +175 -0
  211. data/spec/unit/functions/logging_spec.rb +54 -0
  212. data/spec/unit/functions/lookup_spec.rb +3 -3
  213. data/spec/unit/functions/new_spec.rb +105 -5
  214. data/spec/unit/functions/next_spec.rb +93 -0
  215. data/spec/unit/functions/require_spec.rb +83 -0
  216. data/spec/unit/functions/return_spec.rb +105 -0
  217. data/spec/unit/{parser/functions → functions}/shared.rb +14 -11
  218. data/spec/unit/functions/strftime_spec.rb +152 -0
  219. data/spec/unit/functions4_spec.rb +22 -0
  220. data/spec/unit/indirector/face_spec.rb +10 -2
  221. data/spec/unit/network/http/error_spec.rb +1 -2
  222. data/spec/unit/network/http/handler_spec.rb +6 -5
  223. data/spec/unit/parser/functions/hiera_array_spec.rb +1 -1
  224. data/spec/unit/parser/functions/hiera_hash_spec.rb +1 -1
  225. data/spec/unit/parser/functions/hiera_include_spec.rb +1 -1
  226. data/spec/unit/parser/functions/hiera_spec.rb +1 -1
  227. data/spec/unit/parser/functions/lookup_spec.rb +1 -1
  228. data/spec/unit/parser/functions/regsubst_spec.rb +1 -1
  229. data/spec/unit/parser/functions/split_spec.rb +1 -1
  230. data/spec/unit/pops/evaluator/access_ops_spec.rb +81 -1
  231. data/spec/unit/pops/evaluator/arithmetic_ops_spec.rb +170 -0
  232. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +29 -4
  233. data/spec/unit/pops/evaluator/runtime3_converter_spec.rb +112 -4
  234. data/spec/unit/pops/loaders/dependency_loader_spec.rb +12 -0
  235. data/spec/unit/pops/loaders/static_loader_spec.rb +0 -26
  236. data/spec/unit/pops/lookup/context_spec.rb +149 -0
  237. data/spec/unit/pops/parser/parse_functions_spec.rb +19 -0
  238. data/spec/unit/pops/parser/parse_lambda_spec.rb +19 -0
  239. data/spec/unit/pops/puppet_stack_spec.rb +1 -1
  240. data/spec/unit/pops/resource/resource_type_impl_spec.rb +74 -0
  241. data/spec/unit/pops/serialization/packer_spec.rb +34 -14
  242. data/spec/unit/pops/serialization/serialization_spec.rb +67 -5
  243. data/spec/unit/pops/time/timespan_spec.rb +121 -0
  244. data/spec/unit/pops/types/p_binary_type_spec.rb +243 -0
  245. data/spec/unit/pops/types/p_object_type_spec.rb +7 -7
  246. data/spec/unit/pops/types/p_sensitive_type_spec.rb +1 -1
  247. data/spec/unit/pops/types/p_timespan_type_spec.rb +273 -0
  248. data/spec/unit/pops/types/p_timestamp_type_spec.rb +311 -0
  249. data/spec/unit/pops/types/p_type_set_type_spec.rb +13 -13
  250. data/spec/unit/pops/types/ruby_generator_spec.rb +12 -12
  251. data/spec/unit/pops/types/string_converter_spec.rb +89 -0
  252. data/spec/unit/pops/types/type_asserter_spec.rb +3 -3
  253. data/spec/unit/pops/types/type_calculator_spec.rb +113 -5
  254. data/spec/unit/pops/types/type_formatter_spec.rb +40 -0
  255. data/spec/unit/pops/types/type_mismatch_describer_spec.rb +49 -38
  256. data/spec/unit/pops/types/type_parser_spec.rb +87 -4
  257. data/spec/unit/pops/types/types_spec.rb +1 -1
  258. data/spec/unit/pops/validator/validator_spec.rb +23 -0
  259. data/spec/unit/provider/mount/parsed_spec.rb +47 -29
  260. data/spec/unit/provider/package/pkg_spec.rb +109 -99
  261. data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +1 -0
  262. data/spec/unit/provider/user/aix_spec.rb +1 -1
  263. data/spec/unit/provider/user/directoryservice_spec.rb +101 -30
  264. data/spec/unit/resource/capability_finder_spec.rb +29 -7
  265. data/spec/unit/resource/catalog_spec.rb +127 -0
  266. data/spec/unit/ssl/certificate_request_spec.rb +1 -1
  267. data/spec/unit/transaction/additional_resource_generator_spec.rb +30 -0
  268. data/spec/unit/transaction/persistence_spec.rb +1 -6
  269. data/spec/unit/transaction/report_spec.rb +23 -0
  270. data/spec/unit/transaction_spec.rb +38 -0
  271. data/spec/unit/type/mount_spec.rb +5 -0
  272. data/spec/unit/util/plist_spec.rb +14 -2
  273. metadata +71 -12
  274. data/spec/integration/parser/functions/require_spec.rb +0 -43
  275. data/spec/unit/parser/functions/include_spec.rb +0 -55
  276. data/spec/unit/parser/functions/require_spec.rb +0 -68
@@ -0,0 +1,14 @@
1
+ # Log a message on the server at level notice.
2
+ Puppet::Functions.create_function(:notice, Puppet::Functions::InternalFunction) do
3
+ # @param values The values to log.
4
+ # @return [Undef]
5
+ dispatch :notice do
6
+ scope_param
7
+ repeated_param 'Any', :values
8
+ return_type 'Undef'
9
+ end
10
+
11
+ def notice(scope, *values)
12
+ Puppet::Util::Log.log_func(scope, :notice, values)
13
+ end
14
+ end
@@ -1,40 +1,36 @@
1
1
  # Perform regexp replacement on a string or array of strings.
2
2
  #
3
- # @example
4
- #
5
- # Get the third octet from the node's IP address:
6
- #
7
- # $i3 = regsubst($ipaddress,'^(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)$','\\3')
8
- #
9
- # Put angle brackets around each octet in the node's IP address:
10
- #
11
- # $x = regsubst($ipaddress, /([0-9]+)/, '<\\1>', 'G')
12
- #
13
- # @param target [Array[String]|String]
3
+ # @param target [String, Array[String]]
14
4
  # The string or array of strings to operate on. If an array, the replacement will be
15
5
  # performed on each of the elements in the array, and the return value will be an array.
16
- # @param regexp [String|Regexp|Type[Regexp]]
6
+ # @param pattern [String, Regexp, Type[Regexp]]
17
7
  # The regular expression matching the target string. If you want it anchored at the start
18
8
  # and or end of the string, you must do that with ^ and $ yourself.
19
- # @param replacement [String|Hash[String, String]]
9
+ # @param replacement [String, Hash[String, String]]
20
10
  # Replacement string. Can contain backreferences to what was matched using \\0 (whole match),
21
11
  # \\1 (first set of parentheses), and so on.
22
12
  # If the second argument is a Hash, and the matched text is one of its keys, the corresponding value is the replacement string.
23
- # @param flags [String]
13
+ # @param flags [Optional[Pattern[/^[GEIM]*$/]], Pattern[/^G?$/]]
24
14
  # Optional. String of single letter flags for how the regexp is interpreted (E, I, and M cannot be used
25
15
  # if pattern is a precompiled regexp):
26
16
  # - *E* Extended regexps
27
17
  # - *I* Ignore case in regexps
28
18
  # - *M* Multiline regexps
29
19
  # - *G* Global replacement; all occurrences of the regexp in each target string will be replaced. Without this, only the first occurrence will be replaced.
30
- # @param encoding [String]
20
+ # @param encoding [Enum['N','E','S','U']]
31
21
  # Optional. How to handle multibyte characters when compiling the regexp (must not be used when pattern is a
32
22
  # precompiled regexp). A single-character string with the following values:
33
23
  # - *N* None
34
24
  # - *E* EUC
35
25
  # - *S* SJIS
36
26
  # - *U* UTF-8
37
- # @return [Array[String]|String] The result of the substitution. Result type is the same as for the target parameter.
27
+ # @return [Array[String], String] The result of the substitution. Result type is the same as for the target parameter.
28
+ #
29
+ # @example Get the third octet from the node's IP address:
30
+ # $i3 = regsubst($ipaddress,'^(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)$','\\3')
31
+ #
32
+ # @example Put angle brackets around each octet in the node's IP address:
33
+ # $x = regsubst($ipaddress, /([0-9]+)/, '<\\1>', 'G')
38
34
  #
39
35
  Puppet::Functions.create_function(:regsubst) do
40
36
  dispatch :regsubst_string do
@@ -0,0 +1,37 @@
1
+ # Requires the specified classes
2
+ # For documentation see the 3.x function stub
3
+ Puppet::Functions.create_function(:require, Puppet::Functions::InternalFunction) do
4
+ dispatch :require_impl do
5
+ scope_param
6
+ # The function supports what the type system sees as Ruby runtime objects, and
7
+ # they cannot be parameterized to find what is actually valid instances.
8
+ # The validation is instead done in the function body itself via a call to
9
+ # `transform_and_assert_classnames` on the calling scope.
10
+ required_repeated_param 'Any', :names
11
+ end
12
+
13
+ def require_impl(scope, *classes)
14
+ # Make call patterns uniform and protected against nested arrays, also make
15
+ # names absolute if so desired.
16
+ classes = scope.transform_and_assert_classnames(classes.flatten)
17
+
18
+ result = classes.map {|name| Puppet::Pops::Types::TypeFactory.host_class(name) }
19
+
20
+ # This is the same as calling the include function (but faster) since it again
21
+ # would otherwise need to perform the optional absolute name transformation
22
+ # (for no reason since they are already made absolute here).
23
+ #
24
+ scope.compiler.evaluate_classes(classes, scope, false)
25
+ krt = scope.environment.known_resource_types
26
+
27
+ classes.each do |klass|
28
+ # lookup the class in the scopes
29
+ klass = (classobj = krt.find_hostclass(klass)) ? classobj.name : nil
30
+ raise Puppet::ParseError.new("Could not find class #{klass}") unless klass
31
+ ref = Puppet::Resource.new(:class, klass)
32
+ resource = scope.resource
33
+ resource.set_parameter(:require, [resource[:require]].flatten.compact << ref)
34
+ end
35
+ result
36
+ end
37
+ end
@@ -0,0 +1,22 @@
1
+ # Make iteration continue with the next value optionally given a value for this iteration.
2
+ # If a value is not given it defaults to `undef`
3
+ #
4
+ # @since 4.7.0
5
+ #
6
+ Puppet::Functions.create_function(:return, Puppet::Functions::InternalFunction) do
7
+ dispatch :return_impl do
8
+ optional_param 'Any', :value
9
+ end
10
+
11
+ def return_impl(value = nil)
12
+ stacktrace = Puppet::Pops::PuppetStack.stacktrace()
13
+ if stacktrace.size > 0
14
+ file, line = stacktrace[0]
15
+ else
16
+ file = nil
17
+ line = nil
18
+ end
19
+
20
+ raise Puppet::Pops::Evaluator::Return.new(value, file, line)
21
+ end
22
+ end
@@ -0,0 +1,35 @@
1
+ # (Documentation in 3.x stub)
2
+ #
3
+ # @since 4.8.0
4
+ #
5
+ Puppet::Functions.create_function(:strftime) do
6
+ dispatch :format_timespan do
7
+ param 'Timespan', :time_object
8
+ param 'String', :format
9
+ end
10
+
11
+ dispatch :format_timestamp do
12
+ param 'Timestamp', :time_object
13
+ param 'String', :format
14
+ optional_param 'String', :timezone
15
+ end
16
+
17
+ dispatch :legacy_strftime do
18
+ param 'String', :format
19
+ optional_param 'String', :timezone
20
+ end
21
+
22
+ def format_timespan(time_object, format)
23
+ time_object.format(format)
24
+ end
25
+
26
+ def format_timestamp(time_object, format, timezone = nil)
27
+ time_object.format(format, timezone)
28
+ end
29
+
30
+ def legacy_strftime(format, timezone = nil)
31
+ Puppet.warn_once('deprecation', 'legacy#strftime',
32
+ 'The argument signature (String format, [String timezone]) is deprecated for #strfime. See #strftime documentation and Timespan type for more info')
33
+ Puppet::Pops::Time::Timestamp.format_time(format, Time.now.utc, timezone)
34
+ end
35
+ end
@@ -0,0 +1,14 @@
1
+ # Log a message on the server at level notice.
2
+ Puppet::Functions.create_function(:warning, Puppet::Functions::InternalFunction) do
3
+ # @param values The values to log.
4
+ # @return [Undef]
5
+ dispatch :warning do
6
+ scope_param
7
+ repeated_param 'Any', :values
8
+ return_type 'Undef'
9
+ end
10
+
11
+ def warning(scope, *values)
12
+ Puppet::Util::Log.log_func(scope, :warning, values)
13
+ end
14
+ end
@@ -24,6 +24,9 @@ module Puppet
24
24
  # Gets the isomorphic member attribute of the type
25
25
  attr_reader :isomorphic
26
26
 
27
+ # Gets the capability member attribute of the type
28
+ attr_reader :capability
29
+
27
30
  # Initializes a type model.
28
31
  # @param type [Puppet::Type] The Puppet type to model.
29
32
  # @return [void]
@@ -45,6 +48,7 @@ module Puppet
45
48
  ]
46
49
  end]
47
50
  @isomorphic = type.isomorphic?
51
+ @capability = type.is_capability?
48
52
  end
49
53
 
50
54
  def render(template)
@@ -37,5 +37,6 @@ Puppet::Resource::ResourceType3.new(
37
37
  <%= mapping[0] %> => [<%= mapping[1].join(', ')%>]<%= "," if index + 1 < title_patterns.size %>
38
38
  <%- end -%>
39
39
  },
40
- <%= isomorphic -%>
40
+ <%= isomorphic -%>,
41
+ <%= capability -%>
41
42
  )
@@ -39,7 +39,12 @@ class Puppet::Indirector::Face < Puppet::Face
39
39
 
40
40
  def call_indirection_method(method, key, options)
41
41
  begin
42
- result = indirection.__send__(method, key, options)
42
+ if method == :save
43
+ # key is really the instance to save
44
+ result = indirection.__send__(method, key, nil, options)
45
+ else
46
+ result = indirection.__send__(method, key, options)
47
+ end
43
48
  rescue => detail
44
49
  message = "Could not call '#{method}' on '#{indirection_name}': #{detail}"
45
50
  Puppet.log_exception(detail, message)
@@ -59,11 +59,11 @@ module Puppet::Network::HTTP::Error
59
59
 
60
60
  def initialize(original_error, issue_kind = Issues::RUNTIME_ERROR)
61
61
  super("Server Error: " + original_error.message, CODE, issue_kind)
62
- @backtrace = ["Warning: The 'stacktrace' property is deprecated and will be removed in a future version of Puppet. For security reasons, stacktraces are not returned with Puppet HTTP Error responses."]
62
+ @backtrace = original_error.backtrace
63
63
  end
64
64
 
65
65
  def to_json
66
- JSON({:message => message, :issue_kind => @issue_kind, :stacktrace => self.backtrace})
66
+ JSON({:message => message, :issue_kind => @issue_kind})
67
67
  end
68
68
  end
69
69
  end
@@ -68,7 +68,7 @@ module Puppet::Network::HTTP::Handler
68
68
  new_response.respond_with(e.status, "application/json", e.to_json)
69
69
  rescue StandardError => e
70
70
  http_e = Puppet::Network::HTTP::Error::HTTPServerError.new(e)
71
- log_msg = [http_e.message, *e.backtrace].join("\n")
71
+ log_msg = [http_e.message, *http_e.backtrace].join("\n")
72
72
  Puppet.err(log_msg)
73
73
  new_response.respond_with(http_e.status, "application/json", http_e.to_json)
74
74
  ensure
@@ -168,7 +168,7 @@ module Puppet::Network::HTTP::Handler
168
168
 
169
169
  def configure_profiler(request_headers, request_params)
170
170
  if (request_headers.has_key?(Puppet::Network::HTTP::HEADER_ENABLE_PROFILING.downcase) or Puppet[:profile])
171
- Puppet::Util::Profiler.add_profiler(Puppet::Util::Profiler::Aggregate.new(Puppet.method(:debug), request_params.object_id))
171
+ Puppet::Util::Profiler.add_profiler(Puppet::Util::Profiler::Aggregate.new(Puppet.method(:info), request_params.object_id))
172
172
  end
173
173
  end
174
174
 
@@ -218,6 +218,17 @@ class Puppet::Node::Environment
218
218
  errors
219
219
  end
220
220
 
221
+ # Checks if this environment permits use of rich data types in the catalog
222
+ # @return [Boolean] `true` if rich data is permitted.
223
+ # @api private
224
+ def rich_data?
225
+ if @rich_data.nil?
226
+ environment_conf = Puppet.lookup(:environments).get_conf(name)
227
+ @rich_data = (environment_conf.nil? ? Puppet[:rich_data] : environment_conf.rich_data)
228
+ end
229
+ @rich_data
230
+ end
231
+
221
232
  # Return an environment-specific Puppet setting.
222
233
  #
223
234
  # @api public
@@ -29,6 +29,11 @@ class Puppet::Parser::AST
29
29
  # is called so many times during parsing.
30
30
  begin
31
31
  return self.evaluate(scope)
32
+ rescue Puppet::Pops::Evaluator::PuppetStopIteration => detail
33
+ raise detail
34
+ # # Only deals with StopIteration from the break() function as a general
35
+ # # StopIteration is a general runtime problem
36
+ # raise Puppet::ParseError.new(detail.message, detail.file, detail.line, detail)
32
37
  rescue Puppet::Error => detail
33
38
  raise adderrorcontext(detail)
34
39
  rescue => detail
@@ -61,6 +61,19 @@ class Puppet::Parser::AST::PopsBridge
61
61
  end
62
62
  end
63
63
 
64
+ class ExpressionSupportingReturn < Expression
65
+ def initialize args
66
+ super
67
+ end
68
+
69
+ def evaluate(scope)
70
+ return catch(:return) do
71
+ return catch(:next) do
72
+ return super(scope)
73
+ end
74
+ end
75
+ end
76
+ end
64
77
  # Bridges the top level "Program" produced by the pops parser.
65
78
  # Its main purpose is to give one point where all definitions are instantiated (actually defined since the
66
79
  # Puppet 3x terminology is somewhat misleading - the definitions are instantiated, but instances of the created types
@@ -174,26 +187,26 @@ class Puppet::Parser::AST::PopsBridge
174
187
  end
175
188
 
176
189
  # Produces a hash with data for Definition and HostClass
177
- def args_from_definition(o, modname)
190
+ def args_from_definition(o, modname, expr_class = Expression)
178
191
  args = {
179
192
  :arguments => o.parameters.collect {|p| instantiate_Parameter(p) },
180
193
  :argument_types => create_type_map(o),
181
194
  :module_name => modname
182
195
  }
183
196
  unless is_nop?(o.body)
184
- args[:code] = Expression.new(:value => o.body)
197
+ args[:code] = expr_class.new(:value => o.body)
185
198
  end
186
199
  @ast_transformer.merge_location(args, o)
187
200
  end
188
201
 
189
202
  def instantiate_HostClassDefinition(o, modname)
190
- args = args_from_definition(o, modname)
203
+ args = args_from_definition(o, modname, ExpressionSupportingReturn)
191
204
  args[:parent] = absolute_reference(o.parent_class)
192
205
  Puppet::Resource::Type.new(:hostclass, o.name, @context.merge(args))
193
206
  end
194
207
 
195
208
  def instantiate_ResourceTypeDefinition(o, modname)
196
- instance = Puppet::Resource::Type.new(:definition, o.name, @context.merge(args_from_definition(o, modname)))
209
+ instance = Puppet::Resource::Type.new(:definition, o.name, @context.merge(args_from_definition(o, modname, ExpressionSupportingReturn)))
197
210
  Puppet::Pops::Loaders.register_runtime3_type(instance.name, Puppet::Pops::Adapters::SourcePosAdapter.adapt(o).to_uri)
198
211
  instance
199
212
  end
@@ -585,6 +585,11 @@ class Puppet::Parser::Compiler
585
585
  urs = unevaluated_resources.each do |resource|
586
586
  begin
587
587
  resource.evaluate
588
+ rescue Puppet::Pops::Evaluator::PuppetStopIteration => detail
589
+ # needs to be handled specifically as the error has the file/line/position where this
590
+ # occurred rather than the resource
591
+ fail(Puppet::Pops::Issues::RUNTIME_ERROR, detail, {:detail => detail.message}, detail)
592
+
588
593
  rescue Puppet::Error => e
589
594
  # PuppetError has the ability to wrap an exception, if so, use the wrapped exception's
590
595
  # call stack instead
@@ -860,11 +865,34 @@ class Puppet::Parser::Compiler
860
865
  scope = @topscope.class_scope(settings_type)
861
866
 
862
867
  env = environment
868
+ settings_hash = {}
863
869
  Puppet.settings.each do |name, setting|
864
870
  next if name == :name
865
- scope[name.to_s] = env[name]
871
+ s_name = name.to_s
872
+ # Construct a hash (in anticipation it will be set in top scope under a name like $settings)
873
+ settings_hash[s_name] = transform_setting(env[name])
874
+ scope[s_name] = settings_hash[s_name]
875
+ end
876
+ end
877
+
878
+ def transform_setting(val)
879
+ case val
880
+ when Integer, Float, String, TrueClass, FalseClass, NilClass
881
+ val
882
+ when Symbol
883
+ val == :undef ? nil : val.to_s
884
+ when Array
885
+ val.map {|entry| transform_setting(entry) }
886
+ when Hash
887
+ result = {}
888
+ val.each {|k,v| result[transform_setting(k)] = transform_setting(v) }
889
+ result
890
+ else
891
+ # not ideal, but required as there are settings values that are special
892
+ val.to_s
866
893
  end
867
894
  end
895
+ private :transform_setting
868
896
 
869
897
  # Return an array of all of the unevaluated resources. These will be definitions,
870
898
  # which need to get evaluated into native resources.
@@ -269,4 +269,10 @@ module Puppet::Parser::Functions
269
269
  environment_module(environment).get_function_info(name.intern) || environment_module(Puppet.lookup(:root_environment)).get_function_info(name.intern)
270
270
  end
271
271
  end
272
+
273
+ class Error
274
+ def self.is4x(name)
275
+ raise Puppet::ParseError, "#{name}() can only be called using the 4.x function API. See Scope#call_function"
276
+ end
277
+ end
272
278
  end
@@ -56,5 +56,5 @@ For more information about data types, see the
56
56
  - Since 4.0.0
57
57
  DOC
58
58
  ) do |args|
59
- function_fail(["assert_type() is only available when parser/evaluator future is in effect"])
59
+ Error.is4x('assert_type')
60
60
  end
@@ -0,0 +1,24 @@
1
+ Puppet::Parser::Functions::newfunction(
2
+ :binary_file,
3
+ :type => :rvalue,
4
+ :arity => 1,
5
+ :doc => <<-DOC
6
+ Loads a binary file from a module or file system and returns its contents as a Binary.
7
+
8
+ The argument to this function should be a `<MODULE NAME>/<FILE>`
9
+ reference, which will load `<FILE>` from a module's `files`
10
+ directory. (For example, the reference `mysql/mysqltuner.pl` will load the
11
+ file `<MODULES DIRECTORY>/mysql/files/mysqltuner.pl`.)
12
+
13
+ This function also accepts an absolute file path that allows reading
14
+ binary file content from anywhere on disk.
15
+
16
+ An error is raised if the given file does not exists.
17
+
18
+ To search for the existence of files, use the `find_file()` function.
19
+
20
+ - since 4.8.0
21
+ DOC
22
+ ) do |args|
23
+ Error.is4x('binary_file')
24
+ end
@@ -0,0 +1,39 @@
1
+ Puppet::Parser::Functions::newfunction(
2
+ :break,
3
+ :arity => 0,
4
+ :doc => <<-DOC
5
+ Breaks the innermost iteration as if it encountered an end of input.
6
+ This function does not return to the caller.
7
+
8
+ The signal produced to stop the iteration bubbles up through
9
+ the call stack until either terminating the innermost iteration or
10
+ raising an error if the end of the call stack is reached.
11
+
12
+ The break() function does not accept an argument.
13
+
14
+ **Example:** Using `break`
15
+
16
+ ```puppet
17
+ $data = [1,2,3]
18
+ notice $data.map |$x| { if $x == 3 { break() } $x*10 }
19
+ ```
20
+
21
+ Would notice the value `[10, 20]`
22
+
23
+ **Example:** Using a nested `break`
24
+
25
+ ```puppet
26
+ function break_if_even($x) {
27
+ if $x % 2 == 0 { break() }
28
+ }
29
+ $data = [1,2,3]
30
+ notice $data.map |$x| { break_if_even($x); $x*10 }
31
+ ```
32
+ Would notice the value `[10]`
33
+
34
+ * Also see functions `next` and `return`
35
+ * Since 4.8.0
36
+ DOC
37
+ ) do |args|
38
+ Error.is4x('break')
39
+ end