You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is some awkwardness in boilerplate, and Go in general, with how to identify when you want to set a variable to "no value". In other languages, this would be done using null or None, but in Go, while some types can be set to nil, most primitives can only be set to their "zero values" (e.g. "" for a string, 0 for an int, etc). This makes it hard to set "no value", both in the default parameter in a boilerplate.yml file and as a user when enter the value via interactive prompt or the --var and --var-file options.
Perhaps a simply, albeit not terribly elegant option is to simply define a placeholder that globally means "use the zero value for this type". A simple one would be something like __NO_VALUE__. This is unlikely to collide with any real value a user is likely to enter and pretty clearly communicates the intent. Example:
variables:
name: Titledefault: __NO_VALUE__
The text was updated successfully, but these errors were encountered:
I want to expose a boilerplate var .PortsAccessibleByBastionHost and use an {{ if }} statement in the template to determine whether to include a few security group rules. Ideally, I could just say {{ if len .PortsAccessibleByBastionHost }} ... but since .PortsAccessibleByBastionHost has to be non-empty, I instead have to resort to two separate vars .PortsAccessibleByBastionHost and .EnableAccessOnSpecificPortsFromBastionHost, and even if .EnableAccessOnSpecificPortsFromBastionHost is false, add a dummy not-used value for .PortsAccessibleByBastionHost.
There is some awkwardness in
boilerplate
, and Go in general, with how to identify when you want to set a variable to "no value". In other languages, this would be done usingnull
orNone
, but in Go, while some types can be set tonil
, most primitives can only be set to their "zero values" (e.g. "" for a string, 0 for an int, etc). This makes it hard to set "no value", both in thedefault
parameter in aboilerplate.yml
file and as a user when enter the value via interactive prompt or the--var
and--var-file
options.Perhaps a simply, albeit not terribly elegant option is to simply define a placeholder that globally means "use the zero value for this type". A simple one would be something like
__NO_VALUE__
. This is unlikely to collide with any real value a user is likely to enter and pretty clearly communicates the intent. Example:The text was updated successfully, but these errors were encountered: