[rudder-dev] Best Practises for writing techniques

Jonathan Clarke jonathan.clarke at normation.com
Thu Feb 28 18:42:44 CET 2013


On 28/02/13 18:31, Nicolas Charles wrote:
> On 28/02/2013 12:31, Michael Gliwinski wrote:
>> Hi all,
> Hi Michael,
>
>>
>> I read the new Best Practices doc, looks fantastic, really like the file
>> splitting convention :)
>>
>> Also had a look at the sshConfiguration in master and can't wait to
>> migrate to
>> 2.5 to use the new common reporting helpers :D
> \o/
>>
>> Also a couple of questions, just to better understand intentions, etc.
>>
>> 1. prefixing variables with "rudder_" or "rudder_<technique_name>_";
>> given
>> that to reference variables from other bundles you have to do
>> "rudder_<technique_name>_<action>.<variable>" anyway, is that necessary?
> That's a good point, maybe we've been overzealous on this convention.
> I think we could use only rudder_ to prevent overly long variable names

Why use any prefix for variable names? Their scope is local to each
bundle, so there is no risk of name collision. We can just called
variables "thing", and since the bundles are all named
"rudder_<technique_name>_*", the fully qualified variable name will
contain rudder_, like "rudder_<technique_name>_*.thing".

Dropping the requirement to prefix variable names seems altogether more
lightweight to me, making code easier to read, and not bringing any real
risks.


>> 3. config.st:
>>
>> 3a. is the idea to aggregate various variables used within different
>> bundles
>> in a technique in one place?  (sounds neat)
> Variables defined by Rudder must only go in this file, so yes, the
> idea is to have all variables there

All *StringTemplate* variables from Rudder that is. However, any "pure"
CFEngine variables should not be in this bundle, but in the main bundle
that does stuff.

The intention behind this is to separate files so that some files
contain *only* CFEngine code, with no Rudder specificities, in order
that they could one day be reusable by simply calling the bundle via a
CFEngine methods promises (think one Technique depending on another...).
So this way, we put all Rudder specific stuff (String Template variables
and reporting) in separate bundles.

This should also encourage code sharing with pure-CFEngine users.

Thanks for your comments Michael, it's great to see your interest and
have some feedback on this! By the way, if you like, we can give you
write access to the wiki page, so you can clarify some of these points
if you'd like?

Jonathan

-- 
------------------------------------------------------------------------
*Jonathan CLARKE*
/CTO - Directeur technique/
Normation <http://www.normation.com>
------------------------------------------------------------------------
*87 rue de Turbigo, 75003 Paris, France*
Telephone: 	+33 (0)1 83 62 41 24
Mobile: 	+33 (0)6 99 60 03 10
------------------------------------------------------------------------

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.rudder-project.org/pipermail/rudder-dev/attachments/20130228/0bba43dd/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: logo-square.png
Type: image/png
Size: 3503 bytes
Desc: not available
URL: <http://www.rudder-project.org/pipermail/rudder-dev/attachments/20130228/0bba43dd/attachment.png>


More information about the rudder-dev mailing list