puppet 3.7.1 → 3.7.2

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 (58) hide show
  1. data/ext/build_defaults.yaml +3 -3
  2. data/ext/debian/control +2 -0
  3. data/ext/project_data.yaml +2 -2
  4. data/lib/puppet/application.rb +1 -4
  5. data/lib/puppet/configurer.rb +6 -4
  6. data/lib/puppet/environments.rb +47 -3
  7. data/lib/puppet/indirector/node/exec.rb +1 -1
  8. data/lib/puppet/indirector/request.rb +1 -2
  9. data/lib/puppet/module.rb +1 -1
  10. data/lib/puppet/module_tool.rb +1 -1
  11. data/lib/puppet/network/http/webrick.rb +17 -7
  12. data/lib/puppet/node.rb +2 -2
  13. data/lib/puppet/parser/ast/pops_bridge.rb +1 -11
  14. data/lib/puppet/parser/compiler.rb +1 -2
  15. data/lib/puppet/parser/resource.rb +1 -3
  16. data/lib/puppet/parser/resource/param.rb +1 -1
  17. data/lib/puppet/parser/type_loader.rb +1 -1
  18. data/lib/puppet/pops/evaluator/access_operator.rb +3 -11
  19. data/lib/puppet/pops/evaluator/evaluator_impl.rb +1 -1
  20. data/lib/puppet/pops/evaluator/runtime3_support.rb +30 -4
  21. data/lib/puppet/pops/model/factory.rb +16 -1
  22. data/lib/puppet/pops/parser/egrammar.ra +1 -1
  23. data/lib/puppet/pops/parser/eparser.rb +1 -1
  24. data/lib/puppet/pops/parser/parser_support.rb +19 -1
  25. data/lib/puppet/pops/types/type_calculator.rb +19 -14
  26. data/lib/puppet/provider/package/pkg.rb +12 -1
  27. data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +15 -16
  28. data/lib/puppet/provider/ssh_authorized_key/parsed.rb +16 -0
  29. data/lib/puppet/resource.rb +1 -8
  30. data/lib/puppet/settings.rb +17 -0
  31. data/lib/puppet/type/user.rb +11 -1
  32. data/lib/puppet/util/autoload.rb +10 -6
  33. data/lib/puppet/util/monkey_patches.rb +2 -2
  34. data/lib/puppet/version.rb +1 -1
  35. data/spec/fixtures/unit/provider/package/pkg/dummy_solaris11.certificate_warning +2 -0
  36. data/spec/fixtures/unit/type/user/authorized_keys +1 -0
  37. data/spec/integration/application/apply_spec.rb +29 -23
  38. data/spec/integration/parser/future_compiler_spec.rb +56 -0
  39. data/spec/integration/type/user_spec.rb +22 -1
  40. data/spec/lib/puppet_spec/files.rb +1 -0
  41. data/spec/unit/environments_spec.rb +99 -0
  42. data/spec/unit/network/http/webrick_spec.rb +21 -2
  43. data/spec/unit/parser/compiler_spec.rb +19 -1
  44. data/spec/unit/parser/functions/lookup_spec.rb +13 -12
  45. data/spec/unit/parser/resource/param_spec.rb +10 -22
  46. data/spec/unit/parser/resource_spec.rb +0 -4
  47. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +30 -5
  48. data/spec/unit/pops/parser/parse_calls_spec.rb +20 -5
  49. data/spec/unit/pops/types/type_calculator_spec.rb +61 -0
  50. data/spec/unit/provider/package/pkg_spec.rb +4 -0
  51. data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +47 -14
  52. data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +15 -0
  53. data/spec/unit/type/user_spec.rb +5 -0
  54. data/spec/unit/util/autoload_spec.rb +33 -14
  55. data/spec/unit/util/monkey_patches_spec.rb +12 -0
  56. data/tasks/memwalk.rake +195 -0
  57. metadata +3216 -3205
  58. checksums.yaml +0 -7
@@ -16,7 +16,7 @@ build_gem: TRUE
16
16
  build_dmg: TRUE
17
17
  build_msi:
18
18
  puppet_for_the_win:
19
- ref: 'c61dda253b09bd855488f7b6dd7332fdf84d3039'
19
+ ref: 'f4f74b1c8d8792089d1d3328b01f5ff075771eb0'
20
20
  repo: 'git://github.com/puppetlabs/puppet_for_the_win.git'
