ast

package
v1.10.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeMetadata

func DecodeMetadata(field *ast.Field) error

DecodeMetadata decodes a CUE string literal in the metadata fields to native CUE expressions

func EncodeMetadata

func EncodeMetadata(field *ast.Field) error

EncodeMetadata encodes native CUE in the metadata fields to a CUE string literal

func FindAndValidateField

func FindAndValidateField(sl *ast.StructLit, fieldName string, validator fieldValidator) (found bool, err error)

FindAndValidateField searches for a field at the top level or within top-level if statements

func GetFieldByPath

func GetFieldByPath(node ast.Node, path string) (*ast.Field, bool)

GetFieldByPath retrieves a field by its path in the AST

func GetFieldLabel

func GetFieldLabel(label ast.Label) string

GetFieldLabel retrieves the label of a field in the AST

func GetNodeByPath

func GetNodeByPath(node ast.Node, path string) (ast.Node, *ast.Field, bool)

GetNodeByPath retrieves a node by its path in the AST

func ParseCueContent added in v1.10.5

func ParseCueContent(content string) (*ast.StructLit, bool, bool, error)

ParseCueContent parses CUE content and extracts struct fields, skipping imports/packages

func StringifyStructLitAsCueString

func StringifyStructLitAsCueString(structLit *ast.StructLit) (*ast.BasicLit, error)

StringifyStructLitAsCueString converts a StructLit to a CUE string literal representation

func TrimCueRawString

func TrimCueRawString(s string) string

TrimCueRawString trims a CUE raw string literal and handles escape sequences

func UpdateNodeByPath

func UpdateNodeByPath(root ast.Node, path string, newExpr ast.Expr) bool

UpdateNodeByPath updates a node in the AST by its path

func ValidateCueStringLiteral

func ValidateCueStringLiteral[T ast.Node](lit *ast.BasicLit, validator func(T) error) error

ValidateCueStringLiteral validates a CUE string literal by parsing it and applying a custom validator function

func WrapCueStruct

func WrapCueStruct(s string) string

WrapCueStruct wraps a string in a CUE struct format

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL