Skip to content

Commit

Permalink
Merge pull request #5981 from hlindberg/PUP-7660_virtual-resources-sh…
Browse files Browse the repository at this point in the history
…ould-not-have-relationships-validated

(PUP-7660) Virtual resources should not have relationships validated
  • Loading branch information
hlindberg authored Jun 14, 2017
2 parents 79a2200 + 9ae862a commit 3b8cc79
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class CatalogValidator::RelationshipValidator < CatalogValidator
def validate
catalog.resources.each do |resource|
next unless resource.is_a?(Puppet::Parser::Resource)
next if resource.virtual?
resource.eachparam do |param|
pclass = Puppet::Type.metaparamclass(param.name)
validate_relationship(param) if !pclass.nil? && pclass < Puppet::Type::RelationshipMetaparam
Expand Down
17 changes: 17 additions & 0 deletions spec/integration/parser/compiler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,23 @@ class foo::bar::baz {
}.to raise_error(/Could not find resource 'Notify\[tooth_fairy\]' in parameter '#{meta_param}'/)
end
end

it 'is not reported for virtual resources' do
expect {
compile_to_catalog(<<-PP)
@notify{ x : require => Notify[tooth_fairy] }
PP
}.to_not raise_error
end

it 'is reported for a realized virtual resources' do
expect {
compile_to_catalog(<<-PP)
@notify{ x : require => Notify[tooth_fairy] }
realize(Notify['x'])
PP
}.to raise_error(/Could not find resource 'Notify\[tooth_fairy\]' in parameter 'require'/)
end
end

describe "relationships can be formed" do
Expand Down

0 comments on commit 3b8cc79

Please sign in to comment.