yqlib

package
v3.0.0-...-8846255 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2020 License: MIT Imports: 11 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColorizeAndPrint

func ColorizeAndPrint(bytes []byte, writer io.Writer) error

func DebugNode

func DebugNode(value *yaml.Node)

func KindString

func KindString(kind yaml.Kind) string

Types

type ArrayMergeStrategy

type ArrayMergeStrategy uint32
const (
	UpdateArrayMergeStrategy ArrayMergeStrategy = 1 << iota
	OverwriteArrayMergeStrategy
	AppendArrayMergeStrategy
)

type CommentsMergeStrategy

type CommentsMergeStrategy uint32
const (
	SetWhenBlankCommentsMergeStrategy CommentsMergeStrategy = 1 << iota
	IgnoreCommentsMergeStrategy
	OverwriteCommentsMergeStrategy
	AppendCommentsMergeStrategy
)

type DataNavigator

type DataNavigator interface {
	Traverse(value *yaml.Node, path []interface{}) error
}

func NewDataNavigator

func NewDataNavigator(NavigationStrategy NavigationStrategy) DataNavigator

type Encoder

type Encoder interface {
	Encode(node *yaml.Node) error
}

func NewJsonEncoder

func NewJsonEncoder(destination io.Writer, prettyPrint bool, indent int) Encoder

func NewYamlEncoder

func NewYamlEncoder(destination io.Writer, indent int, colorise bool) Encoder
type NavigationStrategy interface {
	FollowAlias(nodeContext NodeContext) bool
	AutoCreateMap(nodeContext NodeContext) bool
	Visit(nodeContext NodeContext) error
	// node key is the string value of the last element in the path stack
	// we use it to match against the pathExpression in head.
	ShouldTraverse(nodeContext NodeContext, nodeKey string) bool
	ShouldDeeplyTraverse(nodeContext NodeContext) bool
	// when deeply traversing, should we visit all matching nodes, or just leaves?
	ShouldOnlyDeeplyVisitLeaves(NodeContext) bool
	GetVisitedNodes() []*NodeContext
	DebugVisitedNodes()
	GetPathParser() PathParser
}

func DeleteNavigationStrategy

func DeleteNavigationStrategy(pathElementToDelete interface{}) NavigationStrategy

func FilterMatchingNodesNavigationStrategy

func FilterMatchingNodesNavigationStrategy(value string) NavigationStrategy

func MergeNavigationStrategy

func MergeNavigationStrategy(updateCommand UpdateCommand, autoCreate bool) NavigationStrategy

func ReadForMergeNavigationStrategy

func ReadForMergeNavigationStrategy(arrayMergeStrategy ArrayMergeStrategy) NavigationStrategy

func ReadNavigationStrategy

func ReadNavigationStrategy() NavigationStrategy

func UpdateNavigationStrategy

func UpdateNavigationStrategy(updateCommand UpdateCommand, autoCreate bool) NavigationStrategy
type NavigationStrategyImpl struct {
	// contains filtered or unexported fields
}
func (ns *NavigationStrategyImpl) AutoCreateMap(nodeContext NodeContext) bool
func (ns *NavigationStrategyImpl) DebugVisitedNodes()
func (ns *NavigationStrategyImpl) FollowAlias(nodeContext NodeContext) bool
func (ns *NavigationStrategyImpl) GetPathParser() PathParser
func (ns *NavigationStrategyImpl) GetVisitedNodes() []*NodeContext
func (ns *NavigationStrategyImpl) ShouldDeeplyTraverse(nodeContext NodeContext) bool
func (ns *NavigationStrategyImpl) ShouldOnlyDeeplyVisitLeaves(nodeContext NodeContext) bool
func (ns *NavigationStrategyImpl) ShouldTraverse(nodeContext NodeContext, nodeKey string) bool
func (ns *NavigationStrategyImpl) Visit(nodeContext NodeContext) error

type NodeContext

type NodeContext struct {
	Node      *yaml.Node
	Head      interface{}
	Tail      []interface{}
	PathStack []interface{}
	// middle nodes are nodes that match along the original path, but not a
	// target match of the path. This is only relevant when ShouldOnlyDeeplyVisitLeaves is false.
	IsMiddleNode bool
}

func NewNodeContext

func NewNodeContext(node *yaml.Node, head interface{}, tail []interface{}, pathStack []interface{}) NodeContext

type PathParser

type PathParser interface {
	ParsePath(path string) []interface{}
	MatchesNextPathElement(nodeContext NodeContext, nodeKey string) bool
	IsPathExpression(pathElement string) bool
}

func NewPathParser

func NewPathParser() PathParser

type UpdateCommand

type UpdateCommand struct {
	Command               string
	Path                  string
	Value                 *yaml.Node
	Overwrite             bool
	DontUpdateNodeValue   bool
	DontUpdateNodeContent bool
	CommentsMergeStrategy CommentsMergeStrategy
}

type ValueParser

type ValueParser interface {
	Parse(argument string, customTag string, customStyle string, anchorName string, createAlias bool) *yaml.Node
}

func NewValueParser

func NewValueParser() ValueParser

type YqLib

type YqLib interface {
	Get(rootNode *yaml.Node, path string) ([]*NodeContext, error)
	GetForMerge(rootNode *yaml.Node, path string, arrayMergeStrategy ArrayMergeStrategy) ([]*NodeContext, error)
	Update(rootNode *yaml.Node, updateCommand UpdateCommand, autoCreate bool) error
	New(path string) yaml.Node

	PathStackToString(pathStack []interface{}) string
	MergePathStackToString(pathStack []interface{}, arrayMergeStrategy ArrayMergeStrategy) string
}

func NewYqLib

func NewYqLib() YqLib

Jump to

Keyboard shortcuts

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