Documentation ¶
Overview ¶
Use the top level Evaluator or StreamEvaluator to evaluate expressions and return matches.
Index ¶
- Constants
- Variables
- func GetLogger() *logging.Logger
- func InitExpressionParser()
- func KindString(kind yaml.Kind) string
- func NewFrontMatterHandler(originalFilename string) frontMatterHandler
- func NewWriteInPlaceHandler(inputFile string) writeInPlaceHandler
- func NodeToString(node *CandidateNode) string
- func NodesToString(collection *list.List) string
- func SafelyCloseReader(reader io.Reader)
- type CandidateNode
- func (n *CandidateNode) AsList() *list.List
- func (n *CandidateNode) Copy() (*CandidateNode, error)
- func (n *CandidateNode) CreateChildInArray(index int, node *yaml.Node) *CandidateNode
- func (n *CandidateNode) CreateChildInMap(key *yaml.Node, node *yaml.Node) *CandidateNode
- func (n *CandidateNode) CreateReplacement(node *yaml.Node) *CandidateNode
- func (n *CandidateNode) CreateReplacementWithDocWrappers(node *yaml.Node) *CandidateNode
- func (n *CandidateNode) GetKey() string
- func (n *CandidateNode) GetNicePath() string
- func (n *CandidateNode) GetNiceTag() string
- func (n *CandidateNode) UpdateAttributesFrom(other *CandidateNode, prefs assignPreferences)
- func (n *CandidateNode) UpdateFrom(other *CandidateNode, prefs assignPreferences)
- 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 DataTreeNavigator
- type Decoder
- type Encoder
- func NewBase64Encoder() Encoder
- func NewCsvEncoder(separator rune) Encoder
- func NewJSONEncoder(indent int, colorise bool, unwrapScalar bool) Encoder
- func NewPropertiesEncoder(unwrapScalar bool) Encoder
- func NewShEncoder() Encoder
- func NewUriEncoder() Encoder
- func NewXMLEncoder(indent int, prefs XmlPreferences) Encoder
- func NewYamlEncoder(indent int, colorise bool, prefs YamlPreferences) Encoder
- type Evaluator
- type ExpressionNode
- type ExpressionParserInterface
- type InputFormat
- type Operation
- type Printer
- type PrinterOutputFormat
- type PrinterWriter
- type StreamEvaluator
- type StringEvaluator
- type XmlPreferences
- type YamlPreferences
Constants ¶
View Source
const ( YamlInputFormat = 1 << iota XMLInputFormat PropertiesInputFormat Base64InputFormat JsonInputFormat CSVObjectInputFormat TSVObjectInputFormat UriInputFormat )
View Source
const ( YamlOutputFormat = 1 << iota JSONOutputFormat PropsOutputFormat CSVOutputFormat TSVOutputFormat XMLOutputFormat Base64OutputFormat UriOutputFormat ShOutputFormat )
Variables ¶
View Source
var ConfiguredXMLPreferences = NewDefaultXmlPreferences()
View Source
var ConfiguredYamlPreferences = NewDefaultYamlPreferences()
View Source
var LoadYamlPreferences = YamlPreferences{ LeadingContentPreProcessing: false, PrintDocSeparators: true, UnwrapScalar: true, EvaluateTogether: false, }
View Source
var Now = time.Now
for unit tests
View Source
var PrettyPrintExp = `(... | (select(tag != "!!str"), select(tag == "!!str") | select(test("(?i)^(y|yes|n|no|on|off)$") | not)) ) style=""`
Functions ¶
func InitExpressionParser ¶ added in v4.19.1
func InitExpressionParser()
func KindString ¶
func NewFrontMatterHandler ¶ added in v4.11.0
func NewFrontMatterHandler(originalFilename string) frontMatterHandler
func NewWriteInPlaceHandler ¶
func NewWriteInPlaceHandler(inputFile string) writeInPlaceHandler
func NodeToString ¶
func NodeToString(node *CandidateNode) string
func SafelyCloseReader ¶ added in v4.11.0
Types ¶
type CandidateNode ¶
type CandidateNode struct { Node *yaml.Node // the actual node Parent *CandidateNode // parent node Key *yaml.Node // node key, if this is a value from a map (or index in an array) LeadingContent string TrailingContent string Path []interface{} /// the path we took to get to this node Document uint // the document index of this node Filename string FileIndex 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 }
func (*CandidateNode) AsList ¶ added in v4.14.1
func (n *CandidateNode) AsList() *list.List
func (*CandidateNode) Copy ¶
func (n *CandidateNode) Copy() (*CandidateNode, error)
func (*CandidateNode) CreateChildInArray ¶ added in v4.15.1
func (n *CandidateNode) CreateChildInArray(index int, node *yaml.Node) *CandidateNode
func (*CandidateNode) CreateChildInMap ¶ added in v4.15.1
func (n *CandidateNode) CreateChildInMap(key *yaml.Node, node *yaml.Node) *CandidateNode
func (*CandidateNode) CreateReplacement ¶ added in v4.15.1
func (n *CandidateNode) CreateReplacement(node *yaml.Node) *CandidateNode
func (*CandidateNode) CreateReplacementWithDocWrappers ¶ added in v4.25.3
func (n *CandidateNode) CreateReplacementWithDocWrappers(node *yaml.Node) *CandidateNode
func (*CandidateNode) GetKey ¶
func (n *CandidateNode) GetKey() string
func (*CandidateNode) GetNicePath ¶ added in v4.16.2
func (n *CandidateNode) GetNicePath() string
func (*CandidateNode) GetNiceTag ¶ added in v4.16.2
func (n *CandidateNode) GetNiceTag() string
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
type Context ¶ added in v4.5.0
type Context struct { MatchingNodes *list.List Variables map[string]*list.List DontAutoCreate bool // contains filtered or unexported fields }
func (*Context) ChildContext ¶ added in v4.5.0
func (*Context) GetDateTimeLayout ¶ added in v4.20.1
func (*Context) ReadOnlyClone ¶ added in v4.9.2
func (*Context) SetDateTimeLayout ¶ added in v4.20.1
func (*Context) SetVariable ¶ added in v4.5.0
func (*Context) SingleChildContext ¶ added in v4.5.0
func (n *Context) SingleChildContext(candidate *CandidateNode) Context
func (*Context) SingleReadonlyChildContext ¶ added in v4.9.2
func (n *Context) SingleReadonlyChildContext(candidate *CandidateNode) Context
func (*Context) WritableClone ¶ added in v4.9.7
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 ¶ added in v4.17.1
type Decoder interface { Init(reader io.Reader) error Decode() (*CandidateNode, error) }
func NewBase64Decoder ¶ added in v4.21.1
func NewBase64Decoder() Decoder
func NewCSVObjectDecoder ¶ added in v4.27.1
func NewJSONDecoder ¶ added in v4.27.1
func NewJSONDecoder() Decoder
func NewPropertiesDecoder ¶ added in v4.20.1
func NewPropertiesDecoder() Decoder
func NewUriDecoder ¶ added in v4.31.1
func NewUriDecoder() Decoder
func NewXMLDecoder ¶ added in v4.20.1
func NewXMLDecoder(prefs XmlPreferences) Decoder
func NewYamlDecoder ¶ added in v4.17.1
func NewYamlDecoder(prefs YamlPreferences) Decoder
type Encoder ¶
type Encoder interface { Encode(writer io.Writer, node *yaml.Node) error PrintDocumentSeparator(writer io.Writer) error PrintLeadingContent(writer io.Writer, content string) error CanHandleAliases() bool }
func NewBase64Encoder ¶ added in v4.21.1
func NewBase64Encoder() Encoder
func NewCsvEncoder ¶ added in v4.16.1
func NewJSONEncoder ¶ added in v4.27.1
func NewPropertiesEncoder ¶ added in v4.12.0
func NewShEncoder ¶ added in v4.31.1
func NewShEncoder() Encoder
func NewUriEncoder ¶ added in v4.31.1
func NewUriEncoder() Encoder
func NewXMLEncoder ¶ added in v4.20.1
func NewXMLEncoder(indent int, prefs XmlPreferences) Encoder
func NewYamlEncoder ¶
func NewYamlEncoder(indent int, colorise bool, prefs YamlPreferences) 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 ...*yaml.Node) (*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 ¶ added in v4.3.2
type ExpressionNode struct { Operation *Operation LHS *ExpressionNode RHS *ExpressionNode }
type ExpressionParserInterface ¶ added in v4.19.1
type ExpressionParserInterface interface {
ParseExpression(expression string) (*ExpressionNode, error)
}
var ExpressionParser ExpressionParserInterface
type InputFormat ¶ added in v4.17.1
type InputFormat uint
func InputFormatFromString ¶ added in v4.17.1
func InputFormatFromString(format string) (InputFormat, error)
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) }
func NewPrinter ¶
func NewPrinter(encoder Encoder, printerWriter PrinterWriter) Printer
type PrinterOutputFormat ¶ added in v4.12.0
type PrinterOutputFormat uint32
func OutputFormatFromString ¶ added in v4.12.0
func OutputFormatFromString(format string) (PrinterOutputFormat, error)
type PrinterWriter ¶ added in v4.14.1
type PrinterWriter interface {
GetWriter(node *CandidateNode) (*bufio.Writer, error)
}
func NewMultiPrinterWriter ¶ added in v4.14.1
func NewMultiPrinterWriter(expression *ExpressionNode, format PrinterOutputFormat) PrinterWriter
func NewSinglePrinterWriter ¶ added in v4.14.1
func NewSinglePrinterWriter(writer io.Writer) PrinterWriter
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 ¶ added in v4.27.1
type StringEvaluator interface {
Evaluate(expression string, input string, encoder Encoder, decoder Decoder) (string, error)
}
func NewStringEvaluator ¶ added in v4.27.1
func NewStringEvaluator() StringEvaluator
type XmlPreferences ¶ added in v4.17.1
type XmlPreferences struct { AttributePrefix string ContentName string StrictMode bool KeepNamespace bool UseRawToken bool ProcInstPrefix string DirectiveName string SkipProcInst bool SkipDirectives bool }
func NewDefaultXmlPreferences ¶ added in v4.29.1
func NewDefaultXmlPreferences() XmlPreferences
type YamlPreferences ¶ added in v4.29.1
type YamlPreferences struct { LeadingContentPreProcessing bool PrintDocSeparators bool UnwrapScalar bool EvaluateTogether bool }
func NewDefaultYamlPreferences ¶ added in v4.29.1
func NewDefaultYamlPreferences() YamlPreferences
Source Files ¶
- all_at_once_evaluator.go
- candidate_node.go
- chown_linux.go
- color_print.go
- context.go
- data_tree_navigator.go
- decoder.go
- decoder_base64.go
- decoder_csv_object.go
- decoder_json.go
- decoder_properties.go
- decoder_uri.go
- decoder_xml.go
- decoder_yaml.go
- encoder.go
- encoder_base64.go
- encoder_csv.go
- encoder_json.go
- encoder_properties.go
- encoder_sh.go
- encoder_uri.go
- encoder_xml.go
- encoder_yaml.go
- expression_parser.go
- expression_postfix.go
- file_utils.go
- front_matter.go
- lexer.go
- lexer_participle.go
- lib.go
- matchKeyString.go
- operator_add.go
- operator_alternative.go
- operator_anchors_aliases.go
- operator_assign.go
- operator_booleans.go
- operator_collect.go
- operator_collect_object.go
- operator_column.go
- operator_comments.go
- operator_compare.go
- operator_contains.go
- operator_create_map.go
- operator_datetime.go
- operator_delete.go
- operator_document_index.go
- operator_encoder_decoder.go
- operator_entries.go
- operator_env.go
- operator_equals.go
- operator_error.go
- operator_eval.go
- operator_expression.go
- operator_file.go
- operator_flatten.go
- operator_group_by.go
- operator_has.go
- operator_keys.go
- operator_length.go
- operator_line.go
- operator_load.go
- operator_map.go
- operator_multiply.go
- operator_parent.go
- operator_path.go
- operator_pick.go
- operator_pipe.go
- operator_recursive_descent.go
- operator_reduce.go
- operator_reverse.go
- operator_select.go
- operator_self.go
- operator_shuffle.go
- operator_slice.go
- operator_sort.go
- operator_sort_keys.go
- operator_split_document.go
- operator_strings.go
- operator_style.go
- operator_subtract.go
- operator_tag.go
- operator_traverse_path.go
- operator_union.go
- operator_unique.go
- operator_value.go
- operator_variables.go
- operator_with.go
- operators.go
- ordered_map.go
- ordered_map_json.go
- ordered_map_yaml.go
- printer.go
- printer_writer.go
- stream_evaluator.go
- string_evaluator.go
- utils.go
- write_in_place_handler.go
- xml.go
- yaml.go
Click to show internal directories.
Click to hide internal directories.