puppet 4.0.0-x86-mingw32 → 4.1.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 (219) hide show
  1. checksums.yaml +4 -4
  2. data/ext/build_defaults.yaml +8 -35
  3. data/ext/debian/puppet.default +0 -5
  4. data/ext/debian/puppet.init +1 -15
  5. data/lib/hiera/puppet_function.rb +15 -4
  6. data/lib/puppet/application/agent.rb +5 -0
  7. data/lib/puppet/application/apply.rb +23 -2
  8. data/lib/puppet/application/device.rb +8 -3
  9. data/lib/puppet/application/master.rb +16 -5
  10. data/lib/puppet/configurer.rb +7 -5
  11. data/lib/puppet/defaults.rb +18 -0
  12. data/lib/puppet/environments.rb +1 -1
  13. data/lib/puppet/error.rb +27 -1
  14. data/lib/puppet/file_serving/metadata.rb +13 -8
  15. data/lib/puppet/file_serving/terminus_helper.rb +7 -8
  16. data/lib/puppet/file_system.rb +13 -0
  17. data/lib/puppet/file_system/file_impl.rb +4 -0
  18. data/lib/puppet/file_system/memory_impl.rb +4 -0
  19. data/lib/puppet/file_system/windows.rb +8 -0
  20. data/lib/puppet/functions.rb +33 -3
  21. data/lib/puppet/functions/defined.rb +130 -0
  22. data/lib/puppet/functions/regsubst.rb +1 -1
  23. data/lib/puppet/functions/split.rb +1 -1
  24. data/lib/puppet/indirector/catalog/compiler.rb +1 -1
  25. data/lib/puppet/indirector/facts/facter.rb +11 -0
  26. data/lib/puppet/loaders.rb +1 -0
  27. data/lib/puppet/node.rb +17 -1
  28. data/lib/puppet/node/environment.rb +4 -0
  29. data/lib/puppet/parser/ast/pops_bridge.rb +4 -0
  30. data/lib/puppet/parser/compiler.rb +9 -0
  31. data/lib/puppet/parser/functions/defined.rb +25 -1
  32. data/lib/puppet/parser/functions/file.rb +3 -1
  33. data/lib/puppet/parser/scope.rb +11 -2
  34. data/lib/puppet/parser/templatewrapper.rb +2 -1
  35. data/lib/puppet/pops.rb +4 -0
  36. data/lib/puppet/pops/evaluator/access_operator.rb +25 -5
  37. data/lib/puppet/pops/evaluator/closure.rb +28 -2
  38. data/lib/puppet/pops/evaluator/collector_transformer.rb +1 -11
  39. data/lib/puppet/pops/evaluator/collectors/catalog_collector.rb +4 -0
  40. data/lib/puppet/pops/evaluator/collectors/exported_collector.rb +4 -0
  41. data/lib/puppet/pops/evaluator/compare_operator.rb +43 -0
  42. data/lib/puppet/pops/evaluator/epp_evaluator.rb +7 -2
  43. data/lib/puppet/pops/evaluator/evaluator_impl.rb +48 -14
  44. data/lib/puppet/pops/evaluator/runtime3_support.rb +10 -5
  45. data/lib/puppet/pops/functions/dispatch.rb +6 -1
  46. data/lib/puppet/pops/functions/dispatcher.rb +7 -1
  47. data/lib/puppet/pops/issue_reporter.rb +42 -16
  48. data/lib/puppet/pops/issues.rb +116 -2
  49. data/lib/puppet/pops/loader/loader.rb +11 -0
  50. data/lib/puppet/pops/loader/loader_paths.rb +67 -6
  51. data/lib/puppet/pops/loader/module_loaders.rb +19 -8
  52. data/lib/puppet/pops/loader/puppet_function_instantiator.rb +78 -0
  53. data/lib/puppet/pops/loaders.rb +6 -4
  54. data/lib/puppet/pops/migration/migration_checker.rb +54 -0
  55. data/lib/puppet/pops/model/factory.rb +5 -1
  56. data/lib/puppet/pops/model/model_label_provider.rb +2 -0
  57. data/lib/puppet/pops/model/model_meta.rb +5 -1
  58. data/lib/puppet/pops/parser/egrammar.ra +9 -10
  59. data/lib/puppet/pops/parser/eparser.rb +1061 -1047
  60. data/lib/puppet/pops/parser/epp_support.rb +18 -9
  61. data/lib/puppet/pops/parser/evaluating_parser.rb +7 -1
  62. data/lib/puppet/pops/parser/heredoc_support.rb +12 -11
  63. data/lib/puppet/pops/parser/interpolation_support.rb +7 -1
  64. data/lib/puppet/pops/parser/lexer2.rb +29 -12
  65. data/lib/puppet/pops/parser/lexer_support.rb +52 -23
  66. data/lib/puppet/pops/parser/parser_support.rb +11 -14
  67. data/lib/puppet/pops/parser/slurp_support.rb +22 -6
  68. data/lib/puppet/pops/types/type_calculator.rb +156 -55
  69. data/lib/puppet/pops/types/type_factory.rb +66 -13
  70. data/lib/puppet/pops/types/type_parser.rb +22 -13
  71. data/lib/puppet/pops/types/types.rb +23 -4
  72. data/lib/puppet/pops/types/types_meta.rb +13 -2
  73. data/lib/puppet/pops/validation.rb +25 -2
  74. data/lib/puppet/pops/validation/checker4_0.rb +63 -31
  75. data/lib/puppet/provider/group/windows_adsi.rb +8 -4
  76. data/lib/puppet/provider/mount/parsed.rb +145 -2
  77. data/lib/puppet/provider/package/apt.rb +1 -1
  78. data/lib/puppet/provider/package/pip.rb +11 -2
  79. data/lib/puppet/provider/package/pkgng.rb +134 -0
  80. data/lib/puppet/provider/package/portage.rb +1 -1
  81. data/lib/puppet/provider/package/ports.rb +0 -3
  82. data/lib/puppet/provider/package/windows/exe_package.rb +0 -1
  83. data/lib/puppet/provider/package/windows/msi_package.rb +0 -1
  84. data/lib/puppet/provider/package/zypper.rb +50 -15
  85. data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +32 -7
  86. data/lib/puppet/provider/service/debian.rb +1 -1
  87. data/lib/puppet/provider/service/init.rb +7 -0
  88. data/lib/puppet/provider/user/openbsd.rb +1 -0
  89. data/lib/puppet/provider/user/windows_adsi.rb +45 -2
  90. data/lib/puppet/reference/indirection.rb +1 -1
  91. data/lib/puppet/resource.rb +1 -1
  92. data/lib/puppet/resource/catalog.rb +0 -4
  93. data/lib/puppet/settings.rb +19 -0
  94. data/lib/puppet/type/file.rb +1 -0
  95. data/lib/puppet/type/file/ensure.rb +1 -1
  96. data/lib/puppet/type/mount.rb +9 -1
  97. data/lib/puppet/type/scheduled_task.rb +13 -0
  98. data/lib/puppet/type/tidy.rb +3 -1
  99. data/lib/puppet/type/user.rb +32 -0
  100. data/lib/puppet/type/yumrepo.rb +5 -5
  101. data/lib/puppet/util/log.rb +50 -8
  102. data/lib/puppet/util/log/destinations.rb +23 -2
  103. data/lib/puppet/util/logging.rb +37 -1
  104. data/lib/puppet/util/run_mode.rb +1 -14
  105. data/lib/puppet/util/windows/adsi.rb +130 -58
  106. data/lib/puppet/version.rb +1 -1
  107. data/man/man5/puppet.conf.5 +48 -6
  108. data/man/man8/extlookup2hiera.8 +1 -1
  109. data/man/man8/puppet-agent.8 +4 -1
  110. data/man/man8/puppet-apply.8 +4 -1
  111. data/man/man8/puppet-ca.8 +1 -1
  112. data/man/man8/puppet-catalog.8 +1 -1
  113. data/man/man8/puppet-cert.8 +1 -1
  114. data/man/man8/puppet-certificate.8 +1 -1
  115. data/man/man8/puppet-certificate_request.8 +1 -1
  116. data/man/man8/puppet-certificate_revocation_list.8 +1 -1
  117. data/man/man8/puppet-config.8 +1 -1
  118. data/man/man8/puppet-describe.8 +1 -1
  119. data/man/man8/puppet-device.8 +6 -3
  120. data/man/man8/puppet-doc.8 +1 -1
  121. data/man/man8/puppet-epp.8 +1 -1
  122. data/man/man8/puppet-facts.8 +1 -1
  123. data/man/man8/puppet-file.8 +1 -1
  124. data/man/man8/puppet-filebucket.8 +1 -1
  125. data/man/man8/puppet-help.8 +1 -1
  126. data/man/man8/puppet-inspect.8 +1 -1
  127. data/man/man8/puppet-key.8 +1 -1
  128. data/man/man8/puppet-man.8 +1 -1
  129. data/man/man8/puppet-master.8 +4 -1
  130. data/man/man8/puppet-module.8 +1 -1
  131. data/man/man8/puppet-node.8 +1 -1
  132. data/man/man8/puppet-parser.8 +1 -1
  133. data/man/man8/puppet-plugin.8 +1 -1
  134. data/man/man8/puppet-report.8 +1 -1
  135. data/man/man8/puppet-resource.8 +1 -1
  136. data/man/man8/puppet-resource_type.8 +1 -1
  137. data/man/man8/puppet-status.8 +1 -1
  138. data/man/man8/puppet.8 +1 -1
  139. data/spec/fixtures/unit/data_providers/environments/production/lib/puppet/functions/environment/data.rb +3 -1
  140. data/spec/fixtures/unit/data_providers/environments/production/modules/xyz/functions/data.pp +6 -0
  141. data/spec/fixtures/unit/data_providers/environments/production/modules/xyz/lib/puppet/bindings/xyz/default.rb +9 -0
  142. data/spec/fixtures/unit/data_providers/environments/production/modules/xyz/manifests/init.pp +9 -0
  143. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/functions/puppetcalled.pp +3 -0
  144. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/functions/puppetcaller.pp +3 -0
  145. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/functions/puppetcaller4.pp +3 -0
  146. data/spec/fixtures/unit/pops/loaders/loaders/mix_4x_and_3x_functions/user/lib/puppet/functions/user/callingpuppet.rb +5 -0
  147. data/spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/functions/hello.pp +3 -0
  148. data/spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/manifests/init.pp +3 -0
  149. data/spec/fixtures/unit/pops/loaders/loaders/module_no_lib/modules/modulea/metadata.json +10 -0
  150. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/functions/hello.pp +3 -0
  151. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/functions/subspace/hello.pp +3 -0
  152. data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/metadata.json +1 -10
  153. data/spec/fixtures/unit/provider/mount/parsed/aix.filesystems +93 -85
  154. data/spec/fixtures/unit/provider/mount/parsed/aix.mount +11 -7
  155. data/spec/fixtures/unit/provider/package/pkgng/pkg.info +8 -0
  156. data/spec/fixtures/unit/provider/package/pkgng/pkg.query +1 -0
  157. data/spec/fixtures/unit/provider/package/pkgng/pkg.query_absent +1 -0
  158. data/spec/fixtures/unit/provider/package/pkgng/pkg.version +3 -0
  159. data/spec/fixtures/unit/provider/package/zypper/zypper-list-updates-empty.out +3 -0
  160. data/spec/integration/application/apply_spec.rb +49 -0
  161. data/spec/integration/faces/plugin_spec.rb +0 -4
  162. data/spec/integration/indirector/facts/facter_spec.rb +59 -0
  163. data/spec/integration/parser/compiler_spec.rb +850 -0
  164. data/spec/integration/parser/resource_expressions_spec.rb +3 -0
  165. data/spec/integration/parser/scope_spec.rb +26 -5
  166. data/spec/integration/transaction_spec.rb +1 -1
  167. data/spec/integration/type/file_spec.rb +318 -41
  168. data/spec/integration/util/windows/security_spec.rb +14 -5
  169. data/spec/lib/matchers/resource.rb +22 -1
  170. data/spec/lib/puppet_spec/matchers.rb +6 -4
  171. data/spec/unit/application/master_spec.rb +33 -7
  172. data/spec/unit/data_providers/function_data_provider_spec.rb +10 -1
  173. data/spec/unit/file_serving/metadata_spec.rb +1 -1
  174. data/spec/unit/file_serving/terminus_helper_spec.rb +2 -3
  175. data/spec/unit/file_system_spec.rb +38 -0
  176. data/spec/unit/functions/defined_spec.rb +289 -0
  177. data/spec/unit/functions/hiera_spec.rb +8 -6
  178. data/spec/unit/functions/regsubst_spec.rb +4 -0
  179. data/spec/unit/functions/split_spec.rb +8 -0
  180. data/spec/unit/functions4_spec.rb +97 -2
  181. data/spec/unit/indirector/facts/facter_spec.rb +7 -0
  182. data/spec/unit/node_spec.rb +6 -0
  183. data/spec/unit/parser/functions/file_spec.rb +7 -1
  184. data/spec/unit/parser/functions/template_spec.rb +1 -1
  185. data/spec/unit/parser/scope_spec.rb +2 -2
  186. data/spec/unit/parser/templatewrapper_spec.rb +1 -1
  187. data/spec/unit/pops/evaluator/access_ops_spec.rb +19 -0
  188. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +84 -18
  189. data/spec/unit/pops/evaluator/variables_spec.rb +1 -1
  190. data/spec/unit/pops/issues_spec.rb +16 -16
  191. data/spec/unit/pops/loaders/loaders_spec.rb +106 -48
  192. data/spec/unit/pops/migration_spec.rb +53 -0
  193. data/spec/unit/pops/parser/lexer2_spec.rb +142 -1
  194. data/spec/unit/pops/parser/parse_heredoc_spec.rb +26 -0
  195. data/spec/unit/pops/types/type_calculator_spec.rb +205 -12
  196. data/spec/unit/pops/validation_spec.rb +66 -0
  197. data/spec/unit/pops/validator/validator_spec.rb +1 -1
  198. data/spec/unit/provider/group/windows_adsi_spec.rb +57 -9
  199. data/spec/unit/provider/mount/parsed_spec.rb +31 -5
  200. data/spec/unit/provider/package/apt_spec.rb +5 -0
  201. data/spec/unit/provider/package/pip_spec.rb +9 -0
  202. data/spec/unit/provider/package/pkgng_spec.rb +172 -0
  203. data/spec/unit/provider/package/windows/exe_package_spec.rb +0 -1
  204. data/spec/unit/provider/package/windows/msi_package_spec.rb +0 -1
  205. data/spec/unit/provider/package/zypper_spec.rb +50 -19
  206. data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +312 -70
  207. data/spec/unit/provider/service/base_spec.rb +38 -27
  208. data/spec/unit/provider/service/debian_spec.rb +8 -0
  209. data/spec/unit/provider/service/freebsd_spec.rb +1 -0
  210. data/spec/unit/provider/service/gentoo_spec.rb +1 -0
  211. data/spec/unit/provider/service/init_spec.rb +18 -0
  212. data/spec/unit/provider/service/openbsd_spec.rb +1 -0
  213. data/spec/unit/provider/service/redhat_spec.rb +1 -0
  214. data/spec/unit/provider/user/windows_adsi_spec.rb +134 -5
  215. data/spec/unit/settings_spec.rb +11 -0
  216. data/spec/unit/util/log_spec.rb +113 -0
  217. data/spec/unit/util/windows/adsi_spec.rb +135 -41
  218. data/spec/unit/util/windows/sid_spec.rb +0 -10
  219. metadata +48 -2
