Ask Your Question
0

What are the best practices for passing metaparameters around?

asked 2015-02-06 09:57:26 -0500

dcrissma gravatar image

We are debating if and when it make sense to pass metaparameters into contained resources. I am curious if this is simply a bad practices altogether, or are there are some best practices that we should consider?

Example of this being done, where the instantiating class is passing $notify into the define, which turns around and passes it into a File. https://github.com/dcrissman/lightblu...

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2015-02-07 12:43:05 -0500

GregLarkin gravatar image

I am not aware of any guidance for or against what you're describing. In my opinion, if I created a defined type that needed the ability to arbitrarily pass different values for a before or notify metaparameter to a contained resource, it's perfectly fine to make them into parameters to the defined type.

I found the code for your defined type here (https://github.com/lightblue-platform/lightblue-puppet/blob/master/manifests/client/configure.pp), but do you have an example of where that defined type is declared? If you have to support varying values for $before and $notify, then I think you have a reasonable implementation.

edit flag offensive delete link more

Comments

Hmm, that code might be in a private repo - I get a 404 when I try to access it.

GregLarkin gravatar imageGregLarkin ( 2015-02-09 18:30:27 -0500 )edit

Let's try again. It looks like the previous url has a rouge html tag at the end. https://github.com/lightblue-platform/lightblue-puppet/blob/master/manifests/application/migrator.pp

dcrissma gravatar imagedcrissma ( 2015-02-10 08:24:09 -0500 )edit

looks like the second link did it also. You may just need to delete the trailing

from the url manually. Not sure why it is doing that.

dcrissma gravatar imagedcrissma ( 2015-02-10 14:46:56 -0500 )edit

Oh sorry, I didn't notice that.

GregLarkin gravatar imageGregLarkin ( 2015-02-11 10:42:11 -0500 )edit
0

answered 2015-02-09 09:55:37 -0500

rnelson0 gravatar image

As GregLarkin says, if you have to support varying values, then describe them as class parameters and pass them on to other resources as needed. You could go a step further and say that if the values could possibly vary, even if you do not need to support that now, describe them as class parameters and set a default value. The only best practice that I am aware of here is to create code that is understandable by our users and our future selves equally well.

edit flag offensive delete link more

Comments

I absolutely want readable code and had initially gone down the path of adding them to the class parameters. The reason why I dropped that was because puppet-syntax check does not approve, so I assumed not defining them was the correct way to go. That is what ultimately led to this question.

dcrissma gravatar imagedcrissma ( 2015-02-09 10:37:29 -0500 )edit

Do you mean "puppet parser validate" or the puppet-link checks? Can you post the errors that you got?

GregLarkin gravatar imageGregLarkin ( 2015-02-09 18:31:05 -0500 )edit

syntax:manifests rake aborted! before is a metaparam; this value will inherit to all contained resources in the lightblue::client::configure definition notify is a metaparam; this value will inherit to all contained resources in the lightblue::client::configure definition

dcrissma gravatar imagedcrissma ( 2015-02-10 08:26:43 -0500 )edit

I suspect then, that when it says "this value will inherit to all contained resources in the lightblue::client::configure definition", that I shouldn't be passing before/notify/etc at all. That is is implicit.

dcrissma gravatar imagedcrissma ( 2015-02-10 14:46:12 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-02-06 09:57:26 -0500

Seen: 159 times

Last updated: Feb 09 '15