- From: David Petzel <
>
- To: Chef Dev <
>
- Subject: [chef-dev] LWRPBase and required attributes
- Date: Tue, 21 Jul 2015 10:59:11 -0400
I'm attempting to write an LWRP using the LWRPBase pattern. I'm using the Jenkins cookbook as my example. What I'm bumping into is that if I declare an attribute with the required true, its not actually being enforced. The only examples I can find using this pattern with a required attribute only have it set on the name attribute. In my case I have a couple extra attributes which are also required.
Is this a bug, by design, or might I be doing something wrong? Here is shortened version of what I have
class Chef
class Resource::MyResource < Resource::LWRPBase
identity_attr :myid
provides :my_resource
self.resource_name = :my_resource
actions :create, :delete
default_action :create
attribute :command, :kind_of => String, :required => true
end
end
So I whipped up a test which invokes this as this:
my_resource "blah" do
end
I was expecting a validation error, but it happily proceeded into my provider code and wrote a file to disk (without the necessary information).
Assuming this is a bug, whats the cleanest/appropriate way for me to enforce the requirement? I understand I can hack up some code to do this, but if there is an existing method or something I can call that does that in a standard way I'd prefer that.
Thanks
- [chef-dev] LWRPBase and required attributes, David Petzel, 07/21/2015
Archive powered by MHonArc 2.6.16.