@@ -60,6 +60,8 @@ module Puppet::Pops::Evaluator::Runtime3Support
60
60
  if scope.bound?(name)
61
61
  if Puppet::Parser::Scope::RESERVED_VARIABLE_NAMES.include?(name)
62
62
  fail(Puppet::Pops::Issues::ILLEGAL_RESERVED_ASSIGNMENT, o, {:name => name} )
63
+ elsif name == "server_facts" && Puppet[:trusted_server_facts]
64
+ fail(Puppet::Pops::Issues::ILLEGAL_RESERVED_ASSIGNMENT, o, {:name => name} )
63
65
  else
64
66
  fail(Puppet::Pops::Issues::ILLEGAL_REASSIGNMENT, o, {:name => name} )
65
67
  end
@@ -316,7 +318,7 @@ module Puppet::Pops::Evaluator::Runtime3Support
316
318
  # for the type of the name.
317
319
  # Note, locations are available per parameter.
318
320
  #
319
- scope.define_settings(capitalize_qualified_name(type_name), evaluated_parameters)
321
+ scope.define_settings(capitalize_qualified_name(type_name), evaluated_parameters.flatten)
320
322
  end
321
323
 
322
324
  # Capitalizes each segment of a qualified name
@@ -335,7 +337,8 @@ module Puppet::Pops::Evaluator::Runtime3Support
335
337
  # TODO: Revisit and possible improve the accuracy.
