Documentation ¶
Index ¶
- func DecodeValue(v interface{}) (syntax.Node, syntax.Diagnostics)
- func DecodeYAML(filename string, d *yaml.Decoder, tags TagDecoder) (*syntax.ObjectNode, syntax.Diagnostics)
- func DecodeYAMLBytes(filename string, bytes []byte, tags TagDecoder) (*syntax.ObjectNode, syntax.Diagnostics)
- func EncodeValue(n syntax.Node, v interface{}) syntax.Diagnostics
- func EncodeYAML(e *yaml.Encoder, n syntax.Node) syntax.Diagnostics
- func MarshalYAML(n syntax.Node) (*yaml.Node, syntax.Diagnostics)
- func UnmarshalYAML(filename string, n *yaml.Node, tags TagDecoder) (syntax.Node, syntax.Diagnostics)
- func UnmarshalYAMLNode(filename string, n *yaml.Node, tags TagDecoder) (syntax.Node, syntax.Diagnostics)
- type TagDecoder
- type YAMLSyntax
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeValue ¶
func DecodeValue(v interface{}) (syntax.Node, syntax.Diagnostics)
DecodeValue decodes a plain Go value into a syntax.Node.
Decoding uses the following rules:
- Interface and pointer values decode as their element value. Nil interface and pointer values decode as *syntax.NullNode.
- Boolean values decode as *syntax.BooleanNode.
- Floating point and integer values decode as *syntax.NumberNode.
- String values decode as *syntax.StringNode.
- Arrays and slices decode as *syntax.ListNode. Nil slices are decoded as *syntax.NullNode.
- Maps are decoded as *syntax.ObjectNode. Map keys must be strings. Nil maps are deocded as *syntax.NullNode.
- Structs are decoded as *syntax.ObjectNode. Exported struct fields decode into object properties using the name of the field as the property's key. The name of the struct field can be customized using a struct tag of the form `object:"name"`. If a field's value decodes as *syntax.NullNode, that field is omitted from the result.
func DecodeYAML ¶
func DecodeYAML(filename string, d *yaml.Decoder, tags TagDecoder) (*syntax.ObjectNode, syntax.Diagnostics)
DecodeYAML decodes a YAML value from the given decoder into a syntax node. See UnmarshalYAML for mode details on the decoding process.
func DecodeYAMLBytes ¶
func DecodeYAMLBytes(filename string, bytes []byte, tags TagDecoder) (*syntax.ObjectNode, syntax.Diagnostics)
DecodeYAMLBytes decodes a YAML value from the given decoder into a syntax node. See UnmarshalYAML for mode details on the decoding process.
func EncodeValue ¶
func EncodeValue(n syntax.Node, v interface{}) syntax.Diagnostics
EncodeValue encodes a syntax.Node into a plain Go value. The encoding rules are the inverse of the decoding rules described in the documentation for DecodeValue.
func EncodeYAML ¶
func EncodeYAML(e *yaml.Encoder, n syntax.Node) syntax.Diagnostics
EncodeYAML encodes a syntax node into YAML text using the given encoder. See MarshalYAML for mode details on the encoding process.
func MarshalYAML ¶
func MarshalYAML(n syntax.Node) (*yaml.Node, syntax.Diagnostics)
MarshalYAML marshals a syntax node into a YAML node. If a syntax node has an associated YAMLSyntax annotation, the tag, style, and comments on the result will be pulled from the YAMLSyntax. The marshaling process otherwise follows the inverse of the unmarshaling process described in the documentation for UnmarshalYAML.
func UnmarshalYAML ¶
func UnmarshalYAML(filename string, n *yaml.Node, tags TagDecoder) (syntax.Node, syntax.Diagnostics)
UnmarshalYAML unmarshals a YAML node into a syntax node.
Nodes are decoded as follows: - Scalars are decoded as the corresponding literal type (null -> nullNode, bool -> BooleanNode, etc.) - Sequences are decoded as array nodes - Mappings are decoded as object nodes
Tagged nodes are decoded using the given TagDecoder. To avoid infinite recursion, the TagDecoder must call UnmarshalYAMLNode if it needs to unmarshal the node it is processing.
func UnmarshalYAMLNode ¶
func UnmarshalYAMLNode(filename string, n *yaml.Node, tags TagDecoder) (syntax.Node, syntax.Diagnostics)
UnmarshalYAMLNode unmarshals the given YAML node into a syntax Node. UnmarshalYAMLNode does _not_ use the tag decoder for the node itself, though it does use the tag decoder for the node's children. This allows tag decoders to call UnmarshalYAMLNode without infinitely recurring on the same node. See UnmarshalYAML for more details.
Types ¶
type TagDecoder ¶
type TagDecoder interface { // DecodeTag decodes a tagged YAML node. DecodeTag(filename string, n *yaml.Node) (syntax.Node, syntax.Diagnostics, bool) }
A TagDecoder decodes tagged YAML nodes. See the documentation on UnmarshalYAML for more details.
type YAMLSyntax ¶
type YAMLSyntax struct { *yaml.Node // contains filtered or unexported fields }
YAMLSyntax is a syntax.Syntax implementation that is backed by a YAML node.
func (YAMLSyntax) Range ¶
func (s YAMLSyntax) Range() *hcl.Range
Range returns the textual range of the YAML node, if any.