Default Actions for LWRP Resources


#1

Hello Chefs,
As many of you know, setting the default action on LWRP resources is pretty tricky right now since it is not exposed by the DSL. Avishai Ish-Shalom has kindly provided a patch for this issue[1][2]. Avishai’s patch allows you to specify the default action by adding :default => _DEFAULT_ to the list of actions on the resource, like so:

actions :pass_buck, :prepare_thumbs, :twiddle_thumbs, :default => :pass_buck
An alternative implementation that has been proposed is to simply use the first action in the list as the default. Please chime in if you have a strong preference for one or the other.


Dan DeLeo

  1. http://tickets.opscode.com/browse/CHEF-1789
  2. https://github.com/avishai-ish-shalom/chef/tree/CHEF-1789

#2

My preference is away from black magic and toward explicitly setting the
default.

-chris

On Tue, May 24, 2011 at 11:24 AM, Daniel DeLeo dan@kallistec.com wrote:

Hello Chefs,
As many of you know, setting the default action on LWRP resources is pretty
tricky right now since it is not exposed by the DSL. Avishai Ish-Shalom has
kindly provided a patch for this issue[1][2]. Avishai’s patch allows you to
specify the default action by adding :default => _DEFAULT_ to the list of
actions on the resource, like so:

actions :pass_buck, :prepare_thumbs, :twiddle_thumbs, :default =>
:pass_buck
An alternative implementation that has been proposed is to simply use the
first action in the list as the default. Please chime in if you have a
strong preference for one or the other.


Dan DeLeo

  1. http://tickets.opscode.com/browse/CHEF-1789
  2. https://github.com/avishai-ish-shalom/chef/tree/CHEF-1789

#3

I’d prefer explicitly setting the default LWRP action.

On Tue, May 24, 2011 at 2:24 PM, Daniel DeLeo dan@kallistec.com wrote:

Hello Chefs,
As many of you know, setting the default action on LWRP resources is pretty
tricky right now since it is not exposed by the DSL. Avishai Ish-Shalom has
kindly provided a patch for this issue[1][2]. Avishai’s patch allows you to
specify the default action by adding :default => _DEFAULT_ to the list of
actions on the resource, like so:

actions :pass_buck, :prepare_thumbs, :twiddle_thumbs, :default =>
:pass_buck
An alternative implementation that has been proposed is to simply use the
first action in the list as the default. Please chime in if you have a
strong preference for one or the other.


Dan DeLeo

  1. http://tickets.opscode.com/browse/CHEF-1789
  2. https://github.com/avishai-ish-shalom/chef/tree/CHEF-1789


Pat Collins


#4

I like being explicit also, but perhaps a bit of both? You specify the
default action as described, but if no default is specified then the
default becomes the first action listed?

KC

On Tue, May 24, 2011 at 12:14 PM, Pat Collins pat@burned.com wrote:

I’d prefer explicitly setting the default LWRP action.

On Tue, May 24, 2011 at 2:24 PM, Daniel DeLeo dan@kallistec.com wrote:

Hello Chefs,
As many of you know, setting the default action on LWRP resources is
pretty tricky right now since it is not exposed by the DSL. Avishai
Ish-Shalom has kindly provided a patch for this issue[1][2]. Avishai’s patch
allows you to specify the default action by adding :default => _DEFAULT_
to the list of actions on the resource, like so:

actions :pass_buck, :prepare_thumbs, :twiddle_thumbs, :default =>
:pass_buck
An alternative implementation that has been proposed is to simply use the
first action in the list as the default. Please chime in if you have a
strong preference for one or the other.


Dan DeLeo

  1. http://tickets.opscode.com/browse/CHEF-1789
  2. https://github.com/avishai-ish-shalom/chef/tree/CHEF-1789


Pat Collins


#5

Oops, sent to the wrong list. Frickin gmail.

On Tue, May 24, 2011 at 12:25 PM, KC Braunschweig
kcbraunschweig@gmail.com wrote:

I like being explicit also, but perhaps a bit of both? You specify the
default action as described, but if no default is specified then the
default becomes the first action listed?

KC


#6

An alternative that keeps the default explicit is a new method:

actions :prepare_thumbs, :twiddle_thumbs
default_action :pass_buck

I somewhat prefer this over actions taking a hash with :default key as
you don’t have specify an action twice.


Seth Falcon | Senior Software Design Engineer | Opscode | @sfalcon


#7

On 25 May 2011 10:57, Seth Falcon seth@opscode.com wrote:

An alternative that keeps the default explicit is a new method:

actions :prepare_thumbs, :twiddle_thumbs
default_action :pass_buck

This one has my vote, we have methods for the other chef-specific
behavior on the class; why not the “default action” behavior?

Cheers,

–AJ

I somewhat prefer this over actions taking a hash with :default key as
you don’t have specify an action twice.


Seth Falcon | Senior Software Design Engineer | Opscode | @sfalcon


#8

On Tue, May 24, 2011 at 23:59, AJ Christensen aj@junglist.gen.nz wrote:

On 25 May 2011 10:57, Seth Falcon seth@opscode.com wrote:

An alternative that keeps the default explicit is a new method:

actions :prepare_thumbs, :twiddle_thumbs
default_action :pass_buck

This one has my vote, we have methods for the other chef-specific
behavior on the class; why not the “default action” behavior?

Yeah, I agree with Seth and AJ on this one.
-t