336
338
  #
337
339
  file, line = extract_file_line(o)
338
-
340
+ # A *=> results in an array of arrays
341
+ evaluated_parameters = evaluated_parameters.flatten
339
342
  evaluated_resources.each do |r|
340
343
  unless r.is_a?(Puppet::Pops::Types::PResourceType) && r.type_name != 'class'
341
344
  fail(Puppet::Pops::Issues::ILLEGAL_OVERRIDEN_TYPE, o, {:actual => r} )
@@ -409,15 +412,17 @@ module Puppet::Pops::Evaluator::Runtime3Support
409
412
 
410
413
  # This is the same type of "truth" as used in the current Puppet DSL.
411
414
  #
412
- def is_true? o
415
+ def is_true?(value, o)
413
416
  # Is the value true? This allows us to control the definition of truth
414
417
  # in one place.
415
- case o
418
+ case value
416
419
  # Support :undef since it may come from a 3x structure
417
420
  when :undef
418
421
  false
422
+ when String
423
+ true
419
424
  else
420
- !!o
425
+ !!value
421
426
  end
422
427
  end
423
428
 
@@ -71,7 +71,12 @@ class Puppet::Pops::Functions::Dispatch < Puppet::Pops::Evaluator::CallableSigna
71
71
  else
72
72
  # Careful so no new nil arguments are added since they would override default
73
73
  # parameter values in the received
74
- new_args << args[knit] if knit < args.size
74
+ if knit < 0
75
+ idx = -knit - 1
76
+ new_args += args[idx..-1] if idx < args.size
77
+ else
78
+ new_args << args[knit] if knit < args.size
79
+ end
75
80
  end
76
81
  end
77
82
  new_args
@@ -46,7 +46,13 @@ class Puppet::Pops::Functions::Dispatcher
46
46
  #
47
47
  # @api private
48
48
  def add_dispatch(type, method_name, param_names, block_name, injections, weaving, last_captures)
49
- @dispatchers << Puppet::Pops::Functions::Dispatch.new(type, method_name, param_names, block_name, injections, weaving, last_captures)
49
+ add(Puppet::Pops::Functions::Dispatch.new(type, method_name, param_names, block_name, injections, weaving, last_captures))
50
+ end
51
+
52
+ # Adds a dispatch directly to the set of dispathers.
53
+ # @api private
54
+ def add(a_dispatch)
55
+ @dispatchers << a_dispatch
50
56
  end
51
57
 
52
58
  # Produces a CallableType for a single signature, and a Variant[<callables>] otherwise
@@ -11,19 +11,14 @@ class Puppet::Pops::IssueReporter
11
11
  def self.assert_and_report(acceptor, options)
12
12
  return unless acceptor
13
13
 
14
- max_errors = Puppet[:max_errors]
15
- max_warnings = Puppet[:max_warnings]
16
- max_deprecations =
17
- if Puppet[:disable_warnings].include?('deprecations')
18
- 0
19
- else
20
- Puppet[:max_deprecations]
21
- end
14
+ max_errors = options[:max_errors] || Puppet[:max_errors]
15
+ max_warnings = options[:max_warnings] || Puppet[:max_warnings]
16
+ max_deprecations = options[:max_deprecations] || (Puppet[:disable_warnings].include?('deprecations') ? 0 : Puppet[:max_deprecations])
22
17
 
23
- emit_warnings = options[:emit_warnings] || false
24
- emit_errors = options[:emit_errors].nil? ? true : !!options[:emit_errors]
25
- emit_message = options[:message]
26
- emit_exception = options[:exception_class] || Puppet::ParseError
18
+ emit_warnings = options[:emit_warnings] || false
19
+ emit_errors = options[:emit_errors].nil? ? true : !!options[:emit_errors]
20
+ emit_message = options[:message]
21
+ emit_exception = options[:exception_class] || Puppet::ParseErrorWithIssue
27
22
 
28
23
  # If there are warnings output them
29
24
  warnings = acceptor.warnings
@@ -37,10 +32,10 @@ class Puppet::Pops::IssueReporter
37
32
  # deprecation of constructs in manifests! (It is not designed for that purpose even if
38
33
  # used throughout the code base).
39
34
  #
40
- Puppet.warning(formatter.format(w)) if emitted_dw < max_deprecations
35
+ log_message(:warning, formatter, w) if emitted_dw < max_deprecations
41
36
  emitted_dw += 1
42
37
  else
43
- Puppet.warning(formatter.format(w)) if emitted_w < max_warnings
38
+ log_message(:warning, formatter, w) if emitted_w < max_warnings
44
39
  emitted_w += 1
45
40
  end
46
41
  break if emitted_w >= max_warnings && emitted_dw >= max_deprecations # but only then
@@ -56,7 +51,7 @@ class Puppet::Pops::IssueReporter
56
51
  formatter = Puppet::Pops::Validation::DiagnosticFormatterPuppetStyle.new
57
52
  if errors.size == 1 || max_errors <= 1
58
53
  # raise immediately
59
- exception = emit_exception.new(format_with_prefix(emit_message, formatter.format(errors[0])))
54
+ exception = create_exception(emit_exception, emit_message, formatter, errors[0])
60
55
  # if an exception was given as cause, use it's backtrace instead of the one indicating "here"
61
56
  if errors[0].exception
62
57
  exception.set_backtrace(errors[0].exception.backtrace)
@@ -68,7 +63,7 @@ class Puppet::Pops::IssueReporter
68
63
  Puppet.err(emit_message)
69
64
  end
70
65
  errors.each do |e|
71
- Puppet.err(formatter.format(e))
66
+ log_message(:err, formatter, e)
72
67
  emitted += 1
73
68
  break if emitted >= max_errors
74
69
  end
@@ -84,4 +79,35 @@ class Puppet::Pops::IssueReporter
84
79
  return message unless prefix
85
80
  [prefix, message].join(' ')
86
81
  end
82
+
83
+ def self.create_exception(exception_class, emit_message, formatter, diagnostic)
84
+ file = diagnostic.file
85
+ file = (file.is_a?(String) && file.empty?) ? nil : file
86
+ line = pos = nil
87
+ if diagnostic.source_pos
88
+ line = diagnostic.source_pos.line
89
+ pos = diagnostic.source_pos.pos
90
+ end
91
+ exception_class.new(format_with_prefix(emit_message, formatter.format_message(diagnostic)), file, line, pos, nil, diagnostic.issue.issue_code)
92
+ end
93
+ private_class_method :create_exception
94
+
95
+ def self.log_message(severity, formatter, diagnostic)
96
+ file = diagnostic.file
97
+ file = (file.is_a?(String) && file.empty?) ? nil : file
98
+ line = pos = nil
99
+ if diagnostic.source_pos
100
+ line = diagnostic.source_pos.line
101
+ pos = diagnostic.source_pos.pos
102
+ end
103
+ Puppet::Util::Log.create({
104
+ :level => severity,
105
+ :message => formatter.format_message(diagnostic),
106
+ :issue_code => diagnostic.issue.issue_code,
107
+ :file => file,
108
+ :line => line,
109
+ :pos => pos,
110
+ })
111
+ end
112
+ private_class_method :log_message
87
113
  end
@@ -162,11 +162,16 @@ module Puppet::Pops::Issues
162
162
 
