Documentation
¶
Overview ¶
Use the top level Evaluator or StreamEvaluator to evaluate expressions and return matches.
Index ¶
- Variables
- func ClearFilenameAliases()
- func FormatStringFromFilename(filename string) string
- func GetAvailableInputFormatString() string
- func GetAvailableOutputFormatString() string
- func InitExpressionParser()
- func KindString(kind Kind) string
- func MapToYamlStyle(original Style) yaml.Style
- func NewFrontMatterHandler(originalFilename string) frontMatterHandler
- func NewWriteInPlaceHandler(inputFile string) writeInPlaceHandler
- func NodeContentToString(node *CandidateNode, depth int) string
- func NodeToString(node *CandidateNode) string
- func NodesToString(collection *list.List) string
- func PrintYAMLDocumentSeparator(writer io.Writer, PrintDocSeparators bool) error
- func PrintYAMLLeadingContent(writer io.Writer, content string, PrintDocSeparators bool, ColorsEnabled bool) error
- func ReadDocuments(reader io.Reader, decoder Decoder) (*list.List, error)
- func SafelyCloseReader(reader io.Reader)
- func SetFilenameAlias(realPath string, displayName string)
- type CandidateNode
- func (n *CandidateNode) AddChild(rawChild *CandidateNode)
- func (n *CandidateNode) AddChildren(children []*CandidateNode)
- func (n *CandidateNode) AddKeyValueChild(rawKey *CandidateNode, rawValue *CandidateNode) (*CandidateNode, *CandidateNode)
- func (n *CandidateNode) AsList() *list.List
- func (n *CandidateNode) CanVisitValues() bool
- func (n *CandidateNode) ConvertToNodeInfo() *NodeInfo
- func (n *CandidateNode) Copy() *CandidateNode
- func (n *CandidateNode) CopyAsReplacement(replacement *CandidateNode) *CandidateNode
- func (n *CandidateNode) CopyWithoutContent() *CandidateNode
- func (n *CandidateNode) CreateChild() *CandidateNode
- func (n *CandidateNode) CreateReplacement(kind Kind, tag string, value string) *CandidateNode
- func (n *CandidateNode) CreateReplacementWithComments(kind Kind, tag string, style Style) *CandidateNode
- func (n *CandidateNode) FilterMapContentByKey(keyPredicate func(*CandidateNode) bool) []*CandidateNode
- func (n *CandidateNode) GetDocument() uint
- func (n *CandidateNode) GetFileIndex() int
- func (n *CandidateNode) GetFilename() string
- func (n *CandidateNode) GetKey() string
- func (n *CandidateNode) GetNicePath() string
- func (n *CandidateNode) GetPath() []interface{}
- func (n *CandidateNode) GetValueRep() (interface{}, error)
- func (o *CandidateNode) MarshalJSON() ([]byte, error)
- func (o *CandidateNode) MarshalYAML() (*yaml.Node, error)
- func (n *CandidateNode) SetDocument(idx uint)
- func (n *CandidateNode) SetFileIndex(idx int)
- func (n *CandidateNode) SetFilename(name string)
- func (n *CandidateNode) SetParent(parent *CandidateNode)
- func (o *CandidateNode) UnmarshalGoccyYAML(node ast.Node, cm yaml.CommentMap, anchorMap map[string]*CandidateNode) error
- func (o *CandidateNode) UnmarshalJSON(data []byte) error
- func (o *CandidateNode) UnmarshalYAML(node *yaml.Node, anchorMap map[string]*CandidateNode) error
- func (n *CandidateNode) UpdateAttributesFrom(other *CandidateNode, prefs assignPreferences)
- func (n *CandidateNode) UpdateFrom(other *CandidateNode, prefs assignPreferences)
- func (n *CandidateNode) VisitValues(visitor ValueVisitor) error
- type Context
- func (n *Context) ChildContext(results *list.List) Context
- func (n *Context) Clone() Context
- func (n *Context) DeepClone() Context
- func (n *Context) GetDateTimeLayout() string
- func (n *Context) GetVariable(name string) *list.List
- func (n *Context) ReadOnlyClone() Context
- func (n *Context) SetDateTimeLayout(newDateTimeLayout string)
- func (n *Context) SetVariable(name string, value *list.List)
- func (n *Context) SingleChildContext(candidate *CandidateNode) Context
- func (n *Context) SingleReadonlyChildContext(candidate *CandidateNode) Context
- func (n *Context) ToString() string
- func (n *Context) WritableClone() Context
- type CsvPreferences
- type DataTreeNavigator
- type Decoder
- func NewBase64Decoder() Decoder
- func NewCSVObjectDecoder(prefs CsvPreferences) Decoder
- func NewGoccyYAMLDecoder() Decoder
- func NewHclDecoder() Decoder
- func NewINIDecoder(prefs INIPreferences) Decoder
- func NewJSONDecoder() Decoder
- func NewLuaDecoder(prefs LuaPreferences) Decoder
- func NewPropertiesDecoder() Decoder
- func NewTomlDecoder() Decoder
- func NewUriDecoder() Decoder
- func NewXMLDecoder(prefs XmlPreferences) Decoder
- func NewYamlDecoder(prefs YamlPreferences) Decoder
- type DecoderFactoryFunction
- type EncodeHint
- type Encoder
- func NewBase64Encoder() Encoder
- func NewCsvEncoder(prefs CsvPreferences) Encoder
- func NewHclEncoder(prefs HclPreferences) Encoder
- func NewINIEncoder() Encoder
- func NewJSONEncoder(prefs JsonPreferences) Encoder
- func NewKYamlEncoder(prefs KYamlPreferences) Encoder
- func NewLuaEncoder(prefs LuaPreferences) Encoder
- func NewPropertiesEncoder(prefs PropertiesPreferences) Encoder
- func NewShEncoder() Encoder
- func NewShellVariablesEncoder() Encoder
- func NewTomlEncoder() Encoder
- func NewTomlEncoderWithPrefs(prefs TomlPreferences) Encoder
- func NewUriEncoder() Encoder
- func NewXMLEncoder(prefs XmlPreferences) Encoder
- func NewYamlEncoder(prefs YamlPreferences) Encoder
- type EncoderFactoryFunction
- type Evaluator
- type ExpressionNode
- type ExpressionParserInterface
- type Format
- type HclPreferences
- type INIPreferences
- type JsonPreferences
- type KYamlPreferences
- type Kind
- type Logger
- func (l *Logger) Debug(msg string)
- func (l *Logger) Debugf(format string, args ...interface{})
- func (l *Logger) Error(msg string)
- func (l *Logger) Errorf(format string, args ...interface{})
- func (l *Logger) GetLevel() slog.Level
- func (l *Logger) Info(msg string)
- func (l *Logger) Infof(format string, args ...interface{})
- func (l *Logger) IsEnabledFor(level slog.Level) bool
- func (l *Logger) SetLevel(level slog.Level)
- func (l *Logger) SetSlogger(logger *slog.Logger)
- func (l *Logger) Warning(msg string)
- func (l *Logger) Warningf(format string, args ...interface{})
- type LuaPreferences
- type NodeInfo
- type Operation
- type Printer
- type PrinterWriter
- type PropertiesPreferences
- type SecurityPreferences
- type ShellVariablesPreferences
- type StreamEvaluator
- type StringEvaluator
- type Style
- type TomlPreferences
- type ValueVisitor
- type XmlPreferences
- type YamlPreferences
Constants ¶
This section is empty.
Variables ¶
var Base64Format = &Format{"base64", []string{}, func() Encoder { return NewBase64Encoder() }, func() Decoder { return NewBase64Decoder() }, }
var CSVFormat = &Format{"csv", []string{"c"}, func() Encoder { return NewCsvEncoder(ConfiguredCsvPreferences) }, func() Decoder { return NewCSVObjectDecoder(ConfiguredCsvPreferences) }, }
var ConfiguredCsvPreferences = NewDefaultCsvPreferences()
var ConfiguredHclPreferences = NewDefaultHclPreferences()
var ConfiguredINIPreferences = NewDefaultINIPreferences()
var ConfiguredJSONPreferences = NewDefaultJsonPreferences()
var ConfiguredKYamlPreferences = NewDefaultKYamlPreferences()
var ConfiguredLuaPreferences = NewDefaultLuaPreferences()
var ConfiguredPropertiesPreferences = NewDefaultPropertiesPreferences()
var ConfiguredSecurityPreferences = SecurityPreferences{ DisableEnvOps: false, DisableFileOps: false, EnableSystemOps: false, }
var ConfiguredShellVariablesPreferences = NewDefaultShellVariablesPreferences()
var ConfiguredTomlPreferences = NewDefaultTomlPreferences()
var ConfiguredTsvPreferences = NewDefaultTsvPreferences()
var ConfiguredXMLPreferences = NewDefaultXmlPreferences()
var ConfiguredYamlPreferences = NewDefaultYamlPreferences()
var Formats = []*Format{ YamlFormat, KYamlFormat, JSONFormat, PropertiesFormat, CSVFormat, TSVFormat, XMLFormat, Base64Format, UriFormat, ShFormat, TomlFormat, HclFormat, ShellVariablesFormat, LuaFormat, INIFormat, }
var HclFormat = &Format{"hcl", []string{"h", "tf"}, func() Encoder { return NewHclEncoder(ConfiguredHclPreferences) }, func() Decoder { return NewHclDecoder() }, }
var INIFormat = &Format{"ini", []string{"i"}, func() Encoder { return NewINIEncoder() }, func() Decoder { return NewINIDecoder(ConfiguredINIPreferences) }, }
var JSONFormat = &Format{"json", []string{"j"}, func() Encoder { return NewJSONEncoder(ConfiguredJSONPreferences) }, func() Decoder { return NewJSONDecoder() }, }
var KYamlFormat = &Format{"kyaml", []string{"ky"}, func() Encoder { return NewKYamlEncoder(ConfiguredKYamlPreferences) }, func() Decoder { return NewYamlDecoder(ConfiguredYamlPreferences) }, }
var LoadYamlPreferences = YamlPreferences{ LeadingContentPreProcessing: false, PrintDocSeparators: true, UnwrapScalar: true, EvaluateTogether: false, }
var LuaFormat = &Format{"lua", []string{"l"}, func() Encoder { return NewLuaEncoder(ConfiguredLuaPreferences) }, func() Decoder { return NewLuaDecoder(ConfiguredLuaPreferences) }, }
var Now = time.Now
for unit tests
var PrettyPrintExp = `(... | (select(tag != "!!str"), select(tag == "!!str") | select(test("(?i)^(y|yes|n|no|on|off)$") | not)) ) style=""`
var PropertiesFormat = &Format{"props", []string{"p", "properties"}, func() Encoder { return NewPropertiesEncoder(ConfiguredPropertiesPreferences) }, func() Decoder { return NewPropertiesDecoder() }, }
var ShFormat = &Format{"", nil, func() Encoder { return NewShEncoder() }, nil, }
var ShellVariablesFormat = &Format{"shell", []string{"s", "sh"}, func() Encoder { return NewShellVariablesEncoder() }, nil, }
var StringInterpolationEnabled = true
var TSVFormat = &Format{"tsv", []string{"t"}, func() Encoder { return NewCsvEncoder(ConfiguredTsvPreferences) }, func() Decoder { return NewCSVObjectDecoder(ConfiguredTsvPreferences) }, }
var TomlFormat = &Format{"toml", []string{}, func() Encoder { return NewTomlEncoderWithPrefs(ConfiguredTomlPreferences) }, func() Decoder { return NewTomlDecoder() }, }
var UriFormat = &Format{"uri", []string{}, func() Encoder { return NewUriEncoder() }, func() Decoder { return NewUriDecoder() }, }
var XMLFormat = &Format{"xml", []string{"x"}, func() Encoder { return NewXMLEncoder(ConfiguredXMLPreferences) }, func() Decoder { return NewXMLDecoder(ConfiguredXMLPreferences) }, }
var YamlFormat = &Format{"yaml", []string{"y", "yml"}, func() Encoder { return NewYamlEncoder(ConfiguredYamlPreferences) }, func() Decoder { return NewYamlDecoder(ConfiguredYamlPreferences) }, }
Functions ¶
func ClearFilenameAliases ¶
func ClearFilenameAliases()
ClearFilenameAliases removes all filename aliases.
func GetAvailableInputFormatString ¶
func GetAvailableInputFormatString() string
func GetAvailableOutputFormatString ¶
func GetAvailableOutputFormatString() string
func InitExpressionParser ¶
func InitExpressionParser()
func KindString ¶
func MapToYamlStyle ¶
func NewFrontMatterHandler ¶
func NewFrontMatterHandler(originalFilename string) frontMatterHandler
func NewWriteInPlaceHandler ¶
func NewWriteInPlaceHandler(inputFile string) writeInPlaceHandler
func NodeContentToString ¶
func NodeContentToString(node *CandidateNode, depth int) string
func NodeToString ¶
func NodeToString(node *CandidateNode) string
func PrintYAMLDocumentSeparator ¶
Some funcs are shared between encoder_yaml and encoder_kyaml
func PrintYAMLLeadingContent ¶
func SafelyCloseReader ¶
func SetFilenameAlias ¶
SetFilenameAlias registers a display name for a file path so that the filename operator returns the original name instead of a temp path.
Types ¶
type CandidateNode ¶
type CandidateNode struct {
Kind Kind
Style Style
Tag string
Value string
Anchor string
Alias *CandidateNode
Content []*CandidateNode
HeadComment string
LineComment string
FootComment string
Parent *CandidateNode // parent node
Key *CandidateNode // node key, if this is a value from a map (or index in an array)
LeadingContent string
Line int
Column int
// when performing op against all nodes given, this will treat all the nodes as one
// (e.g. top level cross document merge). This property does not propagate to child nodes.
EvaluateTogether bool
IsMapKey bool
// EncodeHint controls how a mapping node is serialised by format-specific encoders
// (e.g. TOML, HCL) that support both inline and block/section representations.
EncodeHint EncodeHint
// contains filtered or unexported fields
}
func (*CandidateNode) AddChild ¶
func (n *CandidateNode) AddChild(rawChild *CandidateNode)
func (*CandidateNode) AddChildren ¶
func (n *CandidateNode) AddChildren(children []*CandidateNode)
func (*CandidateNode) AddKeyValueChild ¶
func (n *CandidateNode) AddKeyValueChild(rawKey *CandidateNode, rawValue *CandidateNode) (*CandidateNode, *CandidateNode)
func (*CandidateNode) AsList ¶
func (n *CandidateNode) AsList() *list.List
func (*CandidateNode) CanVisitValues ¶
func (n *CandidateNode) CanVisitValues() bool
func (*CandidateNode) ConvertToNodeInfo ¶
func (n *CandidateNode) ConvertToNodeInfo() *NodeInfo
func (*CandidateNode) Copy ¶
func (n *CandidateNode) Copy() *CandidateNode
func (*CandidateNode) CopyAsReplacement ¶
func (n *CandidateNode) CopyAsReplacement(replacement *CandidateNode) *CandidateNode
func (*CandidateNode) CopyWithoutContent ¶
func (n *CandidateNode) CopyWithoutContent() *CandidateNode
func (*CandidateNode) CreateChild ¶
func (n *CandidateNode) CreateChild() *CandidateNode
func (*CandidateNode) CreateReplacement ¶
func (n *CandidateNode) CreateReplacement(kind Kind, tag string, value string) *CandidateNode
func (*CandidateNode) CreateReplacementWithComments ¶
func (n *CandidateNode) CreateReplacementWithComments(kind Kind, tag string, style Style) *CandidateNode
func (*CandidateNode) FilterMapContentByKey ¶
func (n *CandidateNode) FilterMapContentByKey(keyPredicate func(*CandidateNode) bool) []*CandidateNode
func (*CandidateNode) GetDocument ¶
func (n *CandidateNode) GetDocument() uint
func (*CandidateNode) GetFileIndex ¶
func (n *CandidateNode) GetFileIndex() int
func (*CandidateNode) GetFilename ¶
func (n *CandidateNode) GetFilename() string
func (*CandidateNode) GetKey ¶
func (n *CandidateNode) GetKey() string
func (*CandidateNode) GetNicePath ¶
func (n *CandidateNode) GetNicePath() string
func (*CandidateNode) GetPath ¶
func (n *CandidateNode) GetPath() []interface{}
func (*CandidateNode) GetValueRep ¶
func (n *CandidateNode) GetValueRep() (interface{}, error)
func (*CandidateNode) MarshalJSON ¶
func (o *CandidateNode) MarshalJSON() ([]byte, error)
func (*CandidateNode) MarshalYAML ¶
func (o *CandidateNode) MarshalYAML() (*yaml.Node, error)
func (*CandidateNode) SetDocument ¶
func (n *CandidateNode) SetDocument(idx uint)
func (*CandidateNode) SetFileIndex ¶
func (n *CandidateNode) SetFileIndex(idx int)
func (*CandidateNode) SetFilename ¶
func (n *CandidateNode) SetFilename(name string)
func (*CandidateNode) SetParent ¶
func (n *CandidateNode) SetParent(parent *CandidateNode)
func (*CandidateNode) UnmarshalGoccyYAML ¶
func (o *CandidateNode) UnmarshalGoccyYAML(node ast.Node, cm yaml.CommentMap, anchorMap map[string]*CandidateNode) error
func (*CandidateNode) UnmarshalJSON ¶
func (o *CandidateNode) UnmarshalJSON(data []byte) error
func (*CandidateNode) UnmarshalYAML ¶
func (o *CandidateNode) UnmarshalYAML(node *yaml.Node, anchorMap map[string]*CandidateNode) error
func (*CandidateNode) UpdateAttributesFrom ¶
func (n *CandidateNode) UpdateAttributesFrom(other *CandidateNode, prefs assignPreferences)
func (*CandidateNode) UpdateFrom ¶
func (n *CandidateNode) UpdateFrom(other *CandidateNode, prefs assignPreferences)
updates this candidate from the given candidate node
func (*CandidateNode) VisitValues ¶
func (n *CandidateNode) VisitValues(visitor ValueVisitor) error
type Context ¶
type Context struct {
MatchingNodes *list.List
Variables map[string]*list.List
DontAutoCreate bool
// contains filtered or unexported fields
}
func (*Context) GetDateTimeLayout ¶
func (*Context) ReadOnlyClone ¶
func (*Context) SetDateTimeLayout ¶
func (*Context) SingleChildContext ¶
func (n *Context) SingleChildContext(candidate *CandidateNode) Context
func (*Context) SingleReadonlyChildContext ¶
func (n *Context) SingleReadonlyChildContext(candidate *CandidateNode) Context
func (*Context) WritableClone ¶
type CsvPreferences ¶
func NewDefaultCsvPreferences ¶
func NewDefaultCsvPreferences() CsvPreferences
func NewDefaultTsvPreferences ¶
func NewDefaultTsvPreferences() CsvPreferences
type DataTreeNavigator ¶
type DataTreeNavigator interface {
// this will process the against the given expressionNode and return
// a new context of matching candidates
GetMatchingNodes(context Context, expressionNode *ExpressionNode) (Context, error)
}
func NewDataTreeNavigator ¶
func NewDataTreeNavigator() DataTreeNavigator
type Decoder ¶
type Decoder interface {
Init(reader io.Reader) error
Decode() (*CandidateNode, error)
}
func NewBase64Decoder ¶
func NewBase64Decoder() Decoder
func NewCSVObjectDecoder ¶
func NewCSVObjectDecoder(prefs CsvPreferences) Decoder
func NewGoccyYAMLDecoder ¶
func NewGoccyYAMLDecoder() Decoder
func NewHclDecoder ¶
func NewHclDecoder() Decoder
func NewINIDecoder ¶
func NewINIDecoder(prefs INIPreferences) Decoder
func NewJSONDecoder ¶
func NewJSONDecoder() Decoder
func NewLuaDecoder ¶
func NewLuaDecoder(prefs LuaPreferences) Decoder
func NewPropertiesDecoder ¶
func NewPropertiesDecoder() Decoder
func NewTomlDecoder ¶
func NewTomlDecoder() Decoder
func NewUriDecoder ¶
func NewUriDecoder() Decoder
func NewXMLDecoder ¶
func NewXMLDecoder(prefs XmlPreferences) Decoder
func NewYamlDecoder ¶
func NewYamlDecoder(prefs YamlPreferences) Decoder
type DecoderFactoryFunction ¶
type DecoderFactoryFunction func() Decoder
type EncodeHint ¶
type EncodeHint int
EncodeHint controls how a mapping node is serialised by format-specific encoders that distinguish between inline and block/section representations (e.g. TOML, HCL).
const ( // EncodeHintDefault lets the encoder choose the representation (e.g. TOML block // mappings default to [section] headers). EncodeHintDefault EncodeHint = iota // EncodeHintSeparateBlock forces the node to be emitted as a separate block or // table-section header (used by TOML [section] and HCL block decoders). EncodeHintSeparateBlock // EncodeHintInline forces the node to be emitted as an inline / flow table // (used by TOML inline-table decoder and TOML encoder). EncodeHintInline )
type Encoder ¶
type Encoder interface {
Encode(writer io.Writer, node *CandidateNode) error
PrintDocumentSeparator(writer io.Writer) error
PrintLeadingContent(writer io.Writer, content string) error
CanHandleAliases() bool
}
func NewBase64Encoder ¶
func NewBase64Encoder() Encoder
func NewCsvEncoder ¶
func NewCsvEncoder(prefs CsvPreferences) Encoder
func NewHclEncoder ¶
func NewHclEncoder(prefs HclPreferences) Encoder
NewHclEncoder creates a new HCL encoder
func NewJSONEncoder ¶
func NewJSONEncoder(prefs JsonPreferences) Encoder
func NewKYamlEncoder ¶
func NewKYamlEncoder(prefs KYamlPreferences) Encoder
func NewLuaEncoder ¶
func NewLuaEncoder(prefs LuaPreferences) Encoder
func NewPropertiesEncoder ¶
func NewPropertiesEncoder(prefs PropertiesPreferences) Encoder
func NewShEncoder ¶
func NewShEncoder() Encoder
func NewShellVariablesEncoder ¶
func NewShellVariablesEncoder() Encoder
func NewTomlEncoder ¶
func NewTomlEncoder() Encoder
func NewTomlEncoderWithPrefs ¶
func NewTomlEncoderWithPrefs(prefs TomlPreferences) Encoder
func NewUriEncoder ¶
func NewUriEncoder() Encoder
func NewXMLEncoder ¶
func NewXMLEncoder(prefs XmlPreferences) Encoder
func NewYamlEncoder ¶
func NewYamlEncoder(prefs YamlPreferences) Encoder
type EncoderFactoryFunction ¶
type EncoderFactoryFunction func() Encoder
type Evaluator ¶
type Evaluator interface {
EvaluateFiles(expression string, filenames []string, printer Printer, decoder Decoder) error
// EvaluateNodes takes an expression and one or more yaml nodes, returning a list of matching candidate nodes
EvaluateNodes(expression string, nodes ...*CandidateNode) (*list.List, error)
// EvaluateCandidateNodes takes an expression and list of candidate nodes, returning a list of matching candidate nodes
EvaluateCandidateNodes(expression string, inputCandidateNodes *list.List) (*list.List, error)
}
A yaml expression evaluator that runs the expression once against all files/nodes in memory.
func NewAllAtOnceEvaluator ¶
func NewAllAtOnceEvaluator() Evaluator
type ExpressionNode ¶
type ExpressionNode struct {
Operation *Operation
LHS *ExpressionNode
RHS *ExpressionNode
Parent *ExpressionNode
}
type ExpressionParserInterface ¶
type ExpressionParserInterface interface {
ParseExpression(expression string) (*ExpressionNode, error)
}
var ExpressionParser ExpressionParserInterface
type Format ¶
type Format struct {
FormalName string
Names []string
EncoderFactory EncoderFactoryFunction
DecoderFactory DecoderFactoryFunction
}
func FormatFromString ¶
func GetAvailableInputFormats ¶
func GetAvailableInputFormats() []*Format
func GetAvailableOutputFormats ¶
func GetAvailableOutputFormats() []*Format
func (*Format) GetConfiguredEncoder ¶
func (*Format) MatchesName ¶
type HclPreferences ¶
type HclPreferences struct {
ColorsEnabled bool
}
func NewDefaultHclPreferences ¶
func NewDefaultHclPreferences() HclPreferences
func (*HclPreferences) Copy ¶
func (p *HclPreferences) Copy() HclPreferences
type INIPreferences ¶
func NewDefaultINIPreferences ¶
func NewDefaultINIPreferences() INIPreferences
func (*INIPreferences) Copy ¶
func (p *INIPreferences) Copy() INIPreferences
type JsonPreferences ¶
func NewDefaultJsonPreferences ¶
func NewDefaultJsonPreferences() JsonPreferences
func (*JsonPreferences) Copy ¶
func (p *JsonPreferences) Copy() JsonPreferences
type KYamlPreferences ¶
type KYamlPreferences struct {
Indent int
ColorsEnabled bool
PrintDocSeparators bool
UnwrapScalar bool
}
func NewDefaultKYamlPreferences ¶
func NewDefaultKYamlPreferences() KYamlPreferences
func (*KYamlPreferences) Copy ¶
func (p *KYamlPreferences) Copy() KYamlPreferences
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger wraps log/slog providing a printf-style interface used throughout yq.
func (*Logger) IsEnabledFor ¶
IsEnabledFor returns true if the given level is enabled.
func (*Logger) SetSlogger ¶
SetSlogger replaces the underlying slog.Logger (e.g. to configure output format).
type LuaPreferences ¶
func NewDefaultLuaPreferences ¶
func NewDefaultLuaPreferences() LuaPreferences
type NodeInfo ¶
type NodeInfo struct {
Kind string `yaml:"kind"`
Style string `yaml:"style,omitempty"`
Anchor string `yaml:"anchor,omitempty"`
Tag string `yaml:"tag,omitempty"`
HeadComment string `yaml:"headComment,omitempty"`
LineComment string `yaml:"lineComment,omitempty"`
FootComment string `yaml:"footComment,omitempty"`
Value string `yaml:"value,omitempty"`
Line int `yaml:"line,omitempty"`
Column int `yaml:"column,omitempty"`
Content []*NodeInfo `yaml:"content,omitempty"`
}
type Operation ¶
type Operation struct {
OperationType *operationType
Value interface{}
StringValue string
CandidateNode *CandidateNode // used for Value Path elements
Preferences interface{}
UpdateAssign bool // used for assign ops, when true it means we evaluate the rhs given the lhs
}
type Printer ¶
type Printer interface {
PrintResults(matchingNodes *list.List) error
PrintedAnything() bool
//e.g. when given a front-matter doc, like jekyll
SetAppendix(reader io.Reader)
SetNulSepOutput(nulSepOutput bool)
}
func NewNodeInfoPrinter ¶
func NewNodeInfoPrinter(printerWriter PrinterWriter) Printer
func NewPrinter ¶
func NewPrinter(encoder Encoder, printerWriter PrinterWriter) Printer
type PrinterWriter ¶
type PrinterWriter interface {
GetWriter(node *CandidateNode) (*bufio.Writer, error)
}
func NewMultiPrinterWriter ¶
func NewMultiPrinterWriter(expression *ExpressionNode, format *Format) PrinterWriter
func NewSinglePrinterWriter ¶
func NewSinglePrinterWriter(writer io.Writer) PrinterWriter
type PropertiesPreferences ¶
type PropertiesPreferences struct {
UnwrapScalar bool
KeyValueSeparator string
UseArrayBrackets bool
}
func NewDefaultPropertiesPreferences ¶
func NewDefaultPropertiesPreferences() PropertiesPreferences
func (*PropertiesPreferences) Copy ¶
func (p *PropertiesPreferences) Copy() PropertiesPreferences
type SecurityPreferences ¶
type ShellVariablesPreferences ¶
func NewDefaultShellVariablesPreferences ¶
func NewDefaultShellVariablesPreferences() ShellVariablesPreferences
type StreamEvaluator ¶
type StreamEvaluator interface {
Evaluate(filename string, reader io.Reader, node *ExpressionNode, printer Printer, decoder Decoder) (uint, error)
EvaluateFiles(expression string, filenames []string, printer Printer, decoder Decoder) error
EvaluateNew(expression string, printer Printer) error
}
A yaml expression evaluator that runs the expression multiple times for each given yaml document. Uses less memory than loading all documents and running the expression once, but this cannot process cross document expressions.
func NewStreamEvaluator ¶
func NewStreamEvaluator() StreamEvaluator
type StringEvaluator ¶
type StringEvaluator interface {
Evaluate(expression string, input string, encoder Encoder, decoder Decoder) (string, error)
EvaluateAll(expression string, input string, encoder Encoder, decoder Decoder) (string, error)
}
func NewStringEvaluator ¶
func NewStringEvaluator() StringEvaluator
type TomlPreferences ¶
type TomlPreferences struct {
ColorsEnabled bool
}
func NewDefaultTomlPreferences ¶
func NewDefaultTomlPreferences() TomlPreferences
func (*TomlPreferences) Copy ¶
func (p *TomlPreferences) Copy() TomlPreferences
type ValueVisitor ¶
type ValueVisitor func(*CandidateNode) error
type XmlPreferences ¶
type XmlPreferences struct {
Indent int
AttributePrefix string
ContentName string
StrictMode bool
KeepNamespace bool
UseRawToken bool
ProcInstPrefix string
DirectiveName string
SkipProcInst bool
SkipDirectives bool
}
func NewDefaultXmlPreferences ¶
func NewDefaultXmlPreferences() XmlPreferences
func (*XmlPreferences) Copy ¶
func (p *XmlPreferences) Copy() XmlPreferences
type YamlPreferences ¶
type YamlPreferences struct {
Indent int
ColorsEnabled bool
LeadingContentPreProcessing bool
PrintDocSeparators bool
UnwrapScalar bool
EvaluateTogether bool
FixMergeAnchorToSpec bool
CompactSequenceIndent bool
}
func NewDefaultYamlPreferences ¶
func NewDefaultYamlPreferences() YamlPreferences
func (*YamlPreferences) Copy ¶
func (p *YamlPreferences) Copy() YamlPreferences
Source Files
¶
- all_at_once_evaluator_gp.go
- candidate_node_goccy_yaml_gp.go
- candidate_node_gp.go
- candidate_node_json.go
- candidate_node_yaml_gp.go
- chown_linux.go
- color_print_gp.go
- context_gp.go
- csv_gp.go
- data_tree_navigator_gp.go
- decoder_base64.go
- decoder_csv_object.go
- decoder_goccy_yaml.go
- decoder_gp.go
- decoder_hcl.go
- decoder_ini.go
- decoder_json.go
- decoder_lua.go
- decoder_properties.go
- decoder_toml.go
- decoder_uri.go
- decoder_xml.go
- decoder_yaml_gp.go
- encoder_base64.go
- encoder_csv.go
- encoder_gp.go
- encoder_hcl.go
- encoder_ini.go
- encoder_json.go
- encoder_kyaml.go
- encoder_lua.go
- encoder_properties.go
- encoder_sh.go
- encoder_shellvariables.go
- encoder_toml.go
- encoder_uri.go
- encoder_xml.go
- encoder_yaml_gp.go
- expression_parser_gp.go
- expression_postfix_gp.go
- file_utils_gp.go
- format_gp.go
- front_matter_gp.go
- hcl_gp.go
- ini_gp.go
- json_gp.go
- kyaml.go
- lexer_gp.go
- lexer_participle_gp.go
- lib_gp.go
- logger_gp.go
- lua_gp.go
- matchKeyString_gp.go
- operation_gp.go
- operator_add_gp.go
- operator_alternative_gp.go
- operator_anchors_aliases_gp.go
- operator_assign_gp.go
- operator_booleans_gp.go
- operator_collect_gp.go
- operator_collect_object_gp.go
- operator_column_gp.go
- operator_comments_gp.go
- operator_compare_gp.go
- operator_contains_gp.go
- operator_create_map_gp.go
- operator_datetime_gp.go
- operator_delete_gp.go
- operator_divide_gp.go
- operator_document_index_gp.go
- operator_encoder_decoder_gp.go
- operator_entries_gp.go
- operator_env_gp.go
- operator_equals_gp.go
- operator_error_gp.go
- operator_eval_gp.go
- operator_expression_gp.go
- operator_file_gp.go
- operator_filter_gp.go
- operator_first_gp.go
- operator_flatten_gp.go
- operator_group_by_gp.go
- operator_has_gp.go
- operator_keys_gp.go
- operator_kind_gp.go
- operator_length_gp.go
- operator_line_gp.go
- operator_load_gp.go
- operator_map_gp.go
- operator_modulo_gp.go
- operator_multiply_gp.go
- operator_omit_gp.go
- operator_parent_gp.go
- operator_path_gp.go
- operator_pick_gp.go
- operator_pipe_gp.go
- operator_pivot_gp.go
- operator_recursive_descent_gp.go
- operator_reduce_gp.go
- operator_reverse_gp.go
- operator_select_gp.go
- operator_self_gp.go
- operator_shuffle_gp.go
- operator_slice_gp.go
- operator_sort_gp.go
- operator_sort_keys_gp.go
- operator_split_document_gp.go
- operator_strings_gp.go
- operator_style_gp.go
- operator_subtract_gp.go
- operator_system_gp.go
- operator_tag_gp.go
- operator_to_number_gp.go
- operator_traverse_path_gp.go
- operator_union_gp.go
- operator_unique_gp.go
- operator_value_gp.go
- operator_variables_gp.go
- operator_with_gp.go
- operators_gp.go
- printer_gp.go
- printer_node_info_gp.go
- printer_writer_gp.go
- properties_gp.go
- security_prefs_gp.go
- shellvariables_gp.go
- stream_evaluator_gp.go
- string_evaluator_gp.go
- toml_gp.go
- utils_gp.go
- write_in_place_handler_gp.go
- xml_gp.go
- yaml_gp.go