puppet 4.7.1-x86-mingw32 → 4.8.0-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.

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
@@ -6,7 +6,7 @@ module HeredocSupport
6
6
  # Pattern for heredoc `@(endtag[:syntax][/escapes])
7
7
  # Produces groups for endtag (group 1), syntax (group 2), and escapes (group 3)
8
8
  #
9
- PATTERN_HEREDOC = %r{@\(([^:/\r\n\)]+)(?::[:blank:]*([a-z][a-zA-Z0-9_+]+)[:blank:]*)?(?:/((?:\w|[$])*)[:blank:]*)?\)}
9
+ PATTERN_HEREDOC = %r{@\(([^:/\r\n\)]+)(?::[[:blank:]]*([a-z][a-zA-Z0-9_+]+)[[:blank:]]*)?(?:/((?:\w|[$])*)[[:blank:]]*)?\)}
10
10
 
11
11
 
12
12
  def heredoc
@@ -19,7 +19,6 @@ module HeredocSupport
19
19
  # find end of the heredoc spec
20
20
  str = scn.scan_until(/\)/) || lex_error(Issues::HEREDOC_UNCLOSED_PARENTHESIS, :followed_by => followed_by)
21
21
  pos_after_heredoc = scn.pos
22
-
23
22
  # Note: allows '+' as separator in syntax, but this needs validation as empty segments are not allowed
24
23
  md = str.match(PATTERN_HEREDOC)
25
24
  lex_error(Issues::HEREDOC_INVALID_SYNTAX) unless md
@@ -34,6 +34,7 @@ module Pcore
34
34
  add_type(Types::PTypeSetType.new(ast_ts_i12n), loader)
35
35
 
36
36
  Resource.register_ptypes(loader, ir)
37
+ Lookup::Context.register_ptype(loader, ir);
37
38
  end
38
39
 
39
40
  # Create and register a new `Object` type in the Puppet Type System and map it to an implementation class
@@ -32,12 +32,12 @@ module PuppetStack
32
32
  end
33
33
 
34
34
  def self.stacktrace
35
- result = caller().reduce([]) do |memo, loc|
36
- if loc =~ /^(.*\.pp)?:([0-9]+):in `stack'/
35
+ caller().reduce([]) do |memo, loc|
36
+ if loc =~ /^(.*\.pp)?:([0-9]+):in (`stack'|`block in call_function')/
37
37
  memo << [$1.nil? ? 'unknown' : $1, $2.to_i]
38
38
  end
39
39
  memo
40
- end.reverse
40
+ end
41
41
  end
42
42
  end
43
43
  end
@@ -10,7 +10,7 @@
10
10
  # This implementation does not support
11
11
  # * setting 'strict' - strictness (must refer to an existing type) is always true
12
12
  # * does not support the indirector
13
- #
13
+ #
14
14
  #
15
15
  module Puppet::Pops
16
16
  module Resource
@@ -43,6 +43,10 @@ class Param
43
43
  @name_var = name_var
44
44
  end
45
45
 
46
+ def to_s
47
+ name
48
+ end
49
+
46
50
  def self._ptype
47
51
  @ptype
48
52
  end
@@ -47,6 +47,10 @@ class ResourceTypeImpl
47
47
  Types::KEY_TYPE => Types::PBooleanType::DEFAULT,
48
48
  Types::KEY_VALUE => true
49
49
  },
50
+ 'capability' => {
51
+ Types::KEY_TYPE => Types::PBooleanType::DEFAULT,
52
+ Types::KEY_VALUE => false
53
+ },
50
54
  },
51
55
  EMPTY_HASH,
52
56
  [Types::KEY_NAME]
@@ -96,14 +100,14 @@ class ResourceTypeImpl
96
100
  attr_reader :parameters
97
101
  attr_reader :title_patterns_hash
98
102
  attr_reader :title_patterns
99
- attr_reader :isomorphic
100
103
 
101
- def initialize(name, properties = EMPTY_ARRAY, parameters = EMPTY_ARRAY, title_patterns_hash = nil, isomorphic = true)
104
+ def initialize(name, properties = EMPTY_ARRAY, parameters = EMPTY_ARRAY, title_patterns_hash = nil, isomorphic = true, capability = false)
102
105
  @name = name
103
106
  @properties = properties
104
107
  @parameters = parameters
105
108
  @title_patterns_hash = title_patterns_hash
106
109
  @isomorphic = isomorphic
110
+ @capability = capability
107
111
 
108
112
  # Compute attributes hash
109
113
  # Compute key_names (possibly compound key if there are multiple name vars).
@@ -172,7 +176,7 @@ class ResourceTypeImpl
172
176
  end
173
177
 
174
178
  def is_capability?
175
- false
179
+ @capability
176
180
  end
177
181
 
178
182
  # Answers if the parameter name is a parameter/attribute of this type
@@ -259,7 +263,7 @@ class ResourceTypeImpl
259
263
 
260
264
  # Answers :property, :param or :meta depending on the type of the attribute
261
265
  # According to original version, this is called millions of times
262
- # and a cache is required.
266
+ # and a cache is required.
263
267
  # @param name [Symbol]
264
268
  def attrtype(name)
265
269
  raise NotImplementedError, "attrtype() - returns the kind (:meta, :param, or :property) of the parameter"
@@ -15,6 +15,7 @@ type Puppet::Resource::ResourceType3 = Object[{
15
15
  parameters => { type => Array[Puppet::Resource::Param], value = []},
16
16
  title_patterns => { type => Optional[Hash[Regexp, Array[String[1]]], value => nil },
17
17
  isomorphic => { type => Boolean, value => true },
18
+ capability => { type => Boolean, value => false },
18
19
  },
19
20
  equality => [name],
20
21
  }]
@@ -16,6 +16,7 @@ module Serialization
16
16
  # - Regexp
17
17
  # - Version
18
18
  # - VersionRange
19
+ # - Timespan
19
20
  # - Timestamp
20
21
  # - Default
21
22
  #
@@ -132,7 +133,15 @@ class AbstractReader
132
133
  read_payload(data) do |ep|
133
134
  sec = ep.read
134
135
  nsec = ep.read
135
- TimeFactory.from_sec_nsec(sec, nsec)
136
+ Time::Timestamp.new(sec * 1000000000 + nsec)
137
+ end
138
+ end
139
+
140
+ register_type(Extension::TIMESPAN) do |data|
141
+ read_payload(data) do |ep|
142
+ sec = ep.read
143
+ nsec = ep.read
144
+ Time::Timespan.new(sec * 1000000000 + nsec)
136
145
  end
137
146
  end
138
147
 
@@ -143,7 +152,15 @@ class AbstractReader
143
152
  register_type(Extension::VERSION_RANGE) do |data|
144
153
  read_payload(data) { |ep| Semantic::VersionRange.parse(ep.read) }
145
154
  end
155
+
156
+ register_type(Extension::SENSITIVE) do |data|
157
+ read_payload(data) { |ep| Types::PSensitiveType::Sensitive.new(ep.read) }
158
+ end
159
+
160
+ register_type(Extension::BINARY) do |data|
161
+ read_payload(data) { |ep| Types::PBinaryType::Binary.from_base64_strict(ep.read) }
162
+ end
146
163
  end
147
164
  end
148
165
  end
149
- end
166
+ end
@@ -19,6 +19,7 @@ MIN_INTEGER = -0x8000000000000000
19
19
  # - Regexp
20
20
  # - Version
21
21
  # - VersionRange
22
+ # - Timespan
22
23
  # - Timestamp
23
24
  # - Default
24
25
  #
@@ -52,7 +53,7 @@ class AbstractWriter
52
53
  when Integer
53
54
  # not tabulated, but integers larger than 64-bit cannot be allowed.
54
55
  raise SerializationError, 'Integer out of bounds' if value > MAX_INTEGER || value < MIN_INTEGER
55
- when Numeric, Symbol, Extension::NotTabulated, true, false, nil
56
+ when Numeric, Symbol, Types::PSensitiveType::Sensitive, Extension::NotTabulated, true, false, nil
56
57
  # not tabulated
57
58
  else
58
59
  if @tabulate
@@ -161,8 +162,12 @@ class AbstractWriter
161
162
  build_payload { |ep| ep.write(o.to_s) }
162
163
  end
163
164
 
164
- register_type(Extension::TIME, Time) do |o|
165
- build_payload { |ep| ep.write(o.tv_sec); ep.write(o.tv_nsec) }
165
+ register_type(Extension::TIME, Time::Timestamp) do |o|
166
+ build_payload { |ep| nsecs = o.nsecs; ep.write(nsecs / 1000000000); ep.write(nsecs % 1000000000) }
167
+ end
168
+
169
+ register_type(Extension::TIMESPAN, Time::Timespan) do |o|
170
+ build_payload { |ep| nsecs = o.nsecs; ep.write(nsecs / 1000000000); ep.write(nsecs % 1000000000) }
166
171
  end
167
172
 
168
173
  register_type(Extension::VERSION, Semantic::Version) do |o|