163
163
  # Variables are immutable, cannot reassign in the same assignment scope
164
164
  ILLEGAL_REASSIGNMENT = hard_issue :ILLEGAL_REASSIGNMENT, :name do
165
- "Cannot reassign variable #{name}"
165
+ if Puppet::Pops::Validation::Checker4_0::RESERVED_PARAMETERS[name]
166
+ "Cannot reassign built in (or already assigned) variable '$#{name}'"
167
+ else
168
+ "Cannot reassign variable '$#{name}'"
169
+ end
166
170
  end
167
171
 
172
+ # Variables facts and trusted
168
173
  ILLEGAL_RESERVED_ASSIGNMENT = hard_issue :ILLEGAL_RESERVED_ASSIGNMENT, :name do
169
- "Attempt to assign to a reserved variable name: '#{name}'"
174
+ "Attempt to assign to a reserved variable name: '$#{name}'"
170
175
  end
171
176
 
172
177
  # Assignment cannot be made to numeric match result variables
@@ -174,6 +179,11 @@ module Puppet::Pops::Issues
174
179
  "Illegal attempt to assign to the numeric match result variable '$#{varname}'. Numeric variables are not assignable"
175
180
  end
176
181
 
182
+ # Assignment can only be made to certain types of left hand expressions such as variables.
183
+ ILLEGAL_ASSIGNMENT_CONTEXT = hard_issue :ILLEGAL_ASSIGNMENT_CONTEXT do
184
+ "Assignment not allowed here"
185
+ end
186
+
177
187
  # parameters cannot have numeric names, clashes with match result variables
178
188
  ILLEGAL_NUMERIC_PARAMETER = issue :ILLEGAL_NUMERIC_PARAMETER, :name do
179
189
  "The numeric parameter name '$#{name}' cannot be used (clashes with numeric match result variables)"
@@ -194,6 +204,14 @@ module Puppet::Pops::Issues
194
204
  "Illegal attempt to assign to #{label.a_an(semantic)} via [index/key]. Not an assignable reference"
195
205
  end
196
206
 
207
+ ILLEGAL_MULTI_ASSIGNMENT_SIZE = hard_issue :ILLEGAL_MULTI_ASSIGNMENT_SIZE, :expected, :actual do
208
+ "Mismatched number of assignable entries and values, expected #{expected}, got #{actual}"
209
+ end
210
+
211
+ MISSING_MULTI_ASSIGNMENT_KEY = hard_issue :MISSING_MULTI_ASSIGNMENT_KEY, :key do
212
+ "No value for required key '#{key}' in assignment to variables from hash"
213
+ end
214
+
197
215
  APPENDS_DELETES_NO_LONGER_SUPPORTED = hard_issue :APPENDS_DELETES_NO_LONGER_SUPPORTED, :operator do
198
216
  "The operator '#{operator}' is no longer supported. See http://links.puppetlabs.com/remove-plus-equals"
199
217
  end
@@ -374,6 +392,10 @@ module Puppet::Pops::Issues
374
392
  "#{label.a_an_uc(left_value)}[] cannot use #{actual} where #{expected_text} expected"
375
393
  end
376
394
 
395
+ BAD_NOT_UNDEF_SLICE_TYPE = issue :BAD_NOT_UNDEF_SLICE_TYPE, :base_type, :actual do
396
+ "#{base_type}[] argument must be a Type or a String. Got #{actual}"
397
+ end
398
+
377
399
  BAD_TYPE_SLICE_TYPE = issue :BAD_TYPE_SLICE_TYPE, :base_type, :actual do
378
400
  "#{base_type}[] arguments must be types. Got #{actual}"
379
401
  end
@@ -549,4 +571,96 @@ module Puppet::Pops::Issues
549
571
  ILLEGAL_CATALOG_RELATED_EXPRESSION = hard_issue :ILLEGAL_CATALOG_RELATED_EXPRESSION do
550
572
  "This #{label.label(semantic)} appears in a context where catalog related expressions are not allowed"
551
573
  end
