puppet 4.5.0 → 4.5.1

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.

@@ -5,4 +5,4 @@ modules that are installed globally (normally in /etc/puppetlabs/code/modules) f
5
5
  puppet master.
6
6
 
7
7
  For more information see
8
- https://docs.puppetlabs.com/puppet/latest/reference/environments.html
8
+ https://docs.puppet.com/puppet/latest/reference/environments.html
@@ -25,6 +25,6 @@ module Puppet::DataProviders
25
25
 
26
26
  def self.lookup_adapter(lookup_invocation)
27
27
  assert_loaded()
28
- LookupAdapter.adapt(lookup_invocation.scope.environment)
28
+ LookupAdapter.adapt(lookup_invocation.scope.compiler)
29
29
  end
30
30
  end
@@ -1,6 +1,8 @@
1
- # A LookupAdapter is a specialized DataAdapter that uses its hash to store module providers. It also remembers the environment
2
- # that it is attached to and maintains a cache of _lookup options_ retrieved from its data providers.
1
+ # A LookupAdapter is a specialized DataAdapter that uses its hash to store module providers. It also remembers the compiler
2
+ # that it is attached to and maintains a cache of _lookup options_ retrieved from the data providers associated with the
3
+ # compiler's environment.
3
4
  #
5
+ # @api private
4
6
  class Puppet::DataProviders::LookupAdapter < Puppet::DataProviders::DataAdapter
5
7
 
6
8
  LOOKUP_OPTIONS = Puppet::Pops::Lookup::LOOKUP_OPTIONS
@@ -9,13 +11,13 @@ class Puppet::DataProviders::LookupAdapter < Puppet::DataProviders::DataAdapter
9
11
  HASH = 'hash'.freeze
10
12
  MERGE = 'merge'.freeze
11
13
 
12
- def self.create_adapter(env)
13
- new(env)
14
+ def self.create_adapter(compiler)
15
+ new(compiler)
14
16
  end
15
17
 
16
- def initialize(env)
18
+ def initialize(compiler)
17
19
  super()
18
- @env = env
20
+ @compiler = compiler
19
21
  @lookup_options = {}
20
22
  end
21
23
 
@@ -77,7 +79,7 @@ class Puppet::DataProviders::LookupAdapter < Puppet::DataProviders::DataAdapter
77
79
  lookup_invocation.with(:global, terminus) do
78
80
  catch(:no_such_key) do
79
81
  return lookup_invocation.report_found(name, Puppet::DataBinding.indirection.find(name,
80
- { :environment => @env, :variables => lookup_invocation.scope, :merge => merge_strategy }))
82
+ { :environment => environment, :variables => lookup_invocation.scope, :merge => merge_strategy }))
81
83
  end
82
84
  lookup_invocation.report_not_found(name)
83
85
  throw :no_such_key
@@ -101,7 +103,7 @@ class Puppet::DataProviders::LookupAdapter < Puppet::DataProviders::DataAdapter
101
103
  throw :no_such_key if module_name.nil?
102
104
 
103
105
  lookup_invocation.with(:module, module_name) do
104
- if @env.module(module_name).nil?
106
+ if environment.module(module_name).nil?
105
107
  lookup_invocation.report_module_not_found
106
108
  throw :no_such_key
107
109
  end
@@ -157,7 +159,7 @@ class Puppet::DataProviders::LookupAdapter < Puppet::DataProviders::DataAdapter
157
159
  meta_invocation = Puppet::Pops::Lookup::Invocation.new(lookup_invocation.scope)
158
160
  meta_invocation.top_key = lookup_invocation.top_key
159
161
  env_opts = env_lookup_options(meta_invocation, merge_strategy)
160
- unless module_name.nil? || @env.module(module_name).nil?
162
+ unless module_name.nil? || environment.module(module_name).nil?
161
163
  catch(:no_such_key) do
162
164
  meta_invocation.module_name = module_name
163
165
  options = module_provider(module_name).lookup(LOOKUP_OPTIONS, meta_invocation, merge_strategy)
@@ -168,7 +170,7 @@ class Puppet::DataProviders::LookupAdapter < Puppet::DataProviders::DataAdapter
168
170
  env_opts
