FAQ

FYI since this came up in a review:


Line 6: define :service_lifecycle, :service_type => "mysql" do
http://wiki.opscode.com/display/chef/Definitions, "Those parameters are then accessed within your definition via the params hash. Since this is a
hash, each parameter must have a value. If no default value is specified, use nil. ". We must provide one default value or nil here. I will provide
nil here.
that means :service_type => nil.
and modify the following line to
if node[:service_lifecycle][:enable] == true && :service_type
That's actually an ambiguity in the Chef documentation, I have now
improved the copy on the wiki to clarify.

The params specified in a definition are just used to initialize a
Hash; the attributes in the invocation of the definition are then
merged on top of that.
There is nothing there that forbids extra params; Chef is just Ruby,
convention trumps "ceremony".

This is not something that is worth obsessing over, but I thought I'd
mention it as a "best practice".



As a side note: definitions are sort of unofficially deprecated;
Opscode cookbooks are slowly but steadily moving away from them and
towards LWRPs. I wouldn't suprised if at some point in the future they
went away completely. Not a big deal for dev_setup, but keep it in
mind.


Andrea



---------- Forwarded message ----------
From: Frank Lu CloudFoundry Code Review <noreply@cloudfoundry.org>
Date: Fri, Jun 29, 2012 at 4:49 AM
Subject: Change in vcap[master]: [dev_setup] Support service
lifecycyle (snapshot/serializati...
To:
Cc: Anfernee Gui <agui@vmware.com>, Andrew Liu <aliu@vmware.com>,
Jesse Zhang <jessezhang@vmware.com>, CI Master <cf-ci@rbcon.com>,
Haipeng Wu <hwu@rbcon.com>, Nicholas Kushmerick
<nicholask@vmware.com>, Figo Feng <ffeng@vmware.com>, Andrea Campi
<andrea.campi@zephirworks.com>


Frank Lu has posted comments on this change.

Change subject: [dev_setup] Support service lifecycyle (snapshot/serialization)
......................................................................


Patch Set 2: (2 inline comments)

....................................................
File dev_setup/cookbooks/redis/recipes/default.rb
Line 41:
I will fix this.

....................................................
File dev_setup/cookbooks/service_lifecycle/definitions/service_lifecycle.rb
Line 6: define :service_lifecycle, :service_type => "mysql" do
http://wiki.opscode.com/display/chef/Definitions, "Those parameters
are then accessed within your definition via the params hash. Since
this is a hash, each parameter must have a value. If no default value
is specified, use nil. ". We must provide one default value or nil
here. I will provide nil here.
that means :service_type => nil.
and modify the following line to
if node[:service_lifecycle][:enable] == true && :service_type

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupvcap-dev @
postedJun 29, '12 at 6:55a
activeJun 29, '12 at 6:55a
posts1
users1

1 user in discussion

Andrea Campi: 1 post

People

Translate

site design / logo © 2021 Grokbase