package yaml
import "cuelang.org/go/internal/encoding/yaml"
Index ¶
- func Encode(n ast.Node) (b []byte, err error)
- func NewDecoder(filename string, b []byte) *decoder
- func Unmarshal(filename string, data []byte) (ast.Expr, error)
- func Validate(c *adt.OpContext, b []byte, v cue.Value) (bool, error)
- func ValidatePartial(c *adt.OpContext, b []byte, v cue.Value) (bool, error)
- type Decoder
Functions ¶
func Encode ¶
Encode converts a CUE AST to YAML.
The given file must only contain values that can be directly supported by YAML:
Type Restrictions BasicLit File no imports, aliases, or definitions StructLit no embeddings, aliases, or definitions List Field must be regular; label must be a BasicLit or Ident CommentGroup
TODO: support anchors through Ident.
func NewDecoder ¶
NewDecoder creates a decoder for YAML values to extract CUE syntax tree nodes.
The filename is used for position information in CUE syntax tree nodes as well as any errors encountered while decoding YAML.
func Unmarshal ¶
Unmarshal parses a single YAML value to a CUE expression.
func Validate ¶
Validate validates YAML and confirms it is an instance of schema. If the YAML source is a stream, every object must match v.
If Validate is called in a broader context, like a validation or function call, the cycle context of n should be accumulated in c before this call. This can be done by using the Expr method on the CallContext.
func ValidatePartial ¶
ValidatePartial validates YAML and confirms it matches the constraints specified by v using unification. This means that b must be consistent with, but does not have to be an instance of v. If the YAML source is a stream, every object must match v.
Types ¶
type Decoder ¶
type Decoder interface { // Decode consumes a YAML value and returns it in CUE syntax tree node. Decode() (ast.Expr, error) }
Decoder is a temporary interface compatible with both the old and new yaml decoders.
Source Files ¶
decode.go encode.go validate.go
- Version
- v0.13.0-alpha.3
- Published
- Mar 31, 2025
- Platform
- linux/amd64
- Imports
- 22 packages
- Last checked
- 2 hours ago –
Tools for package owners.