21
21
  facter:
22
22
  ref: 'refs/tags/2.2.0'
@@ -26,8 +26,8 @@ build_msi:
26
26
  repo: 'git://github.com/puppetlabs/hiera.git'
27
27
  sys:
28
28
  ref:
29
- x86: '890ad47c3b70de4e4956d2699b54d481d5a1b72e'
30
- x64: '2820779a3f4281534a6792b0ab20b2cf213647dc'
29
+ x86: 'cbe94f4cafb0f78d587e8addcf723bc671af7cca'
30
+ x64: '417378f607340d211fbfef89a96e6639bef1bfb1'
31
31
  repo: 'git://github.com/puppetlabs/puppet-win32-ruby.git'
32
32
  apt_host: 'apt.puppetlabs.com'
33
33
  apt_repo_url: 'http://apt.puppetlabs.com'
@@ -60,6 +60,7 @@ Architecture: all
60
60
  Depends: ${misc:Depends}, ruby | ruby-interpreter, puppet-common (= ${binary:Version}), facter (>= 1.7.0), lsb-base
61
61
  Breaks: puppet (<< 0.24.7-1), puppetmaster (<< 2.6.1~rc2-1)
62
62
  Replaces: puppetmaster (<< 2.6.1~rc2-1)
63
+ Conflicts: puppet-common (<< 3.3.0-1puppetlabs1)
63
64
  Suggests: apache2 | nginx, puppet-el, vim-puppet, stompserver, ruby-stomp | libstomp-ruby1.8,
64
65
  rdoc, ruby-ldap | libldap-ruby1.8, puppetdb-terminus
65
66
  Description: Puppet master common scripts
@@ -81,6 +82,7 @@ Package: puppetmaster
81
82
  Architecture: all
82
83
  Depends: ${misc:Depends}, ruby | ruby-interpreter, puppetmaster-common (= ${source:Version}), facter (>= 1.7.0), lsb-base
83
84
  Breaks: puppet (<< 0.24.7-1)
85
+ Conflicts: puppet (<< 3.3.0-1puppetlabs1)
84
86
  Suggests: apache2 | nginx, puppet-el, vim-puppet, stompserver, ruby-stomp | libstomp-ruby1.8,
85
87
  rdoc, ruby-ldap | libldap-ruby1.8, puppetdb-terminus
86
88
  Description: Centralized configuration management - master startup and compatibility scripts
@@ -33,7 +33,7 @@ gem_platform_dependencies:
33
33
  win32-eventlog: '~> 0.6.1'
34
34
  win32-process: '~> 0.7.4'
35
35
  win32-security: '~> 0.2.5'
36
- win32-service: '~> 0.8.4'
36
+ win32-service: '~> 0.8.6'
37
37
  win32console: '1.3.2'
38
38
  minitar: '~> 0.5.4'
39
39
  x64-mingw32:
@@ -43,7 +43,7 @@ gem_platform_dependencies:
43
43
  win32-eventlog: '~> 0.6.1'
44
44
  win32-process: '~> 0.7.4'
45
45
  win32-security: '~> 0.2.5'
46
- win32-service: '~> 0.8.4'
46
+ win32-service: '~> 0.8.6'
47
47
  minitar: '~> 0.5.4'
48
48
  bundle_platforms:
49
49
  x86-mingw32: mingw
@@ -360,10 +360,7 @@ class Application
360
360
  #
361
361
  configured_environment_name = Puppet[:environment]
362
362
  if self.class.run_mode.name != :agent
363
- configured_environment = Puppet.lookup(:environments).get(configured_environment_name)
364
- if configured_environment.nil?
365
- fail(Puppet::Environments::EnvironmentNotFound, configured_environment_name)
366
- end
363
+ configured_environment = Puppet.lookup(:environments).get!(configured_environment_name)
367
364
  else
368
365
  configured_environment = Puppet::Node::Environment.remote(configured_environment_name)
369
366
  end
@@ -156,7 +156,9 @@ class Puppet::Configurer
156
156
  unless options[:catalog]
157
157
  begin
158
158
  if node = Puppet::Node.indirection.find(Puppet[:node_name_value],
159
- :environment => @environment, :ignore_cache => true, :transaction_uuid => @transaction_uuid,
159
+ :environment => Puppet::Node::Environment.remote(@environment),
160
+ :ignore_cache => true,
161
+ :transaction_uuid => @transaction_uuid,
160
162
  :fail_on_404 => true)