169
171
  end
170
172
 
171
- # Retrieve and cache lookup options specific to the environment that this adapter is attached to (i.e. a merge
173
+ # Retrieve and cache lookup options specific to the environment of the compiler that this adapter is attached to (i.e. a merge
172
174
  # of global and environment lookup options).
173
175
  def env_lookup_options(meta_invocation, merge_strategy)
174
176
  if !instance_variable_defined?(:@env_lookup_options)
@@ -214,9 +216,9 @@ class Puppet::DataProviders::LookupAdapter < Puppet::DataProviders::DataAdapter
214
216
  service = injector.lookup(nil, service_type, service_name)
215
217
  provider = service[provider_name]
216
218
  unless provider
217
- raise Puppet::Error.new("Environment '#{@env.name}', cannot find module_data_provider '#{provider_name}'")
219
+ raise Puppet::Error.new("Environment '#{environment.name}', cannot find module_data_provider '#{provider_name}'")
218
220
  end
219
- # Provider is configured per module but cached using environment life cycle so it must be cloned
221
+ # Provider is configured per module but cached using compiler life cycle so it must be cloned
220
222
  provider.clone
221
223
  end
222
224
 
@@ -227,7 +229,7 @@ class Puppet::DataProviders::LookupAdapter < Puppet::DataProviders::DataAdapter
227
229
  return EnvironmentDataProvider.new() unless injector
228
230
 
229
231
  # Get the name of the data provider from the environment's configuration and find the bound implementation
230
- provider_name = @env.configuration.environment_data_provider
232
+ provider_name = environment.configuration.environment_data_provider
231
233
  service_type = Registry.hash_of_environment_data_providers
232
234
  service_name = ENV_DATA_PROVIDERS_KEY
233
235
 
@@ -235,7 +237,7 @@ class Puppet::DataProviders::LookupAdapter < Puppet::DataProviders::DataAdapter
235
237
  service = injector.lookup(nil, service_type, service_name)
236
238
  provider = service[provider_name]
237
239
  unless provider
238
- raise Puppet::Error.new("Environment '#{@env.name}', cannot find environment_data_provider '#{provider_name}'")
240
+ raise Puppet::Error.new("Environment '#{environment.name}', cannot find environment_data_provider '#{provider_name}'")
239
241
  end
240
242
  provider
241
243
  end
@@ -244,4 +246,9 @@ class Puppet::DataProviders::LookupAdapter < Puppet::DataProviders::DataAdapter
244
246
  qual_index = name.index('::')
245
247
  qual_index.nil? ? nil : name[0..qual_index-1]
246
248
  end
249
+
250
+ # @return [Puppet::Node::Environment] the environment of the compiler that this adapter is associated with
251
+ def environment
252
+ @compiler.environment
253
+ end
247
254
  end
@@ -308,7 +308,7 @@ module Puppet
308
308
 
309
309
  This setting must have a value set to enable **directory environments.** The
310
310
  recommended value is `$codedir/environments`. For more details, see
311
- https://docs.puppetlabs.com/puppet/latest/reference/environments.html",
311
+ <https://docs.puppet.com/puppet/latest/reference/environments.html>",
312
312
  :type => :path,
313
313
  },
314
314
  :always_cache_features => {
@@ -1077,7 +1077,7 @@ EOT
1077
1077
  directory environments instead. If you need to use something other than the
1078
1078
  environment's `manifests` directory as the main manifest, you can set
1079
1079
  `manifest` in environment.conf. For more info, see
1080
- https://docs.puppetlabs.com/puppet/latest/reference/environments.html",
1080
+ <https://docs.puppet.com/puppet/latest/reference/environments.html>",
1081
1081
  },
1082
1082
  :modulepath => {
1083
1083
  :default => "",
@@ -1091,7 +1091,7 @@ EOT
1091
1091
  directory environments instead. If you need to use something other than the
1092
1092
  default modulepath of `<ACTIVE ENVIRONMENT'S MODULES DIR>:$basemodulepath`,
1093
1093
  you can set `modulepath` in environment.conf. For more info, see
1094
- https://docs.puppetlabs.com/puppet/latest/reference/environments.html",
1094
+ <https://docs.puppet.com/puppet/latest/reference/environments.html>",
1095
1095
  },
1096
1096
  :config_version => {
1097
1097
  :default => "",
@@ -1103,7 +1103,7 @@ EOT
1103
1103
  Setting a global value for config_version in puppet.conf is not allowed
1104
1104
  (but it can be overridden from the commandline). Please set a
1105
1105
  per-environment value in environment.conf instead. For more info, see
1106
- https://docs.puppetlabs.com/puppet/latest/reference/environments.html",
1106
+ <https://docs.puppet.com/puppet/latest/reference/environments.html>",
1107
1107
  }
1108
1108
  )
1109
1109
 
@@ -1215,7 +1215,7 @@ EOT
1215
1215
  These are the modules that will be used by _all_ environments. Note that
1216
1216
  the `modules` directory of the active environment will have priority over
1217
1217
  any global directories. For more info, see
1218
- https://docs.puppetlabs.com/puppet/latest/reference/environments.html",
1218
+ <https://docs.puppet.com/puppet/latest/reference/environments.html>",
1219
1219
  },
1220
1220
  :ssl_client_header => {
1221
1221
  :default => "HTTP_X_CLIENT_DN",
@@ -27,7 +27,7 @@ class Puppet::Parser::Compiler
27
27
  errors.each { |e| Puppet.err(e) } if errors.size > 1
28
28
  errmsg = [
29
29
  "Compilation has been halted because: #{errors.first}",
30
- "For more information, see https://docs.puppetlabs.com/puppet/latest/reference/environments.html",
30
+ "For more information, see https://docs.puppet.com/puppet/latest/reference/environments.html",
31
31
  ]
32
32
  raise(Puppet::Error, errmsg.join(' '))
33
33
  end
@@ -82,7 +82,7 @@ module Runtime3Support
82
82
  # Must convert :undef back to nil - this can happen when an undefined variable is used in a
83
83
  # parameter's default value expression - there nil must be :undef to work with the rest of 3x.
84
84
  # Now that the value comes back to 4x it is changed to nil.
85
- return :undef == x ? nil : x
85
+ return :undef.equal?(x) ? nil : x
86
86
  }
87
87
  # It is always ok to reference numeric variables even if they are not assigned. They are always undef
88
88
  # if not set by a match expression.
@@ -745,6 +745,34 @@ module Types
745
745
  end
746
746
  end
747
747
 
748
+ def describe_PArrayType(expected, actual, path)
749
+ descriptions = []
750
+ element_type = expected.element_type || PAnyType::DEFAULT
751
+ if actual.is_a?(PTupleType)
752
+ types = actual.types
753
+ expected_size = expected.size_type || PCollectionType::DEFAULT_SIZE
754
+ actual_size = actual.size_type || PIntegerType.new(types.size, types.size)
755
+ if expected_size.assignable?(actual_size)
756
+ types.each_with_index do |type, idx|
757
+ descriptions.concat(describe(element_type, type, path + [ArrayPathElement.new(idx)])) unless element_type.assignable?(type)
758
+ end
759
+ else
760
+ descriptions << SizeMismatch.new(path, expected_size, actual_size)
761
+ end
762
+ elsif actual.is_a?(PArrayType)
763
+ expected_size = expected.size_type
764
+ actual_size = actual.size_type || PCollectionType::DEFAULT_SIZE
765
+ if expected_size.nil? || expected_size.assignable?(actual_size)
766
+ descriptions << TypeMismatch.new(path, expected, actual)
767
+ else
768
+ descriptions << SizeMismatch.new(path, expected_size, actual_size)
769
+ end
770
+ else
771
+ descriptions << TypeMismatch.new(path, expected, actual)
772
+ end
773
+ descriptions
774
+ end
775
+
748
776
  def describe_PHashType(expected, actual, path)
749
777
  descriptions = []
750
778
  key_type = expected.key_type || PAnyType::DEFAULT
@@ -761,6 +789,14 @@ module Types
761
789
  else
762
790
  descriptions << SizeMismatch.new(path, expected_size, actual_size)
763
791
  end
792
+ elsif actual.is_a?(PHashType)
793
+ expected_size = expected.size_type
794
+ actual_size = actual.size_type || PCollectionType::DEFAULT_SIZE
795
+ if expected_size.nil? || expected_size.assignable?(actual_size)
796
+ descriptions << TypeMismatch.new(path, expected, actual)
797
+ else
798
+ descriptions << SizeMismatch.new(path, expected_size, actual_size)
799
+ end
764
800
  else
765
801
  descriptions << TypeMismatch.new(path, expected, actual)
766
802
  end
@@ -915,6 +951,8 @@ module Types
915
951
  describe_PHashType(expected, actual, path)
916
952
  when PTupleType
917
953
  describe_PTupleType(expected, actual, path)
954
+ when PArrayType
955
+ describe_PArrayType(expected, actual, path)
918
956
  when PCallableType
919
957
  describe_PCallableType(expected, actual, path)
920
958
  when POptionalType
@@ -292,20 +292,6 @@ class PAnyType < TypedModelObject
292
292
  end
293
293
  end
294
294
 
295
-
296
- # Transform size_type to min, max
297
- # if size_type == nil the constraint is 1,1
298
- # if size_type.from == nil min size = 1
299
- # if size_type.to == nil max size == Infinity
300
- #
301
- # @api private
302
- def type_to_range(size_type)
303
- return [1,1] if size_type.nil?
304
- from = size_type.from
305
- to = size_type.to
306
- [from.nil? ? 1 : from, to.nil? ? Float::INFINITY : to]
307
- end
308
-
309
295
  # Applies a transformation by sending the given _method_ and _method_args_ to each of the types of the given array
310
296
  # and collecting the results in a new array. If all transformation calls returned the type instance itself (i.e. no
311
297
  # transformation took place), then this method will return `self`. If a transformation did occur, then this method
@@ -606,7 +592,7 @@ class PEnumType < PScalarType
606
592
  attr_reader :values
607
593
 
608
594
  def initialize(values)
609
- @values = values.sort.freeze
595
+ @values = values.uniq.sort.freeze
610
596
  end
611
597
 
612
598
  # Returns Enumerator if no block is given, otherwise, calls the given
@@ -1086,10 +1072,13 @@ class PCollectionType < PAnyType
1086
1072
  (@size_type || DEFAULT_SIZE).assignable?(o.size_type || DEFAULT_SIZE, guard)
1087
1073
  when PTupleType
1088
1074
  # compute the tuple's min/max size, and check if that size matches
1089
- from, to = type_to_range(o.size_type)
1090
- from = o.types.size - 1 + from
1091
- to = o.types.size - 1 + to
1092
- (@size_type || DEFAULT_SIZE).assignable?(PIntegerType.new(from, to), guard)
1075
+ size_s = size_type || DEFAULT_SIZE
1076
+ size_o = o.size_type
1077
+ if size_o.nil?
1078
+ type_count = o.types.size
1079
+ size_o = PIntegerType.new(type_count, type_count)
1080
+ end
1081
+ size_s.assignable?(size_o)
1093
1082
  when PStructType
1094
1083
  from = to = o.elements.size
1095
1084
  (@size_type || DEFAULT_SIZE).assignable?(PIntegerType.new(from, to), guard)
@@ -2008,26 +1997,14 @@ class PArrayType < PCollectionType
2008
1997
  # tuple can be assigned.
2009
1998
  return true if s_entry.nil?
2010
1999
 
2011
- return false unless o.types.all? {|o_element_t| s_entry.assignable?(o_element_t, guard) }
2012
- o_regular = o.types[0..-2]
2013
- o_ranged = o.types[-1]
2014
- o_from, o_to = type_to_range(o.size_type)
2015
- o_required = o_regular.size + o_from
2016
-
2017
- # array type may be size constrained
2000
+ o_types = o.types
2018
2001
  size_s = size_type || DEFAULT_SIZE
2019
- min, max = size_s.range
2020
- # Tuple with fewer min entries can not be assigned
2021
- return false if o_required < min
2022
- # Tuple with more optionally available entries can not be assigned
2023
- return false if o_regular.size + o_to > max
2024
- # each tuple type must be assignable to the element type
2025
- o_required.times do |index|
2026
- o_entry = tuple_entry_at(o, o_to, index)
2027
- return false unless s_entry.assignable?(o_entry, guard)
2002
+ size_o = o.size_type
2003
+ if size_o.nil?
2004
+ type_count = o_types.size
2005
+ size_o = PIntegerType.new(type_count, type_count)
2028
2006
  end
2029
- # ... and so must the last, possibly optional (ranged) type
2030
- s_entry.assignable?(o_ranged)
2007
+ size_s.assignable?(size_o) && o_types.all? { |ot| s_entry.assignable?(ot, guard) }
2031
2008
  elsif o.is_a?(PArrayType)
2032
2009
  super && (s_entry.nil? || s_entry.assignable?(o.element_type, guard))
2033
2010
  else
@@ -82,7 +82,7 @@ private
82
82
  def unique_sections_in(ini, file, allowed_section_names)
83
83
  ini.section_lines.collect do |section|
84
84
  if !allowed_section_names.empty? && !allowed_section_names.include?(section.name)
85
- raise(Puppet::Error, "Illegal section '#{section.name}' in config file #{file} at line #{section.line_number}. The only valid puppet.conf sections are: [#{allowed_section_names.join(", ")}]. Please use the directory environments feature to specify environments. (See https://docs.puppetlabs.com/puppet/latest/reference/environments.html)")
85
+ raise(Puppet::Error, "Illegal section '#{section.name}' in config file #{file} at line #{section.line_number}. The only valid puppet.conf sections are: [#{allowed_section_names.join(", ")}]. Please use the directory environments feature to specify environments. (See https://docs.puppet.com/puppet/latest/reference/environments.html)")
86
86
  end
87
87
  section.name
88
88
  end.uniq
@@ -2132,8 +2132,10 @@ end
2132
2132
 
2133
2133
  # Collect the current prereqs