@@ -172,6 +177,14 @@ class AbstractWriter
172
177
  register_type(Extension::VERSION_RANGE, Semantic::VersionRange) do |o|
173
178
  build_payload { |ep| ep.write(o.to_s) }
174
179
  end
180
+
181
+ register_type(Extension::SENSITIVE, Types::PSensitiveType::Sensitive) do |o|
182
+ build_payload { |ep| ep.write(o.unwrap) }
183
+ end
184
+
185
+ register_type(Extension::BINARY, Types::PBinaryType::Binary) do |o|
186
+ build_payload { |ep| ep.write(o.to_s) }
187
+ end
175
188
  end
176
189
  end
177
190
  end
@@ -6,6 +6,10 @@ module Serialization
6
6
  # resolving tabulations and assembling complex objects. The type of the complex objects are resolved using a loader.
7
7
  # @api public
8
8
  class Deserializer
9
+ # Provides access to the reader.
10
+ # @api private
11
+ attr_reader :reader
12
+
9
13
  # @param [AbstractReader] reader the reader used when reading primitive objects from a stream
10
14
  # @param [Loader::Loader] loader the loader used when resolving names of types
11
15
  # @api public
@@ -57,4 +61,4 @@ module Serialization
57
61
  end
58
62
  end
59
63
  end
60
- end
64
+ end
@@ -26,6 +26,8 @@ module Extension
26
26
  TIMESPAN = 0x34
27
27
  VERSION = 0x35
28
28
  VERSION_RANGE = 0x36
29
+ SENSITIVE = 0x37
30
+ BINARY = 0x38
29
31
 
30
32
  # Marker module indicating whether or not an instance is tabulated or not
31
33
  module NotTabulated; end
@@ -15,6 +15,13 @@ module JSON
15
15
  super(Packer.new(io, options), options)
16
16
  end
17
17
 
18
+ # Clear the underlying io stream but does not clear tabulation cache
19
+ # Specifically designed to enable tabulation to span more than one
20
+ # separately deserialized object.
21
+ def clear_io
22
+ @packer.clear_io
23
+ end
24
+
18
25
  def extension_packer
19
26
  @packer
20
27
  end
@@ -27,6 +34,10 @@ module JSON
27
34
  yield(@packer)
28
35
  end
29
36
 
37
+ def to_a
38
+ @packer.to_a
39
+ end
40
+
30
41
  def to_json
31
42
  @packer.to_json
32
43
  end
@@ -39,6 +50,10 @@ module JSON
39
50
  super(Unpacker.new(io))
40
51
  end
41
52
 
53
+ def re_initialize(io)
54
+ @unpacker.re_initialize(io)
55
+ end
56
+
42
57
  def read_payload(data)
43
58
  yield(@unpacker)
44
59
  end
@@ -49,6 +64,7 @@ module JSON
49
64
  class Packer
50
65
  def initialize(io, options = {})
51
66
  @io = io
67
+ @io << '['
52
68
  @type_registry = {}
53
69
  @nested = []
54
70
  @verbose = options[:verbose]
@@ -60,27 +76,33 @@ module JSON
60
76
  @type_registry[klass] = [type, klass, block]
61
77
  end
62
78
 
79
+ def clear_io
80
+ # Truncate everything except leading '['
81
+ if @io.is_a?(String)
82
+ @io.slice!(1..-1)
83
+ else
84
+ @io.truncate(1)
85
+ end
86
+ end
87
+
63
88
  def empty?
64
- @io.pos == 0
89
+ @io.is_a?(String) ? io.length == 1 : @io.pos == 1
65
90
  end
66
91
 
67
92
  def flush
68
- pos = @io.pos
69
- case pos
70
- when 1
71
- # Just start marker present.
72
- when 0
73
- @io << '['
93
+ # Drop last comma unless just start marker present
94
+ if @io.is_a?(String)
95
+ @io.chop! unless @io.length == 1
96
+ @io << ']'
74
97
  else
75
- # Drop last comma
76
- @io.pos = pos - 1
98
+ pos = @io.pos
99
+ @io.pos = pos - 1 unless pos == 1
100
+ @io << ']'
101
+ @io.flush
77
102
  end
78
- @io << ']'
79
- @io.flush
80
103
  end
81
104
 
82
105
  def write(obj)
83
- assert_started
84
106
  case obj
85
107
  when Array
86
108
  write_array_header(obj.size)
@@ -97,7 +119,6 @@ module JSON
97
119
  alias pack write
98
120
 
99
121
  def write_array_header(n)
100
- assert_started
101
122
  if n < 1
102
123
  @io << '[]'