161
163
 
162
164
  # If we have deserialized a node from a rest call, we want to set
@@ -242,7 +244,7 @@ class Puppet::Configurer
242
244
  def send_report(report)
243
245
  puts report.summary if Puppet[:summarize]
244
246
  save_last_run_summary(report)
245
- Puppet::Transaction::Report.indirection.save(report, nil, :environment => @environment) if Puppet[:report]
247
+ Puppet::Transaction::Report.indirection.save(report, nil, :environment => Puppet::Node::Environment.remote(@environment)) if Puppet[:report]
246
248
  rescue => detail
247
249
  Puppet.log_exception(detail, "Could not send report: #{detail}")
248
250
  end
@@ -274,7 +276,7 @@ class Puppet::Configurer
274
276
  result = nil
275
277
  @duration = thinmark do
276
278
  result = Puppet::Resource::Catalog.indirection.find(Puppet[:node_name_value],
277
- query_options.merge(:ignore_terminus => true, :environment => @environment))
279
+ query_options.merge(:ignore_terminus => true, :environment => Puppet::Node::Environment.remote(@environment)))
278
280
  end
279
281
  Puppet.notice "Using cached catalog"
280
282
  result
@@ -287,7 +289,7 @@ class Puppet::Configurer
287
289
  result = nil
288
290
  @duration = thinmark do
289
291
  result = Puppet::Resource::Catalog.indirection.find(Puppet[:node_name_value],
290
- query_options.merge(:ignore_cache => true, :environment => @environment, :fail_on_404 => true))
292
+ query_options.merge(:ignore_cache => true, :environment => Puppet::Node::Environment.remote(@environment), :fail_on_404 => true))
291
293
  end
292
294
  result
293
295
  rescue SystemExit,NoMemoryError
@@ -48,6 +48,14 @@ module Puppet::Environments
48
48
  # we are looking up
49
49
  # @return [Puppet::Setting::EnvironmentConf, nil] the configuration for the
50
50
  # requested environment, or nil if not found or no configuration is available
51
+ #
52
+ # @!macro [new] loader_get_or_fail
53
+ # Find a named environment or raise
54
+ # Puppet::Environments::EnvironmentNotFound when the named environment is
55
+ # does not exist.
56
+ #
57
+ # @param name [String,Symbol] The name of environment to find
58
+ # @return [Puppet::Node::Environment] the requested environment
51
59
 
52
60
  # A source of pre-defined environments.
53
61
  #
@@ -76,6 +84,14 @@ module Puppet::Environments
76
84
  end
77
85
  end
78
86
 
87
+ # @!macro loader_get_or_fail
88
+ def get!(name)
89
+ if !environment = get(name)
90
+ raise EnvironmentNotFound, name
91
+ end
92
+ environment
93
+ end
94
+
79
95
  # Returns a basic environment configuration object tied to the environment's
80
96
  # implementation values. Will not interpolate.
81
97
  #
@@ -144,6 +160,14 @@ module Puppet::Environments
144
160
  Puppet::Node::Environment.new(name)
145
161
  end
146
162
 
163
+ # @note Because the Legacy system cannot list out all of its environments,
164
+ # this method will never fail and is only calling get directly.
165
+ #
166
+ # @!macro loader_get_or_fail
167
+ def get!(name)
168
+ get(name)
169
+ end
170
+
147
171
  # @note we could return something here, but since legacy environments
148
172
  # are deprecated, there is no point.
149
173
  #
@@ -187,11 +211,11 @@ module Puppet::Environments
187
211
  # @!macro loader_list
188
212
  def list
189
213
  valid_directories.collect do |envdir|
190
- name = Puppet::FileSystem.basename_string(envdir)
214
+ name = Puppet::FileSystem.basename_string(envdir).intern
191
215
 
192
216
  setting_values = Puppet.settings.values(name, Puppet.settings.preferred_run_mode)
