This proposal attempts to solve two problems:
- The fact that it is hard to create Resources and Providers outside the
Chef::
namespace - The fact that classes in the
Chef::Resource
andChef::Provider
namespace (like File) make it harder to write providers (callingFile.exists?
fails because it grabsChef::Provider::File
instead of::File
)
All resources will need to declare what they provide with the "register_resource" declaration, which will be extended with the ability to specify the Provider class.
class Blah::Resource::ArmAndHammer < Chef::Resource
register_resource 'baking_soda', Blah::Provider::ArmAndHammer
end
If the resource name is not specified, it will be inferred from the class name:
class Blah::Resource::ArmAndHammer < Chef::Resource
register_resource Blah::Provider::ArmAndHammer
end
If the Provider class is not specified, it will look to see if the Resource class is under a directory named "Resource", and look for a Provider class with the same name in the corresponding Provider class (in this case, Blah::Resource::MyResource
will have a default provider Blah::Provider::MyResource
).
class Blah::Resource::ArmAndHammer < Chef::Resource
register_resource 'arm_and_hammer'
end
If the class is in a subclass of Chef::Resource
and exists in <any namespace>::Resource
, it will automatically get a standard_resource declaration with no parameters, so there is no decoration needed.
If two resources provide the same thing on the same platform, the winner is undefined.
LWRPs are presently housed in Chef::Resource and Chef::Provider. We will add them into the "ChefLWRP" module (see this line and add a "provides" directive to point them at the right place.
Once the former is done, all Chef standard resources and providers will move from Chef::Provider
and Chef::Resource
to Chef::Core::Provider
and Chef::Core::Resource
.
Yeah, i think I'm +1 on ChefLWRP::FooBarBaz rather than Class:0xblahblahblah
Can you dynamically find the subclasses of Chef::Resource and construct a list of those and map them based on the terminal class and get rid of the need for 'provides'?