574
+
575
+ SYNTAX_ERROR = hard_issue :SYNTAX_ERROR, :where do
576
+ "Syntax error at #{where}"
577
+ end
578
+
579
+ ILLEGAL_CLASS_REFERENCE = hard_issue :ILLEGAL_CLASS_REFERENCE do
580
+ 'Illegal class reference'
581
+ end
582
+
583
+ ILLEGAL_FULLY_QUALIFIED_CLASS_REFERENCE = hard_issue :ILLEGAL_FULLY_QUALIFIED_CLASS_REFERENCE do
584
+ 'Illegal fully qualified class reference'
585
+ end
586
+
587
+ ILLEGAL_FULLY_QUALIFIED_NAME = hard_issue :ILLEGAL_FULLY_QUALIFIED_NAME do
588
+ 'Illegal fully qualified name'
589
+ end
590
+
591
+ ILLEGAL_NAME_OR_BARE_WORD = hard_issue :ILLEGAL_NAME_OR_BARE_WORD do
592
+ 'Illegal name or bare word'
593
+ end
594
+
595
+ ILLEGAL_NUMBER = hard_issue :ILLEGAL_NUMBER, :value do
596
+ "Illegal number '#{value}'"
597
+ end
598
+
599
+ ILLEGAL_UNICODE_ESCAPE = issue :ILLEGAL_UNICODE_ESCAPE do
600
+ "Unicode escape '\\u' was not followed by 4 hex digits or 1-6 hex digits in {} or was > 10ffff"
601
+ end
602
+
603
+ INVALID_HEX_NUMBER = hard_issue :INVALID_HEX_NUMBER, :value do
604
+ "Not a valid hex number #{value}"
605
+ end
606
+
607
+ INVALID_OCTAL_NUMBER = hard_issue :INVALID_OCTAL_NUMBER, :value do
608
+ "Not a valid octal number #{value}"
609
+ end
610
+
611
+ INVALID_DECIMAL_NUMBER = hard_issue :INVALID_DECIMAL_NUMBER, :value do
612
+ "Not a valid decimal number #{value}"
613
+ end
614
+
615
+ NO_INPUT_TO_LEXER = hard_issue :NO_INPUT_TO_LEXER do
616
+ "Internal Error: No string or file given to lexer to process."
617
+ end
618
+
619
+ UNRECOGNIZED_ESCAPE = issue :UNRECOGNIZED_ESCAPE, :ch do
620
+ "Unrecognized escape sequence '\\#{ch}'"
621
+ end
622
+
623
+ UNCLOSED_QUOTE = hard_issue :UNCLOSED_QUOTE, :after, :followed_by do
624
+ "Unclosed quote after #{after} followed by '#{followed_by}'"
625
+ end
626
+
627
+ EPP_INTERNAL_ERROR = hard_issue :EPP_INTERNAL_ERROR, :error do
628
+ "Internal error: #{error}"
629
+ end
630
+
631
+ EPP_UNBALANCED_TAG = hard_issue :EPP_UNBALANCED_TAG do
632
+ 'Unbalanced epp tag, reached <eof> without closing tag.'
633
+ end
634
+
635
+ EPP_UNBALANCED_COMMENT = hard_issue :EPP_UNBALANCED_COMMENT do
636
+ 'Reaching end after opening <%# without seeing %>'
637
+ end
638
+
639
+ EPP_UNBALANCED_EXPRESSION = hard_issue :EPP_UNBALANCED_EXPRESSION do
640
+ 'Unbalanced embedded expression - opening <% and reaching end of input'
641
+ end
642
+
643
+ HEREDOC_UNCLOSED_PARENTHESIS = hard_issue :HEREDOC_UNCLOSED_PARENTHESIS, :followed_by do
644
+ "Unclosed parenthesis after '@(' followed by '#{followed_by}'"
645
+ end
646
+
647
+ HEREDOC_WITHOUT_END_TAGGED_LINE = hard_issue :HEREDOC_WITHOUT_END_TAGGED_LINE do
648
+ 'Heredoc without end-tagged line'
649
+ end
650
+
651
+ HEREDOC_INVALID_ESCAPE = hard_issue :HEREDOC_INVALID_ESCAPE, :actual do
652
+ "Invalid heredoc escape char. Only t, r, n, s, u, L, $ allowed. Got '#{actual}'"
653
+ end
654
+
655
+ HEREDOC_INVALID_SYNTAX = hard_issue :HEREDOC_INVALID_SYNTAX do
656
+ 'Invalid syntax in heredoc expected @(endtag[:syntax][/escapes])'
657
+ end
658
+
659
+ HEREDOC_WITHOUT_TEXT = hard_issue :HEREDOC_WITHOUT_TEXT do
660
+ 'Heredoc without any following lines of text'
661
+ end
662
+
663
+ HEREDOC_MULTIPLE_AT_ESCAPES = hard_issue :HEREDOC_MULTIPLE_AT_ESCAPES, :escapes do
664
+ "An escape char for @() may only appear once. Got '#{escapes.join(', ')}'"
665
+ end
552
666
  end
@@ -21,6 +21,9 @@
21
21
  #
22
22
  class Puppet::Pops::Loader::Loader
23
23
 
24
+ # Describes the kinds of things that loaders can load
25
+ LOADABLE_KINDS = [:func_4x, :func_4xpp].freeze
26
+
24
27
  # Produces the value associated with the given name if already loaded, or available for loading
25
28
  # by this loader, one of its parents, or other loaders visible to this loader.
26
29
  # This is the method an external party should use to "get" the named element.
@@ -119,6 +122,14 @@ class Puppet::Pops::Loader::Loader
119
122
  raise NotImplementedError.new
120
123
  end
121
124
 
125
+ # A loader is by default a loader for all kinds of loadables. An implementation may override
126
+ # if it cannot load all kinds.
127
+ #
128
+ # @api private
129
+ def loadables
130
+ LOADABLE_KINDS
131
+ end
132
+
122
133
  # An entry for one entity loaded by the loader.
