gohcl: document optional attribute

This documents the "optional" attribute, which allows you to specify an
attribute that is optional when parsing.
This commit is contained in:
Chris Marchesi 2020-02-13 18:51:40 -08:00
parent cec773f974
commit 939ae58199
No known key found for this signature in database
GPG Key ID: 8D6F1589D9834498
1 changed files with 4 additions and 0 deletions

View File

@ -17,6 +17,7 @@
// attr (the default) indicates that the value is to be populated from an attribute
// block indicates that the value is to populated from a block
// label indicates that the value is to populated from a block label
// optional is the same as attr, but the field is optional
// remain indicates that the value is to be populated from the remaining body after populating other fields
//
// "attr" fields may either be of type *hcl.Expression, in which case the raw
@ -34,6 +35,9 @@
// the blocks being decoded. In this case, the name token is used only as
// an identifier for the label in diagnostic messages.
//
// "optional" fields behave like "attr" fields, but they are optional
// and will not give parsing errors if they are missing.
//
// "remain" can be placed on a single field that may be either of type
// hcl.Body or hcl.Attributes, in which case any remaining body content is
// placed into this field for delayed processing. If no "remain" field is