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 54
54
[ findresource ( type , title ) ]
55
55
end
56
56
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
+
58
61
matches = params . map do |key , value |
59
62
# 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?
61
64
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
63
70
end
64
71
ret = params . empty? || !matches . include? ( false )
65
72
Original file line number Diff line number Diff line change 94
94
}
95
95
end
96
96
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
+
97
117
describe 'when passed a class' do
98
118
let :pre_condition do
99
119
'class test () { } class { "test": }'
You can’t perform that action at this time.
0 commit comments