123
134
  #
124
135
  class NamedEntry
@@ -4,7 +4,7 @@
4
4
  # The central loader knowledge about paths, what they represent and how to instantiate from them.
5
5
  # Contains helpers (*smart paths*) to deal with lazy resolution of paths.
6
6
  #
7
- # TODO: Currently only supports loading of functions (3 kinds)
7
+ # TODO: Currently only supports loading of functions (2 kinds)
8
8
  #
9
9
  module Puppet::Pops::Loader::LoaderPaths
10
10
  # Returns an array of SmartPath, each instantiated with a reference to the given loader (for root path resolution
@@ -12,10 +12,17 @@ module Puppet::Pops::Loader::LoaderPaths
12
12
  # mutated.
13
13
  #
14
14
  def self.relative_paths_for_type(type, loader)
15
- result =
15
+ result = []
16
16
  case type
17
17
  when :function
18
- [FunctionPath4x.new(loader)]
18
+ # Only include support for the loadable items the loader states it can contain
19
+ if loader.loadables.include?(:func_4x)
20
+ result << FunctionPath4x.new(loader)
21
+ end
22
+ if loader.loadables.include?(:func_4xpp)
23
+ result << FunctionPathPP.new(loader)
24
+ end
25
+ # When wanted also add FunctionPath3x to load 3x functions
19
26
  else
20
27
  # unknown types, simply produce an empty result; no paths to check, nothing to find... move along...
21
28
  []
@@ -44,8 +51,12 @@ module Puppet::Pops::Loader::LoaderPaths
44
51
  def generic_path()
45
52
  return @generic_path unless @generic_path.nil?
46
53
 
47
- root_path = @loader.path
48
- @generic_path = (root_path.nil? ? relative_path : File.join(root_path, relative_path))
54
+ the_root_path = root_path() # @loader.path
55
+ @generic_path = (the_root_path.nil? ? relative_path : File.join(the_root_path, relative_path))
56
+ end
57
+
58
+ def root_path
59
+ @loader.path
49
60
  end
50
61
 
51
62
  # Effective path is the generic path + the name part(s) + extension.
@@ -64,8 +75,10 @@ module Puppet::Pops::Loader::LoaderPaths
64
75
  end
65
76
 
66
77
  class RubySmartPath < SmartPath
78
+ EXTENSION = '.rb'.freeze
79
+
67
80
  def extension
68
- ".rb"
81
+ EXTENSION
69
82
  end
70
83
 
71
84
  # Duplication of extension information, but avoids one call
@@ -74,6 +87,29 @@ module Puppet::Pops::Loader::LoaderPaths
74
87
  end
75
88
  end
76
89
 
90
+ # A PuppetSmartPath is rooted at the loader's directory one level up from what the loader specifies as it
91
+ # path (which is a reference to its 'lib' directory.
92
+ #
93
+ class PuppetSmartPath < SmartPath
94
+ EXTENSION = '.pp'.freeze
95
+
96
+ def extension
97
+ EXTENSION
98
+ end
99
+
100
+ def root_path
101
+ # Drop the lib part (it may not exist and cannot be navigated to in a relative way)
102
+ Puppet::FileSystem.dir_string(@loader.path)
103
+ end
104
+
105
+ # Duplication of extension information, but avoids one call
106
+ def effective_path(typed_name, start_index_in_name)
107
+ # Puppet name to path always skips the name-space as that is part of the generic path
108
+ # i.e. <module>/mymodule/functions/foo.pp is the function mymodule::foo
109
+ "#{File.join(generic_path, typed_name.name_parts[ 1..-1 ])}.pp"
110
+ end
111
+ end
112
+
77
113
  class FunctionPath4x < RubySmartPath
78
114
  FUNCTION_PATH_4X = File.join('puppet', 'functions')
79
115
 
@@ -86,6 +122,31 @@ module Puppet::Pops::Loader::LoaderPaths
86
122
  end
87
123
  end
88
124
 
125
+ class FunctionPath3x < RubySmartPath
126
+ FUNCTION_PATH_3X = File.join('puppet', 'parser', 'functions')
127
+
128
+ def relative_path
129
+ FUNCTION_PATH_3X
130
+ end
131
+
132
+ def instantiator()
133
+ Puppet::Pops::Loader::RubyLegacyFunctionInstantiator
134
+ end
135
+ end
136
+
137
+ class FunctionPathPP < PuppetSmartPath
138
+ # Navigate to directory where 'lib' is, then down again
139
+ FUNCTION_PATH_PP = File.join('functions')
140
+
141
+ def relative_path
142
+ FUNCTION_PATH_PP
143
+ end
144
+
145
+ def instantiator()
146
+ Puppet::Pops::Loader::PuppetFunctionInstantiator
147
+ end
148
+ end
149
+
89
150
  # SmartPaths
90
151
  # ===
91
152
  # Holds effective SmartPath instances per type