103
124
  else
@@ -107,7 +128,6 @@ module JSON
107
128
  end
108
129
 
109
130
  def write_map_header(n)
110
- assert_started
111
131
  if n < 1
112
132
  @io << '{}'
113
133
  else
@@ -117,7 +137,6 @@ module JSON
117
137
  end
118
138
 
119
139
  def write_nil
120
- assert_started
121
140
  @io << 'null'
122
141
  write_delim
123
142
  end
@@ -126,13 +145,16 @@ module JSON
126
145
  to_json
127
146
  end
128
147
 
148
+ def to_a
149
+ ::JSON.parse(io_string)
150
+ end
151
+
129
152
  def to_json
130
- string = @io.string
131
153
  if @indent > 0
132
- options = { :indent => ' ' * @indent }
133
- string = ::JSON.pretty_unparse(::JSON.parse(string), options)
154
+ ::JSON.pretty_unparse(to_a, { :indent => ' ' * @indent })
155
+ else
156
+ io_string
134
157
  end
135
- string
136
158
  end
137
159
 
138
160
  # Write a payload object. Not subject to extensions
@@ -140,10 +162,15 @@ module JSON
140
162
  @io << obj.to_json << ','
141
163
  end
142
164
 
143
- def assert_started
144
- @io << '[' if @io.pos == 0
165
+ def io_string
166
+ if @io.is_a?(String)
167
+ @io
168
+ else
169
+ @io.pos = 0
170
+ @io.read
171
+ end
145
172
  end
146
- private :assert_started
173
+ private :io_string
147
174
 
148
175
  def write_delim
149
176
  nesting = @nested.last
@@ -184,11 +211,17 @@ module JSON
184
211
 
185
212
  def write_extension(ext, obj)
186
213
  @io << '[' << extension_indicator(ext).to_json << ','
214
+ @nested << nil
187
215
  write_extension_payload(ext, obj)
216
+ @nested.pop
188
217
  if obj.is_a?(Extension::SequenceStart) && obj.sequence_size > 0
189
218
  @nested << [false, obj.sequence_size]
190
219
  else
191
- @io.pos -= 1
220
+ if @io.is_a?(String)
221
+ @io.chop!
222
+ else
223
+ @io.pos -= 1
224
+ end
192
225
  @io << ']'
193
226
  write_delim
194
227
  end
@@ -208,13 +241,17 @@ module JSON
208
241
 
209
242
  class Unpacker
210
243
  def initialize(io)
211
- parsed = ::JSON.parse(io.read(nil))
212
- raise SerializationError, "JSON stream is not an array" unless parsed.is_a?(Array)
213
- @etor_stack = [parsed.each]
244
+ re_initialize(io)
214
245
  @type_registry = {}
215
246
  @nested = []
216
247
  end
217
248
 
249
+ def re_initialize(io)
250
+ parsed = parse_io(io)
251
+ raise SerializationError, "JSON stream is not an array. It is a #{io.class.name}" unless parsed.is_a?(Array)
252
+ @etor_stack = [parsed.each]
253
+ end
254
+
218
255
  def read
219
256
  obj = nil
220
257
  loop do
@@ -241,6 +278,19 @@ module JSON
241
278
  def register_type(extension_number, &block)
242
279
  @type_registry[extension_number] = block
243
280
  end
281
+
282
+ private
283
+
284
+ def parse_io(io)
285
+ case io
286
+ when IO, StringIO
287
+ ::JSON.parse(io.read)
288
+ when String
289
+ ::JSON.parse(io)
290
+ else
291
+ io
292
+ end
293
+ end
244
294
  end
245
295
  end
246
296
  end
@@ -6,6 +6,10 @@ module Serialization
6
6
  # tabulating and disassembling complex objects.
7
7
  # @api public
8
8
  class Serializer
9
+ # Provides access to the writer.
10
+ # @api private
11
+ attr_reader :writer
12
+
9
13
  # @param [AbstractWriter] writer the writer that is used for writing primitive values
10
14
  # @api public
11
15
  def initialize(writer)
@@ -67,7 +71,7 @@ module Serialization
67
71
  def write_tabulated_first_time(value)
68
72
  @written[value.object_id] = @written.size
69
73
  case value
70
- when Symbol, Regexp, Semantic::Version, Semantic::VersionRange
74
+ when Symbol, Regexp, Semantic::Version, Semantic::VersionRange, Time::Timestamp, Time::Timespan, Types::PSensitiveType::Sensitive, Types::PBinaryType::Binary
71
75
  @writer.write(value)
72
76
  when Array
73
77
  start_array(value.size)