LWRP - attributes required


#1

Hey All,

Is it possible in the resource file of a LWRP to have attributes required for certain action type.

Exampe:

actions :foo, :bar

default_action :foo

attribute :name, :kind_of => String, :name_attribute => true
attribute :section, :kind_of => String, :required => true (only for :bar action)
attribute :item, :kind_of => String, :required => true (only for :foo action )
attribute :value, :kind_of => [String,Integer], :required => true

Is the :respond_to the right thing?

I tried with no success:

attribute :section, :kind_of => String, :required => true, :respond_to foo?

Wade Peacock
Cloud System Eng - Senior System Engineer/Automation | Vision Critical
direct +1.604.629.9358 mobile +1.604.363.8137
web visioncritical.comhttp://www.visioncritical.com/ | @VisionCritical on Twitterhttps://twitter.com/visioncritical | Visit Vision Critical on LinkedInhttp://www.linkedin.com/company/vision-critical

New York | London | Hong Kong | Vancouver | Paris | San Francisco | Sydney | Tokyo | Toronto | Cologne | Minneapolis | Chicago | Ottawa | Detroit
Click here to watch our clients share their Vision Critical successes: www.visioncritical.com/client-storieshttp://www.visioncritical.com/client-stories


#2

No, you must do that kind of processing in the provider. The resource
itself does not know what action you may or may not invoke on it
eventually when it is being built.

On 05/28/2015 10:40 AM, Wade Peacock wrote:

Hey All,

Is it possible in the resource file of a LWRP to have attributes
required for certain action type.

Exampe:

actions :foo, :bar

default_action :foo

attribute :name, :kind_of => String, :name_attribute => true

attribute :section, :kind_of => String, :required => true (only for
:bar action)

attribute :item, :kind_of => String, :required => true (only for :foo
action )

attribute :value, :kind_of => [String,Integer], :required => true

Is the :respond_to the right thing?

I tried with no success:

attribute :section, :kind_of => String, :required => true, :respond_to
foo?

Wade Peacock

Cloud System Eng - Senior System Engineer/Automation | Vision Critical

direct+1.604.629.9358 mobile+1.604.363.8137

webvisioncritical.com http://www.visioncritical.com/|
@VisionCritical on Twitter https://twitter.com/visioncritical| Visit
Vision Critical on LinkedIn
http://www.linkedin.com/company/vision-critical

New York | London | Hong Kong |Vancouver | Paris | San Francisco |
Sydney | Tokyo | Toronto | Cologne | Minneapolis | Chicago | Ottawa |
Detroit

//

/Click here to watch our clients share their Vision Critical
successes: //www.visioncritical.com/client-stories/
http://www.visioncritical.com/client-stories//


#3

That is what I figured.

I’ve got a solution that is working in there, but I was wondering if I could do it more elegantly.

Wade Peacock
Cloud System Eng - Senior System Engineer/Automation | Vision Critical
direct +1.604.629.9358 mobile +1.604.363.8137
web visioncritical.comhttp://www.visioncritical.com/ | @VisionCritical on Twitterhttps://twitter.com/visioncritical | Visit Vision Critical on LinkedInhttp://www.linkedin.com/company/vision-critical

New York | London | Hong Kong | Vancouver | Paris | San Francisco | Sydney | Tokyo | Toronto | Cologne | Minneapolis | Chicago | Ottawa | Detroit
Click here to watch our clients share their Vision Critical successes: www.visioncritical.com/client-storieshttp://www.visioncritical.com/client-stories

From: Lamont Granquist [mailto:lamont@chef.io]
Sent: Thursday, May 28, 2015 11:04 AM
To: chef@lists.opscode.com
Cc: Wade Peacock
Subject: Re: [chef] LWRP - attributes required

No, you must do that kind of processing in the provider. The resource itself does not know what action you may or may not invoke on it eventually when it is being built.
On 05/28/2015 10:40 AM, Wade Peacock wrote:
Hey All,

Is it possible in the resource file of a LWRP to have attributes required for certain action type.

Exampe:

actions :foo, :bar

default_action :foo

attribute :name, :kind_of => String, :name_attribute => true
attribute :section, :kind_of => String, :required => true (only for :bar action)
attribute :item, :kind_of => String, :required => true (only for :foo action )
attribute :value, :kind_of => [String,Integer], :required => true

Is the :respond_to the right thing?

I tried with no success:

attribute :section, :kind_of => String, :required => true, :respond_to foo?

Wade Peacock
Cloud System Eng - Senior System Engineer/Automation | Vision Critical
direct +1.604.629.9358 mobile +1.604.363.8137
web visioncritical.comhttp://www.visioncritical.com/ | @VisionCritical on Twitterhttps://twitter.com/visioncritical | Visit Vision Critical on LinkedInhttp://www.linkedin.com/company/vision-critical

New York | London | Hong Kong | Vancouver | Paris | San Francisco | Sydney | Tokyo | Toronto | Cologne | Minneapolis | Chicago | Ottawa | Detroit
Click here to watch our clients share their Vision Critical successes: www.visioncritical.com/client-storieshttp://www.visioncritical.com/client-stories