2134
2134
  list.each { |dep|
2135
+ next if dep.nil?
2136
+
2135
2137
  # Support them passing objects directly, to save some effort.
2136
- unless dep.is_a? Puppet::Type
2138
+ unless dep.is_a?(Puppet::Type)
2137
2139
  # Skip autorelation that we aren't managing
2138
2140
  unless dep = rel_catalog.resource(type, dep)
2139
2141
  next
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
  module Puppet
10
- PUPPETVERSION = '4.5.0'
10
+ PUPPETVERSION = '4.5.1'
11
11
 
12
12
  ##
13
13
  # version is a public API method intended to always provide a fast and
@@ -1 +1,2 @@
1
1
  one::test::param_b: module data param_b is 200
2
+ one::my_var: 'In name.yaml'
@@ -1,6 +1,8 @@
1
1
  ---
2
2
  :version: 4
3
3
  :hierarchy:
4
+ - :name: "%{my_fact}"
5
+ :backend: yaml
4
6
  - :name: "name"
5
7
  :backend: yaml
6
8
  - :name: "one path"
@@ -28,14 +28,18 @@ describe "when using a hiera data provider" do
28
28
  end
29
29
 
30
30
  def compile_and_get_notifications(environment, code = nil)
31
- compile(environment, code).resources.map(&:ref).select { |r| r.start_with?('Notify[') }.map { |r| r[7..-2] }
31
+ extract_notifications(compile(environment, code))
32
32
  end
33
33
 
34
34
  def compile(environment, code = nil)
35
35
  Puppet[:code] = code if code
36
36
  node = Puppet::Node.new("testnode", :facts => facts, :environment => environment)
37
37
  compiler = Puppet::Parser::Compiler.new(node)
38
- block_given? ? compiler.compile() { |catalog| yield(compiler); catalog } : compiler.compile()
38
+ block_given? ? compiler.compile { |catalog| yield(compiler); catalog } : compiler.compile
39
+ end
40
+
41
+ def extract_notifications(catalog)
42
+ catalog.resources.map(&:ref).select { |r| r.start_with?('Notify[') }.map { |r| r[7..-2] }
39
43
  end
40
44
 
41
45
  it 'uses default configuration for environment and module data' do
@@ -147,6 +151,22 @@ describe "when using a hiera data provider" do
147
151
  expect(resources).to include('Value from interpolation with alias')
148
152
  end
149
153
 
154
+ it 'uses compiler lifecycle for caching' do
155
+ Puppet[:code] = 'notify{lookup(one::my_var):}'
156
+ node = Puppet::Node.new('testnode', :facts => facts, :environment => 'hiera_module_config')
157
+
158
+ compiler = Puppet::Parser::Compiler.new(node)
159
+ compiler.topscope['my_fact'] = 'server1'
160
+ expect(extract_notifications(compiler.compile)).to include('server1')
161
+
162
+ compiler = Puppet::Parser::Compiler.new(node)
163
+ compiler.topscope['my_fact'] = 'server2'
164
+ expect(extract_notifications(compiler.compile)).to include('server2')
165
+
166
+ compiler = Puppet::Parser::Compiler.new(node)
167
+ expect(extract_notifications(compiler.compile)).to include('In name.yaml')
168
+ end
169
+
150
170
  it 'traps endless interpolate recursion' do
151
171
  expect do
152
172
  compile_and_get_notifications('hiera_misc', '$r1 = "%{r2}" $r2 = "%{r1}" notify{lookup(recursive):}')
@@ -806,6 +806,18 @@ describe 'The type calculator' do
806
806
  expect(empty_array_t).to be_assignable_to(array_t(string_t))
807
807
  expect(empty_array_t).to be_assignable_to(array_t(integer_t))
808
808
  end
809
+
810
+ it 'A Tuple is assignable to an array' do
811
+ expect(tuple_t(String)).to be_assignable_to(array_t(String))
812
+ end
813
+
814
+ it 'A Tuple with <n> elements is assignable to an array with min size <n>' do
815
+ expect(tuple_t(String,String)).to be_assignable_to(array_t(String, range_t(2, :default)))
816
+ end
817
+
818
+ it 'A Tuple with <n> elements where the last 2 are optional is assignable to an array with size <n> - 2' do
819
+ expect(constrained_tuple_t(range_t(2, :default), String,String,String,String)).to be_assignable_to(array_t(String, range_t(2, :default)))
820
+ end
809
821
  end
810
822
 
811
823
  context 'for Hash, such that' do
@@ -25,7 +25,7 @@ describe 'the type mismatch describer' do
25
25
  }
26
26
  f(['a', 23])
27
27
  CODE
28
- expect { eval_and_collect_notices(code) }.to raise_error(Puppet::Error, /expects an Array\[String\] value, got Tuple\[String, Integer\]/)
28
+ expect { eval_and_collect_notices(code) }.to raise_error(Puppet::Error, /'f' parameter 'h' index 1 expects a String value, got Integer/)
29
29
  end
30
30
 
31
31
  it 'will not report details for a mismatch between an array and a struct' do
@@ -48,6 +48,26 @@ describe 'the type mismatch describer' do
48
48
  expect { eval_and_collect_notices(code) }.to raise_error(Puppet::Error, /expects a Hash value, got Tuple/)
49
49
  end
50
50
 
51
+ it 'will report an array size mismatch' do
52
+ code = <<-CODE
53
+ function f(Array[String,1,default] $h) {
54
+ $h[0]
55
+ }
56
+ f([])
57
+ CODE
58
+ expect { eval_and_collect_notices(code) }.to raise_error(Puppet::Error, /expects size to be at least 1, got 0/)
59
+ end
60
+
61
+ it 'will report a hash size mismatch' do
62
+ code = <<-CODE
63
+ function f(Hash[String,String,1,default] $h) {
64
+ $h['a']
65
+ }
66
+ f({})
67
+ CODE
68
+ expect { eval_and_collect_notices(code) }.to raise_error(Puppet::Error, /expects size to be at least 1, got 0/)
69
+ end
70
+
51
71
  it 'will include the aliased type when reporting a mismatch that involves an alias' do
52
72
  code = <<-CODE
53
73
  type UnprivilegedPort = Integer[1024,65537]
@@ -153,6 +153,22 @@ describe 'Puppet Type System' do
153
153
  end
154
154
  end
