searchreplace

package
v0.0.0-...-e57eb4c Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ByValue       = "by-value"
	ByValueRegex  = "by-value-regex"
	ByPath        = "by-path"
	ByFilePath    = "by-file-path"
	PutValue      = "put-value"
	PutComment    = "put-comment"
	PathDelimiter = "."
)

Variables

This section is empty.

Functions

func Decode

func Decode(rn *yaml.RNode, fcd *SearchReplace) error

Decode decodes the input yaml RNode into SearchReplace struct returns error if input yaml RNode contains invalid matcher name inputs

func VisitElements

func VisitElements(rn *yaml.RNode, fn func(node *yaml.RNode, i int) error) error

VisitElements calls fn for each element in a SequenceNode. Returns an error for non-SequenceNodes

Types

type SearchReplace

type SearchReplace struct {
	// ByValue is the value of the field to be matched
	ByValue string

	// ByValueRegex is the value regex of the field to be matched
	ByValueRegex string

	// ByPath is the path of the field to be matched
	ByPath string

	// ByFilePath is the filepath of the resource to be matched
	ByFilePath string

	// Count is the number of matches
	Count int

	// PutValue is the value to be put at to field
	// filtered by path and/or value
	PutValue string

	// PutComment is the comment to be added at to field
	PutComment string

	// Results stores the results of executing the command
	Results []SearchResult
	// contains filtered or unexported fields
}

SearchReplace struct holds the input parameters and results for Search and Replace operations on resource configs

func (*SearchReplace) Filter

func (sr *SearchReplace) Filter(nodes []*yaml.RNode) ([]*yaml.RNode, error)

Filter performs the search and replace operation on all input nodes

func (*SearchReplace) Perform

func (sr *SearchReplace) Perform(object *yaml.RNode) (*yaml.RNode, error)

Perform parses input node and performs search and replace operation on the node

type SearchResult

type SearchResult struct {
	// FilePath is the file path of the matching field
	FilePath string

	// FieldPath is field path of the matching field
	FieldPath string

	// Value of the matching field
	Value string
}

SearchResult holds result of search and replace operation

Jump to

Keyboard shortcuts

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