Skip to content
Permalink
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)
"'#{param.name}' is not a valid relationship to a capability",
param.file, param.line)
end
elsif Puppet[:strict] != :off
# all other relationships requires the referenced resource to exist when mode is strict
else
# 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 '#{param.name.to_s}'"
if Puppet[:strict] == :error
raise CatalogValidationError.new(msg, param.file, param.line)
else
Puppet.warn_once(:undefined_resources, r.to_s, msg, param.file, param.line)
end
raise CatalogValidationError.new(msg, param.file, param.line)
end
end
end

0 comments on commit 3577fc9

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