155
155
 
156
+ context 'Enum type' do
157
+ it 'sorts its entries' do
158
+ code = <<-CODE
159
+ Enum[c,b,a].each |$e| { notice $e }
160
+ CODE
161
+ expect(eval_and_collect_notices(code)).to eq(['a', 'b', 'c'])
162
+ end
163
+
164
+ it 'makes entries unique' do
165
+ code = <<-CODE
166
+ Enum[a,b,c,b,a].each |$e| { notice $e }
167
+ CODE
168
+ expect(eval_and_collect_notices(code)).to eq(['a', 'b', 'c'])
169
+ end
170
+ end
171
+
156
172
  context 'Iterable type' do
157
173
  it 'can be parameterized with element type' do
158
174
  code = <<-CODE
@@ -393,6 +393,24 @@ describe Puppet::Type, :unless => Puppet.features.microsoft_windows? do
393
393
  expect(relationship_graph.edges_between(src,dst).first.event).to eq(:NONE)
394
394
  end
395
395
 
396
+ it 'should not fail autorequire contains undef entries' do
397
+ type = Puppet::Type.newtype(:autorelation_two) do
398
+ newparam(:name) { isnamevar }
399
+ autorequire(:autorelation_one) { [nil, 'foo'] }
400
+ end
401
+
402
+ relationship_graph = compile_to_relationship_graph(<<-MANIFEST)
403
+ autorelation_one { 'foo': }
404
+ autorelation_two { 'bar': }
405
+ MANIFEST
406
+
407
+ src = relationship_graph.vertices.select{ |x| x.ref.to_s == 'Autorelation_one[foo]' }.first
408
+ dst = relationship_graph.vertices.select{ |x| x.ref.to_s == 'Autorelation_two[bar]' }.first
409
+
410
+ expect(relationship_graph.edge?(src,dst)).to be_truthy
411
+ expect(relationship_graph.edges_between(src,dst).first.event).to eq(:NONE)
412
+ end
413
+
396
414
  it "should be able to autosubscribe resources" do
397
415
  type = Puppet::Type.newtype(:autorelation_two) do
398
416
  newparam(:name) { isnamevar }
@@ -411,6 +429,24 @@ describe Puppet::Type, :unless => Puppet.features.microsoft_windows? do
411
429
  expect(relationship_graph.edges_between(src,dst).first.event).to eq(:ALL_EVENTS)
412
430
  end
413
431
 
432
+ it 'should not fail if autosubscribe contains undef entries' do
433
+ type = Puppet::Type.newtype(:autorelation_two) do
434
+ newparam(:name) { isnamevar }
435
+ autosubscribe(:autorelation_one) { [nil, 'foo'] }
436
+ end
437
+
438
+ relationship_graph = compile_to_relationship_graph(<<-MANIFEST)
439
+ autorelation_one { 'foo': }
440
+ autorelation_two { 'bar': }
441
+ MANIFEST
442
+
443
+ src = relationship_graph.vertices.select{ |x| x.ref.to_s == 'Autorelation_one[foo]' }.first
444
+ dst = relationship_graph.vertices.select{ |x| x.ref.to_s == 'Autorelation_two[bar]' }.first
445
+
446
+ expect(relationship_graph.edge?(src,dst)).to be_truthy
447
+ expect(relationship_graph.edges_between(src,dst).first.event).to eq(:ALL_EVENTS)
448
+ end
449
+
414
450
  it "should be able to autobefore resources" do
415
451
  type = Puppet::Type.newtype(:autorelation_two) do
416
452
  newparam(:name) { isnamevar }
@@ -429,6 +465,24 @@ describe Puppet::Type, :unless => Puppet.features.microsoft_windows? do
429
465
  expect(relationship_graph.edges_between(src,dst).first.event).to eq(:NONE)
430
466
  end
431
467
 
