puppetlabs/puppet — pull request #2549 by ffrank (2014-04-18 00:49:45+00:00)
Title: (PUP-2298) add support for Type#in_valid_catalog? methods to transaction

In order to deprecate the builtin defined function (which is often abused
to work around resource duplication between modules) it is desirable to
add resource constraints to the language. An easy approach to allowing such
constraints to work is to add them as a special resource type that does not
take effect during the transaction, but fails the whole catalog in case of
validation failure.

To make this possible, add a lookup for the Type#in_valid_catalog? method
to Transaction#evaluate, in between the generation of additional resources
(which may affect the outcome of catalog consistency checks) and the start
of resource evaluation / graph traversal. Call the in_valid_catalog? method
when found, and fail the catalog if any of them return a false value.