Skip to content
Browse files

(PUP-5659) Validate relationships formed via meta-parameter

Before this, a relationship formed via a meta-parameter was not
validated. This was bad because it meant that errors in manifests were
not detected during compilation and instead blew up much later when
applying the catalog.

Before this it was possible to use strict to control if a warning or
error should be emitted. Now a reference to a non existing resource is
always an error.
  • Loading branch information
hlindberg committed Mar 23, 2017
1 parent 19d596f commit 3577fc913373f05b6c58fd7389e097ba7271c147

File 1 of 2 in 3577fc9

@@ -26,18 +26,14 @@ def validate_relationship(param)
"'#{}' is not a valid relationship to a capability",
param.file, param.line)
elsif Puppet[:strict] != :off
# all other relationships requires the referenced resource to exist when mode is strict
# all other relationships requires the referenced resource to exist
refs = param.value.is_a?(Array) ? param.value.flatten : [param.value]
refs.each do |r|
next if r.nil? || r == :undef
unless catalog.resource(r.to_s)
msg = "Could not find resource '#{r.to_s}' in parameter '#{}'"
if Puppet[:strict] == :error
raise, param.file, param.line)
Puppet.warn_once(:undefined_resources, r.to_s, msg, param.file, param.line)
raise, param.file, param.line)

0 comments on commit 3577fc9

Please sign in to comment.
You can’t perform that action at this time.