Change multiple value parameter recommendation#177
Change multiple value parameter recommendation#177runejuhl wants to merge 2 commits intovoxpupuli:masterfrom
Conversation
340b63b to
7e4662d
Compare
ekohl
left a comment
There was a problem hiding this comment.
I agree with this recommendation. I never liked the x or list of x convention that appears to be common in Ruby. The code (either Puppet or its templates) also becomes easier when you only allow arrays.
I'm not so sure about the 80 column change. With markdown I'm also fine with long lines, but I'd say at least 100 characters is a lot more flexible, especially when you have URLs in there.
|
@ekohl It's often to preserve backwards compatibility when adding data types to an existing module. At the very least we need to warn about using flatten with more complicated examples. |
I'm fine with whatever, I just picked 80 chars because parts of the document was already wrapped to 80 chars. |
|
Actually I like the existing recommendation as its easier for Hiera users, though I don't like that fact that a parameter can be two (or even more oO) data types. vs. Regarding the column length change: I think 80 is way to short, 200 might be better. Personally I prefer to ignore this linting warning. However we decide, can we please do that change in a separate PR? It's basically impossible to read the current git diff. |
That's a fair distinction. |
|
@runejuhl Ups, missed that 🙈 Sorry! |
I wouldn't see this recommendation as changing that; that's still possible and likely the easiest way to add types to old modules. I still think the recommendation is worthy, though. As long as these guidelines aren't strictly enforced anyway I don't see a problem in changing the recommendation, and I don't imagine the guidelines will be strictly enforced anytime soon... (which I personally wouldn't want anyway) |
|
@binford2k what do you think about this / is there an official recommendation? |
|
My preference is for one datatype, not a |
binford2k
left a comment
There was a problem hiding this comment.
I don't know that there's an actual recommendation one way or the other. I personally like the one or many ability, but I dislike having to do the casting myself. Since Puppet does not have a way to automatically cast the parameter, and since this is a recommendation, not a requirement then I'm ok with it.
I do suggest simplifying the wording that I noted though.
| is `Array[String[1]]` instead of `Variant[String[1],Array[String[1]]]`. | ||
|
|
||
| Note that previously the recommendation was to have a `Variant` type, but this | ||
| causes problems with values that contain Arrays, e.g. `Variant[Tuple[String, |
There was a problem hiding this comment.
imo, the complexity of this example takes away from its readability. I think I'd word it more like this and leave the rest as a thought exercise for the reader if they care to do so.
Note that previously the recommendation was to use a
Varianttype, but this added excessive complexity.
There was a problem hiding this comment.
...forgot about this one. I've updated the PR with your text.
7e4662d to
4adff96
Compare
This changes the recommendation for how to handle multiple value parameters to the following:
I know this is a personal preference, and I wouldn't be surprised if I'm a small minority, but I'm open to any arguments for/against this.