Skip to content

Commit 340b63b

Browse files
committed
Change recommendation for multiple value parameters
1 parent b2af595 commit 340b63b

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

docs/index.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,15 @@ There are a few things that can be checked if you review a pull request against
178178
* Does it need additional tests? Add the `needs-tests` label
179179
* Does it have failing tests? Add the `tests-fail` label
180180
* Are new parameters introduced? They must have datatypes
181-
* If you can supply one or multiple values for an attribute it's common practice
182-
to enforce the datatype for one value and an array of that datatype. An
183-
example for string is `Variant[String[1],Array[String[1]]]`. This can be used
184-
in the Puppet code as `[$var].flatten()`
181+
* If you can supply multiple values for an attribute it's common practice to
182+
enforce the datatype as an array of values, even if the default is a single
183+
item. This cuts down on code and remove some edge cases. An example for string
184+
is `Array[String[1]]` instead of `Variant[String[1],Array[String[1]]]`.
185+
186+
Note that previously the recommendation was to have a `Variant` type, but this
187+
causes problems with values that contain Arrays, e.g. `Variant[Tuple[String,
188+
Array], Array[Tuple[String, Array]]]` (which would unintentionally flatten the
189+
array inside the tuple).
185190
* Are facts used? They should only be accessed via `$facts[]` or
186191
[fact()](https://github.com/puppetlabs/puppetlabs-stdlib#fact) from stdlib,
187192
but not topscope variables

0 commit comments

Comments
 (0)