193
217
  env = Puppet::Node::Environment.create(
194
- name.intern,
218
+ name,
195
219
  Puppet::Node::Environment.split_path(setting_values.interpolate(:modulepath)),
196
220
  setting_values.interpolate(:manifest),
197
221
  setting_values.interpolate(:config_version)
@@ -206,6 +230,14 @@ module Puppet::Environments
206
230
  list.find { |env| env.name == name.intern }
207
231
  end
208
232
 
233
+ # @!macro loader_get_or_fail
234
+ def get!(name)
235
+ if !environment = get(name)
236
+ raise EnvironmentNotFound, name
237
+ end
238
+ environment
239
+ end
240
+
209
241
  # @!macro loader_get_conf
210
242
  def get_conf(name)
211
243
  valid_directories.each do |envdir|
@@ -259,6 +291,16 @@ module Puppet::Environments
259
291
  nil
260
292
  end
261
293
 
294
+ # @!macro loader_get_or_fail
295
+ def get!(name)
296
+ @loaders.each do |loader|
297
+ if env = loader.get(name)
298
+ return env
299
+ end
300
+ end
301
+ raise EnvironmentNotFound, name
302
+ end
303
+
262
304
  # @!macro loader_get_conf
263
305
  def get_conf(name)
264
306
  @loaders.each do |loader|
@@ -325,10 +367,12 @@ module Puppet::Environments
325
367
  end
326
368
 
327
369
  # Evicts the entry if it has expired
328
- #
370
+ # Also clears caches in Settings that may prevent the entry from being updated
329
371
  def evict_if_expired(name)
330
372
  if (result = @cache[name]) && result.expired?
331
373
  @cache.delete(name)
374
+
375
+ Puppet.settings.clear_environment_settings(name)
332
376
  end
333
377
  end
334
378
 
@@ -21,7 +21,7 @@ class Puppet::Node::Exec < Puppet::Indirector::Exec
21
21
 
22
22
  # Set the requested environment if it wasn't overridden
23
23
  # If we don't do this it gets set to the local default
24
- result[:environment] ||= request.environment.name
24
+ result[:environment] ||= request.environment
25
25
 
26
26
  create_node(request.key, result)
27
27
  end
@@ -95,8 +95,7 @@ class Puppet::Indirector::Request
95
95
  elsif (current_environment = Puppet.lookup(:current_environment)).name == env
96
96
  current_environment
97
97
  else
98
- Puppet.lookup(:environments).get(env) ||
99
- raise(Puppet::Environments::EnvironmentNotFound, env)
98
+ Puppet.lookup(:environments).get!(env)
100
99
  end
101
100
  end
102
101
 
@@ -29,7 +29,7 @@ class Puppet::Module
29
29
  def self.find(modname, environment = nil)
30
30
  return nil unless modname
31
31
  # Unless a specific environment is given, use the current environment
32
- env = environment ? Puppet.lookup(:environments).get(environment) : Puppet.lookup(:current_environment)
32
+ env = environment ? Puppet.lookup(:environments).get!(environment) : Puppet.lookup(:current_environment)
33
33
  env.module(modname)
34
34
  end
35
35
 
@@ -151,7 +151,7 @@ module Puppet
151
151
  elsif options[:environment]
152
152
  # This use of looking up an environment is correct since it honours
153
153
  # a reguest to get a particular environment via environment name.
154
- Puppet.lookup(:environments).get(options[:environment])
154
+ Puppet.lookup(:environments).get!(options[:environment])
155
155
  else
156
156
  Puppet.lookup(:current_environment)
157
157
  end
@@ -8,18 +8,15 @@ require 'puppet/ssl/certificate_revocation_list'
8
8
  require 'puppet/ssl/configuration'
9
9
 
10
10
  class Puppet::Network::HTTP::WEBrick
11
+ CIPHERS = "EDH+CAMELLIA:EDH+aRSA:EECDH+aRSA+AESGCM:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH:+CAMELLIA256:+AES256:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!IDEA:!ECDSA:kEDH:CAMELLIA256-SHA:AES256-SHA:CAMELLIA128-SHA:AES128-SHA"
12
+
11
13
  def initialize
12
14
  @listening = false
13
15
  end
14
16
 
15
17
  def listen(address, port)
16
- arguments = {:BindAddress => address, :Port => port, :DoNotReverseLookup => true}
17
- arguments.merge!(setup_logger)
18
- arguments.merge!(setup_ssl)
18
+ @server = create_server(address, port)
19
19
 
20
- BasicSocket.do_not_reverse_lookup = true
21
-
22
- @server = WEBrick::HTTPServer.new(arguments)
23
20
  @server.listeners.each { |l| l.start_immediately = false }
24
21
 
25
22
  @server.mount('/', Puppet::Network::HTTP::WEBrickREST)
@@ -55,6 +52,19 @@ class Puppet::Network::HTTP::WEBrick
55
52
  @thread.join
56
53
  end
57
54
 
55
+ # @api private
56
+ def create_server(address, port)
57
+ arguments = {:BindAddress => address, :Port => port, :DoNotReverseLookup => true}
58
+ arguments.merge!(setup_logger)
59
+ arguments.merge!(setup_ssl)
60
+
61
+ BasicSocket.do_not_reverse_lookup = true
62
+
63
+ server = WEBrick::HTTPServer.new(arguments)
64
+ server.ssl_context.ciphers = CIPHERS
65
+ server
66
+ end
67
+
58
68
  # Configure our http log file.
59
69
  def setup_logger
60
70
  # Make sure the settings are all ready for us.
@@ -96,7 +106,7 @@ class Puppet::Network::HTTP::WEBrick
96
106
  results[:SSLCertificate] = host.certificate.content
97
107
  results[:SSLStartImmediately] = true
98
108
  results[:SSLEnable] = true
99
- results[:SSLOptions] = OpenSSL::SSL::OP_NO_SSLv2
109
+ results[:SSLOptions] = OpenSSL::SSL::OP_NO_SSLv2 | OpenSSL::SSL::OP_NO_SSLv3
100
110
 
101
111
  raise Puppet::Error, "Could not find CA certificate" unless Puppet::SSL::Certificate.indirection.find(Puppet::SSL::CA_NAME)
102
112
 
@@ -67,7 +67,7 @@ class Puppet::Node
67
67
  # for a node when it has not specified its environment
68
68
  # Tt will be used to establish what the current environment is.
69
69
  #
70
- self.environment = Puppet.lookup(:environments).get(Puppet[:environment])
70
+ self.environment = Puppet.lookup(:environments).get!(Puppet[:environment])
71
71
  end
72
72
 
73
73
  @environment
@@ -76,7 +76,7 @@ class Puppet::Node
76
76
 
77
77
  def environment=(env)
78
78
  if env.is_a?(String) or env.is_a?(Symbol)
79
- @environment = Puppet.lookup(:environments).get(env)
79
+ @environment = Puppet.lookup(:environments).get!(env)
80
80
  else
81
81
  @environment = env
82
82
  end
@@ -55,13 +55,6 @@ class Puppet::Parser::AST::PopsBridge
55
55
  end
56
56
  end
57
57
 
58
- class NilAsUndefExpression < Expression
59
- def evaluate(scope)
60
- result = super
61
- result.nil? ? :undef : result
62
- end
63
- end
64
-
65
58
  # Bridges the top level "Program" produced by the pops parser.
66
59
  # Its main purpose is to give one point where all definitions are instantiated (actually defined since the
67
60
  # Puppet 3x terminology is somewhat misleading - the definitions are instantiated, but instances of the created types
@@ -113,11 +106,8 @@ class Puppet::Parser::AST::PopsBridge
113
106
 
114
107
  def instantiate_Parameter(o)
115
108
  # 3x needs parameters as an array of `[name]` or `[name, value_expr]`
116
- # One problem is that the parameter evaluation takes place in the wrong context in 3x (the caller's and
117
- # can thus reference all sorts of information. Here the value expression is wrapped in an AST Bridge to a Pops
118
- # expression since the Pops side can not control the evaluation
119
109
  if o.value
120
- [o.name, NilAsUndefExpression.new(:value => o.value)]
110
+ [o.name, Expression.new(:value => o.value)]
121
111
  else
122
112
  [o.name]
123
113
  end
@@ -187,9 +187,8 @@ class Puppet::Parser::Compiler
187
187
  classes_without_params = @node.classes
188
188
  end
189
189
 
190
- evaluate_classes(classes_without_params, @node_scope || topscope)
191
-
192
190
  evaluate_classes(classes_with_params, @node_scope || topscope)
191
+ evaluate_classes(classes_without_params, @node_scope || topscope)
193
192
  end
194
193
 
195
194
  # Evaluate each specified class in turn. If there are any classes we can't
@@ -162,12 +162,10 @@ class Puppet::Parser::Resource < Puppet::Resource
162
162
  # if we ever receive a parameter named 'tag', set
163
163
  # the resource tags with its value.
164
164
  def set_parameter(param, value = nil)
165
- if ! value.nil?
165
+ if ! param.is_a?(Puppet::Parser::Resource::Param)
166
166
  param = Puppet::Parser::Resource::Param.new(
167
167
  :name => param, :value => value, :source => self.source
168
168
  )
169
- elsif ! param.is_a?(Puppet::Parser::Resource::Param)
170
- raise ArgumentError, "Received incomplete information - no value provided for parameter #{param}"
171
169
  end
172
170
 
173
171
  tag(*param.value) if param.name == :tag
@@ -11,7 +11,7 @@ class Puppet::Parser::Resource::Param
11
11
 
12
12
  def initialize(hash)
13
13
  set_options(hash)
14
- requiredopts(:name, :value)
14
+ requiredopts(:name)
15
15
  @name = @name.intern
16
16
  end
17
17
 
@@ -55,7 +55,7 @@ class Puppet::Parser::TypeLoader
55
55
 
56
56
  def environment=(env)
57
57
  if env.is_a?(String) or env.is_a?(Symbol)
58
- @environment = Puppet.lookup(:environments).get(env)
58
+ @environment = Puppet.lookup(:environments).get!(env)
59
59
  else
60
60
  @environment = env
61
61
  end
@@ -232,7 +232,7 @@ class Puppet::Pops::Evaluator::AccessOperator
232
232
  when :default
233
233
  'Default'
234
234
  else
235
- actual.class.name
235
+ Puppet::Pops::Types::TypeCalculator.generalize!(Puppet::Pops::Types::TypeCalculator.infer(actual)).to_s
236
236
  end
237
237
  end
238
238
 
@@ -462,7 +462,7 @@ class Puppet::Pops::Evaluator::AccessOperator
462
462
  else
463
463
  # blame given left expression if it defined the type, else the first given key expression
464
464
  blame = o.type_name.nil? ? @semantic.keys[0] : @semantic.left_expr
465
- fail(Puppet::Pops::Issues::ILLEGAL_RESOURCE_SPECIALIZATION, blame, {:actual => type_name.class})
465
+ fail(Puppet::Pops::Issues::ILLEGAL_RESOURCE_SPECIALIZATION, blame, {:actual => bad_key_type_name(type_name)})
466
466
  end
467
467
 
468
468
  # type name must conform
@@ -508,18 +508,10 @@ class Puppet::Pops::Evaluator::AccessOperator
508
508
  keys = [:no_title] if keys.size < 1 # if there was only a type_name and it was consumed
509
509
  result = keys.each_with_index.map do |t, i|
510
510
  unless t.is_a?(String) || t == :no_title
511
- type_to_report = case t
512
- when nil
513
- 'Undef'
514
- when :default
515
- 'Default'
516
- else
517
- t.class.name
518
- end
519
511
  index = keys_orig_size != keys.size ? i+1 : i
520
512
  fail(Puppet::Pops::Issues::BAD_TYPE_SPECIALIZATION, @semantic.keys[index], {
521
513
  :type => o,
522
- :message => "Cannot use #{type_to_report} where String is expected"
514
+ :message => "Cannot use #{bad_key_type_name(t)} where a resource title String is expected"
523
515
  })
524
516
  end
525
517
 
@@ -706,7 +706,7 @@ class Puppet::Pops::Evaluator::EvaluatorImpl
706
706
  if param_memo.include? p.name
707
707
  fail(Puppet::Pops::Issues::DUPLICATE_ATTRIBUTE, o, {:attribute => p.name})
708
708
  end
709
- param_memo[p.name] = p
709
+ param_memo[p.name] = p
710
710
  end
711
711
  param_memo
712
712
  end
@@ -255,8 +255,7 @@ module Puppet::Pops::Evaluator::Runtime3Support
255
255
  file, line = extract_file_line(o)
256
256
  Puppet::Parser::Resource::Param.new(
257
257
  :name => name,
258
- # Here we must convert nil values to :undef for the 3x logic to work
259
- :value => convert(value, scope, :undef), # converted to 3x since 4x supports additional objects / types
258
+ :value => convert(value, scope, nil), # converted to 3x since 4x supports additional objects / types
260
259
  :source => scope.source, :line => line, :file => file,
261
260
  :add => operator == :'+>'
262
261
  )
@@ -394,6 +393,7 @@ module Puppet::Pops::Evaluator::Runtime3Support
394
393
  # Returns true, if the given name is the name of a resource parameter.
395
394
  #
396
395
  def is_parameter_of_resource?(scope, resource, name)
396
+ return false unless name.is_a?(String)
397
397
  resource.valid_parameter?(name)
398
398
  end
399
399
 
@@ -425,6 +425,7 @@ module Puppet::Pops::Evaluator::Runtime3Support
425
425
 
426
426
  def initialize
427
427
  @@convert_visitor ||= Puppet::Pops::Visitor.new(self, "convert", 2, 2)
428
+ @@convert2_visitor ||= Puppet::Pops::Visitor.new(self, "convert2", 2, 2)
428
429
  end
429
430
 
430
431
  # Converts 4x supported values to 3x values. This is required because
@@ -436,35 +437,53 @@ module Puppet::Pops::Evaluator::Runtime3Support
436
437
  @@convert_visitor.visit_this_2(self, o, scope, undef_value)
437
438
  end
438
439
 
440
+ # Converts nested 4x supported values to 3x values. This is required because
441
+ # resources and other objects do not know about the new type system, and does not support
442
+ # regular expressions. Unfortunately this has to be done for array and hash as well.
443
+ # A complication is that catalog types needs to be resolved against the scope.
444
+ #
445
+ def convert2(o, scope, undef_value)
446
+ @@convert2_visitor.visit_this_2(self, o, scope, undef_value)
447
+ end
448
+
439
449
 
440
450
  def convert_NilClass(o, scope, undef_value)
441
451
  undef_value
442
452
  end
443
453
 
454
+ def convert2_NilClass(o, scope, undef_value)
455
+ :undef
456
+ end
457
+
444
458
  def convert_String(o, scope, undef_value)
445
459
  # although wasteful, needed because user code may mutate these strings in Resources
446
460
  o.frozen? ? o.dup : o
447
461
  end
462
+ alias convert2_String :convert_String
448
463
 
449
464
  def convert_Object(o, scope, undef_value)
450
465
  o
451
466
  end
467
+ alias :convert2_Object :convert_Object
452
468
 
453
469
  def convert_Array(o, scope, undef_value)
454
- o.map {|x| convert(x, scope, undef_value) }
470
+ o.map {|x| convert2(x, scope, undef_value) }
455
471
  end
472
+ alias :convert2_Array :convert_Array
456
473
 
457
474
  def convert_Hash(o, scope, undef_value)
458
475
  result = {}
459
- o.each {|k,v| result[convert(k, scope, undef_value)] = convert(v, scope, undef_value) }
476
+ o.each {|k,v| result[convert2(k, scope, undef_value)] = convert2(v, scope, undef_value) }
460
477
  result
461
478
  end
479
+ alias :convert2_Hash :convert_Hash
462
480
 
463
481
  def convert_Regexp(o, scope, undef_value)
464
482
  # Puppet 3x cannot handle parameter values that are reqular expressions. Turn into regexp string in
465
483
  # source form
466
484
  o.inspect
467
485
  end
486
+ alias :convert2_Regexp :convert_Regexp
468
487
 
469
488
  def convert_Symbol(o, scope, undef_value)
470
489
  case o
@@ -476,9 +495,15 @@ module Puppet::Pops::Evaluator::Runtime3Support
476
495
  end
477
496
  end
478
497
 
498
+ # The :undef symbol should not be converted when nested in arrays or hashes
499
+ def convert2_Symbol(o, scope, undef_value)
500
+ o
501
+ end
502
+
479
503
  def convert_PAnyType(o, scope, undef_value)
480
504
  o
481
505
  end
506
+ alias :convert2_PAnyType :convert_PAnyType
482
507
 
483
508
  def convert_PCatalogEntryType(o, scope, undef_value)
484
509
  # Since 4x does not support dynamic scoping, all names are absolute and can be
@@ -489,6 +514,7 @@ module Puppet::Pops::Evaluator::Runtime3Support
489
514
 
490
515
  Puppet::Resource.new(*catalog_type_to_split_type_title(o))
491
516
  end
517
+ alias :convert2_PCatalogEntryType :convert_PCatalogEntryType
492
518
 
493
519
  private
494
520