468
+ it "should not fail when autobefore contains undef entries" do
469
+ type = Puppet::Type.newtype(:autorelation_two) do
470
+ newparam(:name) { isnamevar }
471
+ autobefore(:autorelation_one) { [nil, 'foo'] }
472
+ end
473
+
474
+ relationship_graph = compile_to_relationship_graph(<<-MANIFEST)
475
+ autorelation_one { 'foo': }
476
+ autorelation_two { 'bar': }
477
+ MANIFEST
478
+
479
+ src = relationship_graph.vertices.select{ |x| x.ref.to_s == 'Autorelation_two[bar]' }.first
480
+ dst = relationship_graph.vertices.select{ |x| x.ref.to_s == 'Autorelation_one[foo]' }.first
481
+
482
+ expect(relationship_graph.edge?(src,dst)).to be_truthy
483
+ expect(relationship_graph.edges_between(src,dst).first.event).to eq(:NONE)
484
+ end
485
+
432
486
  it "should be able to autonotify resources" do
433
487
  type = Puppet::Type.newtype(:autorelation_two) do
434
488
  newparam(:name) { isnamevar }
@@ -446,6 +500,24 @@ describe Puppet::Type, :unless => Puppet.features.microsoft_windows? do
446
500
  expect(relationship_graph.edge?(src,dst)).to be_truthy
447
501
  expect(relationship_graph.edges_between(src,dst).first.event).to eq(:ALL_EVENTS)
448
502
  end
503
+
504
+ it 'should not fail if autonotify contains undef entries' do
505
+ type = Puppet::Type.newtype(:autorelation_two) do
506
+ newparam(:name) { isnamevar }
507
+ autonotify(:autorelation_one) { [nil, 'foo'] }
508
+ end
509
+
510
+ relationship_graph = compile_to_relationship_graph(<<-MANIFEST)
511
+ autorelation_one { 'foo': }
512
+ autorelation_two { 'bar': }
513
+ MANIFEST
514
+
515
+ src = relationship_graph.vertices.select{ |x| x.ref.to_s == 'Autorelation_two[bar]' }.first
516
+ dst = relationship_graph.vertices.select{ |x| x.ref.to_s == 'Autorelation_one[foo]' }.first
517
+
518
+ expect(relationship_graph.edge?(src,dst)).to be_truthy
519
+ expect(relationship_graph.edges_between(src,dst).first.event).to eq(:ALL_EVENTS)
520
+ end
449
521
  end
450
522
  end
451
523
 
@@ -9,6 +9,22 @@ describe Symbol do
9
9
  $unique_warnings.delete('symbol_comparison') if $unique_warnings
10
10
  end
11
11
 
12
+ it 'should have an equal? that is not true for a string with same letters' do
13
+ symbol = :undef
14
+ expect(symbol).to_not equal('undef')
15
+ end
16
+
17
+ it "should have an eql? that is not true for a string with same letters" do
18
+ symbol = :undef
19
+ expect(symbol).to_not eql('undef')
20
+ end
21
+
22
+ it "should have an == that is not true for a string with same letters" do
23
+ pending "JRuby is incompatible with MRI - Cannot test this on JRuby" if RUBY_PLATFORM == 'java'
24
+ symbol = :undef
25
+ expect(symbol == 'undef').to_not be(true)
26
+ end
27
+
12
28
  it "should return self from #intern" do
13
29
  symbol = :foo
14
30
  expect(symbol).to equal symbol.intern
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.5.0
4
+ version: 4.5.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-05-20 00:00:00.000000000 Z
12
+ date: 2016-06-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: facter
@@ -1629,6 +1629,8 @@ files:
1629
1629
  - spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/name.yaml
1630
1630
  - spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/single.yaml
1631
1631
  - spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/second.json
1632
+ - spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/server2.yaml
1633
+ - spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/server1.yaml
1632
1634
  - spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/first.json
1633
1635
  - spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/metadata.json
1634
1636
  - spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/hiera.yaml
@@ -2859,6 +2861,8 @@ test_files:
2859
2861
  - spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/name.yaml
2860
2862
  - spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/single.yaml
2861
2863
  - spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/second.json
2864
+ - spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/server2.yaml
2865
+ - spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/server1.yaml
2862
2866
  - spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/data1/first.json
2863
2867
  - spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/metadata.json
2864
2868
  - spec/fixtures/unit/data_providers/environments/hiera_module_config/modules/one/hiera.yaml