File tree Expand file tree Collapse file tree 2 files changed +30
-3
lines changed
lib/puppet/parser/functions Expand file tree Collapse file tree 2 files changed +30
-3
lines changed Original file line number Diff line number Diff line change 5454 [ findresource ( type , title ) ]
5555 end
5656
57- resources . compact . each do |resource |
57+ resources . compact . each do |res |
58+ # If you call this from within a defined type, it will find itself
59+ next if res . to_s == resource . to_s
60+
5861 matches = params . map do |key , value |
5962 # eql? avoids bugs caused by monkeypatching in puppet
60- resource_is_undef = resource [ key ] . eql? ( :undef ) || resource [ key ] . nil?
63+ res_is_undef = res [ key ] . eql? ( :undef ) || res [ key ] . nil?
6164 value_is_undef = value . eql? ( :undef ) || value . nil?
62- ( resource_is_undef && value_is_undef ) || ( resource [ key ] == value )
65+ found_match = ( res_is_undef && value_is_undef ) || ( res [ key ] == value )
66+
67+ Puppet . debug ( "Matching resource is #{ res } " ) if found_match
68+
69+ found_match
6370 end
6471 ret = params . empty? || !matches . include? ( false )
6572
Original file line number Diff line number Diff line change 9494 }
9595 end
9696
97+ describe 'when called from within a defined type looking for a defined type of the same type' do
98+ let :pre_condition do
99+ <<-PRECOND
100+ define test::deftype(
101+ Optional $port = undef
102+ ) {
103+ if defined_with_params(Test::Deftype, { 'port' => $port }) {
104+ fail('Ruh Roh Shaggy')
105+ }
106+ }
107+
108+ test::deftype { 'foo': }
109+ test::deftype { 'bar': port => 200 }
110+ PRECOND
111+ end
112+
113+ # Testing to make sure that the internal logic handles this case via the pre_condition
114+ it { is_expected . to run . with_params ( 'NoOp[noop]' , { } ) . and_return ( false ) }
115+ end
116+
97117 describe 'when passed a class' do
98118 let :pre_condition do
99119 'class test () { } class { "test": }'
You can’t perform that action at this time.
0 commit comments