puppetlabs/puppet — pull request #3269 by raphink (2014-11-03 11:37:12+00:00)
Title: [PUP-1486] Make the resources type more generic

This is an attempt to fix PUP-1486 by making the `resources` type more generic. In particular, the goal here is to remove anything specific to the the `user` type from the `resources` type definition.

Instead, this PR adds a new `newresourcesparam` method to `Puppet::Type` so each type can define their own parameters to be added to the `resources` type. It makes it possible for types to implement their own security features when purging resources.

This way, the `host` type could implement a `self.host_check` method along with an `unless_localhost` resource param so that purging `host` resources won't affect localhost entries.

I've encountered a few issues when trying to code this. The main one is obvious: in order to dynamically declare parameters for the `resources` type from other types, all other types need to be loaded beforehand. This is why I need to call `Puppet::Type#loadall` in there… which might not be the best solution.

Also, it also means that several types could try to add resources parameters with the same name. In this case, only the first definition will be added. The main goal here for me was to make this change backwards-compatible for the DSL users.